Changes to bldpkg:
* Added more stuff in TODO * Rearranged code that sources bldpkg.conf a few lines up * Renamed function debugmode to tracemode * Defined setbuildfile, autoextractmode, displaysummary and setcputhreads functions and added corresponding option letters to getopts * Added explanation in the help function * Added temporary commented code for detecting stripped binaries and libraries before they are actually stripped * Discarded -exec rm -v since the find command already contains -delete * Discarded --strip-unneeded option from strip command * Miscellaneous fixes
This commit is contained in:
parent
9132b697fe
commit
00b7252c7d
3 changed files with 166 additions and 65 deletions
226
bldpkg
226
bldpkg
|
@ -22,6 +22,12 @@
|
||||||
# TODO
|
# TODO
|
||||||
# -> Uncomment entirety of the code where compilers are to be hard-validated and improve C code
|
# -> Uncomment entirety of the code where compilers are to be hard-validated and improve C code
|
||||||
# in the test files and also add suitable bldpkg.conf switches for it
|
# in the test files and also add suitable bldpkg.conf switches for it
|
||||||
|
# -> Give a warning when more than two directories, a source and a staging directory
|
||||||
|
# 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
|
# Begin subshell
|
||||||
(
|
(
|
||||||
|
@ -33,6 +39,14 @@ set -e
|
||||||
# into package build summary.
|
# into package build summary.
|
||||||
commencedate="$(date '+%a, %d %b %Y, %T')"
|
commencedate="$(date '+%a, %d %b %Y, %T')"
|
||||||
|
|
||||||
|
# Then source the configuration file holding all values
|
||||||
|
if [ -f /etc/bldpkg.conf ] ; then
|
||||||
|
source /etc/bldpkg.conf
|
||||||
|
else
|
||||||
|
echo "[ERROR] /etc/bldpkg.conf not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Store the source directory path the build was initiated from
|
# Store the source directory path the build was initiated from
|
||||||
srcdir="$PWD"
|
srcdir="$PWD"
|
||||||
|
|
||||||
|
@ -40,9 +54,60 @@ srcdir="$PWD"
|
||||||
srcdirpath="$(basename $srcdir)"
|
srcdirpath="$(basename $srcdir)"
|
||||||
buildfile="$srcdirpath.SMBuild"
|
buildfile="$srcdirpath.SMBuild"
|
||||||
|
|
||||||
debugmode() {
|
sourcebuildfile() {
|
||||||
|
if [ -f "$buildfile" ] ; then
|
||||||
|
source "$buildfile"
|
||||||
|
else
|
||||||
|
# We expect a filename as part of -f argument
|
||||||
|
echo "[ERROR] No build file to source from! If you used -f argument, make sure it is"
|
||||||
|
echo "[ERROR] the first argument pointing to a build file before any other argument."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
setbuildfile() {
|
||||||
|
buildfile0="$OPTARG"
|
||||||
|
if [ ! -f "$OPTARG" ] ; then
|
||||||
|
echo "[ERROR] Build file $buildfile0 not found!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
buildfile="$buildfile0"
|
||||||
|
sourcebuildfile
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to invoke bash shell's -x mode for troubleshooting
|
||||||
|
tracemode() {
|
||||||
set -x
|
set -x
|
||||||
source "$buildfile"
|
sourcebuildfile
|
||||||
|
}
|
||||||
|
|
||||||
|
debugmode() {
|
||||||
|
debug=1
|
||||||
|
sourcebuildfile
|
||||||
|
}
|
||||||
|
|
||||||
|
autoextractmode() {
|
||||||
|
# Override extractprompt in bldpkg.conf
|
||||||
|
extractprompt=0
|
||||||
|
autoextract=1
|
||||||
|
sourcebuildfile
|
||||||
|
}
|
||||||
|
|
||||||
|
displaysummary() {
|
||||||
|
# Override showsummary in bldpkg.conf
|
||||||
|
showsummary=1
|
||||||
|
sourcebuildfile
|
||||||
|
}
|
||||||
|
|
||||||
|
setcputhreads() {
|
||||||
|
cputhreads0="$OPTARG"
|
||||||
|
# Validate if the argument is a number. If not, throw an error and exit.
|
||||||
|
if ! echo "$cputhreads0" | egrep -q '^[0-9]+$' ; then
|
||||||
|
echo "[ERROR] Invalid CPU job number. Please try again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
cputhreads="$cputhreads0"
|
||||||
|
sourcebuildfile
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate sha512sums in the build file
|
# Generate sha512sums in the build file
|
||||||
|
@ -75,54 +140,82 @@ genchecksum() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Function to generate help message
|
||||||
help() {
|
help() {
|
||||||
cat << EOF
|
cat << EOF
|
||||||
Bash script for building SMLinux-compatible packages from source.
|
Bash script for building SMLinux-compatible packages from source.
|
||||||
|
Any option used as an argument with this script overrides the
|
||||||
|
corresponding option, if present, in /etc/bldpkg.conf
|
||||||
|
|
||||||
This script takes only one parameter.
|
If no arguments are provided, this script attempts to build a package
|
||||||
|
by matching the parent directory name with a build file that matches
|
||||||
|
that directory's name.
|
||||||
|
|
||||||
|
For example, if the build directory is $HOME/smlinux/alsa-lib, this script will
|
||||||
|
look and source from alsa-lib.SMBuild and build alsa-lib package if the user
|
||||||
|
has cd'd to $HOME/smlinux/alsa-lib
|
||||||
|
|
||||||
|
# pwd
|
||||||
|
/home/smlinux/alsa-lib
|
||||||
|
|
||||||
|
# ls
|
||||||
|
alsa-lib.SMBuild
|
||||||
|
|
||||||
|
# bldpkg
|
||||||
|
Building package 'alsa-lib' version '1.x' build '1sml'...
|
||||||
|
...build output...
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
-d : Invoke bash shell debug mode
|
|
||||||
|
|
||||||
-h : Show this message
|
-d : Produce a package with debug symbols preserved
|
||||||
|
|
||||||
-g : Generate SHA512 checksums of all tarballs and patches and insert them into the package build file
|
-e : Extract the package installer file in the user's PWD if the build
|
||||||
|
completes successfully.
|
||||||
|
|
||||||
|
-f : Alternate build file to source build variables.
|
||||||
|
NOTE: This argument, if used, must come before any other argument
|
||||||
|
|
||||||
|
-g : Generate SHA512 checksums of all tarballs and patches and insert them
|
||||||
|
into the package build file
|
||||||
|
|
||||||
|
-h : Show this help message
|
||||||
|
|
||||||
|
-j<N> : Provide a number of jobs to be run simultaneously
|
||||||
|
|
||||||
|
-s : Display build summary. A summary is produced whenever a build is either
|
||||||
|
interrupted, exits cleanly or aborts due to a build error
|
||||||
|
|
||||||
|
-x : Invoke bash shell command trace mode. This one isn't akin to running
|
||||||
|
bash -x <script> but close enough, because the mode is inserted
|
||||||
|
half way while bldpkg is running
|
||||||
|
|
||||||
If no arguments are provided, this script attempts to build a package provided the package build file and the parent directory name matches.
|
|
||||||
EOF
|
EOF
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ':dhg' option; do
|
# Function for providing handy arguments to users
|
||||||
|
while getopts ':def:ghj:sx' option; do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
d)
|
d) debugmode ;;
|
||||||
debugmode
|
e) autoextractmode ;;
|
||||||
;;
|
f) setbuildfile "$OPTARG" ;;
|
||||||
h)
|
g) genchecksum ;;
|
||||||
help
|
h) help ;;
|
||||||
;;
|
j) setcputhreads "$OPTARG" ;;
|
||||||
g)
|
s) displaysummary ;;
|
||||||
genchecksum
|
x) tracemode ;;
|
||||||
;;
|
*) help ;;
|
||||||
*)
|
|
||||||
help
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# If no argument is given, attempt to source the build file matching the parent directory name
|
# If no argument is given, or if argument is greater than 1, invoke sourcebuildfile function.
|
||||||
if [ "$OPTIND" -eq 1 ] ; then
|
if [ "$OPTIND" -ge 1 ] ; then
|
||||||
if [ -f "$buildfile" ] ; then
|
sourcebuildfile
|
||||||
source "$buildfile"
|
|
||||||
else
|
|
||||||
echo "[ERROR] Could not find $srcdirpath build file to source from!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Determine whether we are using bash version 4 and later
|
# Determine whether we are using bash version 4 and later
|
||||||
if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
|
if [ "${BASH_VERSINFO[0]}" -lt 4 ] ; then
|
||||||
echo "[ERROR] You need to upgrade your bash shell to a minimum of 4.0 or higher"
|
echo "[ERROR] bldpkg requires a minimum of version 4 and later to run"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -209,25 +302,17 @@ applypatch() {
|
||||||
patch -p1 < "$1"
|
patch -p1 < "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Then source the configuration file holding all values
|
|
||||||
if [ -f /etc/bldpkg.conf ] ; then
|
|
||||||
source /etc/bldpkg.conf
|
|
||||||
else
|
|
||||||
echo "[ERROR] /etc/bldpkg.conf not found!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Do a preliminary package dependency check if checkdependencies is set to 1 in bldpkg.conf
|
# Do a preliminary package dependency check if checkdependencies is set to 1 in bldpkg.conf
|
||||||
if [ "$checkdependencies" == "1" ] ; then
|
if [ "$checkdependencies" = "1" ] ; then
|
||||||
|
|
||||||
echo "[INFO] Parsing $app 's dependency list..."
|
echo "[INFO] Parsing $app 's dependency list..."
|
||||||
for packagedep in "$requires"; do
|
for packagedep in "$requires"; do
|
||||||
depcount="$(find /share/doc -name $packagedep.SMBuild | wc -l)"
|
depcount="$(find /share/doc -name $packagedep.SMBuild | wc -l)"
|
||||||
# If count is 1, we are ok
|
# If count is 1, we are ok
|
||||||
if [ "$depcount" == "1" ] ; then
|
if [ "$depcount" = "1" ] ; then
|
||||||
echo "[INFO] Found dependency $packagedep"
|
echo "[INFO] Found dependency $packagedep"
|
||||||
# If count is 0, we exit, because we are in trouble
|
# If count is 0, we exit, because we are in trouble
|
||||||
elif [ "$depcount" == "0" ] ; then
|
elif [ "$depcount" = "0" ] ; then
|
||||||
echo "[ERROR] Did not find dependency $packagedep ."
|
echo "[ERROR] Did not find dependency $packagedep ."
|
||||||
exit 1
|
exit 1
|
||||||
# If count is greater than or equal to 2, we are in slightly less trouble
|
# If count is greater than or equal to 2, we are in slightly less trouble
|
||||||
|
@ -459,7 +544,7 @@ if [ "$globaldistcc" = "1" ] ; then
|
||||||
#checkstatus="$?"
|
#checkstatus="$?"
|
||||||
|
|
||||||
# Discard the files once the validation passes/fails
|
# Discard the files once the validation passes/fails
|
||||||
#if [ "$checkstatus" == "0" ] ; then
|
#if [ "$checkstatus" = "0" ] ; then
|
||||||
# echo "[OK]"
|
# echo "[OK]"
|
||||||
# rm $parenttmp/distcccheck-"$f"{,.c}
|
# rm $parenttmp/distcccheck-"$f"{,.c}
|
||||||
#else
|
#else
|
||||||
|
@ -533,7 +618,7 @@ if [ "$globalccache" = "1" ]; then
|
||||||
#checkstatus="$?"
|
#checkstatus="$?"
|
||||||
|
|
||||||
# Discard the files once the validation passes/fails
|
# Discard the files once the validation passes/fails
|
||||||
#if [ "$checkstatus" == "0" ] ; then
|
#if [ "$checkstatus" = "0" ] ; then
|
||||||
# echo "[OK]"
|
# echo "[OK]"
|
||||||
# rm $parenttmp/ccachecheck-"$f"{,.c}
|
# rm $parenttmp/ccachecheck-"$f"{,.c}
|
||||||
#else
|
#else
|
||||||
|
@ -610,7 +695,7 @@ if [ "$globalsccache" = "1" ]; then
|
||||||
#checkstatus="$?"
|
#checkstatus="$?"
|
||||||
|
|
||||||
# Discard the files once the validation passes/fails
|
# Discard the files once the validation passes/fails
|
||||||
#if [ "$checkstatus" == "0" ] ; then
|
#if [ "$checkstatus" = "0" ] ; then
|
||||||
# echo "[OK]"
|
# echo "[OK]"
|
||||||
# rm $parenttmp/sccachecheck-"$f"{,.c}
|
# rm $parenttmp/sccachecheck-"$f"{,.c}
|
||||||
#else
|
#else
|
||||||
|
@ -853,40 +938,47 @@ mkfinalpkg() {
|
||||||
# Compress and link manpages
|
# Compress and link manpages
|
||||||
if [ -d "$pkg/share/man" ]; then
|
if [ -d "$pkg/share/man" ]; then
|
||||||
echo "[INFO] Compressing and linking man pages..."
|
echo "[INFO] Compressing and linking man pages..."
|
||||||
( cd "$pkg/share/man"
|
(
|
||||||
for manpagedir in $(find . -type d -name "man*") ; do
|
cd "$pkg/share/man"
|
||||||
( cd "$manpagedir"
|
find . -type f -name "*.[0-9]" -o -name "*.[0-9]" | xargs gzip -9
|
||||||
for eachpage in $( find . -type l -maxdepth 1) ; do
|
for eachpage in $( find . -type l -maxdepth 1) ; do
|
||||||
ln -s "$( readlink "$eachpage" ).gz" "$eachpage".gz
|
ln -s "$( readlink "$eachpage" ).gz" "$eachpage".gz
|
||||||
rm "$eachpage"
|
rm "$eachpage"
|
||||||
done
|
done
|
||||||
gzip -9 ./*.? >/dev/null 2>&1 || true
|
)
|
||||||
)
|
|
||||||
done
|
|
||||||
)
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove .la files similar to what slackware devs are doing in slackware-current, but in a more efficient manner :)
|
# Remove .la files similar to what slackware devs are doing in slackware-current, but in a more efficient manner :)
|
||||||
echo "[INFO] Discarding any libtool archive (.la) files..."
|
echo "[INFO] Discarding any libtool archive (.la) files..."
|
||||||
find "$pkg" ! -type d -name "*.la" -exec rm -v {} \;
|
find "$pkg" -type f -name "*.la" -delete
|
||||||
|
|
||||||
# Provide a copy of the package build file so that users know the build options that went into compiling the package
|
# Provide a copy of the package build file so that users know the build options that went into compiling the package
|
||||||
install -Dm 644 "$srcdir/$buildfile" "$pkgdocs/$app.SMBuild"
|
install -Dm 644 "$srcdir/$buildfile" "$pkgdocs/$app.SMBuild"
|
||||||
|
|
||||||
# Now strip the binaries and shared libraries
|
# 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
|
||||||
|
|
||||||
|
# Now strip the binaries and shared libraries. --strip-unneeded is unnecessary for binutils 2.34+
|
||||||
if [ -z "$debug" ] && [ "$debug" != "1" ]; then
|
if [ -z "$debug" ] && [ "$debug" != "1" ]; then
|
||||||
find "$pkg" -print0 | xargs -0 file -m /etc/file/magic/elf | \
|
find "$pkg" -print0 | xargs -0 file -m /etc/file/magic/elf | \
|
||||||
grep -E "executable|shared object|statically linked" | grep "ELF" | \
|
grep -E "executable|shared object|statically linked" | grep "ELF" | \
|
||||||
cut -d: -f1 | xargs strip --strip-unneeded 2>/dev/null || true
|
cut -d: -f1 | xargs strip 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# And static libraries separately unconditionally
|
# And static libraries separately unconditionally
|
||||||
find "$pkg" -print0 | xargs -0 file -m /etc/file/magic/archive | \
|
find "$pkg" -print0 | xargs -0 file -m /etc/file/magic/archive | \
|
||||||
grep -E "current ar archive" | awk '{print $1}' | cut -d: -f1 | \
|
grep -E "current ar archive" | awk '{print $1}' | cut -d: -f1 | \
|
||||||
xargs strip --strip-unneeded 2>/dev/null || true
|
xargs strip 2>/dev/null || true
|
||||||
|
|
||||||
# Calculate total files, directories, symlinks and uncompressed staging directory size
|
# Calculate total files, directories, symlinks and uncompressed staging directory size
|
||||||
if [ "$showsummary" == "1" ] ; then
|
if [ "$showsummary" = "1" ] ; then
|
||||||
totalfilecount="$(find $pkg -type f | wc -l)"
|
totalfilecount="$(find $pkg -type f | wc -l)"
|
||||||
totaldircount="$(find $pkg -type d | wc -l)"
|
totaldircount="$(find $pkg -type d | wc -l)"
|
||||||
totalsymcount="$(find $pkg -type l | wc -l)"
|
totalsymcount="$(find $pkg -type l | wc -l)"
|
||||||
|
@ -912,7 +1004,7 @@ mkfinalpkg() {
|
||||||
cd "$srcdir"
|
cd "$srcdir"
|
||||||
|
|
||||||
|
|
||||||
if [ "$showsummary" == "1" ] || [ "$htmloutput" == "1" ] ; then
|
if [ "$showsummary" = "1" ] || [ "$htmloutput" = "1" ] ; then
|
||||||
# With SECONDS reset, the shell will add in a fresh value, which we can now use to ascertain the packaging time,
|
# With SECONDS reset, the shell will add in a fresh value, which we can now use to ascertain the packaging time,
|
||||||
# by again passing that value as an argument to the runtime function
|
# by again passing that value as an argument to the runtime function
|
||||||
packagetimea="$SECONDS"
|
packagetimea="$SECONDS"
|
||||||
|
@ -920,7 +1012,7 @@ mkfinalpkg() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$showsummary" == "1" ]; then
|
if [ "$showsummary" = "1" ]; then
|
||||||
# Determine size of SRCDIR aka source directory
|
# Determine size of SRCDIR aka source directory
|
||||||
srcdirsize="$(du -s $srcdir | awk '{print $1}')"
|
srcdirsize="$(du -s $srcdir | awk '{print $1}')"
|
||||||
# Determine size of tmp aka build directory size
|
# Determine size of tmp aka build directory size
|
||||||
|
@ -994,7 +1086,7 @@ prepbuildoutput() {
|
||||||
colourg="\e[92m"
|
colourg="\e[92m"
|
||||||
# Cyan for the short questions
|
# Cyan for the short questions
|
||||||
colourc="\e[96m"
|
colourc="\e[96m"
|
||||||
# appNAME/version Colours
|
# App name/version colours
|
||||||
colourv="\e[92m"
|
colourv="\e[92m"
|
||||||
# Restore to default
|
# Restore to default
|
||||||
colourd="\e[0m"
|
colourd="\e[0m"
|
||||||
|
@ -1209,6 +1301,16 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
promptuser() {
|
promptuser() {
|
||||||
|
|
||||||
|
# Extract package at the end of a build if autoextract is set to 1
|
||||||
|
if [ "$autoextract" = "1" ] && [ -z "$autobuild" ] && [ -n "$packlocation" ] ; then
|
||||||
|
echo "[INFO] Extracting package installer inside $srcdir/test..."
|
||||||
|
mkdir -p "$srcdir/test"
|
||||||
|
tar xvf "$packlocation" -C "$srcdir/test"
|
||||||
|
echo ""
|
||||||
|
echo "[INFO] '"$app"' package installer file successfully extracted"
|
||||||
|
fi
|
||||||
|
|
||||||
# Prompt the user at the end of a build whether to extract contents of a newly-built installer into a subdirectory
|
# Prompt the user at the end of a build whether to extract contents of a newly-built installer into a subdirectory
|
||||||
# called "test" inside the package source directory the build was manually initiated from. Has no effect on
|
# called "test" inside the package source directory the build was manually initiated from. Has no effect on
|
||||||
# autobuilds since they are simply installed right away.
|
# autobuilds since they are simply installed right away.
|
||||||
|
|
|
@ -97,7 +97,6 @@ geoclue
|
||||||
redshift
|
redshift
|
||||||
webkitgtk
|
webkitgtk
|
||||||
libhandy
|
libhandy
|
||||||
epiphany
|
|
||||||
balsa
|
balsa
|
||||||
iperf
|
iperf
|
||||||
ipset
|
ipset
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
app=samba
|
app=samba
|
||||||
version=4.15.5
|
version=4.15.5
|
||||||
build=1sml
|
build=2sml
|
||||||
homepage="https://www.samba.org"
|
homepage="https://www.samba.org"
|
||||||
download="https://download.samba.org/pub/samba/stable/samba-4.15.5.tar.gz"
|
download="https://download.samba.org/pub/samba/stable/samba-4.15.5.tar.gz"
|
||||||
desc="CIFS file and print server, version 4"
|
desc="CIFS file and print server, version 4"
|
||||||
|
@ -26,7 +26,7 @@ build() {
|
||||||
applypatch $srcdir/samba-bgqd-include-signal-h.patch
|
applypatch $srcdir/samba-bgqd-include-signal-h.patch
|
||||||
|
|
||||||
# Samba doesn't like our C/CXXFLAGS
|
# Samba doesn't like our C/CXXFLAGS
|
||||||
unset CFLAGS CXXFLAGS
|
#unset CFLAGS CXXFLAGS
|
||||||
|
|
||||||
SAMBAJOBS="$(echo $MAKEFLAGS | sed 's@-j@@')"
|
SAMBAJOBS="$(echo $MAKEFLAGS | sed 's@-j@@')"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue