bash getopts stops parsing options at the first non-option argument.
Rather than import some overblown option parser such as the one used in
makepkg or mkinitcpio, just correct the usage.
FS#31862.
I grappled with the inability of pacstrap to do this while trying to
setup an i686 chroot for myself based on a pacman config from devtools,
rather than my own config which bombs on a "missing" multilib repo.
By default chroot uses SHELL as default shell on the target if not specified otherwise.
As our install iso uses zsh this might fail if zsh is not installed on the target.
[dave: changed shell to /bin/sh]
chroot(1) will default to ${SHELL:-/bin/sh} which might not work, given
SHELL being /bin/zsh instead. Immediately default to /bin/sh, which will
exist in any sane chroot.
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 mainly fixes the case where there's devices mounted under the
chroot directory. Creating a bind mount on top of this will obscure
these other mounts.
However, add a '-c' switch to use the host cache instead. The default is
useful for when installing a system from an install media (which has
possibly constrained storage), but the '-c' switch is useful when
e.g. creating build-chroots.
I considered doing this the other way around ('-c' being the default).
However, I think it makes sense to default to the expected behavior for
install both because a new user is less likely to know that they need to
add a switch, and because the errormessage they'd get when they run out
of space/memory is nonsensical and would cause lots of annoying
questions.
[dave: use proper array addition, nuke readlink, use arithmetic flag]
Signed-off-by: Tom Gundersen <teg@jklm.no>
This would overwrite an existing mirrorlist, but the one at the host
is known to be good at this point, so the loss is minimal.
Signed-off-by: Tom Gundersen <teg@jklm.no>
We want to be able to call pacstrap with the target being an existing
install (in case it has been severely broken), and hence we might want
to preserve the existing keyring.
Signed-off-by: Tom Gundersen <teg@jklm.no>
the api_mount function could, for some bizzare reason, fail midway
through, leaving the user with a half mounted chroot. set the trap
before the function instead, but mask errors since we might see "foo
not mounted" errors.