[Pkg-xen-devel] [PATCH 06/19] d/shuffle-binaries: Fix binary shuffling script for cross-building

Hans van Kranenburg hans at knorrie.org
Sat Dec 5 14:17:59 GMT 2020


On 12/5/20 3:57 AM, Elliott Mitchell wrote:
> 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.

I can read diffs and diffs of diffs. But I don't have a built-in base64
decoder in my eyes. ;-) Neither has git-am, we learned.

> 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`).
> 
> 

K



More information about the Pkg-xen-devel mailing list