Message ID | 20220101175153.1441024-1-foxboron@archlinux.org |
---|---|
State | New, archived |
Headers | show |
Series | makepkg: Handle invalid files in strip | expand |
On 01/01/2022 18.51, Morten Linderud wrote: > From: Morten Linderud <morten@linderud.pw> > > makepkg does a fairly naive pass on the DWARF files to generate source > files. If this is done on things like Golang it will give strip a list > of files that are truncated paths or completely invalid virtual paths > for the runtime to interpret. > > We also explicitly only allow source files that contains the given debug > source directory. We depend on this for file lookup and it would produce > invalid packages with weird paths if they are not present. > > Signed-off-by: Morten Linderud <morten@linderud.pw> > --- > scripts/libmakepkg/tidy/strip.sh.in | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in > index 92a6fb15..d9eb8a95 100644 > --- a/scripts/libmakepkg/tidy/strip.sh.in > +++ b/scripts/libmakepkg/tidy/strip.sh.in > @@ -60,11 +60,11 @@ strip_file() { > while IFS= read -r t; do > file=${t/${dbgsrcdir}/"$srcdir"} > dest="${dbgsrc/"$dbgsrcdir"/}$t" > - if ! [[ -f $dest ]]; then > + if [[ -f "$file" ]] && ! [[ -f $dest ]]; then > mkdir -p "${dest%/*}" > cp -- "$file" "$dest" > fi > - done < <(source_files "$binary") > + done < <(source_files "$binary" | grep "$dbgsrcdir") > > # copy debug symbols to debug directory > mkdir -p "$dbgdir/${binary%/*}" This also removes any warning in case -fdebug-prefix-map= fails to work (e.g. because of upstream build scripts overriding CFLAGS) and just results in a debug package without any source files. Maybe it would be better to unconditionally look at every source file path, and: 1) if it's rooted in $dbgsrcdir, do the copy 2) otherwise, if it's rooted in $srcdir (because the prefix mapping didn't work), warn/error 3) otherwise, skip (it's a mangled filename without any useful meaning) -xiretza
On Sat, Jan 01, 2022 at 07:45:33PM +0100, Xiretza wrote: > On 01/01/2022 18.51, Morten Linderud wrote: > > From: Morten Linderud <morten@linderud.pw> > > > > makepkg does a fairly naive pass on the DWARF files to generate source > > files. If this is done on things like Golang it will give strip a list > > of files that are truncated paths or completely invalid virtual paths > > for the runtime to interpret. > > > > We also explicitly only allow source files that contains the given debug > > source directory. We depend on this for file lookup and it would produce > > invalid packages with weird paths if they are not present. > > > > Signed-off-by: Morten Linderud <morten@linderud.pw> > > --- > > scripts/libmakepkg/tidy/strip.sh.in | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in > > index 92a6fb15..d9eb8a95 100644 > > --- a/scripts/libmakepkg/tidy/strip.sh.in > > +++ b/scripts/libmakepkg/tidy/strip.sh.in > > @@ -60,11 +60,11 @@ strip_file() { > > while IFS= read -r t; do > > file=${t/${dbgsrcdir}/"$srcdir"} > > dest="${dbgsrc/"$dbgsrcdir"/}$t" > > - if ! [[ -f $dest ]]; then > > + if [[ -f "$file" ]] && ! [[ -f $dest ]]; then > > mkdir -p "${dest%/*}" > > cp -- "$file" "$dest" > > fi > > - done < <(source_files "$binary") > > + done < <(source_files "$binary" | grep "$dbgsrcdir") > > # copy debug symbols to debug directory > > mkdir -p "$dbgdir/${binary%/*}" > > This also removes any warning in case -fdebug-prefix-map= fails to work (e.g. > because of upstream build scripts overriding CFLAGS) and just results in a > debug package without any source files. Maybe it would be better to > unconditionally look at every source file path, and: > > 1) if it's rooted in $dbgsrcdir, do the copy > 2) otherwise, if it's rooted in $srcdir (because the prefix mapping didn't work), warn/error > 3) otherwise, skip (it's a mangled filename without any useful meaning) > > -xiretza I think this was a bit naive indeed. However, unless someone is against debugedit I think that patch set supersedes this one and probably solves a few of these issues?
diff --git a/scripts/libmakepkg/tidy/strip.sh.in b/scripts/libmakepkg/tidy/strip.sh.in index 92a6fb15..d9eb8a95 100644 --- a/scripts/libmakepkg/tidy/strip.sh.in +++ b/scripts/libmakepkg/tidy/strip.sh.in @@ -60,11 +60,11 @@ strip_file() { while IFS= read -r t; do file=${t/${dbgsrcdir}/"$srcdir"} dest="${dbgsrc/"$dbgsrcdir"/}$t" - if ! [[ -f $dest ]]; then + if [[ -f "$file" ]] && ! [[ -f $dest ]]; then mkdir -p "${dest%/*}" cp -- "$file" "$dest" fi - done < <(source_files "$binary") + done < <(source_files "$binary" | grep "$dbgsrcdir") # copy debug symbols to debug directory mkdir -p "$dbgdir/${binary%/*}"