Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Jun 2023 08:54:19 -0300
From:      Renato Botelho <garga@FreeBSD.org>
To:        Mathieu Arnold <mat@freebsd.org>, Yuri Victorovich <yuri@freebsd.org>
Cc:        ports-committers@freebsd.org, dev-commits-ports-all@freebsd.org, dev-commits-ports-main@freebsd.org
Subject:   Re: git: 67ce8cec004c - main - Mk/Scripts: Fix the 'stripped' check from 'make check-plist' to report all unstripped files
Message-ID:  <f8dc3305-06eb-3278-0d22-d651dae7744c@FreeBSD.org>
In-Reply-To: <szfldnpn56vsuxnz43ngpaxjev4ywofryunpvrtausomgwhien@vy4flxbzvpgp>
References:  <202306020645.3526jV0Y019662@gitrepo.freebsd.org> <szfldnpn56vsuxnz43ngpaxjev4ywofryunpvrtausomgwhien@vy4flxbzvpgp>

next in thread | previous in thread | raw e-mail | index | archive | help
On 02/06/23 04:11, Mathieu Arnold wrote:
> On Fri, Jun 02, 2023 at 06:45:31AM +0000, Yuri Victorovich wrote:
>> The branch main has been updated by yuri:
>>
>> URL: https://cgit.FreeBSD.org/ports/commit/?id=67ce8cec004c85caeee5a6e965bd10f872e1b895
>>
>> commit 67ce8cec004c85caeee5a6e965bd10f872e1b895
>> Author:     Yuri Victorovich <yuri@FreeBSD.org>
>> AuthorDate: 2023-06-02 06:40:46 +0000
>> Commit:     Yuri Victorovich <yuri@FreeBSD.org>
>> CommitDate: 2023-06-02 06:45:29 +0000
>>
>>      Mk/Scripts: Fix the 'stripped' check from 'make check-plist' to report all unstripped files
>>      
>>      Prior to this patch, the 'stripped' check always skipped the first
>>      unstripped file.
>>      
>>      It uses the "find [...] -exec sh -c 'readelf -S -- /dev/null $0 "$@" || :' -- {} +"
>>      command. When arguments are passed to shell like this:
>>      "sh -c 'script' arg1 arg2 arg3" - $@ within the script is assigned
>>      to 'arg2 arg3', and $0 is assigned to arg1. This is a quirk in
>>      how shells handle arguments in case when the script is passed
>>      using -c.
>>      
>>      This patch adds $0 to account for the first passed file.
> 
> So, you are right, when you run `sh -c 'script' arg1 arg2 arg3`, arg1 is
> in $0, and arg2 and arg3 are in $@.
> 
> Now, here, we are running `sh -c 'script' -- arg1 arg2 arg3`, so, $0
> contains `--`, and arg1-3 are in $@.

On local tests, without this patch, I confirmed first file is always 
skipped, as mentioned on ticket.  I took misc/trurl as example:

❯ find work/stage -type f ! -name '*.a' ! -name '*.o'
work/stage/usr/local/man/man1/trurl.1.gz
work/stage/usr/local/share/licenses/trurl-0.7/LICENSE
work/stage/usr/local/share/licenses/trurl-0.7/catalog.mk
work/stage/usr/local/share/licenses/trurl-0.7/MIT
work/stage/usr/local/bin/trurl

Without the patch, calling readelf I can see:

❯ find work/stage -type f ! -name '*.a' ! -name '*.o' -exec sh -c 
'readelf -S -- /dev/null "$@" || :' -- {} + 2>/dev/null |& grep '^File:'
File: /dev/null
File: work/stage/usr/local/share/licenses/trurl-0.7/LICENSE
File: work/stage/usr/local/share/licenses/trurl-0.7/catalog.mk
File: work/stage/usr/local/share/licenses/trurl-0.7/MIT
File: work/stage/usr/local/bin/trurl

And with the change:

❯ find work/stage -type f ! -name '*.a' ! -name '*.o' -exec sh -c 
'readelf -S -- /dev/null "$0" "$@" || :' -- {} + 2>/dev/null |& grep 
'^File:'
File: /dev/null
File: work/stage/usr/local/man/man1/trurl.1.gz
File: work/stage/usr/local/share/licenses/trurl-0.7/LICENSE
File: work/stage/usr/local/share/licenses/trurl-0.7/catalog.mk
File: work/stage/usr/local/share/licenses/trurl-0.7/MIT
File: work/stage/usr/local/bin/trurl

Did I miss something?

>> -	    -exec sh -c 'readelf -S -- /dev/null "$@" || :' -- {} + 2>/dev/null | awk '
>> +	    -exec sh -c 'readelf -S -- /dev/null $0 "$@" || :' -- {} + 2>/dev/null | awk '
> 
> If the patch was correct, you would need to quote "$0".

Good catch.

> But as I pointed out, it is not correct, so please revert.
> 

-- 
Renato Botelho




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?f8dc3305-06eb-3278-0d22-d651dae7744c>