Skip to content
Snippets Groups Projects
Commit 4ea96134 authored by Francesco Giacomini's avatar Francesco Giacomini
Browse files

Be sure not to apply the patch multiple times

There are at least two places in ngx_http_parse.c where the patch can apply,
so be sure to apply it only once. As extra safety, save a backup of that file
and print a diff at the end.
Return to the original directory at the end.
parent bbdeef8a
No related branches found
No related tags found
1 merge request!26Migration to EL9
......@@ -6,19 +6,27 @@ set -ex
# Set the nginx spec file with the httpg patch
PATCH_NAME="nginx-httpg_no_delegation.patch"
SPEC_FILE="${HOME}/rpmbuild/SPECS/nginx.spec"
if grep --extended-regexp --quiet "^Patch.*: $PATCH_NAME" "$SPEC_FILE"; then
>&2 echo "The patch $PATCH_NAME is already included in the spec file $SPEC_FILE"
exit 0
fi
# Copy the patch in the rpmbuild directory
cp ${CI_PROJECT_DIR}/${PATCH_NAME} ~/rpmbuild/SOURCES/
cd ~/rpmbuild/SOURCES/
pushd ~/rpmbuild/SOURCES/
# Find the highest existing Patch number in the spec file
LAST_PATCH_NUM=$(grep -oP "^Patch\K[0-9]+" $SPEC_FILE | sort -n | tail -1)
if [ -z "$LAST_PATCH_NUM" ]; then
# There are no existing patches: find the highest Source number in the spec file
LAST_SOURCE_NUM=$(grep -oP "^Source\K[0-9]+" $SPEC_FILE | sort -n | tail -1)
# Add the patch to the spec file after the last Source
sed -i "/^Source${LAST_SOURCE_NUM}/a Patch0: ${PATCH_NAME}" "${SPEC_FILE}"
sed -i.backup "/^Source${LAST_SOURCE_NUM}/a Patch0: ${PATCH_NAME}" "${SPEC_FILE}"
else
# Add the new patch to the spec file after the last Patch
sed -i "/^Patch${LAST_PATCH_NUM}/a Patch$((LAST_PATCH_NUM + 1)): ${PATCH_NAME}" "${SPEC_FILE}"
sed -i.backup "/^Patch${LAST_PATCH_NUM}/a Patch$((LAST_PATCH_NUM + 1)): ${PATCH_NAME}" "${SPEC_FILE}"
fi
# Add httpg to release
sed -i '/%define base_release/ s/ngx/httpg/' "${SPEC_FILE}"
diff "${SPEC_FILE}.backup" "${SPEC_FILE}"
popd
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment