diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2020-09-19 04:39:32 -0400 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2020-11-20 22:51:10 -0500 |
commit | 41346f5871f10d261f9202e8d66a8e1c04124a32 (patch) | |
tree | 3fca30b52319113fe24cdaf81e6ff7028f8657a1 | |
parent | 8603c69f9009cbd52159e95af394570069a6e423 (diff) |
housekeeping
-rw-r--r-- | src/chroot-tools/chcleanup.in | 22 | ||||
-rwxr-xr-x | src/chroot-tools/librechroot | 19 | ||||
-rwxr-xr-x | src/chroot-tools/libremakepkg | 3 | ||||
-rwxr-xr-x | src/librefetch/librefetch | 4 | ||||
-rwxr-xr-x | src/pkgbuild-check-nonfree | 6 | ||||
-rwxr-xr-x | test/testenv | 20 |
6 files changed, 42 insertions, 32 deletions
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in index b60bd4c..700c8b5 100644 --- a/src/chroot-tools/chcleanup.in +++ b/src/chroot-tools/chcleanup.in @@ -27,7 +27,7 @@ set -eE # leaves you with a clean system -# Library routines ############################################################# +## Library Routines ## # Statically include various library routines to avoid having # dependencies on outside files. @@ -41,24 +41,28 @@ else fi -# Begin chcleanup.lib ########################################################## +## chcleanup.lib ## + m4_include(chcleanup.lib) -# End chcleanup.lib ############################################################ -# User interface ############################################################### + +## User Interface ## + DRYRUN=${DRYRUN:-false} if [[ ! -f /.arch-chroot ]] && ! ${DRYRUN}; then error "(chcleanup): Must be run inside of a chroot" exit 1 fi -# Load configuration ########################################################### -CHROOTPKG=(base-devel) -# Note: the in-chroot pkgconfdir is non-configurable, this is -# intentionally hard-coded. +## Load Configuration ## + +# NOTE: The in-chroot pkgconfdir is non-configurable. +# This is intentionally hard-coded. source /etc/libretools.d/chroot.conf +CHROOTPKG=(base-devel) + # If we're running makepkg if [[ -f ./PKGBUILD ]]; then if [[ ! -f ./.SRCINFO || ./PKGBUILD -nt ./.SRCINFO ]]; then @@ -71,7 +75,7 @@ else fi -# Main ######################################################################### +## Main Entry ## msg "Cleaning chroot..." diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot index bbc0ec9..0edbdd9 100755 --- a/src/chroot-tools/librechroot +++ b/src/chroot-tools/librechroot @@ -73,7 +73,7 @@ hack_arch_nspawn_flags() { local setarch interpreter case $CARCH in - armv7h) setarch=armv7l; interpreter=/usr/bin/qemu-arm-static ;; + armv7h|armv7l) setarch=armv7l; interpreter=/usr/bin/qemu-arm-static ;; *) setarch=$CARCH; interpreter=/usr/bin/qemu-$CARCH-static ;; esac if ! setarch $setarch /bin/true 2>/dev/null; then @@ -312,7 +312,10 @@ main() { local mode=enter opt declare -Ai used_opts - while getopts 'n:l:NC:M:A:w:r:' opt; do + + ## parse CLI options ## + + while getopts 'n:l:NC:M:A:w:r:' opt; do case $opt in n) CHROOT=$OPTARG;; l) COPY=$OPTARG;; @@ -347,6 +350,9 @@ main() { used_opts[$opt]+=1 done + + ## validate CLI options ## + for opt in n l C M A; do if (( ${used_opts[$opt]:-0} > 1 )); then error "Option -%s may only be given once" "$opt" @@ -373,6 +379,10 @@ main() { fi shift case "$mode" in + help) + usage + return $EXIT_SUCCESS + :;; noop|make|sync|delete|update|enter|clean-pkgs|clean-repo) if [[ $# -gt 0 ]]; then error 'Command `%s` does not take any arguments: %s' "$mode" "$*" @@ -415,11 +425,6 @@ main() { :;; esac - if [[ $mode == help ]]; then - usage - return $EXIT_SUCCESS - fi - [[ $retconf = 0 ]] || exit $retconf eval "$(calculate_directories)" diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg index 10292c7..d6bb17f 100755 --- a/src/chroot-tools/libremakepkg +++ b/src/chroot-tools/libremakepkg @@ -75,8 +75,7 @@ run_hook() { local fails=() for hook in "${!hookvar}"; do - # The "& wait $!" trick is to prevent "||" from - # disabling "set -e" + # The "& wait $!" trick prevents "||" from disabling "set -e" { "$hook" "$@" |& indent; } & wait $! || fails+=("$hook") done diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch index ed354c6..38355b2 100755 --- a/src/librefetch/librefetch +++ b/src/librefetch/librefetch @@ -35,13 +35,13 @@ . "$(librelib conf)" . "$(librelib messages)" setup_traps +trap 'rm -f -- "${tmpfiles[@]}"; rm -rf -- "${tmpdirs[@]}"' EXIT tmpfiles=() tmpdirs=() +cmd=${0##*/} -trap 'rm -f -- "${tmpfiles[@]}"; rm -rf -- "${tmpdirs[@]}"' EXIT -cmd=${0##*/} usage() { print "Usage: %s [OPTIONS] SOURCE_URL [OUTPUT_FILE]" "$cmd" print "Usage: %s -[g|S|M|h]" "$cmd" diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree index 8d9ee83..965d0ab 100755 --- a/src/pkgbuild-check-nonfree +++ b/src/pkgbuild-check-nonfree @@ -1,5 +1,5 @@ #!/usr/bin/env bash -# -*- tab-width: 4 ; sh-basic-offset: 4 -*- + # pkgbuild-check-nonfree # Copyright (C) 2011 Joseph Graham (Xylon) <joe@t67.eu> @@ -27,6 +27,8 @@ # I appologize that this program got *huge*. # It's not complicated, just long. +# i appologize that i deleted your vim metadata - no wait, not sorry :) + . "$(librelib messages)" . "$(librelib conf)" @@ -233,7 +235,7 @@ check_pkg() { panic 'code should never be reached' } -# Usage: pkgbuild_ckec $pkgbuild +# Usage: pkgbuild_check $pkgbuild # Check whether a PKGBUILD has any issues (using the above) pkgbuild_check() ( [[ $# == 1 ]] || panic 'malformed call to pkgbuild_check' diff --git a/test/testenv b/test/testenv index ee89f4c..afa5559 100755 --- a/test/testenv +++ b/test/testenv @@ -3,21 +3,21 @@ set -e # Parse the arguments + if [[ $# > 0 ]]; then NETWORK=true SUDO=true while [[ $# -gt 0 ]]; do - case "$1" in - --no-network) shift; unset NETWORK;; - --network) shift; NETWORK=true;; - --no-sudo) shift; unset SUDO;; - --sudo) shift; SUDO=true;; - --) shift; break;; - *) break;; - esac + case "$1" in + --no-network) shift; unset NETWORK;; + --network) shift; NETWORK=true;; + --no-sudo) shift; unset SUDO;; + --sudo) shift; SUDO=true;; + --) shift; break;; + *) break;; + esac done export NETWORK SUDO - - if [[ $# == 0 ]]; then + else echo 'You need to run testenv with arguments!' >&2 exit 1 fi |