Changes to bldpkg:

* Added code to check if autobuildtemp is set before removing $tempfile
* Added wait argument to nc for probing distccd port
* Removed double quotes from various places
* Updated TODO
This commit is contained in:
PktSurf 2022-09-02 10:37:00 +05:30
parent 3fe6609c23
commit 80441dbcaf

23
bldpkg
View file

@ -35,8 +35,6 @@
# original package build file to be copied and not the modified package build
# file. Use -o <orig_bld_file> -m <modified_bld_file> for doing this, perhaps?
# -> Email the user about the outcome of the build?
# -> Remove double quotes next to command substitution statements
# -> Remove unnecessary PATH variable exports
# Determine whether we are using bash version 4 and later. If not, exit.
if ((BASH_VERSINFO[0] < 4)) ; then
@ -334,7 +332,7 @@ if [[ -z $skipchecksum ]] ; then
IFS=$'\n'
for src in "$sums"; do
echo "$src" | sha512sum -c
echo $src | sha512sum -c
checksumresult=$?
if [[ $checksumresult != 0 ]] ; then
echo "[ERROR] Checksums failed to match!"
@ -626,7 +624,6 @@ if [[ $globaldistcc = 1 ]] ; then
# $PATH otherwise export DISTCC_HOSTS and DISTCC_IO_TIMEOUT variables.
if [[ $distcc = 0 ]] ; then
PATH="$(echo "$PATH" | sed "s@:$distccsympath@@g")"
export PATH
else
# netcat hosts inside $DISTCC_HOSTS by checking for an open port
echo "Validating hosts supplied in DISTCC_HOSTS variable"
@ -636,9 +633,9 @@ if [[ $globaldistcc = 1 ]] ; then
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')"
for host in "${hosts[@]}" ; do
for host in ${hosts[@]} ; do
# We only run distccd on TCP port 3632
if ! /bin/nc -z "$host" 3632 > /dev/null 2>&1 ; then
if ! /bin/nc -z -w 1 "$host" 3632 > /dev/null 2>&1 ; then
echo "[WARNING] Distcc host '"$host"' is OFFLINE"
sleep 0.5
echo "Rewriting DISTCC_HOSTS"
@ -652,7 +649,6 @@ if [[ $globaldistcc = 1 ]] ; then
else
# Remove $distccsympath
PATH="$(echo "$PATH" | sed "s@:$distccsympath@@g")"
export PATH
fi
# Validate everything related to ccache if globalccache is set
@ -719,12 +715,10 @@ if [[ $globalccache = 1 ]]; then
# from $PATH and export it again
if [[ $ccache = 0 ]]; then
PATH="$(echo "$PATH" | sed "s@$ccachesympath:@@g")"
export PATH
fi
else
# Remove $ccachesympath
PATH="$(echo "$PATH" | sed "s@$ccachesympath:@@g")"
export PATH
fi
# Validate everything related to sccache if globalccache is set
@ -800,12 +794,10 @@ if [[ $globalsccache = 1 ]]; then
# from $PATH and export it again
if [[ $sccache = 0 ]]; then
PATH="$(echo "$PATH" | sed "s@$sccachepath:@@g")"
export PATH
fi
else
# Remove $sccachepath
PATH="$(echo "$PATH" | sed "s@$sccachepath:@@g")"
export PATH
fi
# Apply CPU-specific compiler variables defined inside bldpkg.conf
@ -1174,7 +1166,12 @@ EOF
buildfilecleanup() {
# Discard all temporary files
rm -f "$parenttmp/BUILDING" "$tempfile"
rm -f "$parenttmp/BUILDING"
# Autobuild discards $tempfile automatically, so only discard $tempfile if $autobuildtemp is unset
if [[ -z $autobuildtemp ]] ; then
rm "$tempfile"
fi
}
@ -1320,7 +1317,7 @@ prepbuildoutput() {
# Output the section name if autobuildtemp is set. This means we are running an autobuild.
if [[ -n $autobuildtemp ]]; then
echo -e ""$colourc" Build Section:"$colourd" $SECTION" >> "$tempfile"
echo -e ""$colourc" Build Section:"$colourd" $section" >> "$tempfile"
fi