summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathieu Mitchell <mmitchell@iweb.com>2017-02-02 06:41:01 -0500
committerMathieu Mitchell <mmitchell@iweb.com>2017-02-06 15:09:04 -0500
commit7ff6948d5f237afed4a967403306b297b1e3d7a0 (patch)
tree873faad5e118c9ecde3d8af83c9092193bb48e11
parentae0146151cd9b8c65af741eae4006cd46bdf6f21 (diff)
downloadironic-python-agent-7ff6948d5f237afed4a967403306b297b1e3d7a0.tar.gz
[TinyIPA] Avoid running rm with no parameters
Currently, during ramdisk optimization steps, the find tool is used to look for files to remove. We pipe all files found by find to the rm command running as sudo. This is necessary because of the ownership of the files to be removed. This commit uses the "--no-run-if-empty" GNU extension to xargs. This extension should be present on all machines running the TinyIPA build, because non-GNU systems simply cannot build TinyIPA. An alternative would have been to use the -delete flag to find, and to run find as root. Change-Id: I78854c8901433b7d45e014dd18e7a5ff794a9c45 Closes-bug: #1661219 (cherry picked from commit e49f05028ce9082e46fc0d257ffd0cd53b4a5a78)
-rwxr-xr-ximagebuild/tinyipa/finalise-tinyipa.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/imagebuild/tinyipa/finalise-tinyipa.sh b/imagebuild/tinyipa/finalise-tinyipa.sh
index 023130be..49b5d8cd 100755
--- a/imagebuild/tinyipa/finalise-tinyipa.sh
+++ b/imagebuild/tinyipa/finalise-tinyipa.sh
@@ -151,11 +151,11 @@ sudo sed -i '/# Main/a NOZSWAP=1' "$FINALDIR/etc/init.d/tc-config"
set +e
$CHROOT_CMD /bin/bash -c "python -OO -m compileall /usr/local/lib/python2.7"
set -e
-find $FINALDIR/usr/local/lib/python2.7 -name "*.py" -not -path "*ironic_python_agent/api/config.py" | sudo xargs rm
-find $FINALDIR/usr/local/lib/python2.7 -name "*.pyc" | sudo xargs rm
+find $FINALDIR/usr/local/lib/python2.7 -name "*.py" -not -path "*ironic_python_agent/api/config.py" | sudo xargs --no-run-if-empty rm
+find $FINALDIR/usr/local/lib/python2.7 -name "*.pyc" | sudo xargs --no-run-if-empty rm
# Delete unnecessary Babel .dat files
-find $FINALDIR -path "*babel/locale-data/*.dat" -not -path "*en_US*" | sudo xargs rm
+find $FINALDIR -path "*babel/locale-data/*.dat" -not -path "*en_US*" | sudo xargs --no-run-if-empty rm
# Allow an extension to be added to the generated files by specifying
# $BRANCH_PATH e.g. export BRANCH_PATH=master results in tinyipa-master.gz etc