diff --git a/bldpkg b/bldpkg index 91f6655..254838f 100755 --- a/bldpkg +++ b/bldpkg @@ -21,7 +21,6 @@ ############ # TODO -# -> 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 # -> Email the user about the outcome of the build? @@ -134,7 +133,7 @@ validatebldfile() { # $download variable is optional but recommended for buildvariables in app version build homepage desc requires ; do if [[ ! ${!buildvariables} ]] ; then - echo "[ERROR] Required variable \"${buildvariables}\" is not set. Please check your build file." + echo "[ERROR] Required variable '$buildvariables' is not set. Please check your build file." exit 1 elif grep -E -q "$buildvariables='*'" "$buildfile" ; then echo "[ERROR] Please dont use single quotes to define the \"${buildvariables}\" variable" @@ -478,11 +477,11 @@ fi if ! touch "$parenttmp/.smlinuxwritetest" ; then echo "[ERROR] Parent temp directory '$parenttmp' is not writable!" exit 1 +else + # Discard the test file + rm -f "$parenttmp/.smlinuxwritetest" fi -# Discard the test file -[[ -e "$parenttmp/.smlinuxwritetest" ]] && rm -f "$parenttmp/.smlinuxwritetest" - # If htmloutput is set to 1, echo $app, $version and $build as file names inside the parent build directory. # This will output into an HTML file so that the basic status of the build process (whether started, stopped, # interrupted or failed) can be viewed in the web browser. @@ -595,7 +594,7 @@ if [[ $usetmpfs = 1 ]] && [[ -n $tmpfsdir ]] && [[ -z $tmpfscheckfailed ]] ; the # In the absence of tmpfs, we use the normal directory tmp="$nontmpfsdir/$app.src" - pkg="${pkg:-$nontmpfsdir/package-$app}" + pkg="$nontmpfsdir/package-$app" else # We compile inside tmpfsdir. Set the tmpfsenabledforthispackage variable here to inform build # summary function at the bottom @@ -611,16 +610,15 @@ if [[ $usetmpfs = 1 ]] && [[ -n $tmpfsdir ]] && [[ -z $tmpfscheckfailed ]] ; the # Get the directory from the tmpfsdir variable for extracting the source and set it as our build # and staging directory tmp="$tmpfsdir/$app.src" - pkg="${pkg:-$tmpfsdir/package-$app}" + pkg="$tmpfsdir/package-$app" fi else # If usetmpfs is disabled, we compile in the non-TMPFS directory tmp="$nontmpfsdir/$app.src" - pkg=${pkg:-$nontmpfsdir/package-$app} + pkg="$nontmpfsdir/package-$app" fi - if inarray "${pkg}" "${protecteddirectories[@]}" ; then echo "############ ATTENTION ############" echo "[ERROR] 'pkg' VARIABLE IS SET TO '$pkg' WHICH IS A PROTECTED DIRECTORY! EXITING!" @@ -645,6 +643,39 @@ else export MAKEFLAGS fi +validatecompiler() { + + # Function called as: validatecompiler distcc $distccsympath $f + if [[ $validatecompilers = 1 ]] ; then + compiler=$1 + compilerpath=$2 + maincompiler=$3 + randomnum=$(shuf -i 100-999 -n1) + + echo "Validating $compiler compiler... " + + cat << EOF > "$parenttmp/$compiler-$maincompiler.c" +#include +int main() { + printf("$randomnum\n"); + return 0; +} +EOF + + "$compilerpath/$maincompiler" -o "$parenttmp/$compiler-$maincompiler" "$parenttmp/$compiler-$maincompiler.c" + + binaryoutput=$($parenttmp/$compiler-$maincompiler) + + if [[ $binaryoutput != $randomnum ]] ; then + echo "FAILED!" + exit 1 + fi + + rm "$parenttmp/$compiler-$maincompiler.c" "$parenttmp/$compiler-$maincompiler" + fi + +} + # Validate all compilers starting with distcc # Validate everything related to distcc if globaldistcc is set if [[ $globaldistcc = 1 ]] ; then @@ -657,7 +688,7 @@ if [[ $globaldistcc = 1 ]] ; then # Check if the symlinks are right elif [[ ! $(echo "$PATH" | grep "$distccsympath") ]] ; then - echo "[ERROR] '"$distccsympath"' directory not found in your env PATH" + echo "[ERROR] '$distccsympath' directory not found in your env PATH" exit 1 elif [[ ! -d $distccsympath ]] ; then echo "[ERROR] '$distccsympath' directory containing symlinks to distcc" @@ -676,35 +707,12 @@ if [[ $globaldistcc = 1 ]] ; then 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] Symlink '$f' either does not exist or is not a symlink inside '$distccsympath'." + echo "[ERROR] Kindly fix this! " exit 1 fi - - #echo -n "Validating distcc $f compiler... " - # This is a really small C program taken from autoconf tests - #cat << EOF > $parenttmp/distcccheck-"$f".c -#int -#main() -#{ -# ; -# return 0; -#} -#EOF - - #"$distccsympath/$f" -o $parenttmp/distcccheck-"$f" $parenttmp/distcccheck-"$f".c - #checkstatus="$?" - - # Discard the files once the validation passes/fails - #if [[ $checkstatus = 0 ]] ; then - # echo "[OK]" - # rm $parenttmp/distcccheck-"$f"{,.c} - #else - # echo "Something's up with distcc $f" - # rm $parenttmp/distcccheck-"$f"{,.c} - # exit 1 - #fi + validatecompiler distcc $distccsympath $f done @@ -766,35 +774,12 @@ if [[ $globalccache = 1 ]]; then exit 1 fi else - echo "[ERROR] $f either does not exist or is not a symlink inside '$ccachesympath'" + echo "[ERROR] Symlink '$f' either does not exist or is not a symlink inside '$ccachesympath'" echo "[ERROR] Kindly fix this!" exit 1 fi - #echo -n "Validating ccache $f compiler... " - - # This is a really small C program taken from autoconf tests - #cat << EOF > $parenttmp/ccachecheck-"$f".c -#int -#main() -#{ -# ; -# return 0; -#} -#EOF - - #"$ccachesympath/$f" -o $parenttmp/ccachecheck-"$f" $parenttmp/ccachecheck-"$f".c - #checkstatus="$?" - - # Discard the files once the validation passes/fails - #if [[ $checkstatus = 0 ]] ; then - # echo "[OK]" - # rm $parenttmp/ccachecheck-"$f"{,.c} - #else - # echo "Something's up with ccache $f" - # rm $parenttmp/ccachecheck-"$f"{,.c} - # exit 1 - #fi + validatecompiler ccache $ccachesympath $f done @@ -847,31 +832,8 @@ if [[ $globalsccache = 1 ]]; then exit 1 fi - #echo -n "Validating sccache $f compiler... " + validatecompiler sccache $sccachepath $f - # This is a really small C program taken from autoconf tests - #cat << EOF > $parenttmp/sccachecheck-"$f".c -#int -#main() -#{ -# ; -# return 0; -#} -#EOF - - #"$sccachepath/$f" -o $parenttmp/sccachecheck-"$f" $parenttmp/sccachecheck-"$f".c - #checkstatus="$?" - - # Discard the files once the validation passes/fails - #if [[ $checkstatus = 0 ]] ; then - # echo "[OK]" - # rm $parenttmp/sccachecheck-"$f"{,.c} - #else - # echo "Something's up with sccache $f" - # rm $parenttmp/sccachecheck-"$f"{,.c} - # exit 1 - #fi - # Useful for rust-specific builds. RUSTC_WRAPPER="$sccachebinpath" export RUSTC_WRAPPER @@ -1035,7 +997,7 @@ preprunitservice() { if [[ -f $srcdir/$1.run ]] ; then cp "$srcdir/$1.run" "etc/service/$1/run" else - echo "[ERROR] $1.run does not exist!" + echo "[ERROR] Runit service file '$1.run' does not exist!" exit 1 fi @@ -1150,13 +1112,11 @@ EOF rmdir "$pkg/share/doc/$app" fi - # We'd like pkgconfig files to only go into /lib; some packages have other ideas. So fix for them + # We'd like pkgconfig files to only go into /lib; some packages have other ideas. 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/pkgconfig" - mv "$pkg/share/pkgconfig"/* "$pkg/lib/pkgconfig/" - rmdir "$pkg/share/pkgconfig" + echo "[ERROR] '$app' has created /share/pkgconfig directory!" + echo "[ERROR] Please fix its build file!" + exit 1 fi # Normally we'd expect some debug symbols in the newly-produced binaries. But that isn't always the @@ -1217,7 +1177,7 @@ EOF if [[ -z $disablepkgsymlinks ]] ; then if find . -type l | grep -qm1 .; then echo "[INFO] Found symlinks, preparing install/doinst.sh..." - find . -type l -printf '( cd %h ; rm -rf %f )\n( cd %h ; ln -sf %l %f )\n' -delete > install/symlinks + find . -type l -printf '( cd %h ; rm -f %f )\n( cd %h ; ln -sf %l %f )\n' -delete > install/symlinks if [[ -f install/doinst.sh ]]; then printf '\n' | cat - install/doinst.sh >> install/symlinks fi