Merge branch 'pr-33'

This commit is contained in:
Morten Linderud 2022-11-20 14:56:54 +01:00
commit 4457e31ee3
No known key found for this signature in database
GPG Key ID: 9C02FF419FECBE16
3 changed files with 12 additions and 4 deletions

View File

@ -8,7 +8,7 @@ _pacstrap() {
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-C -c -G -i -K -M -N -P -U -h"
opts="-C -c -D -G -i -K -M -N -P -U -h"
for i in "${COMP_WORDS[@]:1:COMP_CWORD-1}"; do
if [[ -d ${i} ]]; then

View File

@ -28,6 +28,9 @@ Options
*-c*::
Use the package cache on the host, rather than the target.
*-D*::
Skip pacman dependency checks.
*-G*::
Avoid copying the host's pacman keyring to the target.

View File

@ -16,6 +16,7 @@ hostcache=0
copykeyring=1
initkeyring=0
copymirrorlist=1
pacman_args=()
pacmode=-Sy
setup=chroot_setup
unshare=0
@ -29,6 +30,7 @@ usage: ${0##*/} [options] root [packages...]
Options:
-C <config> Use an alternate config file for pacman
-c Use the package cache on the host, rather than the target
-D Skip pacman dependency checks
-G Avoid copying the host's pacman keyring to the target
-i Prompt for package confirmation when needed (run interactively)
-K Initialize an empty pacman keyring in the target (implies '-G')
@ -50,11 +52,14 @@ if [[ -z $1 || $1 = @(-h|--help) ]]; then
exit $(( $# ? 0 : 1 ))
fi
while getopts ':C:cGiKMNPU' flag; do
while getopts ':C:cDGiKMNPU' flag; do
case $flag in
C)
pacman_config=$OPTARG
;;
D)
pacman_args+=(-dd)
;;
c)
hostcache=1
;;
@ -92,7 +97,7 @@ shift $(( OPTIND - 1 ))
(( $# )) || die "No root directory specified"
newroot=$1; shift
pacman_args=("${@:-base}" --config="$pacman_config")
pacman_args+=("$pacmode" "${@:-base}" --config="$pacman_config")
if (( ! hostcache )); then
pacman_args+=(--cachedir="$newroot/var/cache/pacman/pkg")
@ -126,7 +131,7 @@ pacstrap() {
fi
msg 'Installing packages to %s' "$newroot"
if ! $pid_unshare pacman -r "$newroot" $pacmode "${pacman_args[@]}"; then
if ! $pid_unshare pacman -r "$newroot" "${pacman_args[@]}"; then
die 'Failed to install packages to new root'
fi