Fix colours. Minor bugfixes. Add support for ccache.
This commit is contained in:
parent
18920e99c1
commit
ba124ba6b9
1 changed files with 34 additions and 29 deletions
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# Version: 0.6.0
|
||||
# Version: 0.6.1
|
||||
# Copyright (c) 2005-2022:
|
||||
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
|
||||
# Licensed under the terms of the GNU General Public License version 3.
|
||||
|
@ -24,7 +24,7 @@ check_installed() {
|
|||
die() {
|
||||
# $1 = The message to write to stderr on exit.
|
||||
|
||||
printf "\\033[1;31m$%s: %s\\033[0;39m\\n" "${0##*/}" "${1:-Abort}" >&2
|
||||
printf "\\033[1;31;40m%s: %s\\033[0;39m\\n" "${0##*/}" "${1:-Abort}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,12 @@ cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)"
|
|||
# Read global buildconf settings.
|
||||
# shellcheck disable=SC1091
|
||||
[[ -e ../buildconf ]] && {
|
||||
. ../buildconf || die "Error sourcing global buildconf"
|
||||
. ../buildconf 2>/dev/null || die "Error sourcing global buildconf"
|
||||
}
|
||||
|
||||
# Package specific buildconf settings.
|
||||
# shellcheck disable=SC2015,SC1090
|
||||
[[ -e "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" ]] && . "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" || \
|
||||
[[ -e "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" ]] && . "./$(basename "${BASH_SOURCE[0]}" .SlackBuild).buildconf" 2>/dev/null || \
|
||||
die "Error sourcing package buildconf"
|
||||
|
||||
# Package storage path.
|
||||
|
@ -49,7 +49,7 @@ cd "$(cd "${BASH_SOURCE[0]%/*}"; pwd -P)"
|
|||
PKG_STORE='${PKG_STORE:-/tmp/pkg-store/$DIST_OS_ID$BUILD_LIBDIRSUFFIX-$DIST_OS_VERSION_ID}'
|
||||
|
||||
# Parse command line options.
|
||||
while [[ $# -gt 0 ]]; do
|
||||
while (( $# > 0 )); do
|
||||
if [[ "$1" =~ ^-(-)?f(orce)?$ ]]; then
|
||||
BUILD_FORCE=1
|
||||
elif [[ "$1" =~ ^-(-)?n(o-cleanup)?$ ]]; then
|
||||
|
@ -68,14 +68,14 @@ while [[ $# -gt 0 ]]; do
|
|||
done
|
||||
|
||||
# Pre-build checks.
|
||||
if (( ${BUILD_FORCE:-0} != 1 )); then
|
||||
printf "%s\\n" "${BUILD_CONFLICTS[@]}" | while read -r PKG; do
|
||||
(( ${BUILD_FORCE:-0} != 1 )) && {
|
||||
while read -r PKG; do
|
||||
check_installed "$PKG" && die "Conflicting package installed: $PKG"
|
||||
done
|
||||
printf "%s\\n" "${BUILD_REQUIRES[@]}" | while read -r PKG; do
|
||||
done < <(printf "%s\\n" "${BUILD_CONFLICTS[@]}")
|
||||
while read -r PKG; do
|
||||
check_installed "$PKG" || die "Required package not installed: $PKG"
|
||||
done
|
||||
fi
|
||||
done < <(printf "%s\\n" "${BUILD_REQUIRES[@]}")
|
||||
}
|
||||
|
||||
# Gather some system information.
|
||||
# shellcheck disable=SC2046
|
||||
|
@ -92,6 +92,8 @@ unset DIST_OS_VERSION_CODENAME
|
|||
BUILD_WORKDIR="${BUILD_WORKDIR:-/tmp/pkg-build}"
|
||||
BUILD_ROOT="$BUILD_WORKDIR/pkg-$PKG_NAME"
|
||||
BUILD_PREFIX="${BUILD_PREFIX:-/opt}"
|
||||
BUILD_ALTCC="${BUILD_ALTCC:-}"
|
||||
BUILD_ALTCXX="${BUILD_ALTCXX:-}"
|
||||
BUILD_NUMJOBS="${BUILD_NUMJOBS:-7}"
|
||||
case "${BUILD_ARCH:=$(uname -m)}" in
|
||||
i[45]86)
|
||||
|
@ -146,23 +148,25 @@ SRC_DIR="$(pwd)"
|
|||
umask 0022
|
||||
[[ ! -e "$BUILD_WORKDIR" ]] || mkdir -p -m 750 "$BUILD_WORKDIR" || die "Failed to create working directory"
|
||||
rm -rf "$BUILD_ROOT" && mkdir -m 755 "$BUILD_ROOT" || die "Failed to clear build root"
|
||||
rm -rf "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || die "Failed to clear source directories"
|
||||
[[ -n "${SRC_DIRNAMES[*]}" ]] && { rm -rf "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || die "Failed to clear source directories"; }
|
||||
|
||||
# Get sources if they aren't downloaded already.
|
||||
WGET="$(command -v wget)"
|
||||
I=0
|
||||
printf "%s\\n" "${SRC_DOWNLOADS[@]}" | while read -r SRC; do
|
||||
[[ ! -e "${SRC_FILENAMES[$I]}" ]] && {
|
||||
[[ -z "$WGET" ]] && die "wget is required to download sources"
|
||||
"$WGET" -t 3 -c -T 30 --waitretry=5 --retry-connrefused --retry-on-host-error --no-check-certificate --passive-ftp -O "${SRC_FILENAMES[$I]}" "$SRC" ||\
|
||||
die "Failed to download source file: $SRC"
|
||||
}
|
||||
[[ "$(md5sum "${SRC_FILENAMES[$I]}" | cut -d' ' -f1)" != "${SRC_MD5SUMS[$I]}" ]] && die "md5sum verification failed: ${SRC_FILENAMES[$I]}"
|
||||
(( I++ ))
|
||||
done
|
||||
[[ -n "${SRC_DOWNLOADS[*]}" ]] && {
|
||||
WGET="$(command -v wget)"
|
||||
I=0
|
||||
while read -r SRC; do
|
||||
[[ ! -e "${SRC_FILENAMES[$I]}" ]] && {
|
||||
[[ -z "$WGET" ]] && die "wget is required to download sources"
|
||||
"$WGET" -t 3 -c -T 30 -w 5 --retry-connrefused --retry-on-host-error --no-check-certificate --passive-ftp -O "${SRC_FILENAMES[$I]}" "$SRC" || \
|
||||
{ rm "${SRC_FILENAMES[$I]}"; die "Failed to download source file: $SRC"; }
|
||||
}
|
||||
[[ "$(md5sum "${SRC_FILENAMES[$I]}" | cut -d' ' -f1)" != "${SRC_MD5SUMS[$I]}" ]] && die "md5sum verification failed: ${SRC_FILENAMES[$I]}"
|
||||
(( I++ ))
|
||||
done < <(printf "%s\\n" "${SRC_DOWNLOADS[@]}")
|
||||
}
|
||||
|
||||
# Unpack sources.
|
||||
printf "%s\\n" "${SRC_FILENAMES[@]}" | while read -r SRC; do
|
||||
while read -r SRC; do
|
||||
case "$SRC" in
|
||||
*.tar.?z|*.t?z)
|
||||
tar -xv -C "$BUILD_WORKDIR" -f "$SRC" || die "Failed to extract source: $SRC"
|
||||
|
@ -174,15 +178,16 @@ printf "%s\\n" "${SRC_FILENAMES[@]}" | while read -r SRC; do
|
|||
die "Un-handled source archive format: ${SRC##*.}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done < <(printf "%s\\n" "${SRC_FILENAMES[@]}")
|
||||
|
||||
# Fix any weird permissions on sources.
|
||||
chown -R root:root "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" && chmod -R go-w "${SRC_DIRNAMES[@]/#/$BUILD_WORKDIR/}" || \
|
||||
die "Failed to correct source directory permissions"
|
||||
|
||||
# Standard ./configure options.
|
||||
CONFIGURE_OPTS=("--prefix=\"$BUILD_PREFIX\"" "--libdir=\"$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX\"" "--sysconfdir=\"/etc/$PKG_NAME\"" "--localstatedir=/var"
|
||||
"--mandir=\"$BUILD_PREFIX/man\"" "--infodir=\"$BUILD_PREFIX/info\"" "--build=\"$PKG_ARCH-slackware-linux\"" "--enable-shared" "--disable-static")
|
||||
CONFIGURE_OPTS=("${BUILD_ALTCC:+CC=\"$BUILD_ALTCC\"}" "${BUILD_ALTCXX:+CXX=\"$BUILD_ALTCXX\"}" "--prefix=\"$BUILD_PREFIX\""
|
||||
"--libdir=\"$BUILD_PREFIX/lib$BUILD_LIBDIRSUFFIX\"" "--sysconfdir=\"/etc/$PKG_NAME\"" "--localstatedir=/var" "--mandir=\"$BUILD_PREFIX/man\""
|
||||
"--infodir=\"$BUILD_PREFIX/info\"" "--build=\"$PKG_ARCH-slackware-linux\"" "--enable-shared" "--disable-static")
|
||||
|
||||
# Process each of the sources.
|
||||
for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
|
||||
|
@ -205,7 +210,7 @@ for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
|
|||
die "Source ./configure failed: ${SRC_DIRNAMES[$I]}"
|
||||
|
||||
# Build and install.
|
||||
make -j "BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" && make -j "BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" DESTDIR="$BUILD_ROOT" install || \
|
||||
make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" && make -j "$BUILD_NUMJOBS" "${BUILD_MAKEFLAGS[@]}" DESTDIR="$BUILD_ROOT" install || \
|
||||
die "Failed to build and install source: ${SRC_DIRNAMES[$I]}"
|
||||
|
||||
# Package documentation.
|
||||
|
@ -317,5 +322,5 @@ makepkg -l y -p -c n --acls --xattrs "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/
|
|||
mkdir -p -m 755 "$PKG_STORE" && mv --backup=numbered "$BUILD_WORKDIR/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT" \
|
||||
"$PKG_STORE" || die "Failed to move package to store - package left in $BUILD_WORKDIR"
|
||||
|
||||
printf "\\033[1;32m%s:\\n %s\\033[0;39m\\n" "Package built and moved to store" \
|
||||
printf "\\033[1;32;40m%s:\\n %s\\033[0;39m\\n" "Package built and moved to store" \
|
||||
"$PKG_STORE/$PKG_NAME-${PKG_VERSION//-/_}-$PKG_ARCH-$PKG_BUILD${PKG_TAG//-/_}.$PKG_EXT"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue