mirror of
git://github.com/lxc/lxc
synced 2025-08-31 10:19:37 +00:00
lxc-archlinux: support different architectures
Signed-off-by: John Lane <john@lane.uk.net> Acked-by: Stéphane Graber <stgraber@ubuntu.com>
This commit is contained in:
committed by
Stéphane Graber
parent
d8c77af0ae
commit
734d0bed55
26
templates/lxc-archlinux.in
Normal file → Executable file
26
templates/lxc-archlinux.in
Normal file → Executable file
@@ -166,10 +166,32 @@ EOF
|
||||
|
||||
# install packages within container chroot
|
||||
install_arch() {
|
||||
[ "${arch}" != "$(uname -m)" ] && different_arch=true
|
||||
|
||||
if [ "${different_arch}" = "true" ]; then
|
||||
container_pacman_config=$(mktemp)
|
||||
container_mirrorlist=$(mktemp)
|
||||
sed -e "s:Architecture =.*:Architecture = ${arch}:g" \
|
||||
-e "s:/etc/pacman.d/mirrorlist:${container_mirrorlist}:g" \
|
||||
"${pacman_config}" > "${container_pacman_config}"
|
||||
sed -e "s:\(x86_64\|\$arch\):${arch}:g" \
|
||||
/etc/pacman.d/mirrorlist > "${container_mirrorlist}"
|
||||
|
||||
pacman_config="${container_pacman_config}"
|
||||
fi
|
||||
|
||||
if ! pacstrap -dcC "${pacman_config}" "${rootfs_path}" ${base_packages[@]}; then
|
||||
echo "Failed to install container packages"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ "${different_arch}" = "true" ]; then
|
||||
sed -i -e "s:Architecture =.*:Architecture = ${arch}:g" \
|
||||
"${rootfs_path}"/etc/pacman.conf
|
||||
cp "${container_mirrorlist}" "${rootfs_path}"/etc/pacman.d/mirrorlist
|
||||
rm "${container_pacman_config}" "${container_mirrorlist}"
|
||||
fi
|
||||
|
||||
[ -d "${rootfs_path}/lib/modules" ] && ldconfig -r "${rootfs_path}"
|
||||
return 0
|
||||
}
|
||||
@@ -185,6 +207,7 @@ Optional args:
|
||||
-p,--path path to where the container rootfs will be created, defaults to ${default_path}/rootfs. The container config will go under ${default_path} in that case
|
||||
-P,--packages preinstall additional packages, comma-separated list
|
||||
-c,--config use specified pacman config when installing container packages
|
||||
-a,--arch use specified architecture instead of host's architecture
|
||||
-t,--network_type set container network interface type (${lxc_network_type})
|
||||
-l,--network_link set network link device (${lxc_network_link})
|
||||
-h,--help print this help
|
||||
@@ -192,7 +215,7 @@ EOF
|
||||
return 0
|
||||
}
|
||||
|
||||
options=$(getopt -o hp:P:n:c:l:t: -l help,rootfs:,path:,packages:,name:,config:,network_type:,network_link: -- "${@}")
|
||||
options=$(getopt -o hp:P:n:c:a:l:t: -l help,rootfs:,path:,packages:,name:,config:,arch:,network_type:,network_link: -- "${@}")
|
||||
if [ ${?} -ne 0 ]; then
|
||||
usage $(basename ${0})
|
||||
exit 1
|
||||
@@ -208,6 +231,7 @@ do
|
||||
--rootfs) rootfs_path=${2}; shift 2;;
|
||||
-P|--packages) additional_packages=${2}; shift 2;;
|
||||
-c|--config) pacman_config=${2}; shift 2;;
|
||||
-a|--arch) arch=${2}; shift 2;;
|
||||
-t|--network_type) lxc_network_type=${2}; shift 2;;
|
||||
-l|--network_link) lxc_network_link=${2}; shift 2;;
|
||||
--) shift 1; break ;;
|
||||
|
Reference in New Issue
Block a user