Skip to content

Commit

Permalink
Improve apply-patches
Browse files Browse the repository at this point in the history
The default installation of patches/apply-patches uses a hardcoded
value, which will be incorrect in most cases, so we will query python
instead.

The messages during installation are misleading:

  Patching /usr/lib/python3.6/site-packages with cinderlib-bug-1856556.patch
  Patch already applied, skipping
  Patching /usr/lib/python3.6/site-packages with cinderlib-bug-1873312.patch
  1 out of 1 hunk FAILED
  1 out of 1 hunk FAILED

So it's hard to tell if the FAILED messages should have been a failure
or not.

So we update the script to have a clearer output:

  Checking if cinderlib-bug-1856556.patch is already present in /home/geguileo/code/reuse-cinder-drivers/ember/.venv3/lib/python3.7/site-packages
      Patch already applied, skipping
  Checking if cinderlib-bug-1873312.patch is already present in /home/geguileo/code/reuse-cinder-drivers/ember/.venv3/lib/python3.7/site-packages
      Patch not present, applying it
  • Loading branch information
Akrog committed May 26, 2020
1 parent aebee4f commit 499041c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions patches/apply-patches
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
set -ev
PACKAGES_DIR=${1:-/usr/lib/python2.7/site-packages}
PACKAGES_DIR=${1:-`python -m site --user-site`}
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Use a manual list instead of file listing in case we have a required order
# Generated to avoid including tests using:
Expand All @@ -12,12 +12,12 @@ declare -a PATCHES=("cinderlib-bugs-1849339-1849828.patch"
"cinderlib-bug-1873312.patch")

for patch_file in "${PATCHES[@]}"; do
echo "Patching $PACKAGES_DIR with $patch_file"
PATCH_FILE="$SCRIPT_DIR/$patch_file"
# Check if already applied
if ! patch -R -p0 -s -f --dry-run -d $PACKAGES_DIR <$PATCH_FILE; then
echo "Checking if $patch_file is already present in $PACKAGES_DIR"
if ! patch -R -p0 -s -f --dry-run -d $PACKAGES_DIR >/dev/null <$PATCH_FILE; then
echo -e "\tPatch not present, applying it"
patch -p0 -N --silent -d $PACKAGES_DIR <$PATCH_FILE
else
echo "Patch already applied, skipping"
echo -e "\tPatch already applied, skipping"
fi
done

0 comments on commit 499041c

Please sign in to comment.