Hans van Kranenburg
2020-Dec-04 21:04 UTC
[Pkg-xen-devel] [PATCH 06/19] d/shuffle-binaries: Fix binary shuffling script for cross-building
On 7/17/20 8:37 AM, Elliott Mitchell wrote:> `ldd` doesn't work with cross-builds, so use `file` to detect scripts > and `strings | grep` for identifying linked libraries. Even though > debhelper depends on file, make the requirement explicit. > > Heavily simplify script inner loop. While the core of that inner loop > was often executed only once, it is best to shrink inner loops. > > Signed-off-by: Elliott Mitchell <ehem+debian at m5p.com> > --- > debian/control | 1 + > debian/shuffle-binaries | 31 ++++++++++++++++--------------- > 2 files changed, 17 insertions(+), 15 deletions(-) > > diff --git a/debian/control b/debian/control > index 942bf6711c..90007f6a02 100644 > --- a/debian/control > +++ b/debian/control > @@ -6,6 +6,7 @@ Section: admin > Standards-Version: 4.5.0 > Build-Depends: > debhelper (>= 10), > + file, > dh-exec, > dpkg-dev (>= 1.16.0~), > rdfind, > diff --git a/debian/shuffle-binaries b/debian/shuffle-binaries > index 37176d26e7..03b4bc4794 100755 > --- a/debian/shuffle-binaries > +++ b/debian/shuffle-binaries > @@ -24,28 +24,29 @@ mkdir -p "$t/$vd" > > find "$t"/usr/*bin -type f | while read binary; do > > - reason='' > - { ldd "$binary" ||: ; } | { fgrep '=>' ||: ; } \ > - | ( > - while read lib dummy; do > + # filter for executables (ignore scripts) > + file "$binary" | grep -q -eELF.\\+version.\\+interpreter || continue > + > + # ldd doesn't work for cross-building > + reason=$( > + strings "$binary" | grep -e^lib.\\+\\.so\\.\[.0-9\]\\+\$ | \ > + while read lib; do > lib=${lib%.so.*} > - if grep -F "usr/lib/*/$lib.so.*" $list >/dev/null; then > - reason+=" $lib" > + if grep -q -F "usr/lib/*/$lib.so.*" $list; then > + printf " %s" "$lib" > fi > done > + ) > > - if [ "x$reason" = x ]; then > - exit 0 > - fi > + # if no reason, then skip > + [ -n "$reason" ] || continue > > - echo "shuffling $binary $reason" > + echo "shuffling $binary$reason" > > - leaf=${binary##*} > - mv -v $binary $t/$vd/$leaf > - ln -vs $cd/xen-utils-wrapper $binary > + mv -v "$binary" "$t/$vd/" > + ln -vs "$cd/xen-utils-wrapper" "$binary" > > - touch debian/shuffle-binaries.stamp > - ) > + touch "$0.stamp" > done > > if [ ! -e "$0.stamp" ]; then >Ok, this one does not apply: ~/build/xen/debian-xen k (knorrie/sid) 0-$ git am -3 20201204-2028-ehem/06\ d_shuffle-binaries\:\ Fix\ binary\ shuffling\ script\ for\ cross-building\ -\ Elliott\ Mitchell\ \<ehem+debian at m5p.com\>\ -\ 2020-07-17\ 0837.eml Applying: d/shuffle-binaries: Fix binary shuffling script for cross-building error: sha1 information is lacking or useless (debian/shuffle-binaries). error: could not build fake ancestor Patch failed at 0001 d/shuffle-binaries: Fix binary shuffling script for cross-building hint: Use 'git am --show-current-patch' to see the failed patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort". When I use git am --show-current-patch I get a big pile of crap because you're not using git send-email. I don't know what to do with this now. Hans
Elliott Mitchell
2020-Dec-05 02:57 UTC
[Pkg-xen-devel] [PATCH 06/19] d/shuffle-binaries: Fix binary shuffling script for cross-building
On Fri, Dec 04, 2020 at 10:04:35PM +0100, Hans van Kranenburg wrote:> When I use git am --show-current-patch I get a big pile of crap because > you're not using git send-email. > > I don't know what to do with this now.Strong indicator of a missing patch. In this case you got 1-4, but then missed #5 and started on #6. #5 and #6 don't modify the same lines, but they modify lines next together and thus missing #5 kills the context lines for #6. Eventually you'll learn how to read patches whether you want to or not. As such, a quick overview of the format: --- a/debian/shuffle-binaries +++ b/debian/shuffle-binaries @@ -22,7 +22,7 @@ cd=/usr/lib/xen-common/bin mkdir -p "$t/$vd" -for binary in `find $t/usr/{bin,sbin} -type f`; do +find "$t"/usr/*bin -type f | while read binary; do # filter for executables (ignore scripts) file "$binary" | grep -q -eELF.\\+version.\\+interpreter || continue --end The first two are the source and destination files, plus a triple repetition of their respective prefixes. Most often '-' is used for source and '+' is used for destination and the source is listed before destination, but the format *DOES* *NOT* require this! Though now that I've tried, `git am` doesn't like anything other than '-' for source and '+' for destination (`patch` is perfectly happy with '%' and '$'). Hunks start with "@@". The '-' is the character used for the source file, the '+' is the character used for the destination file. The first number is the line number from the respective file, the second is the number of lines included from that file. The following lines start with one of 3 characters. Space is for lines which are identical between both files. If a line starts with the source prefix, then that line is *only* present in the source file. If a line starts with the destination prefix, then that line is *only* present in the destination file. This likely isn't the greatest description of the patch format. Your favored search engine can find other descriptions of the "patch" or "unified diff" format. For reference, the below is considered *identical* to the above: ### b/debian/shuffle-binaries zzz a/debian/shuffle-binaries @@ z22,7 #22,7 @@ cd=/usr/lib/xen-common/bin mkdir -p "$t/$vd" zfor binary in `find $t/usr/{bin,sbin} -type f`; do #find "$t"/usr/*bin -type f | while read binary; do reason='' { ldd "$binary" ||: ; } | { fgrep '=>' ||: ; } \ | ( --end `diff -u $src $dst` can generate the same result. Generally source/destination filenames include the parent directory. Any patch acceptable to `git am` can also be applied using `patch -p1 < $file` If you're doing this long enough you'll learn the basics of the patterns since humans are great at pattern recognition and at some point you'll need to deal with a funky patch due to wanting its result. Perversions like the above are rare, but the format (though not `git am`) allows it (yes, prior to sending this message I tested with `patch -p1`). -- (\___(\___(\______ --=> 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