enforce user-specified root directory
Remove the -r option, forcing the user to explicitly pass a root directory. This removes some confusion wherein we set defaults, but wouldn't allow all the defaults to be accepted. This also adds some mild documentation to the help output for genfstab and pacstrap.
This commit is contained in:
parent
de68d4cc02
commit
1d9c98c5ee
@ -6,7 +6,7 @@ m4_include(common)
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
usage: ${0##*/} <chroot-dir>
|
||||
usage: ${0##*/} chroot-dir
|
||||
|
||||
EOF
|
||||
}
|
||||
|
19
genfstab.in
19
genfstab.in
@ -39,14 +39,16 @@ root=/mnt
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
usage: ${0##*/} [options]
|
||||
usage: ${0##*/} root [options]
|
||||
|
||||
Options:
|
||||
-L Use labels for source identifiers
|
||||
-p Avoid printing pseudofs mounts
|
||||
-r root Generate based on 'root' (default: /mnt)
|
||||
-U Use UUIDs for source identifiers
|
||||
|
||||
genfstab generates output suitable for addition to an fstab file based on the
|
||||
devices mounted under the mountpoint specified by the given root.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -55,7 +57,7 @@ if [[ -z $1 || $1 = @(-h|--help) ]]; then
|
||||
exit $(( $# ? 0 : 1 ))
|
||||
fi
|
||||
|
||||
while getopts ':Lpr:U' flag; do
|
||||
while getopts ':LpU' flag; do
|
||||
case $flag in
|
||||
L)
|
||||
bylabel=1
|
||||
@ -66,10 +68,6 @@ while getopts ':Lpr:U' flag; do
|
||||
p)
|
||||
nopseudofs=1
|
||||
;;
|
||||
r)
|
||||
# trim trailing slashes
|
||||
root=${OPTARG%%+(/)}
|
||||
;;
|
||||
:)
|
||||
die '%s: option requires an argument -- '\''%s'\' "${0##*/}" "$OPTARG"
|
||||
;;
|
||||
@ -80,6 +78,13 @@ while getopts ':Lpr:U' flag; do
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
(( $# )) || die "No root directory specified"
|
||||
root=${1%%+(/)}; shift
|
||||
|
||||
if ! mountpoint -q "$root"; then
|
||||
die "$root is not a mountpoint"
|
||||
fi
|
||||
|
||||
if (( bylabel && byuuid )); then
|
||||
die "cannot specify both -U and -L"
|
||||
fi
|
||||
|
21
pacstrap.in
21
pacstrap.in
@ -17,12 +17,14 @@ hostcache=0
|
||||
|
||||
usage() {
|
||||
cat <<EOF
|
||||
usage: ${0##*/} [options]
|
||||
usage: ${0##*/} [options] root [packages...]
|
||||
|
||||
Options:
|
||||
-r root Install to 'root' (default: /mnt)
|
||||
-d Allow installation to a non-mountpoint directory
|
||||
-c Use the package cache on the host, rather than the target
|
||||
-d Allow installation to a non-mountpoint directory
|
||||
|
||||
pacstrap installs packages to the specified new root directory. If no packages
|
||||
are given, pacstrap defaults to the "base" group.
|
||||
|
||||
EOF
|
||||
}
|
||||
@ -34,14 +36,11 @@ fi
|
||||
|
||||
(( EUID == 0 )) || die 'This script must be run with root privileges'
|
||||
|
||||
while getopts ':cdr:' flag; do
|
||||
while getopts ':cd' flag; do
|
||||
case $flag in
|
||||
d)
|
||||
directory=1
|
||||
;;
|
||||
r)
|
||||
newroot=$OPTARG
|
||||
;;
|
||||
c)
|
||||
hostcache=1
|
||||
;;
|
||||
@ -55,11 +54,9 @@ while getopts ':cdr:' flag; do
|
||||
done
|
||||
shift $(( OPTIND - 1 ))
|
||||
|
||||
if (( $# )); then
|
||||
pacman_args=("$@")
|
||||
else
|
||||
pacman_args=('base' 'base-devel')
|
||||
fi
|
||||
(( $# )) || die "No root directory specified"
|
||||
newroot=$1; shift
|
||||
pacman_args=("${@:-base}")
|
||||
|
||||
if (( ! hostcache )); then
|
||||
pacman_args+=(--cachedir="$newroot/var/cache/pacman/pkg")
|
||||
|
Loading…
Reference in New Issue
Block a user