[PATCH 1/1] strip: Use debugedit instead of AWK to parse source files

Xiretza xiretza+archml at xiretza.xyz
Sun Jan 2 15:00:56 UTC 2022


On 02/01/2022 15.48, Allan McRae wrote:
> On 3/1/22 00:29, Xiretza wrote:
>>
>> On 02/01/2022 15.24, Allan McRae wrote:
>>> On 3/1/22 00:20, Allan McRae wrote:
>>>>
>>>> Add -n.
>>>>
>>
>> No change.
>>
>>>
>>> For a better example, here is my testing code:
>>>
>>> source_files() {
>>>      dbgsrcdir="${DBGSRCDIR:-/usr/src/debug}"
>>>      local dbgsrclist="$(mktemp "${startdir}/dbgsrclist.${binary##*/}.XXXXXXXXX")"
>>> echo $1 >> $startdir/dbginfo
>>> echo sha256sum-orig: $(sha256sum $1) >> $startdir/dbginfo
>>>      LANG=C debugedit -n -b "${srcdir}" -d "${dbgsrcdir}" -l "${dbgsrclist}" "$1" > /dev/null
>>>      sort -zu "${dbgsrclist}" | tr '\0' '\n'
>>> sort -zu "${dbgsrclist}" | tr '\0' '\n' >> $startdir/dbginfo
>>> echo sha256sum-after: $(sha256sum $1) >> $startdir/dbginfo
>>>      rm -f "$dbgsrclist"
>>> }
>>>
>>>
>>> and a snippet of the output:
>>>
>>> ./usr/bin/vercmp
>>> sha256sum-orig: 844e2a18277df5d46544fc977a028b02b58d642bc9754d7d9868197d23f42407 ./usr/bin/vercmp
>>> pacman/builddir/<artificial>
>>> pacman/builddir/<built-in>
>>> pacman/lib/libalpm/version.c
>>> pacman/src/util/vercmp.c
>>> sha256sum-after: 844e2a18277df5d46544fc977a028b02b58d642bc9754d7d9868197d23f42407 ./usr/bin/vercmp
>>
>> Is it possible that there are simply no source file entries referencing $srcdir (because -fdebug-prefix-map is working as expected)? As I said, if that's the case, the binary is not modified because there are no occurrences of $srcdir to be rewritten to $dbgsrcdir.
> 
> That is possible - I mostly tested packages I know obey CFLAGS.  Saying that, any change would be a good thing, or else those source files placed in ${dbgsrcdir} are kindof useless!  So I'm happy to have this rewrite paths - we are not regenerating the build-id, so I'm assuming this does not cause package reproducibility issues...

Makes sense, I can't think of any issues this would cause either - the source file paths have to be deterministic anyway, applying a deterministic transform on top won't change that.

Still, having a function called "source_files" actually modify the passed binary deserves a comment, I think.

> 
> Also, I get a very different list of files with and without -b/-d. Without using them I get a lot of system files.  With, I just get the package source files.

Right, without -b/-d, it just lists all source files.
With just -b, it prints all source files rooted in the specified directory, but strips the prefix from the output.
With both -b and -d, it replaces any base-dir prefixes with dest-dir (modifying the binary), then prints all paths rooted in the dest-dir (again, stripping the dest-dir prefix in the output), regardless if they've always been rooted in dest-dir (due to -fdebug-prefix-map) or if they were just transformed from base-dir.

I hope that made sense.

> 
> A



More information about the pacman-dev mailing list