mkarchroot, arch-nspawn: Add an `-f` flag to add files to copy.
This allows us to copy in files like `qemu-arm-static`, which is necessary for running an ARM chroot on an x86 box.
This commit is contained in:
parent
35da846dde
commit
82e6bfcd7a
|
@ -15,6 +15,8 @@ m4_include(lib/archroot.sh)
|
||||||
|
|
||||||
working_dir=''
|
working_dir=''
|
||||||
|
|
||||||
|
files=()
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
|
echo "Usage: ${0##*/} [options] working-dir [systemd-nspawn arguments]"
|
||||||
echo "A wrapper around systemd-nspawn. Provides support for pacman."
|
echo "A wrapper around systemd-nspawn. Provides support for pacman."
|
||||||
|
@ -23,15 +25,17 @@ usage() {
|
||||||
echo ' -C <file> Location of a pacman config file'
|
echo ' -C <file> Location of a pacman config file'
|
||||||
echo ' -M <file> Location of a makepkg config file'
|
echo ' -M <file> Location of a makepkg config file'
|
||||||
echo ' -c <dir> Set pacman cache'
|
echo ' -c <dir> Set pacman cache'
|
||||||
|
echo ' -f <file> Copy file from the host to the chroot'
|
||||||
echo ' -h This message'
|
echo ' -h This message'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'hC:M:c:' arg; do
|
while getopts 'hC:M:c:f:' arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
C) pac_conf="$OPTARG" ;;
|
C) pac_conf="$OPTARG" ;;
|
||||||
M) makepkg_conf="$OPTARG" ;;
|
M) makepkg_conf="$OPTARG" ;;
|
||||||
c) cache_dir="$OPTARG" ;;
|
c) cache_dir="$OPTARG" ;;
|
||||||
|
f) files+=("$OPTARG") ;;
|
||||||
h|?) usage ;;
|
h|?) usage ;;
|
||||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||||
esac
|
esac
|
||||||
|
@ -77,6 +81,12 @@ copy_hostconf () {
|
||||||
[[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf"
|
[[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf"
|
||||||
[[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf"
|
[[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf"
|
||||||
|
|
||||||
|
local file
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
mkdir -p "$(dirname "$working_dir$file")"
|
||||||
|
cp -T "$file" "$working_dir$file"
|
||||||
|
done
|
||||||
|
|
||||||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf"
|
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
|
@ -15,21 +15,25 @@ m4_include(lib/archroot.sh)
|
||||||
|
|
||||||
working_dir=''
|
working_dir=''
|
||||||
|
|
||||||
|
files=()
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
echo "Usage: ${0##*/} [options] working-dir package-list..."
|
||||||
echo ' options:'
|
echo ' options:'
|
||||||
echo ' -C <file> Location of a pacman config file'
|
echo ' -C <file> Location of a pacman config file'
|
||||||
echo ' -M <file> Location of a makepkg config file'
|
echo ' -M <file> Location of a makepkg config file'
|
||||||
echo ' -c <dir> Set pacman cache'
|
echo ' -c <dir> Set pacman cache'
|
||||||
|
echo ' -f <file> Copy file from the host to the chroot'
|
||||||
echo ' -h This message'
|
echo ' -h This message'
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'hC:M:c:' arg; do
|
while getopts 'hC:M:c:f:' arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
C) pac_conf="$OPTARG" ;;
|
C) pac_conf="$OPTARG" ;;
|
||||||
M) makepkg_conf="$OPTARG" ;;
|
M) makepkg_conf="$OPTARG" ;;
|
||||||
c) cache_dir="$OPTARG" ;;
|
c) cache_dir="$OPTARG" ;;
|
||||||
|
f) files+=("$OPTARG") ;;
|
||||||
h|?) usage ;;
|
h|?) usage ;;
|
||||||
*) error "invalid argument '%s'" "$arg"; usage ;;
|
*) error "invalid argument '%s'" "$arg"; usage ;;
|
||||||
esac
|
esac
|
||||||
|
@ -67,6 +71,11 @@ if is_btrfs "$working_dir"; then
|
||||||
chmod 0755 "$working_dir"
|
chmod 0755 "$working_dir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for file in "${files[@]}"; do
|
||||||
|
mkdir -p "$(dirname "$working_dir$file")"
|
||||||
|
cp "$file" "$working_dir$file"
|
||||||
|
done
|
||||||
|
|
||||||
pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
|
pacstrap -GMcd ${pac_conf:+-C "$pac_conf"} "$working_dir" \
|
||||||
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
"${cache_dirs[@]/#/--cachedir=}" "$@" || die 'Failed to install all packages'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue