[Pkg-xen-devel] [PATCH 12/19] d/shuffle-boot-files: Simplify loop structure

Elliott Mitchell ehem+debian at m5p.com
Wed Dec 2 19:50:57 GMT 2020


Rather than changing into the work directory and then running find,
instead simply run find and strip off the directory name later.  Since
the directory name was being re-added to the source filename later, this
reduces complexity.  Instead the work directory name needs to be stripped
off the target filename.

Put another way, remove all processing of source filename and do more
processing of target filename.

While at it use structures which conform to POSIX, allowing the use of
/bin/sh instead of bash.

Signed-off-by: Elliott Mitchell <ehem+debian at m5p.com>
---
 debian/shuffle-boot-files | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/debian/shuffle-boot-files b/debian/shuffle-boot-files
index 88bcdd8d68..f4b11eddb6 100755
--- a/debian/shuffle-boot-files
+++ b/debian/shuffle-boot-files
@@ -25,6 +25,8 @@ verstring="$(readlink debian/tmp/boot/xen.?z* ||
 verstring="${verstring##*xen-}"
 verstring="${verstring%.?z*}"
 
-for f in `cd "$t/boot" && find * -type f -print`; do
-	cp -v "$t/boot/$f" "$dest/${f/$verstring/$newvers}"
+find "$t/boot" -type f -print | while read f; do
+	head="${f%$verstring*}"
+	tail="${f#*$verstring}"
+	cp -vl "$f" "$dest${head#$t/boot}$newvers${tail}"
 done
-- 


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         ehem+sigmsg at m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445






More information about the Pkg-xen-devel mailing list