Merge commit 'refs/pull/23/head' of github.com:archlinux/arch-install-scripts

This commit is contained in:
Morten Linderud 2022-08-28 14:57:23 +02:00
commit e6dd0455db
No known key found for this signature in database
GPG Key ID: 9C02FF419FECBE16
3 changed files with 15 additions and 5 deletions

View File

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

View File

@ -34,6 +34,9 @@ Options
*-i*:: *-i*::
Prompt for package confirmation when needed (run interactively). Prompt for package confirmation when needed (run interactively).
*-K*::
Initialize an empty pacman keyring in the target (implies '-G').
*-M*:: *-M*::
Avoid copying the host's mirrorlist to the target. Avoid copying the host's mirrorlist to the target.

View File

@ -14,6 +14,7 @@ m4_include(common)
hostcache=0 hostcache=0
copykeyring=1 copykeyring=1
initkeyring=0
copymirrorlist=1 copymirrorlist=1
pacmode=-Sy pacmode=-Sy
setup=chroot_setup setup=chroot_setup
@ -28,6 +29,7 @@ usage: ${0##*/} [options] root [packages...]
-c Use the package cache on the host, rather than the target -c Use the package cache on the host, rather than the target
-G Avoid copying the host's pacman keyring to the target -G Avoid copying the host's pacman keyring to the target
-i Prompt for package confirmation when needed (run interactively) -i Prompt for package confirmation when needed (run interactively)
-K Initialize an empty pacman keyring in the target (implies '-G')
-M Avoid copying the host's mirrorlist to the target -M Avoid copying the host's mirrorlist to the target
-N Run in unshare mode as a regular user -N Run in unshare mode as a regular user
-U Use pacman -U to install packages -U Use pacman -U to install packages
@ -45,7 +47,7 @@ if [[ -z $1 || $1 = @(-h|--help) ]]; then
exit $(( $# ? 0 : 1 )) exit $(( $# ? 0 : 1 ))
fi fi
while getopts ':C:cdGiMNU' flag; do while getopts ':C:cdGiKMNU' flag; do
case $flag in case $flag in
C) C)
pacman_config=$OPTARG pacman_config=$OPTARG
@ -62,6 +64,9 @@ while getopts ':C:cdGiMNU' flag; do
G) G)
copykeyring=0 copykeyring=0
;; ;;
K)
initkeyring=1
;;
M) M)
copymirrorlist=0 copymirrorlist=0
;; ;;
@ -112,9 +117,11 @@ pacstrap() {
# mount API filesystems # mount API filesystems
$setup "$newroot" || die "failed to setup chroot %s" "$newroot" $setup "$newroot" || die "failed to setup chroot %s" "$newroot"
if (( copykeyring )); then if [[ ! -d $newroot/etc/pacman.d/gnupg ]]; then
# if there's a keyring on the host, copy it into the new root, unless it exists already if (( initkeyring )); then
if [[ -d /etc/pacman.d/gnupg && ! -d $newroot/etc/pacman.d/gnupg ]]; then pacman-key --gpgdir "$newroot"/etc/pacman.d/gnupg --init
elif (( copykeyring )) && [[ -d /etc/pacman.d/gnupg ]]; then
# if there's a keyring on the host, copy it into the new root
cp -a --no-preserve=ownership /etc/pacman.d/gnupg "$newroot/etc/pacman.d/" cp -a --no-preserve=ownership /etc/pacman.d/gnupg "$newroot/etc/pacman.d/"
fi fi
fi fi