diff --git a/cve-agency-manager/cve_tracking/core/verification/packing.sh b/cve-agency-manager/cve_tracking/core/verification/packing.sh index 9c0ad1663b3ee50950136872dd7840d7a4d6569e..445b51c16c0988452b9440264ecb67f4b7cab5d5 100755 --- a/cve-agency-manager/cve_tracking/core/verification/packing.sh +++ b/cve-agency-manager/cve_tracking/core/verification/packing.sh @@ -113,13 +113,18 @@ function update_spec() { sed -i "${last_patch_row}a Patch${new_patch_num}: ${path_file_name}" ${spec_file} fi # add %patch - last_patch_apply=$(grep "%patch.* " ${spec_file} | sed -n '$p') - if [[ -n ${last_patch_apply} ]]; then - last_patch_apply_row=$(grep -n "${last_patch_apply}" ${spec_file} | awk -F ':' '{print $1}') - last_patch_apply_num=$(echo ${last_patch_apply} | awk -F ' ' '{print $1}' | awk -F 'patch' '{print $2}') - ignore_level_num=$(echo ${last_patch_apply} | awk -F ' ' '{print $2}') - new_patch_apply_num=$(expr ${last_patch_apply_num} + 1) - sed -i "${last_patch_apply_row}a %patch${new_patch_apply_num} ${ignore_level_num} " ${spec_file} + is_autosetup_exist=$(grep "%autosetup" ${spec_file} | sed -n '$p') + if [[ -n ${is_autosetup_exist} ]]; then + break; + else + last_patch_apply=$(grep "%patch.* " ${spec_file} | sed -n '$p') + if [[ -n ${last_patch_apply} ]]; then + last_patch_apply_row=$(grep -n "${last_patch_apply}" ${spec_file} | awk -F ':' '{print $1}') + last_patch_apply_num=$(echo ${last_patch_apply} | awk -F ' ' '{print $1}' | awk -F 'patch' '{print $2}') + ignore_level_num=$(echo ${last_patch_apply} | awk -F ' ' '{print $2}') + new_patch_apply_num=$(expr ${last_patch_apply_num} + 1) + sed -i "${last_patch_apply_row}a %patch${new_patch_apply_num} ${ignore_level_num} " ${spec_file} + fi fi # add changelog change_log_row=$(grep -n '%changelog' ${spec_file} | sed -n '$p' | awk -F ':' '{print $1}')