summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2023-12-26 16:30:04 -0500
committerbill-auger <mr.j.spam.me@gmail.com>2024-01-04 16:09:39 -0500
commit4299bd7ddb3761d1629ed8e35fa42a069e872574 (patch)
treea0b1b4068a12b61e40fa776912012bee7fe53c57
parentb10085cc9e6eab5839cadc6d8a669f39dc5f6571 (diff)
housekeeping
-rw-r--r--src/chroot-tools/chcleanup.in6
-rwxr-xr-xsrc/chroot-tools/librechroot61
-rwxr-xr-xsrc/chroot-tools/libremakepkg4
-rw-r--r--src/lib/conf.sh.in23
-rw-r--r--src/lib/notifications.sh2
-rwxr-xr-xsrc/librefetch/librefetch-install1
-rwxr-xr-xsrc/pkgbuild-check-nonfree2
7 files changed, 47 insertions, 52 deletions
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in
index b682050..15a01e7 100644
--- a/src/chroot-tools/chcleanup.in
+++ b/src/chroot-tools/chcleanup.in
@@ -67,7 +67,7 @@ fi
m4_include(chcleanup.lib)
-## User Interface ##
+## Sanity Checks ##
DRYRUN=${DRYRUN:-false}
if ! is_in_chroot && ! ${DRYRUN}; then
@@ -157,7 +157,7 @@ done
# DEPENDS are not included in this optimization;
# because this assumption doesn't hold for them.
mapfile -t fresh_pkgs < <("${PacmanCmd[@]}" -Sp --print-format='%n %v' \
- -- "${CHROOTPKG[@]}" "${CHROOTEXTRAPKG[@]}")
+ -- "${CHROOTPKG[*]}" "${CHROOTEXTRAPKG[*]}")
stale_pkgs=()
for pkg in "${fresh_pkgs[@]}"; do
pkg_name_ver=${pkg/ /-}
@@ -182,7 +182,7 @@ if (( ${#CHROOTPKG[*]} ))
then for var in CHROOTPKG CHROOTEXTRAPKG DEPENDS
do declare -n pkgsref="$var"
# prose " * collecting '$var' packages: ${pkgsref[*]}" # TODO: column -t maybe better?
- indent <<<" * collecting '$var' packages: ${pkgsref[*]}"
+ indent <<< " * collecting '$var' packages: ${pkgsref[*]}"
done
if ! "${PacmanCmd[@]}" ${pacman_opts[*]} ${PHANTOM_PKGS[*]} \
-- ${CHROOTPKG[*]} ${CHROOTEXTRAPKG[*]} ${DEPENDS[*]} \
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 4863c4d..d017c4d 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -33,17 +33,15 @@
# - the "handle commands" switch block which handles them
-set -euE
-
-
source "$(librelib conf )" # defines $BASE_PKGS, $CHROOT_CONF
# defines $LIBRETOOLS_CONF_SH
# defines $PACMAN_DEFS_DIR, $SUPPORTED_ARCHES
- # defines $CHCLEANUP_FILE, $CHROOTEXEC_FILE
# implements base_pkgs()
source "$(librelib messages )"
source "$(librelib chroot/makechrootpkg)"
+
+set -euE
shopt -s nullglob
umask 0022
@@ -56,7 +54,7 @@ umask 0022
detect_chroot_arch()
(
local makepkg_conf="$1"
- local arches_rx="^($(sed 's/ /|/g' <<<${SUPPORTED_ARCHES[*]}))$"
+ local arches_rx="^($(sed 's/ /|/g' <<< ${SUPPORTED_ARCHES[*]}))$"
unset CARCH ; source "$makepkg_conf" &> /dev/null ;
if [[ "$CARCH" =~ $arches_rx ]]; then
@@ -251,10 +249,7 @@ readonly COMMANDS=(
run enter clean-repo help
)
-
usage() {
- # NOTE: assumes that 'calculate_directories' has executed
-
local mount_msg="$(_ 'PATH[:INSIDE_PATH[:OPTIONS]]')"
print "Usage: %s [OPTIONS] COMMAND [ARGS...]" "${0##*/}"
@@ -333,13 +328,15 @@ usage() {
echo
prose "The \`%s\` option is the preferred way to create new chroot-sets. E.g.:" -A
echo " $ sudo librechroot -A i686 -n my-32bit-x86 make"
- print "The \`%s\` option sets \`%s\` and \`%s\` implicitly, as:" '-A <CARCH>' -C -M
+ print "The \`%s\` option sets \`%s\` and \`%s\` implicitly, as:" -A -C -M
flag '-C' "%s" "${PACMAN_DEFS_DIR}/pacman.conf.\$<CARCH>"
flag '-M' "%s" "${PACMAN_DEFS_DIR}/makepkg.conf.\$<CARCH>"
prose "However, %s will be modified to:" pacman.conf
bullet "set %s to match %s per %s" Architecture '$CARCH' makepkg.conf
bullet "comment-out any '%s' lines" 'Include = /etc/pacman.d/*.conf'
bullet "add special-case build support repos (commented-out)"
+ prose "If none of the \`%s\`, \`%s\`, or \`%s\` options are given, the chroot
+ architecture will be that of the host." -A -C -M
echo
flag 'Options:' \
"-n <$(_ NAME)>" "Name of the chroot to use" \
@@ -429,14 +426,13 @@ main() {
M) seed_makepkgconf="$OPTARG"
target_arch=$(detect_chroot_arch "$OPTARG") ;;
A) target_arch=$OPTARG
- use_tmp_pacmanconf=1
def_pacmanconf="${PACMAN_DEFS_DIR}"/pacman.conf.${target_arch}
def_makepkgconf="${PACMAN_DEFS_DIR}"/makepkg.conf.${target_arch}
- seed_pacmanconf="${tmp_pacmanconf}" ;;
- N ) ChrootRunFlags+=( -N ) ;;
- w ) ChrootRunFlags+=(-b "-B:$OPTARG") ;;
- r ) ChrootRunFlags+=(-b "-Br:$OPTARG") ;;
- * ) ExitInvalidArgument ;;
+ seed_pacmanconf="${tmp_pacmanconf}" ; use_tmp_pacmanconf=1 ; ;;
+ N) ChrootRunFlags+=( -N ) ;;
+ w) ChrootRunFlags+=(-b "-B:$OPTARG") ;;
+ r) ChrootRunFlags+=(-b "-Br:$OPTARG") ;;
+ *) ExitInvalidArgument ;;
esac
used_opts[$opt]+=1
done
@@ -445,7 +441,7 @@ main() {
shift $OPTIND
- ## validate state ##
+ ## validate and finalize state ##
if (( was_conf_error )); then
error "Could not load chroot.conf configuration"
@@ -561,10 +557,10 @@ main() {
fi
- ## chroot setup ##
+ ## environment validation and chroot instantiation ##
if (( EUID )); then
- error "This program must be run as root."
+ error "The '%s' command must be run with super-user privileges." $mode
return $EXIT_NOPERMISSION
fi
@@ -594,30 +590,25 @@ main() {
fi
fi
+ # Create or sync working copy
if [[ ! -d $copydir ]] || [[ $mode == sync ]]; then
msg "Syncing copy [%s] with root copy" "$COPY"
sync_chroot "$CHROOTDIR/$CHROOT/root" "$copydir" "$COPY"
fi
- # Note: the in-chroot pkgconfdir is non-configurable, this is
- # intentionally hard-coded.
- mkdir -p "$copydir/etc/libretools.d"
- {
- if [[ ${#CHROOTEXTRAPKG[*]} -eq 0 ]]; then
- echo 'CHROOTEXTRAPKG=()'
- else
- printf 'CHROOTEXTRAPKG=('
- printf '%q ' "${CHROOTEXTRAPKG[@]}"
- printf ')\n'
- fi
- } > "$copydir"/etc/libretools.d/chroot.conf
+
+ ## chroot configuration ##
+
+ echo "CHROOTEXTRAPKG=( $(printf '%q ' "${CHROOTEXTRAPKG[@]}") )" |
+ install -Dm644 /dev/stdin "$copydir"$CHROOT_CONF
+ install -Dm644 $LIBRETOOLS_CONF_SH "$copydir"$LIBRETOOLS_CONF_SH
# "touch" the chroot first
# this will
# - overwrite '/etc/pacman.d/mirrorlist'"
# - set 'CacheDir' in \`/etc/pacman.conf'"
# - apply -C or -M flags
- chroot-run "$copydir" true </dev/null
+ chroot-run "$copydir" true < /dev/null
fi
# cleanup
@@ -630,7 +621,7 @@ main() {
case "$mode" in
# Create/copy/delete
- make|sync) :;;
+ make|sync) : ;; # make and sync operations are managed implicitly above
delete)
if [[ -d $copydir ]]; then
delete_chroot "$copydir"
@@ -639,14 +630,14 @@ main() {
# Dealing with packages
install-file)
- install_packages "$copydir" "$@" </dev/null
+ install_packages "$copydir" "$@" < /dev/null
chroot_add_to_local_repo "$copydir" "$@"
;;
install-name)
- chroot-run "$copydir" pacman -Sy --noconfirm -- "$@" </dev/null
+ chroot-run "$copydir" pacman -Sy --noconfirm -- "$@" < /dev/null
;;
upgrade)
- chroot-run "$copydir" pacman -Syu --noconfirm </dev/null
+ chroot-run "$copydir" pacman -Syu --noconfirm < /dev/null
;;
clean-pkgs)
trap "rm -f -- ${copydir@Q}{$CHCLEANUP_FILE,$CHROOTEXEC_FILE}" EXIT
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index 6fefacc..4d6c4ad 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -29,8 +29,8 @@
set -euE
-source "$(librelib conf)"
-source "$(librelib messages)"
+source "$(librelib conf )"
+source "$(librelib messages )"
source "$(librelib chroot/makechrootpkg)"
set -o pipefail
diff --git a/src/lib/conf.sh.in b/src/lib/conf.sh.in
index 91f86a6..fc0ee85 100644
--- a/src/lib/conf.sh.in
+++ b/src/lib/conf.sh.in
@@ -121,11 +121,11 @@ list_envvars() {
case $slug in
makepkg)
- printf '%s\n' \
+ printf '%s\n' \
PKGDEST SRCDEST SRCPKGDEST LOGDEST \
- BUILDDIR \
- PKGEXT SRCEXT \
- GPGKEY PACKAGER \
+ BUILDDIR \
+ PKGEXT SRCEXT \
+ GPGKEY PACKAGER \
CARCH
;;
libretools)
@@ -144,8 +144,8 @@ list_envvars() {
load_conf() {
local slug_or_path="$1" ; shift ;
local vars=( "$@" )
- declare -i ret=0 # $EXIT_SUCCESS
local files envvars slug var file
+ declare -i ret
if [[ "$slug_or_path" == /* ]]; then
files=("$slug_or_path")
@@ -176,6 +176,7 @@ load_conf() {
done
# Verify that the variables we need were set
+ ret=0 # $EXIT_SUCCESS
for var in "${vars[@]}"; do
if [[ -z ${!var:-} ]]; then
if [[ ${#files[@]} -gt 1 ]]; then
@@ -187,6 +188,7 @@ load_conf() {
ret=6 # $EXIT_NOTCONFIGURED
fi
done >&2
+
return $ret
}
@@ -249,7 +251,7 @@ base_pkgs() {
if [[ "$init" == non-systemd ]] || ( [[ -z "$init" ]] && is_nonsystemd ); then
sed "s|^base$|nonsystemd/&|" <<< ${BASE_PKGS[*]} ; echo ${NONSYSTEMD_PKGS[*]} ;
else
- sed "s|^base$|libre/&|" <<<${BASE_PKGS[*]} ; echo ${SYSTEMD_PKGS[*]} ;
+ sed "s|^base$|libre/&|" <<< ${BASE_PKGS[*]} ; echo ${SYSTEMD_PKGS[*]} ;
fi
}
@@ -260,7 +262,7 @@ unset_PKGBUILD() {
# This routine is based primarily off of the PKGBUILD(5) man-page,
# version 4.2.0, dated 2014-12-31
- # For each arg, `unset -v` all variables matching ${arg} and ${arg}_*
+ # For each arg, `unset -v` all variables matching ${arg} and ${arg}_*
unset_pkgbuild_vars() {
local v
for v in "$@"; do
@@ -270,7 +272,6 @@ unset_PKGBUILD() {
}
- # These are taken from makepkg::util/schema.sh)
local known_hash_algos=( $( LIBRARY=${LIBRARY:-'/usr/share/makepkg'} ; \
source "$LIBRARY/util/schema.sh" ; \
printf ${known_hash_algos[*]} ) )
@@ -297,7 +298,11 @@ unset_PKGBUILD() {
unset -f $(declare -f|sed -n 's/^\(package_\S*\) ()\s*$/\1/p')
unset -v pkgbase
- # These are used by the `librefetch` program
+ # Parabola makepkg extensions (aka: mksource)
+ # These are used by `librefetch` to generate an FSDG-fit source-ball,
+ # before the prepare() funtion runs,
+ # instead of the standard --allsource source-ball,
+ # which is rolled before the prepare() funtions runs.
unset -v mksource mknoextract "${sums[@]/#/mk}"
unset -v mkdepends
unset -f mksource
diff --git a/src/lib/notifications.sh b/src/lib/notifications.sh
index 7cb68b1..99f9bbf 100644
--- a/src/lib/notifications.sh
+++ b/src/lib/notifications.sh
@@ -19,7 +19,7 @@ notify_release() # ( ssh_cmd* ) file_list->STDIN
[[ "${filename}" =~ ${select_rx} ]] || continue
[[ "${filename}" =~ ${reject_rx} ]] && continue || :
- sed -E "${filename_sed}" <<<${filename} || :
+ sed -E "${filename_sed}" <<< ${filename} || :
done | sort -u | xargs || :) )
local pbotsay_msg="$(printf "$(_ "%s just published:")" ${repo_user}) ${releases[@]}"
local pbotsay_cmd="which pbot-say &> /dev/null && pbot-say '${pbotsay_msg}'"
diff --git a/src/librefetch/librefetch-install b/src/librefetch/librefetch-install
index 4aa34d2..b229070 100755
--- a/src/librefetch/librefetch-install
+++ b/src/librefetch/librefetch-install
@@ -39,7 +39,6 @@
# TODO: one of those should be renamed, to avoid the name collision/confusion
-
set -ueE
source "$(librelib messages)"
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index affbbe1..8c19d49 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -187,7 +187,7 @@ check_dep() {
local line replacement
line="$(blacklist-cat|blacklist-lookup "$pkg")"
- replacement="$(blacklist-get-rep <<<"$line")"
+ replacement="$(blacklist-get-rep <<< "$line")"
if [[ -z $line ]]; then
# not mentioned in blacklist; free
info '%s: not blacklisted' "$pkg"