pacwrap v0.9.11
- Miscellaneous cleanup and fixes - Interpretation of command line switches has been fixed pacwrap-common: Additional runtime dependency conditionals pacwrap-common: Universally defined EXEC_SCRIPT variable pacwrap-common: get_foreign_packages() pacwrap-common: Fixed typo pacwrap-sync: Rudimentary argument validation pacwrap-sync: Forcibly sync explicit packages from foreign databases with --explicit switch pacwrap-sync: Fixed validation with manual container configuration pacwrap-utils: Defined human parsable command switches pacwrap-ps: Defined --kill switch
This commit is contained in:
parent
828c939797
commit
ee803d01e0
8 changed files with 111 additions and 109 deletions
|
@ -20,10 +20,9 @@
|
|||
|
||||
source pacwrap-common
|
||||
|
||||
EXEC_NAME="pacwrap"
|
||||
|
||||
main () {
|
||||
parse_args "$@"
|
||||
runtime_check
|
||||
|
||||
[[ $SWITCH != V ]] && [[ $SWITCH != h ]] && distro_warn
|
||||
|
||||
|
@ -34,13 +33,11 @@ main () {
|
|||
S) source $(type -P $SYNC_SCRIPT);;
|
||||
U) source $(type -P $UTILS_SCRIPT);;
|
||||
h|V) manual_script;;
|
||||
*) ARGS=($@)
|
||||
log_invalid_arguments $1
|
||||
*) log_invalid_arguments $1
|
||||
esac
|
||||
}
|
||||
|
||||
parse_args () {
|
||||
ARGS=()
|
||||
for var in "$@"; do case $var in
|
||||
--process|-P) SWITCH=P;;
|
||||
--create|-C) SWITCH=C;;
|
||||
|
@ -52,6 +49,7 @@ parse_args () {
|
|||
-h|--help) SWITCH=h;;
|
||||
-V|--version) SWITCH=V;;
|
||||
-E*|-C*|-S*|-U*|-P*) SWITCH=$(echo $var | cut -c 2-2);;
|
||||
*) ARGS+=("$var")
|
||||
esac; done
|
||||
}
|
||||
|
||||
|
|
|
@ -18,9 +18,12 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
ARGS=()
|
||||
|
||||
[[ $RUNTIME_ARGS ]] && return
|
||||
|
||||
RUNTIME_ARGS="$0 $@"
|
||||
EXEC_NAME="${0##*/}"
|
||||
|
||||
BOLD=$(tput bold)
|
||||
RED=$(tput setaf 1)
|
||||
|
@ -36,7 +39,7 @@ ARROW="$CYAN$BOLD->$RESET"
|
|||
ARROW_GREEN="$GREEN$BOLD->$RESET"
|
||||
ARROW_RED="$RED$BOLD->$RESET"
|
||||
|
||||
VER="v0.9.10 ${BOLD}BETA$RESET"
|
||||
VER="v0.9.11 ${BOLD}BETA$RESET"
|
||||
|
||||
MAN_SCRIPT="pacwrap-man"
|
||||
EXEC_SCRIPT="pacwrap-exec"
|
||||
|
@ -49,7 +52,6 @@ LOG_ERR_HELP=1
|
|||
LOG_ERR_WARN=2
|
||||
LOG_ERR_ERROR=3
|
||||
|
||||
declare -A INSTANCE_CONFIG
|
||||
[[ ! $PACWRAP_DATA_DIR ]] && PACWRAP_DATA_DIR="$HOME/.local/share/pacwrap"
|
||||
[[ ! $PACWRAP_CACHE_DIR ]] && PACWRAP_CACHE_DIR="$HOME/.cache/pacwrap"
|
||||
[[ ! $PACWRAP_CONFIG_DIR ]] && PACWRAP_CONFIG_DIR="$HOME/.config/pacwrap"
|
||||
|
@ -60,6 +62,8 @@ LOCK_FILE="$PACWRAP_DATA_DIR/pacwrap.lck"
|
|||
LOG_FILE="$PACWRAP_DATA_DIR/pacwrap.log"
|
||||
OUTPUT_DEST=$LOG_FILE
|
||||
|
||||
declare -A INSTANCE_CONFIG
|
||||
|
||||
INSTANCE_ROOT_DIR=$PACWRAP_DATA_DIR/root
|
||||
INSTANCE_HOME_DIR=$PACWRAP_DATA_DIR/home
|
||||
INSTANCE_CONFIG_DIR=$PACWRAP_CONFIG_DIR/root
|
||||
|
@ -75,11 +79,12 @@ INSTANCE_PACMAN_CACHE="$PACWRAP_CACHE_DIR/pkg"
|
|||
INSTANCE_PACMAN_CFG_DIR="$PACWRAP_CONFIG_DIR/pacman"
|
||||
|
||||
init() {
|
||||
runtime_check
|
||||
[[ $EXEC_NAME != "pacwrap" ]] &&
|
||||
runtime_check
|
||||
|
||||
case $SWITCH in
|
||||
*n*) WITCH_NOCONFIRM=1;;
|
||||
*v*) RBOSE="/dev/stdout";;
|
||||
*v*) VERBOSE="/dev/stdout";;
|
||||
*h*|*V*) manual_script;;
|
||||
esac
|
||||
|
||||
|
@ -257,6 +262,16 @@ progress_bar() {
|
|||
print_progress_bar $((PROGRESS_LENGTH+1)) $bar_percent $percent
|
||||
}
|
||||
|
||||
get_foreign_packages() {
|
||||
local dbsyncpkgs=()
|
||||
local deps=$(return_dependencies)
|
||||
|
||||
for dep in ${deps[@]}; do
|
||||
dbsyncpkgs+=("$($EXEC_SCRIPT $dep --root --exec pacman -Qqe | sed -z -E "s/\<base\>//g")")
|
||||
done
|
||||
echo ${dbsyncpkgs[@]}
|
||||
}
|
||||
|
||||
localized_text() {
|
||||
eval "echo \$$1_EN"
|
||||
}
|
||||
|
@ -351,12 +366,14 @@ _CONFIG
|
|||
runtime_check() {
|
||||
[[ $(id -u) -lt 1000 ]] && log_error "$EXEC_NAME cannot be executed within a privileged context." 1
|
||||
|
||||
if [[ ! $(type -P bwrap) ]] || [[ ! $(type -P bwrap) ]] || [[ ! $(type -P pacman-key gpg) ]]; then
|
||||
if [[ ! $(type -P bwrap) ]] || [[ ! $(type -P zstd ) ]] ||
|
||||
[[ ! $(type -P fakechroot) ]] || [[ ! $(type -P fakeroot) ]] ||
|
||||
[[ ! $(type -P pacman-key gpg) ]]; then
|
||||
cat << _WARN
|
||||
$BOLD${RED}error:$RESET Requisite dependencies are missing.
|
||||
Please make sure that the following binaries are present in \$PATH:
|
||||
|
||||
${BOLD}bwrap$RESET, ${BOLD}zstd$RESET, ${BOLD}pacman-key$RESET or ${BOLD}gpg$RESET.
|
||||
${BOLD}bwrap$RESET, ${BOLD}fakechroot${BOLD}, ${BOLD}fakeroot$RESET, ${BOLD}zstd$RESET, ${BOLD}pacman-key$RESET or ${BOLD}gpg$RESET.
|
||||
|
||||
_WARN
|
||||
exit 2
|
||||
|
|
|
@ -19,20 +19,15 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
source pacwrap-common
|
||||
|
||||
EXEC_NAME="pacwrap-create"
|
||||
|
||||
export PACWRAP_CREATE=1
|
||||
|
||||
main () {
|
||||
trap exit INT
|
||||
export PACWRAP_CREATE=1
|
||||
|
||||
local args=$@
|
||||
|
||||
|
||||
parse_args "$@"
|
||||
init $PACWRAP_UTILS
|
||||
|
||||
local instance=$INSTANCE
|
||||
local args="$0 $@"
|
||||
|
||||
log "$BAR_GREEN Initializing container $INSTANCE..." \
|
||||
"Initializing container $INSTANCE running '$RUNTIME_ARGS'"
|
||||
|
@ -53,14 +48,12 @@ main () {
|
|||
}
|
||||
|
||||
parse_args () {
|
||||
ArGS=()
|
||||
for var in "$@"; do case $var in
|
||||
-V|--version) SWITCH="V";;
|
||||
--dep=*) DEPEND=$(echo $var | cut -c 7-);;
|
||||
--verbose) SWITCH=v$SWITCH;;
|
||||
--is-dep) SWITCH=d$SWITCH ;;
|
||||
--is-base) SWITCH=b$SWITCH;;
|
||||
-C*) SWITCH=$(echo $var | cut -c 3-)$SWITCH;;
|
||||
-*) SWITCH=$(echo $var | cut -c 2-)$SWITCH;;
|
||||
--is-dep) SWITCH+="d";;
|
||||
--is-base) SWITCH+="b";;
|
||||
-C*) SWITCH+=$(echo $var | cut -c 3-);;
|
||||
*) ARGS+=("$var");;
|
||||
esac; CLI_INVOCATION+="$var "; done
|
||||
}
|
||||
|
@ -79,7 +72,7 @@ script_init () {
|
|||
ARCHLINUX_TARBALL="archlinux-bootstrap-x86_64.tar.gz"
|
||||
ARCHLINUX_TARBALL_CACHE="$PACWRAP_CACHE_DIR/$ARCHLINUX_TARBALL"
|
||||
|
||||
PARAMS="$INSTANCE --root --exec"
|
||||
EXEC_SCRIPT="$EXEC_SCRIPT $INSTANCE --root --exec"
|
||||
MACHINE_ID=$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1)
|
||||
|
||||
case $SWITCH in
|
||||
|
@ -283,16 +276,16 @@ get_directory_pop() {
|
|||
init_trust () {
|
||||
log "$BAR_GREEN Initializing pacman trust database..." \
|
||||
"Initializing pacman trust database"
|
||||
$EXEC_SCRIPT $PARAMS pacman-key --init 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
$EXEC_SCRIPT pacman-key --init 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
log "$ARROW Populating pacman trust database..."
|
||||
$EXEC_SCRIPT $PARAMS pacman-key --populate 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
$EXEC_SCRIPT pacman-key --populate 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
}
|
||||
|
||||
finalise () {
|
||||
log "$ARROW Generating locale..."
|
||||
$EXEC_SCRIPT $PARAMS locale-gen 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
$EXEC_SCRIPT locale-gen 1>>$OUTPUT_DEST 2>>$OUTPUT_DEST
|
||||
log "$ARROW Updating certificate trust..."
|
||||
$EXEC_SCRIPT $PARAMS update-ca-trust 1>>$OUTPUT_DEST 2p>>$OUTPUT_DEST
|
||||
$EXEC_SCRIPT update-ca-trust 1>>$OUTPUT_DEST 2p>>$OUTPUT_DEST
|
||||
[[ $C_TYPE != "BASE" ]] && sync_foreign_database
|
||||
$SYNC_SCRIPT -Sg $INSTANCE
|
||||
[[ $C_TYPE == "BASE" ]] && sync_base_packages
|
||||
|
@ -308,7 +301,7 @@ install_packages () {
|
|||
fi
|
||||
|
||||
log_to_file "Installing specified packages"
|
||||
$EXEC_SCRIPT $PARAMS pacman -Sy ${ARGS[@]} --logfile /tmp/pacman.log --noconfirm 2>>$VERBOSE
|
||||
$EXEC_SCRIPT pacman -Sy ${ARGS[@]} --logfile /tmp/pacman.log --noconfirm 2>>$VERBOSE
|
||||
if [[ $? != 0 ]]; then
|
||||
log_error $ARROW_RED "Installation failed." \
|
||||
"Use pacwrap -Cv and examine stdout for details."
|
||||
|
@ -321,9 +314,9 @@ install_packages () {
|
|||
|
||||
sync_base_packages () {
|
||||
log "$ARROW Some housekeeping..." "Removing arch-install-scripts"
|
||||
$EXEC_SCRIPT $PARAMS pacman -R arch-install-scripts --noconfirm --logfile /tmp/pacman.log 2>/dev/null 1>>$VERBOSE
|
||||
$EXEC_SCRIPT pacman -R arch-install-scripts --noconfirm --logfile /tmp/pacman.log 2>/dev/null 1>>$VERBOSE
|
||||
log "$BAR_GREEN Checking $INSTANCE for updates..." "Checking $INSTANCE for updates"
|
||||
$EXEC_SCRIPT $PARAMS pacman -Syu --logfile /tmp/pacman.log --noconfirm 2>>$VERBOSE
|
||||
$EXEC_SCRIPT pacman -Syu --logfile /tmp/pacman.log --noconfirm 2>>$VERBOSE
|
||||
}
|
||||
|
||||
sync_foreign_database () {
|
||||
|
@ -333,16 +326,10 @@ sync_foreign_database () {
|
|||
rm -r "$INSTANCE_ROOT/var/lib/pacman/local"
|
||||
cp -rn "$INSTANCE_DEPEND_ROOT/var/lib/pacman/local" "$INSTANCE_ROOT/var/lib/pacman/"
|
||||
|
||||
local deps=$(return_dependencies)
|
||||
local dbsyncpkgs=()
|
||||
local i=0
|
||||
|
||||
for dep in ${deps[@]}; do
|
||||
dbsyncpkgs[i++]="$($EXEC_SCRIPT $dep --root --exec pacman -Qqe | sed -z -E "s/\<base\>//g")"
|
||||
done
|
||||
local dbsyncpkgs=$(get_foreign_packages)
|
||||
|
||||
[[ ${dbsyncpkgs[@]} ]] &&
|
||||
$EXEC_SCRIPT $PARAMS pacman -Su \
|
||||
$EXEC_SCRIPT pacman -Su \
|
||||
--dbonly \
|
||||
--logfile /tmp/pacman.log \
|
||||
--noconfirm ${dbsyncpkgs[@]} 2>/dev/null 1>>$VERBOSE
|
||||
|
|
|
@ -20,17 +20,14 @@
|
|||
|
||||
source pacwrap-common
|
||||
|
||||
EXEC_NAME="pacwrap-exec"
|
||||
|
||||
main () {
|
||||
export PACWRAP_EXEC=1
|
||||
parse_args "$@"
|
||||
init 1
|
||||
|
||||
case $SWITCH in
|
||||
*rc*|*cr*) execute_fakeroot "${ARGS[@]}";;
|
||||
*rs*|*sr*) execute_fakeroot bash;;
|
||||
s) execute_sandbox bash;;
|
||||
*s) execute_sandbox bash;;
|
||||
*) execute_sandbox "${ARGS[@]}";;
|
||||
esac
|
||||
}
|
||||
|
@ -51,17 +48,15 @@ script_init () {
|
|||
}
|
||||
|
||||
parse_args () {
|
||||
ARGS=()
|
||||
local sbdefined=
|
||||
|
||||
for var in "$@"; do case $var in
|
||||
-h) SWITCH=h;;
|
||||
-V) SWITCH=V;;
|
||||
--root) SWITCH=r$SWITCH;;
|
||||
--shell) SWITCH=s$SWITCH;;
|
||||
--dep) SWITCH=d$SWITCH;;
|
||||
--exec) SWITCH=rc$SWITCH;;
|
||||
-E*) SWITCH=$(echo $var | cut -c 3-)$SWITCH;;
|
||||
-V|--version) SWITCH="V";;
|
||||
--root) SWITCH+="r";;
|
||||
--shell) SWITCH+="s";;
|
||||
--dep) SWITCH+="d";;
|
||||
--exec) SWITCH+="rc";;
|
||||
-E*) SWITCH+=$(echo $var | cut -c 3-);;
|
||||
*) [[ $sbdefined ]] && ARGS+=("$var") && continue
|
||||
INSTANCE=$var
|
||||
sbdefined=1;;
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
|
||||
source pacwrap-common
|
||||
|
||||
EXEC_NAME="pacwrap-man"
|
||||
|
||||
HEADER=$BOLD
|
||||
HEADER_RESET=$RESET
|
||||
TAB=$(echo -e '\t')
|
||||
|
@ -41,12 +39,11 @@ main () {
|
|||
}
|
||||
|
||||
parse_args () {
|
||||
ARGS=()
|
||||
for var in "$@"; do case $var in
|
||||
--help=*) HELP=("$(echo $var | cut -c 8-)")
|
||||
SWITCH=h;;
|
||||
-h|--help) SWITCH=h;;
|
||||
-V|--version) SWITCH=V;;
|
||||
SWITCH="h";;
|
||||
-h|--help) SWITCH="h";;
|
||||
-V|--version) SWITCH="V";;
|
||||
*) ARGS+=("$var")
|
||||
esac; done
|
||||
}
|
||||
|
|
|
@ -23,14 +23,12 @@ source pacwrap-common
|
|||
declare -A PROCESS
|
||||
declare -A INSTANCE
|
||||
declare -A START
|
||||
declare -A RUNTIME_ARGS
|
||||
declare -A RUNTIME
|
||||
declare -A PROCESS_CHILDREN
|
||||
|
||||
EXEC_NAME="pacwrap-ps"
|
||||
KILL_PARAM="-1"
|
||||
|
||||
main () {
|
||||
export PACWRAP_UTILS=1
|
||||
trap exit INT
|
||||
|
||||
local roots=()
|
||||
|
@ -42,17 +40,17 @@ main () {
|
|||
parse_args $@
|
||||
init 1
|
||||
|
||||
[[ $SWITCH != s* ]] && log_to_file "Running '$RUNTIME_ARGS'"
|
||||
[[ $SWITCH != Ps* ]] && log_to_file "Running '$RUNTIME_ARGS'"
|
||||
|
||||
case $SWITCH in
|
||||
k*) kill_instance ${roots[@]};;
|
||||
Pk*) kill_instance ${roots[@]};;
|
||||
*) summary; local sum=$?
|
||||
[[ $sum == 1 ]] && log_invalid_arguments $1
|
||||
esac
|
||||
}
|
||||
|
||||
script_init () {
|
||||
[[ $SWITCH == s* ]] && SHOW_HEADER=1
|
||||
[[ $SWITCH == Ps* ]] && SHOW_HEADER=1
|
||||
[[ $SWITCH == *n* ]] || [[ $SHOW_HEADER ]] && SHOW_CONTAINER=1
|
||||
[[ $SWITCH == *id* ]] || [[ $SHOW_HEADER ]] && SHOW_PID=1
|
||||
[[ $SWITCH == *x* ]] && SHOW_RUNTIME=1
|
||||
|
@ -80,17 +78,19 @@ script_init () {
|
|||
|
||||
parse_args () {
|
||||
for var in "$@"; do case $var in
|
||||
-[0-9]*) KILL_PARAM="$var";;
|
||||
-V|--version) SWITCH=V;;
|
||||
-P*) SWITCH=$(echo $var | cut -c 3-);;
|
||||
*) ARGS+=("$var");;
|
||||
-[0-9]|-[0-9][0-9]) KILL_PARAM="$var";;
|
||||
-n|--noconfirm) SWITCH+="n";;
|
||||
-k|--kill) SWITCH="k";;
|
||||
-V|--version) SWITCH="V";;
|
||||
-P*) SWITCH+=$(echo $var | cut -c 3-);;
|
||||
*) ARGS+=("$var");;
|
||||
esac; done
|
||||
}
|
||||
|
||||
summary() {
|
||||
IFS=; local ps_list=$(enumerate_ps_list ${roots[@]})
|
||||
[[ ! $ps_list ]] && return 1
|
||||
echo -e $([[ $SHOW_HEADER ]] && column_headers)$ps_list | column -t -s ' '
|
||||
echo -e $([[ $SHOW_HEADER ]] && column_headers)$ps_list | column -t -s $(echo -e '\t')
|
||||
}
|
||||
|
||||
populate_process_array() {
|
||||
|
@ -125,12 +125,12 @@ populate_process_array() {
|
|||
source $INSTANCE_RUNTIME_DIR/$pid
|
||||
INSTANCE[$pid]="$instance"
|
||||
START[$pid]="$start"
|
||||
RUNTIME_ARGS[$pid]="$runtime_args"
|
||||
RUNTIME[$pid]="$runtime_args"
|
||||
else
|
||||
log_error $LOG_ERR_WARN "Runtime metadata for $pid was modified or not found."
|
||||
INSTANCE[$pid]="$instance"
|
||||
START[$pid]="$pmod"
|
||||
RUNTIME_ARGS[$pid]="${cmdlist[@]}"
|
||||
RUNTIME[$pid]="${cmdlist[@]}"
|
||||
fi
|
||||
|
||||
PROCESS[$pid]="${pid}"
|
||||
|
@ -219,7 +219,7 @@ enumerate_ps_list() {
|
|||
[[ $SHOW_CONTAINER ]] && vars+=($instance)
|
||||
[[ $SHOW_UPTIME ]] && vars+=($time)
|
||||
[[ $SHOW_PIDS ]] && vars+=($pids)
|
||||
[[ $SHOW_RUNTIME ]] && vars+=(${RUNTIME_ARGS[$pid]})
|
||||
[[ $SHOW_RUNTIME ]] && vars+=(${RUNTIME[$pid]})
|
||||
[[ ${#vars[@]} > 0 ]] && printf "\n%s\t%s\t%s\t%s\t%s" ${vars[@]}
|
||||
done
|
||||
}
|
||||
|
|
|
@ -24,13 +24,10 @@ declare -A updated
|
|||
declare -A synced
|
||||
declare -A syncreq
|
||||
|
||||
EXEC_NAME="pacwrap-sync"
|
||||
EXEC_SCRIPT="pacwrap-exec --root --exec"
|
||||
|
||||
EXEC_SCRIPT="$EXEC_SCRIPT --root --exec"
|
||||
LINKFILES=("bin" "lib" "lib32" "share")
|
||||
|
||||
main () {
|
||||
export PACWRAP_UTILS=1
|
||||
trap abort INT
|
||||
|
||||
local roots=()
|
||||
|
@ -42,13 +39,13 @@ main () {
|
|||
parse_args $@
|
||||
init $PACWRAP_CREATE
|
||||
|
||||
[[ ! $SWITCH ]] && log_invalid_arguments
|
||||
[[ ! $SWITCH ]] ||
|
||||
([[ ! $SYNC_UPDATE ]] && [[ ! $SYNC_UPGRADE ]] && [[ ! $SYNC_CONFIG ]]) &&
|
||||
log_invalid_arguments $@
|
||||
|
||||
if [[ $SWITCH == *g* ]]; then
|
||||
if [[ $SYNC_CONFIG ]]; then
|
||||
local instance=${ARGS[0]}
|
||||
|
||||
[[ ! -d $INSTANCE_ROOT_DIR/$instance ]] && return
|
||||
|
||||
[[ ! $instance ]] || [[ ! -d $INSTANCE_ROOT_DIR/$instance ]] && return
|
||||
log "$ARROW Configuring container..."
|
||||
sync_pacman_conf && return
|
||||
fi
|
||||
|
@ -86,11 +83,13 @@ main () {
|
|||
|
||||
parse_args () {
|
||||
for var in "$@"; do case $var in
|
||||
--generate-config|-g) SWITCH=g$SWITCH;;
|
||||
--update|-u) SWITCH=u$SWITCH;;
|
||||
--no-confirm|-n) SWITCH=n$SWITCH;;
|
||||
--sync|-y) SWITCH=y$SWITCH;;
|
||||
-S*) SWITCH=$(echo $var | cut -c 3-);;
|
||||
-V|--version) SWITCH="V";;
|
||||
--generate-config|-g) SWITCH+="g";;
|
||||
--update|-u) SWITCH+="u";;
|
||||
--noconfirm|-n) SWITCH+="n";;
|
||||
--explicit|-e) SWITCH+="e";;
|
||||
--sync|-y) SWITCH+="y";;
|
||||
-S*) SWITCH+=$(echo $var | cut -c 3-);;
|
||||
*) ARGS+=("$var");;
|
||||
esac; done
|
||||
}
|
||||
|
@ -98,11 +97,13 @@ parse_args () {
|
|||
script_init () {
|
||||
log_to_file "Running '$RUNTIME_ARGS'"
|
||||
|
||||
[[ $SWITCH == g ]] && SYNC_CONFIG=1
|
||||
[[ $SWITCH == *y* ]] && SYNC_UPDATE=1
|
||||
[[ $SWITCH == *u* ]] && SYNC_UPGRADE=1
|
||||
[[ $SWITCH == *yy* ]] && SYNC_FOREIGN=1
|
||||
[[ $SWITCH == *yyy* ]] && SYNC_OVERRIDE=1
|
||||
[[ $SWITCH == *yyyy* ]] && SYNC_FORCE=1
|
||||
[[ $SWITCH == *e* ]] && SYNC_EXPLICIT_FOREIGN=1
|
||||
|
||||
syncroots=(${roots[@]})
|
||||
|
||||
|
@ -259,7 +260,6 @@ check_root() {
|
|||
update_config() {
|
||||
declare -A skip
|
||||
|
||||
local i=
|
||||
local old_local_pkgs=$(return_packages)
|
||||
local package_list=()
|
||||
local local_pkgs=$($EXEC_SCRIPT $instance pacman -Qqe)
|
||||
|
@ -277,7 +277,7 @@ update_config() {
|
|||
|
||||
for pkg in $local_pkgs; do
|
||||
[[ ${skip[$pkg]} ]] && continue
|
||||
package_list[i++]="$pkg"
|
||||
package_list+=("$pkg")
|
||||
done
|
||||
|
||||
[[ "$(echo ${package_list[@]})" != "$(echo ${old_local_pkgs[@]})" ]] &&
|
||||
|
@ -351,6 +351,7 @@ syncdb_pacman_conf() {
|
|||
|
||||
invoke_update() {
|
||||
local instance=$1
|
||||
local dbsyncpkgs=
|
||||
|
||||
[[ ${updated[$instance]} ]] && return
|
||||
updated[$instance]=1
|
||||
|
@ -381,15 +382,16 @@ invoke_update() {
|
|||
[[ $(return_type) != "BASE" ]]; then
|
||||
log "$ARROW Synchronizing database against foreign packages..." \
|
||||
"Synchronizing $instance against foreign packages"
|
||||
|
||||
[[ $SYNC_EXPLICIT_FOREIGN ]] && dbsyncpkgs=$(get_foreign_packages)
|
||||
|
||||
$EXEC_SCRIPT $instance pacman -Su \
|
||||
--logfile /tmp/pacman.log \
|
||||
--dbonly --noconfirm \
|
||||
--config=/tmp/pacman.conf 2>/dev/null 1>$VERBOSE
|
||||
|
||||
--config=/tmp/pacman.conf ${dbsyncpkgs[@]} 2>/dev/null 1>$VERBOSE
|
||||
[[ $? != 0 ]] &&
|
||||
log_error $ARROW_RED "Foreign database synchronization failed." \
|
||||
"Use pacwrap -Sv and examine stdout for details." 1
|
||||
|
||||
log " Database synchronization complete!"
|
||||
fi
|
||||
|
||||
|
|
|
@ -19,12 +19,11 @@
|
|||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
source pacwrap-common
|
||||
export PACWRAP_UTILS=1
|
||||
|
||||
EXEC_NAME="pacwrap-utils"
|
||||
NUMFMT="numfmt --to=si --suffix=B --round=nearest --from-unit=1000 --format=%2f "
|
||||
|
||||
main () {
|
||||
export PACWRAP_UTILS=1
|
||||
trap exit INT
|
||||
|
||||
local roots=()
|
||||
|
@ -36,18 +35,18 @@ main () {
|
|||
parse_args $@
|
||||
init
|
||||
|
||||
[[ $SWITCH != ls* ]] && log_to_file "Running '$RUNTIME_ARGS'"
|
||||
[[ $SWITCH != Uls* ]] && log_to_file "Running '$RUNTIME_ARGS'"
|
||||
|
||||
case $SWITCH in
|
||||
c*) [[ -f /usr/bin/paccache ]] &&
|
||||
Uc*) [[ -f /usr/bin/paccache ]] &&
|
||||
paccache --cachedir $INSTANCE_CACHE_DIR ${ARGS[@]};;
|
||||
i*) initialize_data_directory;;
|
||||
r*) replicate ${baserootdeps[@]} ${rootdeps[@]} ${roots[@]};;
|
||||
v*) edit_file 1;;
|
||||
e*) edit_file;;
|
||||
ls*) summary;;
|
||||
l*) link_root;;
|
||||
d*) [[ $SWITCH == *r* ]] && delete "root" "$INSTANCE_ROOT_DIR"
|
||||
Ui*) initialize_data_directory;;
|
||||
Ur*) replicate ${baserootdeps[@]} ${rootdeps[@]} ${roots[@]};;
|
||||
Uv*) edit_file 1;;
|
||||
Ue*) edit_file;;
|
||||
Uls*) summary;;
|
||||
Ul*) link_root;;
|
||||
Ud*) [[ $SWITCH == *r* ]] && delete "root" "$INSTANCE_ROOT_DIR"
|
||||
[[ $SWITCH == *h* ]] && delete "home" "$INSTANCE_HOME_DIR";;
|
||||
*) log_invalid_arguments $1
|
||||
esac
|
||||
|
@ -76,7 +75,7 @@ summary() {
|
|||
parse_du
|
||||
|
||||
if [[ $SWITCH != *ddd* ]]; then
|
||||
list_root ${baserootdeps[@]} ${rootdeps[@]} ${roots[@]} ${links[@]} | column -t -s ' '
|
||||
list_root ${baserootdeps[@]} ${rootdeps[@]} ${roots[@]} ${links[@]} | column -t -s "$(echo -e '\t')"
|
||||
fi
|
||||
|
||||
if [[ $SWITCH == *d* ]]; then
|
||||
|
@ -97,9 +96,16 @@ summary() {
|
|||
|
||||
parse_args () {
|
||||
for var in "$@"; do case $var in
|
||||
--list|-l) SWITCH=l$SWITCH;;
|
||||
-V|--version) SWITCH=V;;
|
||||
-U*) SWITCH=$(echo $var | cut -c 3-);;
|
||||
--noconfirm|-n) SWITCH+="n";;
|
||||
--list|-ls) SWITCH+="ls";;
|
||||
--edit|-e) SWITCH+="e";;
|
||||
--view|-v) SWITCH+="v";;
|
||||
--replicate|-r) SWITCH+="r";;
|
||||
--delete|-d) SWITCH+="d";;
|
||||
--link|-l) SWITCH+="l";;
|
||||
--tar|-t) SWITCH+="t";;
|
||||
-V|--version) SWITCH="V";;
|
||||
-U*) SWITCH+=$(echo $var | cut -c 3-);;
|
||||
--cfg-dir=*) REPLICATION_CONFIG_DIR=$(echo $var | cut -c 11-);;
|
||||
*) ARGS+=("$var");;
|
||||
esac; done
|
||||
|
@ -404,10 +410,10 @@ edit_file() {
|
|||
log "$ARROW_GREEN Changes written." \
|
||||
"Changes written to $file."
|
||||
else
|
||||
log "$BAR_GREEN No changes made"
|
||||
log "$ARROW No changes made"
|
||||
fi
|
||||
else
|
||||
log "$BAR_GREEN No changes made."
|
||||
log "$ARROW No changes made."
|
||||
fi
|
||||
|
||||
rm $tmpfile
|
||||
|
|
Loading…
Reference in a new issue