[Pkg-xen-devel] [PATCH 04/12] debian/rules: Adjust boot shuffling script for POSIX

Elliott Mitchell ehem+debian at m5p.com
Sun Sep 20 04:55:50 BST 2020


On Thu, Sep 17, 2020 at 05:01:21PM +0100, Ian Jackson wrote:
> Elliott Mitchell writes ("[PATCH 04/12] debian/rules: Adjust boot shuffling script for POSIX"):
> > diff --git a/debian/shuffle-boot-files b/debian/shuffle-boot-files
> > index f7492c0c72..8e4ed7e64c 100755
> > --- a/debian/shuffle-boot-files
> > +++ b/debian/shuffle-boot-files
> > @@ -1,4 +1,4 @@
> > -#!/bin/bash
> > +#!/bin/sh
> >  
> >  set -e
> >  
> > @@ -26,6 +26,7 @@ verstring=$(readlink debian/tmp/boot/xen.gz ||
> >  verstring=${verstring##*/}
> >  verstring=${verstring%.gz}
> >  
> > -for f in `cd $t/boot && find * -type f -print`; do
> > -	cp -v $t/boot/$f $dest/${f/$verstring/xen-$version-$flavour}
> > +find "$t/boot" -type f -print | while read f
> > +do
> > +	cp -v "$f" "$dest${f#$t/boot}"
> >  done
> 
> (1) I'm not sure this does precisely the same thing as before
> (2) even the amount of time I have just spent staring at it was
> wasted because there is no need for this change.

A test certainly appeared to produce identical results.  Tell you what,
the below version most definitely does not do precisely the same thing as
before.

Notably instead of passing two arguments which get merged to the same
thing twice, this simply uses a single pre-merged argument.

This also isolates the Xen version string more precisely.  As a result
this can instead swap strictly the Xen version string for the one used in
the Debian packages.

This is valuable since sometime between 11 and 13, the Xen build started
shipping an SE Linux policy and that filename doesn't conform to the
pattern "xen-X.Y.Z*".  I'm unsure about whether it should actually be in
/boot, but for the first pass at least the name matches now.

-----
d/shuffle-boot-files: Rework boot shuffling script

Rather than passing two strings which are strictly joined and used to
replace filename versions, turn them into a simple version replacement.

Rework the script logic to specifically target the version string in
filenames and replace *that*.  This fixes an issues with some Xen files
having names distinct enough names to not match the assumed format.

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/rules              |  2 +-
 debian/shuffle-boot-files | 26 ++++++++++++++------------
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/debian/rules b/debian/rules
index eb4e1190de..ca939ef3a5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -270,7 +270,7 @@ xenstore_rm = $(addprefix debian/xen-utils-common/,		\
 override_dh_install:
 	debian/shuffle-binaries $(upstream_version)
 	:
-	debian/shuffle-boot-files $(upstream_version) $(flavour)
+	debian/shuffle-boot-files $(upstream_version)-$(flavour)
 	:
 	dh_install $(dh_install_excludes)
 	if test -d debian/xen-utils-common; then rm -v $(xenstore_rm); fi
diff --git a/debian/shuffle-boot-files b/debian/shuffle-boot-files
index f7492c0c72..7338032fe6 100755
--- a/debian/shuffle-boot-files
+++ b/debian/shuffle-boot-files
@@ -1,14 +1,13 @@
-#!/bin/bash
+#!/bin/sh
 
 set -e
 
-version=$1; shift
-flavour=$1; shift
+newvers=$1; shift
 t=debian/tmp
 
-hv=xen-hypervisor-$version-$flavour
-dest=debian/$hv/boot
-mkdir -p $dest
+hv="xen-hypervisor-$newvers"
+dest="debian/$hv/boot"
+mkdir -p "$dest"
 
 # The upstream build system puts a pile of needless symlinks in /boot.
 #
@@ -21,11 +20,14 @@ mkdir -p $dest
 # more useful when the -i386 flavour existed and was coinstallable
 # with the -amd64 flavour.)
 
-verstring=$(readlink debian/tmp/boot/xen.gz ||
-            readlink debian/tmp/boot/xen)
-verstring=${verstring##*/}
-verstring=${verstring%.gz}
+xenvers="$(readlink debian/tmp/boot/xen.?z* ||
+            readlink debian/tmp/boot/xen)"
+xenvers="${xenvers##*xen-}"
+xenvers="${xenvers%.?z*}"
 
-for f in `cd $t/boot && find * -type f -print`; do
-	cp -v $t/boot/$f $dest/${f/$verstring/xen-$version-$flavour}
+find "$t/boot" -type f -print | while read f
+do
+	head="${f%$xenvers*}"
+	tail="${f#*$xenvers}"
+	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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-d-shuffle-boot-files-Rework-boot-shuffling-script.patch
Type: text/x-diff
Size: 2603 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-xen-devel/attachments/20200919/48859f38/attachment.patch>


More information about the Pkg-xen-devel mailing list