|
|
|
@ -4,6 +4,8 @@
|
|
|
|
|
imagesize=${IMAGE_SIZE:-2361393152}
|
|
|
|
|
fs_label="${FS_LABEL:-rootfs}"
|
|
|
|
|
|
|
|
|
|
AUTOMATION_HEADER="# Automatically generated by installer build process"
|
|
|
|
|
|
|
|
|
|
rootfs_dev_mapper=
|
|
|
|
|
loop_device=
|
|
|
|
|
loop_raw=
|
|
|
|
@ -45,7 +47,7 @@ create_manifest() {
|
|
|
|
|
if [ "$PROJECT" = ubuntu-cpc ]; then
|
|
|
|
|
echo "create_manifest creating file listing."
|
|
|
|
|
local target_filelist=${2%.manifest}.filelist
|
|
|
|
|
(cd "${chroot_root}" && find -xdev) > "${target_filelist}"
|
|
|
|
|
(cd "${chroot_root}" && find -xdev) | sort > "${target_filelist}"
|
|
|
|
|
fi
|
|
|
|
|
echo "create_manifest finished"
|
|
|
|
|
}
|
|
|
|
@ -60,6 +62,7 @@ mount_image() {
|
|
|
|
|
trap clean_loops EXIT
|
|
|
|
|
backing_img="$1"
|
|
|
|
|
local rootpart="$2"
|
|
|
|
|
|
|
|
|
|
loop_device=$(losetup --show -f -P -v ${backing_img})
|
|
|
|
|
|
|
|
|
|
if [ ! -b ${loop_device} ]; then
|
|
|
|
@ -98,15 +101,27 @@ use_lp_archives_in_sourceslist(){
|
|
|
|
|
# recover_sourceslist
|
|
|
|
|
|
|
|
|
|
mountpoint="${1}"
|
|
|
|
|
MOUNTPOINT_BACKUP_SOURCES_LIST="sources.list.tmp"
|
|
|
|
|
. config/bootstrap # For the LB_MIRROR_* variables
|
|
|
|
|
cp -a "${mountpoint}/etc/apt/sources.list" "${MOUNTPOINT_BACKUP_SOURCES_LIST}"
|
|
|
|
|
sed -i "s#http://archive.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
sed -i "s#http://security.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
|
|
|
|
|
sha256sum "${mountpoint}/etc/apt/sources.list" > sources.list.sha
|
|
|
|
|
if [ -e "${mountpoint}/etc/apt/sources.list.d/ubuntu.sources" ]; then
|
|
|
|
|
MOUNTPOINT_BACKUP_UBUNTU_SOURCES="ubuntu.sources.tmp"
|
|
|
|
|
cp -a "${mountpoint}/etc/apt/sources.list.d/ubuntu.sources" "${MOUNTPOINT_BACKUP_UBUNTU_SOURCES}"
|
|
|
|
|
sed -i "s#http://archive.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list.d/ubuntu.sources"
|
|
|
|
|
sed -i "s#http://security.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list.d/ubuntu.sources"
|
|
|
|
|
|
|
|
|
|
sha256sum "${mountpoint}/etc/apt/sources.list.d/ubuntu.sources" > ubuntu.sources.sha
|
|
|
|
|
fi
|
|
|
|
|
if [ -e "${mountpoint}/etc/apt/sources.list" ]; then
|
|
|
|
|
MOUNTPOINT_BACKUP_SOURCES_LIST="sources.list.tmp"
|
|
|
|
|
cp -a "${mountpoint}/etc/apt/sources.list" "${MOUNTPOINT_BACKUP_SOURCES_LIST}"
|
|
|
|
|
sed -i "s#http://archive.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
sed -i "s#http://security.ubuntu.com/ubuntu#${LB_PARENT_MIRROR_CHROOT}#g" \
|
|
|
|
|
"${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
|
|
|
|
|
sha256sum "${mountpoint}/etc/apt/sources.list" > sources.list.sha
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
recover_sourceslist(){
|
|
|
|
@ -118,10 +133,18 @@ recover_sourceslist(){
|
|
|
|
|
# sources.list.sha
|
|
|
|
|
|
|
|
|
|
mountpoint="${1}"
|
|
|
|
|
sha256sum --check sources.list.sha
|
|
|
|
|
if [ -e "${MOUNTPOINT_BACKUP_UBUNTU_SOURCES:-/doesnotexist}" ]; then
|
|
|
|
|
sha256sum --check ubuntu.sources.sha
|
|
|
|
|
|
|
|
|
|
mv "${MOUNTPOINT_BACKUP_SOURCES_LIST}" "${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
unset MOUNTPOINT_BACKUP_SOURCES_LIST
|
|
|
|
|
mv "${MOUNTPOINT_BACKUP_UBUNTU_SOURCES}" "${mountpoint}/etc/apt/sources.list.d/ubuntu.sources"
|
|
|
|
|
unset MOUNTPOINT_BACKUP_UBUNTU_SOURCES
|
|
|
|
|
fi
|
|
|
|
|
if [ -e "${MOUNTPOINT_BACKUP_SOURCES_LIST:-/doesnotexist}" ]; then
|
|
|
|
|
sha256sum --check sources.list.sha
|
|
|
|
|
|
|
|
|
|
mv "${MOUNTPOINT_BACKUP_SOURCES_LIST}" "${mountpoint}/etc/apt/sources.list"
|
|
|
|
|
unset MOUNTPOINT_BACKUP_SOURCES_LIST
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setup_mountpoint() {
|
|
|
|
@ -132,7 +155,8 @@ setup_mountpoint() {
|
|
|
|
|
chown root:kmem /dev/mem
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
mount --rbind /dev "$mountpoint/dev"
|
|
|
|
|
mount dev-live -t devtmpfs "$mountpoint/dev"
|
|
|
|
|
mount devpts-live -t devpts -o nodev,nosuid "$mountpoint/dev/pts"
|
|
|
|
|
mount proc-live -t proc "$mountpoint/proc"
|
|
|
|
|
mount sysfs-live -t sysfs "$mountpoint/sys"
|
|
|
|
|
mount securityfs -t securityfs "$mountpoint/sys/kernel/security"
|
|
|
|
@ -209,18 +233,24 @@ get_lowerdirs_for_pass () {
|
|
|
|
|
mount_disk_image() {
|
|
|
|
|
local disk_image=${1}
|
|
|
|
|
local mountpoint=${2}
|
|
|
|
|
mount_image ${disk_image} 1
|
|
|
|
|
local rootpart=${3:-1}
|
|
|
|
|
mount_image ${disk_image} "${rootpart}"
|
|
|
|
|
mount_partition "${rootfs_dev_mapper}" $mountpoint
|
|
|
|
|
|
|
|
|
|
local uefi_dev="${loop_device}p15"
|
|
|
|
|
local boot_dev="${loop_device}p16"
|
|
|
|
|
if flock -x ${loop_device} \
|
|
|
|
|
[ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
|
|
|
|
|
flock -x ${loop_device} mount "${uefi_dev}" $mountpoint/boot/efi
|
|
|
|
|
[ -b ${boot_dev} -a -e $mountpoint/boot ]; then
|
|
|
|
|
flock -x ${loop_device} mount "${boot_dev}" $mountpoint/boot
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Having one partition mounted should avoid udev-triggered partition
|
|
|
|
|
# rescans on that device, so we no longer need to flock.
|
|
|
|
|
|
|
|
|
|
local uefi_dev="${loop_device}p15"
|
|
|
|
|
if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
|
|
|
|
|
mount "${uefi_dev}" $mountpoint/boot/efi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# This is needed to allow for certain operations
|
|
|
|
|
# such as updating grub and installing software
|
|
|
|
|
cat > $mountpoint/usr/sbin/policy-rc.d << EOF
|
|
|
|
@ -375,7 +405,7 @@ create_derivative() {
|
|
|
|
|
convert_to_qcow2() {
|
|
|
|
|
src="$1"
|
|
|
|
|
destination="$2"
|
|
|
|
|
qemu-img convert -c -O qcow2 -o compat=0.10 "$src" "$destination"
|
|
|
|
|
qemu-img convert -c -O qcow2 "$src" "$destination"
|
|
|
|
|
qemu-img info "$destination"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -717,6 +747,12 @@ snap_preseed() {
|
|
|
|
|
SNAP=${SNAP%=*}
|
|
|
|
|
# strip /classic confinement
|
|
|
|
|
local SNAP_NAME=${SNAP%/*}
|
|
|
|
|
|
|
|
|
|
# For snap preseed to work, we need to ensure that fuse3 is installed in the chroot.
|
|
|
|
|
# fuse3 is a recommends of snapd but if this is a minimized image then recommends are not installed
|
|
|
|
|
# and preseeding will fail.
|
|
|
|
|
chroot "${CHROOT_ROOT}" apt-get install --assume-yes --no-install-recommends fuse3
|
|
|
|
|
|
|
|
|
|
# Seed from the specified channel (e.g. core18 latest/stable)
|
|
|
|
|
# Or Channel endcoded in the snap name (e.g. lxd=4.0/stable/ubuntu-20.04)
|
|
|
|
|
# Or Ubuntu policy default channel latest/stable/ubuntu-$(release_ver)
|
|
|
|
@ -805,56 +841,6 @@ snap_validate_seed() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snap_from_seed() {
|
|
|
|
|
local base_seed=$1
|
|
|
|
|
local out=$2
|
|
|
|
|
local all_snaps
|
|
|
|
|
local seeds_expanded
|
|
|
|
|
|
|
|
|
|
seeds_expanded=$(inheritance ${base_seed})
|
|
|
|
|
for seed in ${seeds_expanded}; do
|
|
|
|
|
echo "snap: considering ${seed}"
|
|
|
|
|
file=config/germinate-output/${seed}.snaps
|
|
|
|
|
[ -e "${file}" ] || continue
|
|
|
|
|
# extract the first column (snap package name) from germinate's output
|
|
|
|
|
# translate the human-readable "foo (classic)" into a
|
|
|
|
|
# more machine readable "foo/classic"
|
|
|
|
|
seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
|
|
|
|
|
for snap in ${seed_snaps}; do
|
|
|
|
|
echo "snap: found ${snap}"
|
|
|
|
|
all_snaps="${all_snaps:+${all_snaps} }${snap}"
|
|
|
|
|
done
|
|
|
|
|
done
|
|
|
|
|
if [ -n "${all_snaps}" ]; then
|
|
|
|
|
echo "${all_snaps}" > $out
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
seed_from_task ()
|
|
|
|
|
{
|
|
|
|
|
# Retrieve the name of the seed from a task name
|
|
|
|
|
local task=$1
|
|
|
|
|
local seed
|
|
|
|
|
local seedfile
|
|
|
|
|
local seedfiles
|
|
|
|
|
|
|
|
|
|
seedfile="$(grep -lE "^Task-Key: +${task}\$" config/germinate-output/*seedtext|head -1)"
|
|
|
|
|
if [ -n "$seedfile" ]; then
|
|
|
|
|
basename $seedfile .seedtext
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
seedfiles="$(grep -lE "^Task-Per-Derivative: *1\$" config/germinate-output/*seedtext)"
|
|
|
|
|
if [ -n "$seedfiles" ]; then
|
|
|
|
|
for seed in $(echo $seedfiles | xargs basename -s .seedtext); do
|
|
|
|
|
if [ ${PROJECT}-${seed} = $task ]; then
|
|
|
|
|
echo ${seed}
|
|
|
|
|
return
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
list_packages_from_seed () {
|
|
|
|
|
# Store all packages for a given seed, including its seed dependency
|
|
|
|
|
# $1: Name of the seed to expand to a package list
|
|
|
|
@ -906,48 +892,58 @@ configure_universe() {
|
|
|
|
|
# debian-installer's apt-setup:
|
|
|
|
|
|
|
|
|
|
cat > chroot/etc/apt/sources.list << EOF
|
|
|
|
|
# Ubuntu sources have moved to the /etc/apt/sources.list.d/ubuntu.sources
|
|
|
|
|
# file, which uses the deb822 format. Use deb822-formatted .sources files
|
|
|
|
|
# to manage package sources in the /etc/apt/sources.list.d/ directory.
|
|
|
|
|
# See the sources.list(5) manual page for details.
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat > chroot/etc/apt/sources.list.d/ubuntu.sources << EOF
|
|
|
|
|
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
|
|
|
|
|
# newer versions of the distribution.
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted
|
|
|
|
|
|
|
|
|
|
## Major bug fix updates produced after the final release of the
|
|
|
|
|
## distribution.
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
|
|
|
|
|
|
|
|
|
|
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
|
|
|
|
## team. Also, please note that software in universe WILL NOT receive any
|
|
|
|
|
## review or updates from the Ubuntu security team.
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
|
|
|
|
|
|
|
|
|
|
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
|
|
|
|
## team, and may not be under a free licence. Please satisfy yourself as to
|
|
|
|
|
## your rights to use the software. Also, please note that software in
|
|
|
|
|
## multiverse WILL NOT receive any review or updates from the Ubuntu
|
|
|
|
|
## security team.
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
|
|
|
|
|
|
|
|
|
|
## N.B. software from this repository may not have been tested as
|
|
|
|
|
## extensively as that contained in the main release, although it includes
|
|
|
|
|
## newer versions of some applications which may provide useful features.
|
|
|
|
|
## Also, please note that software in backports WILL NOT receive any review
|
|
|
|
|
## or updates from the Ubuntu security team.
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
|
|
|
|
|
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
|
|
|
|
|
deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
|
|
|
|
|
# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
|
|
|
|
|
|
|
|
|
|
## Ubuntu distribution repository
|
|
|
|
|
##
|
|
|
|
|
## The following settings can be adjusted to configure which packages to use from Ubuntu.
|
|
|
|
|
## Mirror your choices (except for URIs and Suites) in the security section below to
|
|
|
|
|
## ensure timely security updates.
|
|
|
|
|
##
|
|
|
|
|
## Types: Append deb-src to enable the fetching of source package.
|
|
|
|
|
## URIs: A URL to the repository (you may add multiple URLs)
|
|
|
|
|
## Suites: The following additional suites can be configured
|
|
|
|
|
## <name>-updates - Major bug fix updates produced after the final release of the
|
|
|
|
|
## distribution.
|
|
|
|
|
## <name>-backports - software from this repository may not have been tested as
|
|
|
|
|
## extensively as that contained in the main release, although it includes
|
|
|
|
|
## newer versions of some applications which may provide useful features.
|
|
|
|
|
## Also, please note that software in backports WILL NOT receive any review
|
|
|
|
|
## or updates from the Ubuntu security team.
|
|
|
|
|
## Components: Aside from main, the following components can be added to the list
|
|
|
|
|
## restricted - Software that may not be under a free license, or protected by patents.
|
|
|
|
|
## universe - Community maintained packages.
|
|
|
|
|
## Software from this repository is only maintained and supported by Canonical
|
|
|
|
|
## for machines with Ubuntu Pro subscriptions. Without Ubuntu Pro, the Ubuntu
|
|
|
|
|
## community provides best-effort security maintenance.
|
|
|
|
|
## multiverse - Community maintained of restricted. Software from this repository is
|
|
|
|
|
## ENTIRELY UNSUPPORTED by the Ubuntu team, and may not be under a free
|
|
|
|
|
## licence. Please satisfy yourself as to your rights to use the software.
|
|
|
|
|
## Also, please note that software in multiverse WILL NOT receive any
|
|
|
|
|
## review or updates from the Ubuntu security team.
|
|
|
|
|
##
|
|
|
|
|
## See the sources.list(5) manual page for further settings.
|
|
|
|
|
Types: deb
|
|
|
|
|
URIs: $LB_PARENT_MIRROR_BINARY
|
|
|
|
|
Suites: $LB_DISTRIBUTION $LB_DISTRIBUTION-updates $LB_DISTRIBUTION-backports
|
|
|
|
|
Components: main universe restricted multiverse
|
|
|
|
|
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
|
|
|
|
|
|
|
|
|
## Ubuntu security updates. Aside from URIs and Suites,
|
|
|
|
|
## this should mirror your choices in the previous section.
|
|
|
|
|
Types: deb
|
|
|
|
|
URIs: $LB_PARENT_MIRROR_BINARY_SECURITY
|
|
|
|
|
Suites: $LB_DISTRIBUTION-security
|
|
|
|
|
Components: main universe restricted multiverse
|
|
|
|
|
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
fi
|
|
|
|
@ -959,7 +955,6 @@ configure_oci() {
|
|
|
|
|
# at https://github.com/tianon/docker-brew-ubuntu-core/blob/master/update.sh
|
|
|
|
|
|
|
|
|
|
local chroot=$1
|
|
|
|
|
local serial=$2
|
|
|
|
|
|
|
|
|
|
if [ ! -d "${chroot}" ]; then
|
|
|
|
|
echo "The chroot does not exist"
|
|
|
|
@ -974,13 +969,6 @@ configure_oci() {
|
|
|
|
|
Chroot ${chroot} "chmod +x /usr/sbin/policy-rc.d"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Inject a build stamp into the image
|
|
|
|
|
mkdir -p ${chroot}/etc/cloud
|
|
|
|
|
cat > ${chroot}/etc/cloud/build.info << EOF
|
|
|
|
|
serial: $serial
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# https://github.com/docker/docker/blob/9a9fc01af8fb5d98b8eec0740716226fadb3735c/contrib/mkimage/debootstrap#L54-L56
|
|
|
|
|
Chroot ${chroot} "dpkg-divert --local --rename --add /sbin/initctl"
|
|
|
|
|
cp -a ${chroot}/usr/sbin/policy-rc.d ${chroot}/sbin/initctl
|
|
|
|
@ -1022,7 +1010,10 @@ EOF
|
|
|
|
|
mkdir -p ${chroot}/run/systemd
|
|
|
|
|
echo 'docker' > ${chroot}/run/systemd/container
|
|
|
|
|
|
|
|
|
|
# Create Ubuntu user
|
|
|
|
|
Chroot ${chroot} useradd ubuntu -U -u 1000 --comment Ubuntu --groups adm,audio,cdrom,dialout,dip,floppy,plugdev,sudo,video --shell /bin/bash -m
|
|
|
|
|
rm -rf ${chroot}/var/cache/apt/*.bin
|
|
|
|
|
|
|
|
|
|
echo "==== Configuring OCI done ===="
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1031,7 +1022,7 @@ configure_network_manager() {
|
|
|
|
|
# default. Installing NM on an existing system only manages wifi and wwan via
|
|
|
|
|
# /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf. When setting
|
|
|
|
|
# the global backend to NM, netplan overrides that file.
|
|
|
|
|
if [ -e chroot/usr/sbin/NetworkManager -a ! -f chroot/etc/netplan/01-network-manager-all.yaml ]; then
|
|
|
|
|
if [ -e chroot/usr/sbin/NetworkManager -a ! -f chroot/etc/netplan/01-network-manager-all.yaml -a "$SUBPROJECT" != "desktop-preinstalled" ]; then
|
|
|
|
|
echo "===== Enabling all devices in NetworkManager ===="
|
|
|
|
|
mkdir -p chroot/etc/netplan
|
|
|
|
|
cat <<EOF > chroot/etc/netplan/01-network-manager-all.yaml
|
|
|
|
@ -1040,6 +1031,74 @@ network:
|
|
|
|
|
version: 2
|
|
|
|
|
renderer: NetworkManager
|
|
|
|
|
EOF
|
|
|
|
|
# Do not limit cloud-init renderers to network-manager as suggested
|
|
|
|
|
# in LP: #1982855 because subiquity needs to render full networking
|
|
|
|
|
# in ephemeral boot time when autoinstall.network is provided.
|
|
|
|
|
# Neither subiquity nor netplan is aware of /etc/NetworkManager config
|
|
|
|
|
# artifacts emmitted by cloud-init. It's best if cloud-init reports
|
|
|
|
|
# network config directly to /etc/netplan with the configured netplan
|
|
|
|
|
# backend: NetworkManager per 01-network-manager-all.yaml above.
|
|
|
|
|
|
|
|
|
|
# cloud-init's default renderer discovery will prefer netplan.
|
|
|
|
|
# Any time subiquity needs to write and apply network config
|
|
|
|
|
# it disables all previous network config in /etc/netplan so
|
|
|
|
|
# any previous 50-cloud-init.yaml will be rendered inert.
|
|
|
|
|
|
|
|
|
|
# Position cloud-init.service After=NetworkManager.service.
|
|
|
|
|
# (LP: #2008952).
|
|
|
|
|
# We override the entire cloud-init.service definition because
|
|
|
|
|
# systemd drop-in files only allow adding Before/After constraints
|
|
|
|
|
# yet we are dropping the Before=sysinit.target from the upstream
|
|
|
|
|
# cloud-init.service.
|
|
|
|
|
# This override can be dropped when NetworkManager.service can run
|
|
|
|
|
# Before=sysinit.target when it drops strict dbus.service dependency.
|
|
|
|
|
cat <<EOF > chroot/lib/systemd/system/cloud-init.service
|
|
|
|
|
${AUTOMATION_HEADER}
|
|
|
|
|
# Based on cloud-init 23.1 for Desktop LiveCD
|
|
|
|
|
[Unit]
|
|
|
|
|
Description=Initial cloud-init job (metadata service crawler)
|
|
|
|
|
DefaultDependencies=no
|
|
|
|
|
Wants=cloud-init-local.service
|
|
|
|
|
Wants=sshd-keygen.service
|
|
|
|
|
Wants=sshd.service
|
|
|
|
|
After=cloud-init-local.service
|
|
|
|
|
After=systemd-networkd-wait-online.service
|
|
|
|
|
# Installer Added After=NetworkManager* ordering
|
|
|
|
|
After=NetworkManager.service
|
|
|
|
|
After=NetworkManager-wait-online.service
|
|
|
|
|
After=networking.service
|
|
|
|
|
Before=network-online.target
|
|
|
|
|
Before=sshd-keygen.service
|
|
|
|
|
Before=sshd.service
|
|
|
|
|
# Before=sysinit.target Installer removed to allow for NM dependency
|
|
|
|
|
Before=shutdown.target
|
|
|
|
|
Conflicts=shutdown.target
|
|
|
|
|
Before=systemd-user-sessions.service
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
Type=oneshot
|
|
|
|
|
ExecStart=/usr/bin/cloud-init init
|
|
|
|
|
RemainAfterExit=yes
|
|
|
|
|
TimeoutSec=0
|
|
|
|
|
|
|
|
|
|
# Output needs to appear in instance console output
|
|
|
|
|
StandardOutput=journal+console
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
WantedBy=cloud-init.target
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
# Allow cloud-init clean to inform of strict network-manager config
|
|
|
|
|
mkdir -p chroot/etc/cloud/clean.d
|
|
|
|
|
cat <<EOF > chroot/etc/cloud/clean.d/99-installer-use-networkmanager
|
|
|
|
|
#!/bin/sh
|
|
|
|
|
# Inform clone image creators about strict network-manager cfg for cloud-init
|
|
|
|
|
if [ -f /etc/cloud/cloud.cfg.d/99-installer-use-networkmanager.cfg ]; then
|
|
|
|
|
echo "WARNING: cloud-init network config is limited to using network-manager."
|
|
|
|
|
echo "If this is undesirable: rm /etc/cloud/cloud.cfg.d/99-installer-use-networkmanager.cfg"
|
|
|
|
|
fi
|
|
|
|
|
EOF
|
|
|
|
|
chmod +x chroot/etc/cloud/clean.d/99-installer-use-networkmanager
|
|
|
|
|
else
|
|
|
|
|
echo "==== NetworkManager not installed ===="
|
|
|
|
|
fi
|
|
|
|
@ -1125,7 +1184,7 @@ END
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setup_cinocloud() {
|
|
|
|
|
if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" != "1" ] || [ "${IMAGE_TARGETS:-}" != "disk1-img-xz" ]; then
|
|
|
|
|
if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" != "1" ] || ( [ "${IMAGE_TARGETS:-}" != "disk1-img-xz" ] && [ "${IMAGE_TARGETS:-}" != "disk-image-non-cloud" ] ); then
|
|
|
|
|
echo "unexpected attempt to add a hardcoded password to an image"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
@ -1223,3 +1282,15 @@ EOF
|
|
|
|
|
undivert_grub "${mountpoint}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# find all files under /var/lib/snapd in the target directory that aren't
|
|
|
|
|
# shipped by the snapd package itself, and remove them
|
|
|
|
|
reset_snapd_state() {
|
|
|
|
|
rootdir="$1"
|
|
|
|
|
|
|
|
|
|
/usr/lib/snapd/snap-preseed --reset $(realpath "$rootdir") || true
|
|
|
|
|
rm -rf "$rootdir/var/lib/snapd"
|
|
|
|
|
setup_mountpoint "$rootdir"
|
|
|
|
|
chroot "$rootdir" apt-get install --reinstall -y snapd
|
|
|
|
|
teardown_mountpoint "$rootdir"
|
|
|
|
|
}
|
|
|
|
|