Skip to content

Commit

Permalink
Filterdiff patch and apply separately to bin and lib; fix #249
Browse files Browse the repository at this point in the history
  • Loading branch information
rdimaio authored and rcarpa committed Jan 24, 2024
1 parent 4a0f1f2 commit df75f9b
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 42 deletions.
34 changes: 21 additions & 13 deletions daemons/start-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,41 @@ fi
if [ -d "/patch" ]
then
echo "Patches found. Trying to apply them"
for patchfile in /patch/*

TMP_PATCH_DIR="$(mktemp -d)"
trap 'rm -rf -- "$TMP_PATCH_DIR"' EXIT # Deletes temp dir when script exits

for patchfile in /patch/*.patch
do
echo "Applying patch ${patchfile}"

bin_patch=$(filterdiff -i '*/bin/*' ${patchfile})
tmp_bin_file="${TMP_PATCH_DIR}/tmp_bin"
filterdiff -i '*/bin/*' "${patchfile}" > ${tmp_bin_file}

if [ -n "$bin_patch" ]
if [ -s ${tmp_bin_file} ]
then
if patch -p3 -d "$RUCIO_PYTHON_PATH" < $bin_patch
if patch -p2 -d "/usr/local/bin/" < ${tmp_bin_file}
then
echo "Patch ${bin_patch} applied."
echo "Patch ${patchfile}/bin applied."
else
echo "Patch ${bin_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/bin could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi

lib_patch=$(filterdiff -i '*/lib/*' ${patchfile})
tmp_lib_file="${TMP_PATCH_DIR}/tmp_lib"
filterdiff -i '*/lib/*' "${patchfile}" > ${tmp_lib_file}

if [ -n "$lib_patch" ]
if [ -s ${tmp_lib_file} ]
then
if patch -p3 -d "$RUCIO_PYTHON_PATH" < $lib_patch
if patch -p3 -d "$RUCIO_PYTHON_PATH" < ${tmp_lib_file}
then
echo "Patch ${lib_patch} applied."
echo "Patch ${patchfile}/lib applied."
else
echo "Patch ${lib_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/lib could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi
done
fi

Expand Down
2 changes: 1 addition & 1 deletion server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ RUN dnf install -y epel-release.noarch && \
procps-ng \
python-pip \
python-mod_wsgi \
memcached && \
memcached \
patchutils && \
dnf clean all && \
rm -rf /var/cache/dnf
Expand Down
36 changes: 22 additions & 14 deletions server/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,36 +46,44 @@ echo ""
if [ -d "/patch" ]
then
echo "Patches found. Trying to apply them"
for patchfile in /patch/*

TMP_PATCH_DIR="$(mktemp -d)"
trap 'rm -rf -- "$TMP_PATCH_DIR"' EXIT # Deletes temp dir when script exits

for patchfile in /patch/*.patch
do
echo "Applying patch ${patchfile}"

bin_patch=$(filterdiff -i '*/bin/*' ${patchfile})
tmp_bin_file="${TMP_PATCH_DIR}/tmp_bin"
filterdiff -i '*/bin/*' "${patchfile}" > ${tmp_bin_file}

if [ -n "$bin_patch" ]
if [ -s ${tmp_bin_file} ]
then
if patch -p3 -d "$RUCIO_PYTHON_PATH" < $bin_patch
if patch -p2 -d "/usr/local/bin/" < ${tmp_bin_file}
then
echo "Patch ${bin_patch} applied."
echo "Patch ${patchfile}/bin applied."
else
echo "Patch ${bin_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/bin could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi

lib_patch=$(filterdiff -i '*/lib/*' ${patchfile})
tmp_lib_file="${TMP_PATCH_DIR}/tmp_lib"
filterdiff -i '*/lib/*' "${patchfile}" > ${tmp_lib_file}

if [ -n "$lib_patch" ]
if [ -s ${tmp_lib_file} ]
then
if patch -p3 -d "$RUCIO_PYTHON_PATH" < $lib_patch
if patch -p3 -d "$RUCIO_PYTHON_PATH" < ${tmp_lib_file}
then
echo "Patch ${lib_patch} applied."
echo "Patch ${patchfile}/lib applied."
else
echo "Patch ${lib_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/lib could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi
done
fi

pkill httpd || :
sleep 2
exec httpd -D FOREGROUND
exec httpd -D FOREGROUND
35 changes: 21 additions & 14 deletions webui/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,43 @@ echo ""
if [ -d "/patch" ]
then
echo "Patches found. Trying to apply them"
for patchfile in /patch/*

TMP_PATCH_DIR="$(mktemp -d)"
trap 'rm -rf -- "$TMP_PATCH_DIR"' EXIT # Deletes temp dir when script exits

for patchfile in /patch/*.patch
do
echo "Applying patch ${patchfile}"

bin_patch=$(filterdiff -i '*/bin/*' ${patchfile})
tmp_bin_file="${TMP_PATCH_DIR}/tmp_bin"
filterdiff -i '*/bin/*' "${patchfile}" > ${tmp_bin_file}

if [ -n "$bin_patch" ]
if [ -s ${tmp_bin_file} ]
then
if patch -p3 -d "$RUCIO_WEBUI_PATH" < $bin_patch
if patch -p2 -d "/usr/local/bin/" < ${tmp_bin_file}
then
echo "Patch ${bin_patch} applied."
echo "Patch ${patchfile}/bin applied."
else
echo "Patch ${bin_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/bin could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi

lib_patch=$(filterdiff -i '*/lib/*' ${patchfile})
tmp_lib_file="${TMP_PATCH_DIR}/tmp_lib"
filterdiff -i '*/lib/*' "${patchfile}" > ${tmp_lib_file}

if [ -n "$lib_patch" ]
if [ -s ${tmp_lib_file} ]
then
if patch -p3 -d "$RUCIO_WEBUI_PATH" < $lib_patch
if patch -p3 -d "$RUCIO_WEBUI_PATH" < ${tmp_lib_file}
then
echo "Patch ${lib_patch} applied."
echo "Patch ${patchfile}/lib applied."
else
echo "Patch ${lib_patch} could not be applied successfully (exit code $?). Exiting setup."
echo "Patch ${patchfile}/lib could not be applied successfully (exit code $?). Exiting setup."
exit 1
fi
fi
fi
done
fi


echo "=================== Starting RUCIO WEBUI ========================"
npm run start

0 comments on commit df75f9b

Please sign in to comment.