Couple of minor fixups.

This commit is contained in:
Darren 'Tadgy' Austin 2022-10-07 17:34:22 +01:00
commit 409a7923f3

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# Version: 0.6.7 # Version: 0.6.9
# Copyright (c) 2005-2022: # Copyright (c) 2005-2022:
# Darren 'Tadgy' Austin <darren (at) afterdark.org.uk> # Darren 'Tadgy' Austin <darren (at) afterdark.org.uk>
# Licensed under the terms of the GNU General Public License version 3. # Licensed under the terms of the GNU General Public License version 3.
@ -12,6 +12,9 @@
# Silence shellcheck. # Silence shellcheck.
# shellcheck disable=SC2015,SC2174 # shellcheck disable=SC2015,SC2174
# extglob is required.
shopt -s extglob
# Functions. # Functions.
check_installed() { check_installed() {
# $1 = The package name to check is installed. # $1 = The package name to check is installed.
@ -152,7 +155,7 @@ eval "$(declare -p PKG_STORE PKG_CONFIG_ARCHIVE | sed -re 's/\\\$/$/g')"
# Sanity. # Sanity.
SRC_DIR="$(pwd)" SRC_DIR="$(pwd)"
umask 0022 umask 0022
[[ ! -e "$BUILD_WORKDIR" ]] { || mkdir -p -m 750 "$BUILD_WORKDIR" || die "Failed to create working directory"; } [[ ! -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 "$BUILD_ROOT" && mkdir -m 755 "$BUILD_ROOT" || die "Failed to clear build root"
[[ -n "${SRC_DIRNAMES[*]}" ]] && { 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"; }
@ -161,12 +164,12 @@ rm -rf "$BUILD_ROOT" && mkdir -m 755 "$BUILD_ROOT" || die "Failed to clear build
WGET="$(command -v wget)" WGET="$(command -v wget)"
I=0 I=0
while read -r SRC; do while read -r SRC; do
[[ ! -e "${SRC_FILENAMES[$I]}" ]] && { [[ ! -e "${SRC_FILENAMES[I]}" ]] && {
[[ -z "$WGET" ]] && die "wget is required to download sources" [[ -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" || \ "$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"; } { 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]}" [[ "$(md5sum "${SRC_FILENAMES[I]}" | cut -d' ' -f1)" != "${SRC_MD5SUMS[I]}" ]] && die "md5sum verification failed: ${SRC_FILENAMES[I]}"
(( I++ )) (( I++ ))
done < <(printf "%s\\n" "${SRC_DOWNLOADS[@]}") done < <(printf "%s\\n" "${SRC_DOWNLOADS[@]}")
} }
@ -200,7 +203,7 @@ CONFIGURE_OPTS=("${BUILD_ALTCC:+CC=\"$BUILD_ALTCC\"}" "${BUILD_ALTCXX:+CXX=\"$BU
# Process each of the sources. # Process each of the sources.
for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
# Be in the source directory. # Be in the source directory.
cd "$BUILD_WORKDIR/${SRC_DIRNAMES[$I]}" || die "Failed to change to source directory: $BUILD_WORKDIR/${SRC_DIRNAMES[$I]}" cd "$BUILD_WORKDIR/${SRC_DIRNAMES[I]:?Failed to change to source directory}" || die "Failed to change to source directory"
############################################ ############################################
# Begin section that will require editing. # # Begin section that will require editing. #
@ -210,20 +213,20 @@ for ((I = 0; I < ${#SRC_DIRNAMES[@]}; I++)); do
case "$I" in case "$I" in
0) 0)
# Patch before build. # Patch before build.
# zcat $SRC_DIR/patches/EDITME.diff.gz | patch -p0 || die "Source patching failed on: EDITME.diff.gz" # zcat $SRC_DIR/patches/EDITME.diff.gz | patch -p0 || die "Source patching failed for: EDITME.diff.gz"
# Configure. # Configure.
CFLAGS="$BUILD_CFLAGS" CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" ./configure "${CONFIGURE_OPTS[@]}" \ CFLAGS="$BUILD_CFLAGS" CXXFLAGS="$BUILD_CXXFLAGS" LDFLAGS="$BUILD_LDFLAGS" ./configure "${CONFIGURE_OPTS[@]}" \
--docdir="$BUILD_PREFIX/doc/${SRC_FILENAMES[$I]%%.*}" EDITME || \ --docdir="$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%%.*}" EDITME || \
die "Source ./configure failed: ${SRC_DIRNAMES[$I]}" die "Source ./configure failed: ${SRC_DIRNAMES[I]}"
# Build and install. # 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]}" die "Failed to build and install source: ${SRC_DIRNAMES[I]}"
# Package documentation. # Package documentation.
mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[$I]%%.*}" && cp --parents EDITME \ mkdir -p -m 755 "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.?z|t?z|zip)}" && cp --parents EDITME \
"$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[$I]%%.*}" || die "Documentation copy failed: ${SRC_DIRNAMES[$I]}" "$BUILD_ROOT/$BUILD_PREFIX/doc/${SRC_FILENAMES[I]%.@(tar|tar.?z|t?z|zip)}" || die "Documentation copy failed: ${SRC_DIRNAMES[I]}"
;; ;;
*) *)
die "Un-handled source file - no build configuration" die "Un-handled source file - no build configuration"