smlinux/ssb.SMBuild
SMLinux 16246f3ef9 -> Updated CREDITS
-> Added licenses and copyrights in main and section build files
-> Fixed identation and added miscellaneous code and commentsin bldpkg
2022-02-15 10:31:48 +05:30

140 lines
4 KiB
Bash
Executable file

#!/bin/bash
# Version: 1.3 GSB SMBuild.
# Copyright (c) 2007 Darren 'Tadgy' Austin <darren (at) gnomeslackbuild.org>
# Copyright (c) 2019-2022 PktSurf <smlinux@pktsurf.in>
#
# Licenced under the terms of the GNU General Public Licence version 3.
#
# Modified and trimmed extensively for use with SMLinux distribution
# The default list of GSB sections, in the order they should be processed.
sections="${sections:- base xorg gtk extra net xfce }"
# Generate HTML and TXT reports. Use 1 to enable and 0 to disable.
generatereports=0
# Usage.
function usage() {
cat << EOF
Usage: ${0##*/} [options]
Options:
-help Show this help screen.
-list For each of the GSB sections, list the packages which
will be built. When the SECTIONS environment variable
is set (see README) only those sections are displayed.
EOF
}
export -f usage
function list_packages() {
echo "The sections and packages below (listed in processing order) will be built."
for section in $sections
do
echo
echo " $section:"
echo "$( $section/ssb.$section.SMBuild --list | cut -d$'\n' -f2- )"
done
}
function runtime() {
# $1 = Number of seconds to convert to readable text
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) ))
if [ $D -gt 0 ]; then
echo -n "${D}d, ${H}h ${M}m ${S}s"
else
echo -n "${H}h, ${M}m ${S}s"
fi
return 0
}
export -f runtime
# Make sure we are in the right directory (you can never trust users..)
cd $( cd ${BASH_SOURCE%/*} ; pwd )
# Setup the environment
# Use custom build variables file
parenttmp="/tmp"
pkgdest=${pkgdest:-$parenttmp/sml/packages}
logsdir=${logsdir:-$parenttmp/sml/sml-buildlogs}
autobuild=1
arch="$HOSTTYPE"
export pkgdest logsdir autobuild arch parenttmp
# Temporary space, package and log file storage.
mkdir -p $pkgdest $logsdir
autobuildtemp="$(mktemp $parenttmp/SMBUILD.XXXXXX)"
export autobuildtemp
function autointerruptsummary() {
cat "$autobuildtemp"
rm "$autobuildtemp"
}
trap "autointerruptsummary" INT
###################################################
# Parse command line arguments.
while [ $# -gt 0 ]; do
if [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
usage
exit 0
elif [ "$1" = "-list" ] || [ "$1" = "--list" ]; then
list_packages
exit 0
shift
else
echo "${0##*/}: Unknown option: $1"
echo "Try: $0 -help"
exit 1
fi
done
# Do the build.
( echo
echo "*********************************************************************"
echo "* Building SMLinux - this may take a while..."
echo "*********************************************************************"
for section in $sections
do
( cd $section && ./ssb.$section.SMBuild 2>&1 ) || {
echo
echo "*********************************************************************"
echo "* Build aborted: error building in section '$section'."
echo "* Check the build logs in '$logsdir' and try again."
echo "*********************************************************************"
echo "* Build failed after $( runtime $SECONDS )."
echo "*********************************************************************"
rm -f "$autobuildtemp"
exit 1
}
# Generate HTML tables
if [ "$generatereports" = "1" ] && [ -x /bin/genreports ] ; then
/bin/genreports $SECTION 1.0 aarch64
fi
done
echo
echo "*********************************************************************"
echo "* Successfully finished building SMLinux!"
echo "* SMLinux packages are in '$pkgdest/$arch'."
echo "* Build logs are in '$logsdir'."
echo "*********************************************************************"
echo "* Complete build time was $( runtime $SECONDS )."
echo "*********************************************************************"
rm -f "$autobuildtemp"
) 2>&1 | tee $logsdir/$( basename $0 .SMBuild )-$arch.log.txt
# Return the exit status from the sub-shell, not the tee command.
exit ${PIPESTATUS[0]}