Changes to bldpkg:

* Added code that detects stripped binaries before we actually strip them of debug symbols
Fixed various typos and code
This commit is contained in:
PktSurf 2022-08-09 15:49:36 +05:30
parent 90569a2a82
commit 73cff466bf

38
bldpkg
View file

@ -26,8 +26,6 @@
# not belonging to the current build are present inside tmpfs
# -> Warn user when /share/icons or /share/applications directory is present but
# a doinst.sh file that should update the icon caching is absent in the source directory
# -> Warn users if mkfinalpkg finds binaries and shared libraries that are already stripped
# prior to us stripping them manually ; a file count would be useful.
# Begin subshell
(
@ -465,7 +463,7 @@ if [ "$usetmpfs" = "1" ] && [ -n "$tmpfsdir" ] && [ -z "$tmpfscheckfailed" ] ; t
# Disable ccache
ccache=0
# Override preservebuilddir and preservpackagedir to remove both build and package directories
# Override preservebuilddir and preservepackagedir to remove both build and package directories
preservebuilddir=0
preservepackagedir=0
@ -956,15 +954,25 @@ mkfinalpkg() {
install -Dm 644 "$srcdir/$buildfile" "$pkgdocs/$app.SMBuild"
# Normally we'd expect some debug symbols in the newly-produced binaries.
# But that isn't always the case.
#find "$pkg" -print0 -type f | xargs -0 file -m /etc/file/magic/elf | \
# grep -q "not stripped"
#if [ "$?" = "0" ] ; then
# echo "[WARNING] Binaries were stripped before hand!"
# sleep 2
#fi
# But that isn't always the case with some packages whose build systems
# strip objects before hand
if [ "$debug" = "1" ] ; then
for file in \
$( find $pkg )
do
file -m /etc/file/magic/elf $file | \
grep -E "executable|shared object" | \
grep ", stripped" | cut -d: -f1 >> "$pkg/install/package.$app.debugfailedfilenames"
done
debugfilecount="$(wc -l < "$pkg/install/package.$app.debugfailedfilenames")"
if [ "$debugfilecount" -ge "1" ]; then
debugwarning=1
else
rm "$pkg/install/package.$app.debugfailedfilenames"
fi
fi
# Now strip the binaries and shared libraries. --strip-unneeded is unnecessary for binutils 2.34+
if [ -z "$debug" ] && [ "$debug" != "1" ]; then
find "$pkg" -print0 | xargs -0 file -m /etc/file/magic/elf | \
@ -998,7 +1006,7 @@ mkfinalpkg() {
echo "[INFO] Leaving staging directory $pkg"
# cd back to $srcdir when preservpackagedir is set to 0 to prevent this error: shell-init: error retrieving
# cd back to $srcdir when preservepackagedir is set to 0 to prevent this error: shell-init: error retrieving
# current directory: getcwd: cannot access parent directories: No such file or directory
echo "[INFO] Re-entering source directory $srcdir"
cd "$srcdir"
@ -1042,7 +1050,7 @@ mkfinalpkg() {
fi
fi
# Delete the package build directory if preservpackagedir is set to 0
# Delete the package build directory if preservepackagedir is set to 0
if [ "$preservepackagedir" = "0" ] ; then
if ! inarray "${pkg}" "${protecteddirectories[@]}" ; then
rm -rf "$pkg"
@ -1135,8 +1143,10 @@ prepbuildoutput() {
# Determine the build type
if [ "$debug" = "1" ] ; then
if [ "$debug" = "1" ] && [ -z "$debugwarning" ] ; then
bldtype="*DEBUG* build"
elif [ "$debug" = "1" ] && [ "$debugwarning" = "1" ]; then
bldtype="*DEBUG* build[WARNING]"
else
bldtype="General build, no debug symbols"
fi