Added more version-specific URL to download variable in base/shellcheck build file
Undertook code cleanup in bldpkg based on suggestions from shellcheck binary Shellcheck suggestions aside, changes to bldpkg include: -> Updated TODO list -> Added set -e again -> Replaced single-letter variables in runtime function with more sensible variable names -> Restored man page compression and linking code from earlier bldpkg commits -> Fixed code to move pkgconfig files from $pkg/share to $pkg/lib
This commit is contained in:
parent
bcd911eea9
commit
983adfe29f
2 changed files with 172 additions and 164 deletions
|
@ -2,7 +2,7 @@ app=shellcheck-bin
|
|||
version=0.8.0
|
||||
build=1sml
|
||||
homepage="https://github.com/koalaman/shellcheck"
|
||||
download="https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.$arch.tar.xz"
|
||||
download="https://github.com/koalaman/shellcheck/releases/download/v$version/shellcheck-v$version.linux.$arch.tar.xz"
|
||||
desc="Static Binary Of CLI Shell script analyzer"
|
||||
requires="musl"
|
||||
|
||||
|
@ -23,4 +23,4 @@ build() {
|
|||
|
||||
sha512sums="
|
||||
8913b4318a6bbce94db8952f84d61e103554ccd67ec25ff2165f6891db6f7572f5331677fdc314d7190a7a6a2ef979ee52e11d588e491e9ea3098f1e0dd565e8 shellcheck-bins.tar.lz
|
||||
"
|
||||
"
|
||||
|
|
332
bldpkg
332
bldpkg
|
@ -1,4 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Part of the SMLinux distribution
|
||||
# http://git.pktsurf.in/smlinux
|
||||
#
|
||||
|
@ -23,10 +24,9 @@
|
|||
# -> 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
|
||||
# -> Write code to log build output to a log file inside a particular directory
|
||||
# -> Add code to show extended help?
|
||||
# -> Email the user about the outcome of the build?
|
||||
# -> Use 'select' bash builtin instead of while true/case/esac
|
||||
# -> Remove static libraries by default unless preservestaticlibs is set to 1?
|
||||
# -> Increment warnings as they are issued during the build and show final warning total in the build summary
|
||||
# -> Determine if the staging directory is empty at the end of the build, and if it is, error out
|
||||
|
||||
# Determine whether we are using bash version 4 and later. If not, exit.
|
||||
if ((BASH_VERSINFO[0] < 4)) ; then
|
||||
|
@ -34,9 +34,11 @@ if ((BASH_VERSINFO[0] < 4)) ; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
set -e
|
||||
|
||||
# Time when the build commenced. Note: elapsed time is logged by the runtime function way below.
|
||||
# This output goes into package build summary.
|
||||
commencedate="$(date '+%a, %d %b %Y, %T')"
|
||||
commencedate=$(date '+%a, %d %b %Y, %T')
|
||||
|
||||
# Function to generate help message
|
||||
help() {
|
||||
|
@ -126,35 +128,35 @@ validatebldfile() {
|
|||
if [[ ! ${!buildvariables} ]] ; then
|
||||
echo "[ERROR] Required variable \"${buildvariables}\" is not set. Please check your build file."
|
||||
exit 1
|
||||
elif egrep -q "$buildvariables='*'" "$buildfile" ; then
|
||||
elif grep -E -q "$buildvariables='*'" "$buildfile" ; then
|
||||
echo "[ERROR] Please dont use single quotes to define the \"${buildvariables}\" variable"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Validate $app
|
||||
if ! echo "$app" | egrep -q '^[a-z0-9-]+$' ; then
|
||||
if ! echo "$app" | grep -E -q '^[a-z0-9-]+$' ; then
|
||||
echo "[ERROR] Only lower case, numeric characters and dash allowed in the 'app' variable in the build file."
|
||||
exit 1
|
||||
|
||||
# Validate $version
|
||||
elif ! echo "$version" | egrep -q '^[a-z0-9.]+$' ; then
|
||||
elif ! echo "$version" | grep -E -q '^[a-z0-9.]+$' ; then
|
||||
echo "[ERROR] Only lower case, numeric characters and a period allowed in the 'version' variable in the build file."
|
||||
exit 1
|
||||
|
||||
# Validate $homepage
|
||||
elif ! echo "$homepage" | egrep -q '^http://|^https://|^ftp://' ; then
|
||||
elif ! echo "$homepage" | grep -E -q '^http://|^https://|^ftp://' ; then
|
||||
echo "[ERROR] Invalid URL in the 'homepage' variable in the build file."
|
||||
exit 1
|
||||
|
||||
# Validate $download, first the URL type
|
||||
elif [[ -n $download ]]; then
|
||||
if ! echo "$download" | egrep -q '^http://|^https://|^ftp://' ; then
|
||||
if ! echo "$download" | grep -E -q '^http://|^https://|^ftp://' ; then
|
||||
echo "[ERROR] Invalid URL in the 'download' variable in the build file."
|
||||
exit 1
|
||||
|
||||
# Then check for single quotes
|
||||
elif egrep -q "download='*'" "$buildfile" ; then
|
||||
elif grep -E -q "download='*'" "$buildfile" ; then
|
||||
echo "[ERROR] Single quotes disallowed in the 'download' variable in the build file"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -165,7 +167,7 @@ validatebldfile() {
|
|||
exit 1
|
||||
|
||||
# Check if build() function exists in the build file
|
||||
elif ! egrep -q '^build()' $buildfile ; then
|
||||
elif ! grep -E -q '^build()' "$buildfile" ; then
|
||||
echo "[ERROR] 'build()' function does not exist in your build file."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -184,9 +186,9 @@ buildfile="$(basename $srcdir).SMBuild"
|
|||
rqfiles=( installpkg upgradepkg sha512sum patch find findmnt patch tput bc tar )
|
||||
|
||||
# Run a for loop to find the files
|
||||
for requiredfile in ${rqfiles[@]}; do
|
||||
if [[ ! -x $(type -p $requiredfile) ]] ; then
|
||||
echo "[ERROR] Could not find required program '"$requiredfile!"'"
|
||||
for requiredfile in "${rqfiles[@]}"; do
|
||||
if [[ ! -x $(type -p "$requiredfile") ]] ; then
|
||||
echo "[ERROR] Could not find required program '$requiredfile'!"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
@ -214,12 +216,12 @@ done
|
|||
if [[ $OPTIND = 1 ]] ; then
|
||||
if [[ ! -f $buildfile ]] ; then
|
||||
echo "[ERROR] No package build file to source from!"
|
||||
echo "[ERROR] Was expecting '"$buildfile"' to be present inside this directory '"$PWD"'."
|
||||
echo "[ERROR] Was expecting '$buildfile' to be present inside this directory '$PWD'."
|
||||
echo "[ERROR] Try -f <build_file> if your build file has a different name (Not recommended)"
|
||||
exit 1
|
||||
else
|
||||
if ! validatebldfile $buildfile ; then
|
||||
echo "[ERROR] '"$buildfile"' Build file validation failed!"
|
||||
if ! validatebldfile "$buildfile" ; then
|
||||
echo "[ERROR] '$buildfile' Build file validation failed!"
|
||||
exit 1
|
||||
else
|
||||
source "$buildfile"
|
||||
|
@ -233,8 +235,8 @@ elif [[ $OPTIND -gt 1 ]] ; then
|
|||
# passed on to MAKEFLAGS
|
||||
if [[ -n $customcputhreads ]] ; then
|
||||
# And validate whether the value is a number
|
||||
if ! echo "$customcputhreads" | egrep -q '^[0-9]+$' ; then
|
||||
echo "[ERROR] Invalid CPU job number '"$customcputhreads"'. Please provide a valid number."
|
||||
if ! echo "$customcputhreads" | grep -E -q '^[0-9]+$' ; then
|
||||
echo "[ERROR] Invalid CPU job number '$customcputhreads'. Please provide a valid number."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -245,12 +247,12 @@ elif [[ $OPTIND -gt 1 ]] ; then
|
|||
# If $origbuildfile is set and is a file, check if $setbuildfile and $origbuildfile are the same
|
||||
if [[ -n $origbuildfile ]] ; then
|
||||
if [[ ! -f $origbuildfile ]] ; then
|
||||
echo "[ERROR] Original build file '"$origbuildfile"' does not exist!"
|
||||
echo "[ERROR] Original build file '$origbuildfile' does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -n $setbuildfile ]] && [[ -f $setbuildfile ]] ; then
|
||||
if [[ $origbuildfile = $setbuildfile ]] ; then
|
||||
if [[ $origbuildfile = "$setbuildfile" ]] ; then
|
||||
echo "[ERROR] Original build file and alternate build file are the same!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -266,8 +268,8 @@ elif [[ $OPTIND -gt 1 ]] ; then
|
|||
# If $setbuildfile is set and is a file, set buildfile to its value, source it and initialise the build
|
||||
if [[ -n $setbuildfile ]] && [[ -f $setbuildfile ]] ; then
|
||||
buildfile="$setbuildfile"
|
||||
if ! validatebldfile $buildfile ; then
|
||||
echo "[ERROR] '"$buildfile"' validation failed!"
|
||||
if ! validatebldfile "$buildfile" ; then
|
||||
echo "[ERROR] '$buildfile' validation failed!"
|
||||
exit 1
|
||||
else
|
||||
source "$buildfile"
|
||||
|
@ -275,13 +277,13 @@ elif [[ $OPTIND -gt 1 ]] ; then
|
|||
|
||||
# If $setbuildfile is set but a file passed as an argument is not found, give an error
|
||||
elif [[ -n $setbuildfile ]] && [[ ! -f $setbuildfile ]] ; then
|
||||
echo "[ERROR] '"$setbuildfile"' not found!"
|
||||
echo "[ERROR] '$setbuildfile' not found!"
|
||||
exit 1
|
||||
|
||||
# If the above two conditions don't meet, get the presumed $buildfile value as a file and source it
|
||||
elif [[ -f "$buildfile" ]] ; then
|
||||
if ! validatebldfile $buildfile ; then
|
||||
echo "[ERROR] '"$buildfile"' validation failed!"
|
||||
if ! validatebldfile "$buildfile" ; then
|
||||
echo "[ERROR] '$buildfile' validation failed!"
|
||||
exit 1
|
||||
else
|
||||
source "$buildfile"
|
||||
|
@ -290,7 +292,7 @@ elif [[ $OPTIND -gt 1 ]] ; then
|
|||
# If even that file is not found, throw an error and exit
|
||||
else
|
||||
echo "[ERROR] No package build file to source from!"
|
||||
echo "[ERROR] Was expecting '"$buildfile"' to be present inside this directory '"$PWD"'."
|
||||
echo "[ERROR] Was expecting '$buildfile' to be present inside this directory '$PWD'."
|
||||
echo "[ERROR] Try -f <build_file> if your build file has a different name (Not recommended)"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -303,14 +305,14 @@ unset OPTIND OPTARG
|
|||
if [[ $genchecksum = 1 ]] ; then
|
||||
|
||||
# File types whose checksums will go into the new build file
|
||||
echo "[INFO] Discarding any old sha512sums from '"$buildfile"'"
|
||||
echo "[INFO] Discarding any old sha512sums from '$buildfile'"
|
||||
sed -E -i \
|
||||
-e '/^sha512sums=".*"$/d' \
|
||||
-e '/^sha512sums="/,/"$/d' \
|
||||
-e "/^sha512sums='.*'\$/d" \
|
||||
"$buildfile"
|
||||
|
||||
echo "[INFO] Adding new sha512sums in '"$buildfile"'"
|
||||
echo "[INFO] Adding new sha512sums in '$buildfile'"
|
||||
printf 'sha512sums="\n' >> "$buildfile"
|
||||
|
||||
files=( *.tar.* *.zip *.t?z *.patch *.diff *.c *.h )
|
||||
|
@ -325,7 +327,7 @@ if [[ $genchecksum = 1 ]] ; then
|
|||
|
||||
printf '"' >> "$buildfile"
|
||||
|
||||
if [[ "$(find . -type d -maxdepth 1 -print0 | wc -l)" -ge 1 ]]; then
|
||||
if [[ $(find . -type d -maxdepth 1 -print0 | wc -l) -ge 1 ]]; then
|
||||
echo "[WARNING] SHA512 checksums not generated for files inside directories!"
|
||||
fi
|
||||
|
||||
|
@ -334,7 +336,7 @@ if [[ $genchecksum = 1 ]] ; then
|
|||
fi
|
||||
|
||||
# Display the package and its version we are building
|
||||
echo "[INFO] Building package '"$app"' version '"$version"' ..."
|
||||
echo "[INFO] Building package '$app' version '$version' ..."
|
||||
sleep 0.5
|
||||
|
||||
# Invoke auditd if useauditd is set to 1 in bldpkg.conf
|
||||
|
@ -366,10 +368,10 @@ terminateauditd() {
|
|||
/bin/kill "$auditpid"
|
||||
echo "[INFO] /bin/auditd stopped."
|
||||
|
||||
auditlogtermsize="$(wc -l < $auditlogfile)"
|
||||
auditlogtermsize=$(wc -l < $auditlogfile)
|
||||
|
||||
if [[ $auditlogtermsize -gt 10 ]] ; then
|
||||
echo "[WARNING] Auditd log file '"$auditlogfile"' is greater than 10 lines!"
|
||||
echo "[WARNING] Auditd log file '$auditlogfile' is greater than 10 lines!"
|
||||
echo "[WARNING] Highly recommend that you examine its file!"
|
||||
sleep 5
|
||||
fi
|
||||
|
@ -378,7 +380,7 @@ terminateauditd() {
|
|||
|
||||
# sha512sums variable is expected in every single package build file
|
||||
if [[ -z $sha512sums ]] ; then
|
||||
echo "[ERROR] SHA512 checksums don't exist in '"$buildfile"' !"
|
||||
echo "[ERROR] SHA512 checksums don't exist in '$buildfile' !"
|
||||
echo "[ERROR] Please run 'bldpkg -g' to add them"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -409,16 +411,16 @@ applypatch() {
|
|||
echo "[ERROR] Please provide valid patch file name"
|
||||
exit 1
|
||||
elif [[ ! -f $patchfile ]] ; then
|
||||
echo "[ERROR] Patch file '"$patchfile"' not found inside $srcdir!"
|
||||
echo "[ERROR] Patch file '$patchfile' not found inside $srcdir!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get relative path of the patch file
|
||||
relativepath="$(basename $patchfile)"
|
||||
echo "[INFO] Applying patch '"$relativepath"'.."
|
||||
relativepath=$(basename $patchfile)
|
||||
echo "[INFO] Applying patch '$relativepath'.."
|
||||
# We use if/else to determine if the patch applied successfully
|
||||
if ! patch -p1 < "$patchfile" ; then
|
||||
echo "[ERROR] Failed to aply patch file '"$patchfile"'"
|
||||
echo "[ERROR] Failed to apply patch file '$patchfile'"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -426,18 +428,18 @@ applypatch() {
|
|||
if [[ $checkdependencies = 1 ]] ; then
|
||||
|
||||
echo "[INFO] Parsing $app 's dependency list..."
|
||||
for packagedep in "$requires"; do
|
||||
depcount="$(find /share/doc -type f -name $packagedep.SMBuild | wc -l)"
|
||||
for packagedep in $requires; do
|
||||
depcount=$(find /share/doc -type f -name "$packagedep.SMBuild" | wc -l)
|
||||
# If count is 1, we are ok
|
||||
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
|
||||
elif [[ $depcount = 0 ]] ; then
|
||||
echo "[ERROR] Did not find dependency '"$packagedep"'."
|
||||
echo "[ERROR] Did not find dependency '$packagedep'."
|
||||
exit 1
|
||||
# If count is greater than or equal to 2, we are in slightly less trouble
|
||||
elif [[ $depcount -ge 2 ]] ; then
|
||||
echo "[WARNING] Found multiple versions of '"$packagedep"' !"
|
||||
echo "[WARNING] Found multiple versions of '$packagedep' !"
|
||||
sleep 0.5
|
||||
fi
|
||||
done
|
||||
|
@ -460,24 +462,24 @@ if [[ -z $parenttmp ]] ; then
|
|||
echo "[ERROR] parenttmp variable not set in /etc/bldpkg.conf."
|
||||
exit 1
|
||||
elif [[ ! -d $parenttmp ]] ; then
|
||||
echo "[ERROR] parenttmp variable set to '"$parenttmp"' in /etc/bldpkg.conf is not a directory."
|
||||
echo "[ERROR] parenttmp variable set to '$parenttmp' in /etc/bldpkg.conf is not a directory."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Attempt to write to the $parenttmp directory. This directory is used for everything related to the
|
||||
# build process outside the source directory $srcdir
|
||||
if ! touch "$parenttmp"/.smlinuxwritetest ; then
|
||||
echo "[ERROR] Parent temp directory '"$parenttmp"' is not writable!"
|
||||
if ! touch "$parenttmp/.smlinuxwritetest" ; then
|
||||
echo "[ERROR] Parent temp directory '$parenttmp' is not writable!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Discard the test file
|
||||
[[ -e "$parenttmp"/.smlinuxwritetest ]] && rm -f "$parenttmp"/.smlinuxwritetest
|
||||
[[ -e "$parenttmp/.smlinuxwritetest" ]] && rm -f "$parenttmp/.smlinuxwritetest"
|
||||
|
||||
# Determine if $tmpfsdir is listed inside $protecteddirectories array
|
||||
if inarray "${parenttmp}" "${protecteddirectories[@]}" ; then
|
||||
echo "############ ATTENTION ############"
|
||||
echo "[ERROR] parenttmp IS SET TO '"$tmpfsdir"' WHICH IS A PROTECTED DIRECTORY!! EXITING!!"
|
||||
echo "[ERROR] parenttmp IS SET TO '$tmpfsdir' WHICH IS A PROTECTED DIRECTORY!! EXITING!!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -487,7 +489,7 @@ fi
|
|||
if [[ $htmloutput = 1 ]] ; then
|
||||
|
||||
if [[ -n $autobuild ]] ; then
|
||||
cat << EOF >> $parenttmp/BUILDMONITOR
|
||||
cat << EOF >> "$parenttmp/BUILDMONITOR"
|
||||
<b>$commencedate | Building package # $currentpkgnumber / $totalpkgnumber: <i><a href="/smlinux/pkgresults?pkg=$app&smver=1.0&arch=all&resultnum=25">$app $version</a></i></b>
|
||||
EOF
|
||||
else
|
||||
|
@ -502,7 +504,7 @@ fi
|
|||
# Validate compressor and set extension
|
||||
validpkgextensions=( tgz tbz tlz txz )
|
||||
if ! inarray "${pkgext}" "${validpkgextensions[@]}" ; then
|
||||
echo "[ERROR] '"$pkgext"' is not a valid package extension for an SMLinux installer file."
|
||||
echo "[ERROR] '$pkgext' is not a valid package extension for an SMLinux installer file."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -531,7 +533,7 @@ esac
|
|||
|
||||
# Borrowed from slackware's installpkg utility
|
||||
if ! "$compressor" --help > /dev/null 2>&1 ; then
|
||||
echo "[ERROR] '"$compressor"' Compressor validation failed."
|
||||
echo "[ERROR] '$compressor' Compressor validation failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -539,8 +541,8 @@ fi
|
|||
# declare a variable for the build summary.
|
||||
if [[ $usetmpfs = 1 ]] && [[ -n $tmpfsdir ]]; then
|
||||
if [[ ! -d $tmpfsdir ]] || ! touch "$tmpfsdir/.smlinuxtmpwritetest" \
|
||||
|| [[ "$(findmnt -no TARGET $tmpfsdir)" != "$tmpfsdir" ]] \
|
||||
|| [[ "$(findmnt -no FSTYPE $tmpfsdir)" != "tmpfs" ]]; then
|
||||
|| [[ $(findmnt -no TARGET "$tmpfsdir") != "$tmpfsdir" ]] \
|
||||
|| [[ $(findmnt -no FSTYPE "$tmpfsdir") != "tmpfs" ]]; then
|
||||
tmpfscheckfailed=1
|
||||
fi
|
||||
|
||||
|
@ -548,9 +550,9 @@ if [[ $usetmpfs = 1 ]] && [[ -n $tmpfsdir ]]; then
|
|||
[[ -e "$tmpfsdir/.smlinuxtmpwritetest" ]] && rm -f "$tmpfsdir/.smlinuxtmpwritetest"
|
||||
|
||||
# Check the tmpfsdir for stale directories other than the current package about to be built. If found, issue a warning.
|
||||
if [[ "$(find $tmpfsdir -type d -maxdepth 1 -print0 | wc -l)" -gt 1 ]]; then
|
||||
if [[ $(find "$tmpfsdir" -type d -maxdepth 1 -print0 | wc -l) -gt 1 ]]; then
|
||||
if [[ ! -d $app.src ]] || [[ ! -d package-$app ]] ; then
|
||||
echo "[WARNING] TMPFS directory '"$tmpfsdir"' has stale directories from previous builds!"
|
||||
echo "[WARNING] TMPFS directory '$tmpfsdir' has stale directories from previous builds!"
|
||||
sleep 5
|
||||
fi
|
||||
fi
|
||||
|
@ -565,10 +567,10 @@ if [[ $swapcheck = 1 ]]; then
|
|||
# Check whether swap is available on the system and if it is, determine its size. If its size
|
||||
# is >= swapsize, we are all good. If it's less than swapsize, we exit with a status 1.
|
||||
|
||||
swapcheck="$(grep "SwapFree" /proc/meminfo | awk '{print $2}')"
|
||||
swapcheck=$(grep "SwapFree" /proc/meminfo | awk '{print $2}')
|
||||
if [[ $swapcheck -lt $swapsize ]]; then
|
||||
echo "[ERROR] Insufficient swap to build '"$app"' which is listed"
|
||||
echo "[ERROR] in $packagesrequiringswap. Kindly add/increase"
|
||||
echo "[ERROR] Insufficient swap to build '$app' which is listed"
|
||||
echo "[ERROR] in '$packagesrequiringswap'. Kindly add/increase"
|
||||
echo "[ERROR] swap size on this system and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -625,7 +627,7 @@ if [[ -n $cputhreads ]]; then
|
|||
export MAKEFLAGS
|
||||
else
|
||||
# Or fetch the number from nproc
|
||||
MAKEFLAGS="$(nproc --all)"
|
||||
MAKEFLAGS=$(nproc --all)
|
||||
export MAKEFLAGS
|
||||
fi
|
||||
|
||||
|
@ -635,16 +637,16 @@ if [[ $globaldistcc = 1 ]] ; then
|
|||
# Check if distcc exists and is an executable
|
||||
if [[ ! -x $distccbinpath ]]; then
|
||||
echo "[ERROR] Oops! Distcc binary was not found but building with it"
|
||||
echo "[ERROR] was requested! Either ensure distcc is in your "'$PATH'" or"
|
||||
echo '[ERROR] was requested! Either ensure distcc is in your $PATH or'
|
||||
echo "[ERROR] disable this option in bldpkg.conf file."
|
||||
exit 1
|
||||
|
||||
# Check if the symlinks are right
|
||||
elif [[ ! "$(echo "$PATH" | grep "$distccsympath")" ]] ; then
|
||||
echo "[ERROR] '"$distccsympath"' not found in "'$PATH'"! Fix it please."
|
||||
elif [[ ! $(echo "$PATH" | grep "$distccsympath") ]] ; then
|
||||
echo "[ERROR] '"$distccsympath"' directory not found in your env PATH"
|
||||
exit 1
|
||||
elif [[ ! -d $distccsympath ]] ; then
|
||||
echo "[ERROR] '"$distccsympath"' directory containing symlinks to distcc"
|
||||
echo "[ERROR] '$distccsympath' directory containing symlinks to distcc"
|
||||
echo "[ERROR] does not exist! Kindly create it and create symlinks"
|
||||
echo "[ERROR] based on instructions in bldpkg.conf!"
|
||||
exit 1
|
||||
|
@ -654,14 +656,14 @@ if [[ $globaldistcc = 1 ]] ; then
|
|||
for f in gcc g++ cc c++ ; do
|
||||
if [[ -e $distccsympath/$f ]] && [[ -L $distccsympath/$f ]]; then
|
||||
# We use "realpath" to follow the $distccsympath/$f symlink and act on the exit code.
|
||||
if [[ "$(realpath -e $distccsympath/$f)" != $distccbinpath ]] ; then
|
||||
echo "[ERROR] $distccsympath/$f does not point to '"$distccbinpath"'. "
|
||||
if [[ $(realpath -e "$distccsympath/$f") != "$distccbinpath" ]] ; then
|
||||
echo "[ERROR] $distccsympath/$f does not point to '$distccbinpath'. "
|
||||
echo "[ERROR] Kindly fix this!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "[ERROR] $f either does not exist or is not a symlink inside"
|
||||
echo "[ERROR] '"$distccsympath"'. Kindly fix this! "
|
||||
echo "[ERROR] '$distccsympath'. Kindly fix this! "
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -695,7 +697,7 @@ if [[ $globaldistcc = 1 ]] ; then
|
|||
# If distcc=0 is set in the package build file to disable distcc, remove the value of $distccsympath from
|
||||
# $PATH otherwise export DISTCC_HOSTS and DISTCC_IO_TIMEOUT variables.
|
||||
if [[ $distcc = 0 ]] ; then
|
||||
PATH="$(echo "$PATH" | sed "s@:$distccsympath@@g")"
|
||||
PATH="${PATH//$distccsympath:/}"
|
||||
else
|
||||
# netcat hosts inside $DISTCC_HOSTS by checking for an open port
|
||||
echo "[INFO] Validating distcc hosts..."
|
||||
|
@ -704,13 +706,13 @@ if [[ $globaldistcc = 1 ]] ; then
|
|||
echo "[WARNING] nc does not exist! Ignoring this..."
|
||||
else
|
||||
# Remove the common options along with the slash and the numbers after it
|
||||
hosts="$(echo $DISTCC_HOSTS | sed -e 's@/[a-z0-9]*@@g' -e 's@--randomize@@' -e 's@localhost@@' -e 's@,lzo@@g')"
|
||||
hosts=$(echo "$DISTCC_HOSTS" | sed -e 's@/[a-z0-9]*@@g' -e 's@--randomize@@' -e 's@localhost@@' -e 's@,lzo@@g')
|
||||
for host in ${hosts[@]} ; do
|
||||
# We only run distccd on TCP port 3632
|
||||
if ! /bin/nc -z -w 1 "$host" 3632 > /dev/null 2>&1 ; then
|
||||
echo "[WARNING] Distcc host '"$host"' is OFFLINE"
|
||||
echo "[WARNING] Distcc host '$host' is OFFLINE"
|
||||
echo "[WARNING] Rewriting DISTCC_HOSTS"
|
||||
DISTCC_HOSTS="$(echo $DISTCC_HOSTS | sed "s@$host/[a-z0-9,]*@@")"
|
||||
DISTCC_HOSTS=$(echo "$DISTCC_HOSTS" | sed "s@$host/[a-z0-9,]*@@")
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
@ -719,23 +721,23 @@ if [[ $globaldistcc = 1 ]] ; then
|
|||
fi
|
||||
else
|
||||
# Remove $distccsympath
|
||||
PATH="$(echo "$PATH" | sed "s@:$distccsympath@@g")"
|
||||
PATH="${PATH//$distccsympath:/}"
|
||||
fi
|
||||
|
||||
# Validate everything related to ccache if globalccache is set
|
||||
if [[ $globalccache = 1 ]]; then
|
||||
if [[ ! -x $ccachebinpath ]] ; then
|
||||
echo "[ERROR] Oops! ccache binary was not found but building with it"
|
||||
echo "[ERROR] was requested! Either ensure ccache is in your "'$PATH'" or"
|
||||
echo '[ERROR] was requested! Either ensure ccache is in your $PATH or'
|
||||
echo "[ERROR] disable this option in bldpkg.conf."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$(echo $PATH | grep $ccachesympath)" ]] ; then
|
||||
echo "[ERROR] '"$ccachesympath"' not found in "'$PATH!'" Fix it please."
|
||||
if [[ ! $(echo "$PATH" | grep "$ccachesympath") ]] ; then
|
||||
echo "[ERROR] '"$ccachesympath"' directory not found in your env PATH"
|
||||
exit 1
|
||||
elif [[ ! -d $ccachesympath ]] ; then
|
||||
echo "[ERROR] '"$ccachesympath"' directory containing symlinks to ccache"
|
||||
echo "[ERROR] '$ccachesympath' directory containing symlinks to ccache"
|
||||
echo "[ERROR] does not exist! Kindly create it and create symlinks"
|
||||
echo "[ERROR] based on instructions in bldpkg.conf."
|
||||
exit 1
|
||||
|
@ -744,13 +746,13 @@ if [[ $globalccache = 1 ]]; then
|
|||
for f in gcc g++ cc c++ ; do
|
||||
if [[ -e $ccachesympath/$f ]] && [[ -L $ccachesympath/$f ]]; then
|
||||
# We use "realpath" to follow the $ccachesympath/$f symlink and act on the exit code
|
||||
if [[ "$(realpath -e $ccachesympath/$f)" != $ccachebinpath ]] ; then
|
||||
echo "[ERROR] '"$ccachesympath/$f"' does not point to '"$ccachebinpath"'. "
|
||||
if [[ $(realpath -e "$ccachesympath/$f") != "$ccachebinpath" ]] ; then
|
||||
echo "[ERROR] '$ccachesympath/$f' does not point to '$ccachebinpath'. "
|
||||
echo "[ERROR] Kindly fix this!"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "[ERROR] $f either does not exist or is not a symlink inside '"$ccachesympath"'"
|
||||
echo "[ERROR] $f either does not exist or is not a symlink inside '$ccachesympath'"
|
||||
echo "[ERROR] Kindly fix this!"
|
||||
exit 1
|
||||
fi
|
||||
|
@ -785,11 +787,11 @@ if [[ $globalccache = 1 ]]; then
|
|||
# If ccache=0 is set in the package build file to disable ccache, remove the value of ccachesympath
|
||||
# from $PATH and export it again
|
||||
if [[ $ccache = 0 ]]; then
|
||||
PATH="$(echo "$PATH" | sed "s@$ccachesympath:@@g")"
|
||||
PATH="${PATH//$ccachesympath:/}"
|
||||
fi
|
||||
else
|
||||
# Remove $ccachesympath
|
||||
PATH="$(echo "$PATH" | sed "s@$ccachesympath:@@g")"
|
||||
PATH="${PATH//$ccachesympath:/}"
|
||||
fi
|
||||
|
||||
# Validate everything related to sccache if globalccache is set
|
||||
|
@ -801,11 +803,11 @@ if [[ $globalsccache = 1 ]]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$(echo $PATH | grep $sccachepath)" ]] ; then
|
||||
echo "[ERROR] '"$sccachepath"' not found in "'$PATH!'" Fix it please."
|
||||
if [[ ! $(echo "$PATH" | grep "$sccachepath") ]] ; then
|
||||
echo "[ERROR] '"$sccachepath"' directory not found in your env PATH"
|
||||
exit 1
|
||||
elif [[ ! -d $sccachepath ]] ; then
|
||||
echo "[ERROR] '"$sccachepath"' directory containing symlinks to ccache"
|
||||
echo "[ERROR] '$sccachepath' directory containing symlinks to ccache"
|
||||
echo "[ERROR] does not exist! Kindly create it and create symlinks"
|
||||
echo "[ERROR] based on instructions in bldpkg.conf."
|
||||
exit 1
|
||||
|
@ -815,16 +817,16 @@ if [[ $globalsccache = 1 ]]; then
|
|||
# A hard link is basically a copy of a file with the same inode number stored in a different location.
|
||||
# We are trying a bit hard to ascertain whether a binary is a hard link or not.
|
||||
# First get the inode number of the binary in the original location
|
||||
sccache_binary_inode_num="$(stat --printf '%i\n' $sccachebinpath)"
|
||||
sccache_binary_inode_num=$(stat --printf '%i\n' $sccachebinpath)
|
||||
# Then get the inode number of the file inside the hard link path
|
||||
sccache_hardlink_file_inode_num="$(stat --printf '%i\n' $sccachepath/$f)"
|
||||
sccache_hardlink_file_inode_num=$(stat --printf '%i\n' $sccachepath/$f)
|
||||
|
||||
if [[ ! -e $sccachepath/$f ]] ; then
|
||||
echo "[ERROR] $f either does not exist inside '"$sccachepath"'"
|
||||
echo "[ERROR] '$f' either does not exist inside '"$sccachepath"'"
|
||||
echo "[ERROR] Kindly fix this!"
|
||||
exit 1
|
||||
# If the hard link's inode number does not match the original binary's inode number, throw an error and exit
|
||||
elif [[ $sccache_hardlink_file_inode_num != $sccache_binary_inode_num ]] ; then
|
||||
elif [[ $sccache_hardlink_file_inode_num != "$sccache_binary_inode_num" ]] ; then
|
||||
echo "[ERROR] File '"$f"' inside '"$sccachepath"' is not a hard link!"
|
||||
echo "[ERROR] Kindly fix this!"
|
||||
exit 1
|
||||
|
@ -864,11 +866,11 @@ if [[ $globalsccache = 1 ]]; then
|
|||
# If sccache=0 is set in the package build file to disable sccache, remove the value of sccachepath
|
||||
# from $PATH and export it again
|
||||
if [[ $sccache = 0 ]]; then
|
||||
PATH="$(echo "$PATH" | sed "s@$sccachepath:@@g")"
|
||||
PATH=$(echo "$PATH" | sed "s@$sccachepath:@@g")
|
||||
fi
|
||||
else
|
||||
# Remove $sccachepath
|
||||
PATH="$(echo "$PATH" | sed "s@$sccachepath:@@g")"
|
||||
PATH=$(echo "$PATH" | sed "s@$sccachepath:@@g")
|
||||
fi
|
||||
|
||||
# Apply CPU-specific compiler variables defined inside bldpkg.conf
|
||||
|
@ -889,7 +891,7 @@ elif [[ $arch = aarch64 ]]; then
|
|||
builddist="$aarch64builddist"
|
||||
|
||||
if [[ -n $debug ]]; then
|
||||
CFLAGS="$(echo $gccdebug $aarch64cflags)"
|
||||
CFLAGS="$gccdebug $aarch64cflags"
|
||||
else
|
||||
CFLAGS="$aarch64cflags"
|
||||
fi
|
||||
|
@ -901,7 +903,7 @@ elif [[ $arch = x86_64 ]]; then
|
|||
builddist="$x8664builddist"
|
||||
|
||||
if [[ -n $debug ]]; then
|
||||
CFLAGS="$(echo $gccdebug $x8664cflags)"
|
||||
CFLAGS="$gccdebug $x8664cflags"
|
||||
else
|
||||
CFLAGS="$x8664cflags"
|
||||
fi
|
||||
|
@ -929,7 +931,7 @@ fi
|
|||
if [[ -n $autobuildtemp ]]; then
|
||||
tempfile="$autobuildtemp"
|
||||
else
|
||||
tempfile="$(mktemp $parenttmp/SMBUILD.XXXXXX)"
|
||||
tempfile=$(mktemp "$parenttmp/SMBUILD.XXXXXX")
|
||||
fi
|
||||
|
||||
# Function to prevent a package from compiling on an unsupported architecture
|
||||
|
@ -939,9 +941,9 @@ compileonlyfor() {
|
|||
archname="$(uname -m)"
|
||||
archargument="$1"
|
||||
|
||||
if [[ $archname != $archargument ]]; then
|
||||
if [[ $archname != "$archargument" ]]; then
|
||||
echo ""
|
||||
echo "[INFO] '"$app"' not supported on '"$archname"' and hence not"
|
||||
echo "[INFO] '$app' not supported on '$archname' and hence not"
|
||||
echo "[INFO] not being built. Exiting."
|
||||
exit 0
|
||||
fi
|
||||
|
@ -976,17 +978,18 @@ fixbuilddirpermissions() {
|
|||
# Function to calculate elapsed build time. runtime takes the $SECONDS variable as an argument. $SECONDS is an
|
||||
# environment variable set by bash to show the number of whole seconds the shell has been running.
|
||||
runtime() {
|
||||
[[ -z $1 ]] && return 1
|
||||
TIMER=$1
|
||||
[[ -z $TIMER ]] && return 1
|
||||
|
||||
local D=$(( $1 / 86400 ))
|
||||
local H=$(( ($1 - ($D * 86400)) / 3600 ))
|
||||
local M=$(( ($1 - ($D * 86400) - ($H * 3600)) / 60 ))
|
||||
local S=$(( $1 - ($D * 86400) - ($H * 3600) - ($M * 60) ))
|
||||
local DAY=$(( TIMER / 86400 ))
|
||||
local HOUR=$(( (TIMER - (DAY * 86400)) / 3600 ))
|
||||
local MINS=$(( (TIMER - (DAY * 86400) - (HOUR * 3600)) / 60 ))
|
||||
local SECS=$(( TIMER - (DAY * 86400) - (HOUR * 3600) - (MINS * 60) ))
|
||||
|
||||
if [[ $D -gt 0 ]]; then
|
||||
echo -n "${D}d, ${H}h ${M}m ${S}s"
|
||||
if [[ $DAY -gt 0 ]]; then
|
||||
echo -n "${DAY}d, ${HOUR}h ${MINS}m ${SECS}s"
|
||||
else
|
||||
echo -n "${H}h, ${M}m ${S}s"
|
||||
echo -n "${HOUR}h, ${MINS}m ${SECS}s"
|
||||
fi
|
||||
|
||||
return 0
|
||||
|
@ -1049,7 +1052,7 @@ mkfinalpkg() {
|
|||
compiletimea="$SECONDS"
|
||||
|
||||
# compiletimeb will run the runtime function against compiletimea and store the resulting output
|
||||
compiletimeb="$( runtime $compiletimea )"
|
||||
compiletimeb=$(runtime $compiletimea)
|
||||
|
||||
echo "[INFO] Leaving build directory $tmp"
|
||||
echo "[INFO] Entering staging directory $pkg"
|
||||
|
@ -1058,16 +1061,16 @@ mkfinalpkg() {
|
|||
|
||||
# Check if /lib64 was created inside $pkg
|
||||
if [[ -d $pkg/lib64 ]] ; then
|
||||
echo "[ERROR] $app has /lib64 directory. Musl does not support multilib."
|
||||
echo "[ERROR] '$app' has /lib64 directory. Musl does not support multilib."
|
||||
echo "[ERROR] Please fix the build options and ensure the /lib64 is not created."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if /usr and /sbin were created inside $pkg
|
||||
# Check if /usr and /sbin were created inside $pkg only if allowusrdir=1 is not set in the package build file
|
||||
for directory in usr sbin ; do
|
||||
if [[ -d $pkg/$directory ]] ; then
|
||||
echo "[ERROR] $app has '"$directory"' directory which is a symlink to /bin on SMLinux."
|
||||
echo "[ERROR] Please fix the build options and ensure '"$directory"' is not created."
|
||||
echo "[ERROR] '$app' has '$directory' directory which is a symlink to /bin on SMLinux."
|
||||
echo "[ERROR] Please fix the build options and ensure '$directory' is not created."
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
@ -1080,14 +1083,15 @@ mkfinalpkg() {
|
|||
if [[ -d $pkg/share/applications ]] && [[ ! -e $srcdir/doinst.sh ]] ; then
|
||||
echo "[INFO] Found /share/applications but couldn't find any doinst.sh in the source directory."
|
||||
echo "[INFO] Creating one automatically that refreshes GTK cache."
|
||||
cat << EOF >> $pkg/install/doinst.sh
|
||||
cat << EOF >> "$pkg/install/doinst.sh"
|
||||
[[ -x /etc/rc.d/rc.gtk ]] && /etc/rc.d/rc.gtk
|
||||
EOF
|
||||
|
||||
# Or if /share/applications directory exists, and there is a doinst.sh file in the source directory, but there is no mention of rc.gtk, then too create one using cat
|
||||
elif [[ -d $pkg/share/applications ]] && [[ -e $srcdir/doinst.sh ]] && ! grep -q 'rc.gtk' "$srcdir/doinst.sh" ; then
|
||||
echo "[INFO] Found /share/applications but couldn't find any rc.gtk lines inside doinst.sh in the source directory."
|
||||
echo "[INFO] Creating one automatically that refreshes GTK cache."
|
||||
cat << EOF >> $pkg/install/doinst.sh
|
||||
cat << EOF >> "$pkg/install/doinst.sh"
|
||||
[[ -x /etc/rc.d/rc.gtk ]] && /etc/rc.d/rc.gtk
|
||||
EOF
|
||||
fi
|
||||
|
@ -1095,21 +1099,24 @@ EOF
|
|||
# Compress and link manpages
|
||||
if [[ -d "$pkg/share/man" ]]; then
|
||||
echo "[INFO] Compressing and linking man pages..."
|
||||
(
|
||||
cd "$pkg/share/man"
|
||||
find . -type f -name "*.[0-9]" -o -name "*.[0-9]" | xargs gzip -9
|
||||
for eachpage in $( find . -type l -maxdepth 1) ; do
|
||||
ln -s "$( readlink "$eachpage" ).gz" "$eachpage".gz
|
||||
rm "$eachpage"
|
||||
done
|
||||
( cd "$pkg/share/man"
|
||||
for manpagedir in $(find . -type d -name "man*") ; do
|
||||
( cd $manpagedir
|
||||
for eachpage in $( find . -type l -maxdepth 1) ; do
|
||||
ln -s $( readlink $eachpage ).gz $eachpage.gz
|
||||
rm $eachpage
|
||||
done
|
||||
gzip -9 ./*.? >/dev/null 2>&1 || true
|
||||
)
|
||||
done
|
||||
)
|
||||
fi
|
||||
|
||||
# Remove .la files similar to what slackware devs are doing in slackware-current, but in a more efficient manner :)
|
||||
# Remove libtool archive files
|
||||
echo "[INFO] Discarding any libtool archive (.la) files..."
|
||||
find "$pkg" -type f -name "*.la" -exec rm -v {} \;
|
||||
|
||||
# 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 as a source of reference for users
|
||||
if [[ -n $origbuildfile ]] && [[ -f $srcdir/$origbuildfile ]] ; then
|
||||
install -Dm 644 "$srcdir/$origbuildfile" "$pkgdocs/$app.SMBuild"
|
||||
else
|
||||
|
@ -1119,10 +1126,10 @@ EOF
|
|||
|
||||
# We don't want multiple directories for documentation. Detect if $pkg/share/doc/<app-name> was created.
|
||||
# If it has been created, move its contents into $pkgdocs and discard the old doc directory.
|
||||
if [[ -d $pkg/share/doc/$app ]] ; then
|
||||
if [[ -d "$pkg/share/doc/$app" ]] ; then
|
||||
echo "[INFO] Found share/doc/$app documentation directory."
|
||||
echo "[INFO] Moving its contents into share/doc/$app-$version/"
|
||||
mv $pkg/share/doc/$app/* $pkgdocs/
|
||||
mv "$pkg/share/doc/$app/"* "$pkgdocs"/
|
||||
rmdir "$pkg/share/doc/$app"
|
||||
fi
|
||||
|
||||
|
@ -1130,8 +1137,9 @@ EOF
|
|||
if [[ -d $pkg/share/pkgconfig ]] ; then
|
||||
echo "[WARNING] $app has created share/pkgconfig directory."
|
||||
echo "[WARNING] Moving this directory into /lib"
|
||||
mkdir -p "$pkg/lib"
|
||||
mv "$pkg/share/pkgconfig" "$pkg/lib/"
|
||||
mkdir -p "$pkg/lib/pkgconfig"
|
||||
mv "$pkg/share/pkgconfig"/* "$pkg/lib/pkgconfig/"
|
||||
rmdir "$pkg/share/pkgconfig"
|
||||
fi
|
||||
|
||||
# Normally we'd expect some debug symbols in the newly-produced binaries. But that isn't always the
|
||||
|
@ -1140,12 +1148,12 @@ EOF
|
|||
for file in \
|
||||
$( find "$pkg" -type f )
|
||||
do
|
||||
file -m /etc/file/magic/elf $file | \
|
||||
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")"
|
||||
debugfilecount=$(wc -l < "$pkg/install/package.$app.debugfailedfilenames")
|
||||
if [[ $debugfilecount -ge 1 ]]; then
|
||||
debugwarning=1
|
||||
else
|
||||
|
@ -1170,10 +1178,10 @@ EOF
|
|||
|
||||
# Calculate total files, directories, symlinks and uncompressed staging directory size
|
||||
if [[ $showsummary = 1 ]] ; then
|
||||
totalfilecount="$(find $pkg -type f | wc -l)"
|
||||
totaldircount="$(find $pkg -type d | wc -l)"
|
||||
totalsymcount="$(find $pkg -type l | wc -l)"
|
||||
packusize1="$(du -s $pkg | awk '{print $1}')"
|
||||
totalfilecount=$(find "$pkg" -type f | wc -l)
|
||||
totaldircount=$(find "$pkg" -type d | wc -l)
|
||||
totalsymcount=$(find "$pkg" -type l | wc -l)
|
||||
packusize1=$(du -s "$pkg" | awk '{print $1}')
|
||||
fi
|
||||
|
||||
# Here we ascertain the packaging time taken to actually prepare the final package. For this, we
|
||||
|
@ -1202,11 +1210,11 @@ EOF
|
|||
|
||||
tar cvf - . --format gnu \
|
||||
--xform 'sx^\./\(.\)x\1x' \
|
||||
--show-stored-names | $compressor $compressoropts > "$newpkglocation"
|
||||
--show-stored-names | "$compressor" "$compressopts" > "$newpkglocation"
|
||||
pkgstatus=$?
|
||||
|
||||
echo ""
|
||||
echo "[INFO] SMLinux package '"$app-$version-$arch-$build.$pkgext"' successfully generated in $pkgdest."
|
||||
echo "[INFO] SMLinux package '$app-$version-$arch-$build.$pkgext' successfully generated in $pkgdest."
|
||||
|
||||
# Terminate auditd daemon
|
||||
terminateauditd
|
||||
|
@ -1224,30 +1232,30 @@ EOF
|
|||
# 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
|
||||
packagetimea="$SECONDS"
|
||||
packagetimeb="$( runtime $packagetimea )"
|
||||
packagetimeb=$(runtime "$packagetimea")
|
||||
fi
|
||||
|
||||
|
||||
if [[ $showsummary = 1 ]]; then
|
||||
# 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
|
||||
builddirsize="$(du -s $tmp | awk '{print $1}')"
|
||||
builddirsize=$(du -s "$tmp" | awk '{print $1}')
|
||||
|
||||
# Calculate SSD write savings if TMPFS has been used
|
||||
if [[ $usetmpfs = 1 ]] && [[ $tmpfsenabledforthispackage = 1 ]] ; then
|
||||
|
||||
# Determine size of staging directory
|
||||
pkgdirsize="$(du -s $pkg | awk '{print $1}')"
|
||||
pkgdirsize=$(du -s "$pkg" | awk '{print $1}')
|
||||
|
||||
# Sum total of the above two variables is the amount of writes we saved
|
||||
tmpfssavingssum0="$(( $builddirsize + $pkgdirsize ))"
|
||||
tmpfssavingssum0="$((builddirsize + pkgdirsize))"
|
||||
|
||||
# We'll get sum in kB. Convert that to MB.
|
||||
tmpfssavingssum1="$(echo "scale=2 ; "$tmpfssavingssum0" / 1024" | bc)"
|
||||
tmpfssavingssum1=$(echo "scale=2 ; "$tmpfssavingssum0" / 1024" | bc)
|
||||
|
||||
# Store the result for build summary to pickup.
|
||||
tmpfssavingsize="$(echo and $tmpfssavingssum1"MB" writes to SSD saved)"
|
||||
tmpfssavingsize="and $tmpfssavingssum1"MB" writes to SSD saved"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -1280,16 +1288,16 @@ buildfilecleanup() {
|
|||
prepbuildoutput() {
|
||||
|
||||
# Get the build completion time and store it in a variable
|
||||
finishdate="$(date '+%a, %d %b %Y, %T')"
|
||||
finishdate=$(date '+%a, %d %b %Y, %T')
|
||||
|
||||
# If compiletimea is set, then do a sum total of compiletimea and packagetimea variables to get the
|
||||
# total time in seconds and use that as an argument for the runtime function. If compiletimea is not set,
|
||||
# invoke the runtime function alone on new reset $SECONDS
|
||||
if [[ -n $compiletimea ]] && [[ $pkgstatus = 0 ]] ; then
|
||||
finalcompiletime="$(( $compiletimea + $packagetimea ))"
|
||||
totaltime="$( runtime $finalcompiletime )"
|
||||
finalcompiletime=$((compiletimea + packagetimea))
|
||||
totaltime=$(runtime $finalcompiletime)
|
||||
else
|
||||
totaltime="$( runtime $SECONDS )"
|
||||
totaltime=$(runtime $SECONDS)
|
||||
fi
|
||||
|
||||
# Start of the showsummary if/else check
|
||||
|
@ -1297,20 +1305,20 @@ prepbuildoutput() {
|
|||
|
||||
# Stick to 8/16 colours, those are supported on most terminals
|
||||
if [[ $colours = 1 ]]; then
|
||||
colourscheck="$(tput colors 2>/dev/null)"
|
||||
colourscheck=$(tput colors 2>/dev/null)
|
||||
if [[ "$?" = 0 ]] && [[ $colourscheck -gt 2 ]] ; then
|
||||
# Red when the build fails
|
||||
colourr="$(printf '\e[41m')"
|
||||
colourr=$(printf '\e[41m')
|
||||
# Yellow when the build is interrupted
|
||||
coloury="$(printf '\e[93m')"
|
||||
coloury=$(printf '\e[93m')
|
||||
# Green when the build succeeds
|
||||
colourg="$(printf '\e[92m')"
|
||||
colourg=$(printf '\e[92m')
|
||||
# Cyan for the short questions
|
||||
colourc="$(printf '\e[96m')"
|
||||
colourc=$(printf '\e[96m')
|
||||
# App name/version colours
|
||||
colourv="$(printf '\e[92m')"
|
||||
colourv=$(printf '\e[92m')
|
||||
# Restore to default
|
||||
colourd="$(printf '\e[0m')"
|
||||
colourd=$(printf '\e[0m')
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -1328,7 +1336,7 @@ prepbuildoutput() {
|
|||
# package build file, then set dstats in the build summary
|
||||
if [[ $globaldistcc = 1 ]] && [[ -z $distcc ]]; then
|
||||
# If distcc was used, cut out --randomize and output rest of the DISTCC_HOSTS variable
|
||||
distccvar="$(echo "$DISTCC_HOSTS" | sed 's@--randomize@@')"
|
||||
distccvar=$(echo "$DISTCC_HOSTS" | sed 's@--randomize@@')
|
||||
dstats="Yes,$distccvar"
|
||||
# Else if globaldistcc is enabled and set to 1 and distcc is set to 0 in the package build file, then set
|
||||
# dstats in the build summary
|
||||
|
@ -1347,8 +1355,8 @@ prepbuildoutput() {
|
|||
cstats="Enabled globally but disabled due to tmpfs"
|
||||
|
||||
elif [[ $globalccache = 1 ]] && [[ $usetmpfs = 0 ]] && [[ -z $ccache ]] ; then
|
||||
ccacheusedsize="$(ccache -s | grep "cache size" | head -n 1 | awk '{ $1=$2="" ; print $0}' | sed 's@ @@g')"
|
||||
ccachetotalsize="$(ccache -s | grep "max cache size" | awk '{ $1=$2=$3="" ; print $0}' | sed 's@ @@g')"
|
||||
ccacheusedsize=$(ccache -s | grep "cache size" | head -n 1 | awk '{ $1=$2="" ; print $0}' | sed 's@ @@g')
|
||||
ccachetotalsize=$(ccache -s | grep "max cache size" | awk '{ $1=$2=$3="" ; print $0}' | sed 's@ @@g')
|
||||
cstats="Yes, $ccacheusedsize / $ccachetotalsize Allocated"
|
||||
|
||||
elif [[ $globalccache = 1 ]] && [[ -z $usetmpfs ]] ; then
|
||||
|
@ -1393,18 +1401,18 @@ prepbuildoutput() {
|
|||
# Determine if the build was successful or not
|
||||
if [[ $pkgstatus = 0 ]] ; then
|
||||
# Determine the compressed size
|
||||
packsize="$(du -bk "$newpkglocation" | awk '{print $1}')"
|
||||
packsize=$(du -bk "$newpkglocation" | awk '{print $1}')
|
||||
|
||||
# Determine the uncompressed size
|
||||
packusize="$(echo $packusize1)"
|
||||
packusize="$packusize1"
|
||||
|
||||
# If the package was built successfully, output the installer sizes
|
||||
# Space saving = 1 - Compressed Size / Uncompressed size.
|
||||
# Also, bc code taken from:
|
||||
# https://stackoverflow.com/questions/56945130/bash-echo-percentage-with-no-decimal-point-with-result-returned-from-bc-comman
|
||||
compressedsize="$(echo $(echo "scale=2 ; 1 - "$packsize" / "$packusize"" | bc ) | sed 's@.@@')"
|
||||
compressedsize=$(echo $(echo "scale=2 ; 1 - "$packsize" / "$packusize"" | bc ) | sed 's@.@@')
|
||||
|
||||
bldstatus="$colourg Successful! :-D $colourd
|
||||
bldstatus="$colourg Successful! :-D $colourd
|
||||
Srce Size: $colourd Compressed: $srcdirsize"K", Uncompressed: $builddirsize"K"
|
||||
Pkg Size: $colourd Uncompressed: $packusize"K", Compressed: $packsize"K" ("$compressedsize'%'")
|
||||
Pkg Has: $colourd $totalfilecount files and $totalsymcount symlinks in $totaldircount dirs"
|
||||
|
@ -1445,7 +1453,7 @@ $colourc Stopped: $colourd $finishdate
|
|||
$colourc Ccache Used? $colourd $cstats
|
||||
$colourc Distcc Used? $colourd $dstats
|
||||
$colourc TMPFS Used? $colourd $tmpfsstate $tmpfssavingsize
|
||||
$colourc CPU Threads: $colourd $(echo $makeflags | sed 's@-j@@')
|
||||
$colourc CPU Threads: $colourd ${makeflags/-j/}
|
||||
$colourc CFLAGS Used: $colourd $CFLAGS
|
||||
$colourc Compressor: $colourd $compressor ($compressopts)
|
||||
$colourc Build Type: $colourd $buildsys & $bldtype
|
||||
|
@ -1472,15 +1480,15 @@ EOF
|
|||
prephtmloutput() {
|
||||
if [[ $htmloutput = 1 ]] ; then
|
||||
if [[ $pkgstatus = 0 ]] ; then
|
||||
cat << EOF >> $parenttmp/BUILDMONITOR.html
|
||||
cat << EOF >> "$parenttmp/BUILDMONITOR.html"
|
||||
<tr><td><b><i><a href="/smlinux/pkgresults?pkg=$app&smver=1.0&arch=all&resultnum=25">$app $version</a></i></b></td><td>$commencedate</td><td>$finishdate</td><td>$totaltime</td><td><b style="color:#00cc00;">SUCCEEDED</b></td></tr>
|
||||
EOF
|
||||
elif [[ $wasinterrupted = 1 ]]; then
|
||||
cat << EOF >> $parenttmp/BUILDMONITOR.html
|
||||
cat << EOF >> "$parenttmp/BUILDMONITOR.html"
|
||||
<tr><td><b><i><a href="/smlinux/pkgresults?pkg=$app&smver=1.0&arch=all&resultnum=25">$app $version</a></i></b></td><td>$commencedate</td><td>$finishdate</td><td>$totaltime</td><td><b>INTERRUPTED</b></td></tr>
|
||||
EOF
|
||||
else
|
||||
cat << EOF >> $parenttmp/BUILDMONITOR.html
|
||||
cat << EOF >> "$parenttmp/BUILDMONITOR.html"
|
||||
<tr><td><b><i><a href="/smlinux/pkgresults?pkg=$app&smver=1.0&arch=all&resultnum=25">$app $version</a></i></b></td><td>$commencedate</td><td>$finishdate</td><td>$totaltime</td><td><b style="color:#ff1a1a;">FAILED</b></td></tr>
|
||||
EOF
|
||||
fi
|
||||
|
@ -1495,7 +1503,7 @@ promptuser() {
|
|||
mkdir -p "$srcdir/test"
|
||||
tar xvf "$newpkglocation" -C "$srcdir/test"
|
||||
echo ""
|
||||
echo "[INFO] '"$app"' package installer file successfully extracted"
|
||||
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
|
||||
|
@ -1504,7 +1512,7 @@ promptuser() {
|
|||
if [[ $extractprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $newpkglocation ]] ; then
|
||||
while true ; do
|
||||
echo
|
||||
echo "[NOTIFY] '"$app"' has been built and extractprompt is enabled in"
|
||||
echo "[NOTIFY] '$app' has been built and extractprompt is enabled in"
|
||||
echo "[NOTIFY] bldpkg.conf file. Would you like to extract and examine contents"
|
||||
echo "[NOTIFY] of its package installer in a 'test' directory within the"
|
||||
echo "[NOTIFY] current source directory"
|
||||
|
@ -1529,7 +1537,7 @@ promptuser() {
|
|||
if [[ $installprompt = 1 ]] && [[ -z $autobuild ]] && [[ -n $newpkglocation ]] ; then
|
||||
while true ; do
|
||||
echo
|
||||
echo "[NOTIFY] '"$app"' successfully built and installprompt is enabled in the bldpkg.conf file."
|
||||
echo "[NOTIFY] '$app' successfully built and installprompt is enabled in the bldpkg.conf file."
|
||||
|
||||
read -r -p "[NOTIFY] Would you like to install/upgrade it? (y/N) " yn
|
||||
case "$yn" in
|
||||
|
|
Loading…
Reference in a new issue