Merge branch 'preinstalled' of git+ssh://git.launchpad.net/~xnox/livecd-rootfs into ubuntu/master

delete-obsolete-ubuntu-core
Dimitri John Ledkov 4 years ago
commit 20f76e7cf8
No known key found for this signature in database
GPG Key ID: 9B8EC849D5EF70ED

@ -295,6 +295,19 @@ if [ -z "${IMAGEFORMAT:-}" ]; then
esac esac
fi fi
# Configure preinstalled ubuntu-cpc images with included password
# one also must request disk1-img-xz image format
if [ "$IMAGEFORMAT" = "ext4" ] && [ "$PROJECT" = "ubuntu-cpc" ]; then
case $ARCH:$SUBARCH in
armhf:raspi2|riscv64:sifive_*|*:generic)
IMAGE_HAS_HARDCODED_PASSWORD=1
if [ -z "${IMAGE_TARGETS:-}" ]; then
export IMAGE_TARGETS="disk1-img-xz"
fi
;;
esac
fi
skip_lb_stage() { skip_lb_stage() {
STAGE="$1" STAGE="$1"
mkdir -p .build mkdir -p .build
@ -825,6 +838,14 @@ case $PROJECT in
;; ;;
arm64) arm64)
add_package install flash-kernel add_package install flash-kernel
if [ "${SUBARCH:-}" = "generic" ]; then
KERNEL_FLAVOURS=generic
fi
;;
amd64)
if [ "${SUBARCH:-}" = "generic" ]; then
KERNEL_FLAVOURS=generic
fi
;; ;;
riscv64) riscv64)
if [ -n "$SUBARCH" ]; then if [ -n "$SUBARCH" ]; then
@ -1032,6 +1053,13 @@ echo "BUILDSTAMP=\"$NOW\"" >> config/binary
echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary
echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/binary echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/binary
if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" = "1" ]; then
echo IMAGE_HAS_HARDCODED_PASSWORD=1 >> config/binary
if [ -n "${IMAGE_TARGETS:-}" ]; then
echo "IMAGE_TARGETS=\"${IMAGE_TARGETS:-}\"" >> config/binary
fi
fi
case $PROJECT in case $PROJECT in
ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci|base) ubuntu-cpc|ubuntu-core|ubuntu-base|ubuntu-oci|base)
# ubuntu-cpc gets this added in 025-create-groups.chroot, and we do # ubuntu-cpc gets this added in 025-create-groups.chroot, and we do

@ -1060,6 +1060,42 @@ END
umount ${mountpoint} umount ${mountpoint}
} }
setup_cinocloud() {
if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" != "1" ] || [ "${IMAGE_TARGETS:-}" != "disk1-img-xz" ]; then
echo "unexpected attempt to add a hardcoded password to an image"
exit 1
fi
local mountpoint=$1
mkdir -p $mountpoint/var/lib/cloud/seed/nocloud-net
cat <<EOF >$mountpoint/var/lib/cloud/seed/nocloud-net/meta-data
instance-id: iid-$(openssl rand -hex 8)
EOF
cat <<EOF >$mountpoint/var/lib/cloud/seed/nocloud-net/user-data
#cloud-config
chpasswd:
expire: True
list:
- ubuntu:ubuntu
ssh_pwauth: True
EOF
cat <<EOF >$mountpoint/var/lib/cloud/seed/nocloud-net/network-config
# This is the initial network config.
# It can be overwritten by cloud-init.
version: 2
ethernets:
zz-all-en:
match:
name: "en*"
dhcp4: true
optional: true
zz-all-eth:
match:
name: "eth*"
dhcp4: true
optional: true
EOF
}
replace_kernel () { replace_kernel () {
mountpoint=$1 mountpoint=$1
new_kernel=$2 new_kernel=$2

@ -21,8 +21,11 @@ case ${PROJECT:-} in
;; ;;
esac esac
if [ "$ARCH" = "riscv64" ] && [ -n "${SUBARCH:-}" ]; then # Change image size for preinstalled generic images & all preinstalled riscv64 images
IMAGE_SIZE=3758096384 # bump to 3.5G (3584*1024**2), due to linux-generic instead of virtual if [ -n "${SUBARCH:-}" ]; then
if [ "${SUBARCH:-}" = "generic" ] || [ "$ARCH" = "riscv64" ]; then
IMAGE_SIZE=3758096384 # bump to 3.5G (3584*1024**2), due to linux-generic instead of virtual
fi
fi fi
. config/binary . config/binary
@ -34,10 +37,20 @@ create_partitions() {
sgdisk "${disk_image}" --zap-all sgdisk "${disk_image}" --zap-all
case $ARCH in case $ARCH in
arm64|armhf) arm64|armhf)
sgdisk "${disk_image}" \ if [ "${SUBARCH:-}" = "generic" ]; then
--new=15:0:204800 \ sgdisk "${disk_image}" \
--typecode=15:ef00 \ --new=15:0:204800 \
--new=1: --typecode=15:ef00 \
--attributes=15:set:2 \
--new=14::+4M \
--change-name=14:CIDATA \
--new=1:
else
sgdisk "${disk_image}" \
--new=15:0:204800 \
--typecode=15:ef00 \
--new=1:
fi
;; ;;
riscv64) riscv64)
# same as arm64/armhf, but set bit 2 legacy bios bootable # same as arm64/armhf, but set bit 2 legacy bios bootable
@ -72,13 +85,25 @@ create_partitions() {
fi fi
;; ;;
amd64) amd64)
sgdisk "${disk_image}" \ if [ "${SUBARCH:-}" = "generic" ]; then
--new=14::+4M \ sgdisk "${disk_image}" \
--new=15::+106M \ --new=14::+4M \
--new=1:: --typecode=14:ef02 \
sgdisk "${disk_image}" \ --attributes=14:set:2 \
-t 14:ef02 \ --new=15::+106M \
-t 15:ef00 --typecode=15:ef00 \
--new=13::+4M \
--change-name=13:CIDATA \
--new=1::
else
sgdisk "${disk_image}" \
--new=14::+4M \
--new=15::+106M \
--new=1::
sgdisk "${disk_image}" \
-t 14:ef02 \
-t 15:ef00
fi
;; ;;
esac esac
sgdisk "${disk_image}" \ sgdisk "${disk_image}" \
@ -119,14 +144,38 @@ install_grub() {
arm64) arm64)
chroot mountpoint apt-get -qqy install --no-install-recommends shim-signed grub-efi-arm64-signed chroot mountpoint apt-get -qqy install --no-install-recommends shim-signed grub-efi-arm64-signed
efi_target=arm64-efi efi_target=arm64-efi
if [ "${SUBARCH:-}" = "generic" ]; then
# Server preinstalled image
# Setup cidata sample data & nocloud fallback
# Allows login on first boot with or without metadata
cidata_dev="/dev/mapper${loop_device///dev/}p14"
setup_cidata "${cidata_dev}"
setup_cinocloud mountpoint
fi
;; ;;
armhf) armhf)
chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm grub-efi-arm-bin chroot mountpoint apt-get -qqy install --no-install-recommends grub-efi-arm grub-efi-arm-bin
efi_target=arm-efi efi_target=arm-efi
if [ "${SUBARCH:-}" = "generic" ]; then
# Server preinstalled image
# Setup cidata sample data & nocloud fallback
# Allows login on first boot with or without metadata
cidata_dev="/dev/mapper${loop_device///dev/}p14"
setup_cidata "${cidata_dev}"
setup_cinocloud mountpoint
fi
;; ;;
amd64) amd64)
chroot mountpoint apt-get install -qqy grub-pc shim-signed chroot mountpoint apt-get install -qqy grub-pc shim-signed
efi_target=x86_64-efi efi_target=x86_64-efi
if [ "${SUBARCH:-}" = "generic" ]; then
# Server preinstalled image
# Setup cidata sample data & nocloud fallback
# Allows login on first boot with or without metadata
cidata_dev="/dev/mapper${loop_device///dev/}p13"
setup_cidata "${cidata_dev}"
setup_cinocloud mountpoint
fi
;; ;;
riscv64) riscv64)
# TODO grub-efi-riscv64 does not exist yet on riscv64 # TODO grub-efi-riscv64 does not exist yet on riscv64
@ -153,34 +202,7 @@ install_grub() {
# Provide stock nocloud datasource # Provide stock nocloud datasource
# Allow interactive login on baremetal SiFive board, # Allow interactive login on baremetal SiFive board,
# without a cloud datasource. # without a cloud datasource.
mkdir -p mountpoint/var/lib/cloud/seed/nocloud-net setup_cinocloud mountpoint
cat <<EOF >mountpoint/var/lib/cloud/seed/nocloud-net/meta-data
instance-id: iid-$(openssl rand -hex 8)
EOF
cat <<EOF >mountpoint/var/lib/cloud/seed/nocloud-net/user-data
#cloud-config
chpasswd:
expire: True
list:
- ubuntu:ubuntu
ssh_pwauth: True
EOF
cat <<EOF >mountpoint/var/lib/cloud/seed/nocloud-net/network-config
# This is the initial network config.
# It can be overwritten by cloud-init.
version: 2
ethernets:
zz-all-en:
match:
name: "en*"
dhcp4: true
optional: true
zz-all-eth:
match:
name: "eth*"
dhcp4: true
optional: true
EOF
fi fi
## TODO remove below once we have grub-efi-riscv64 ## TODO remove below once we have grub-efi-riscv64
rm mountpoint/tmp/device.map rm mountpoint/tmp/device.map

@ -31,6 +31,10 @@ case $ARCH:$SUBARCH in
echo "We only create EFI images for $ARCH." echo "We only create EFI images for $ARCH."
exit 0 exit 0
;; ;;
amd64:generic)
echo "We only create EFI images for $SUBARCH."
exit 0
;;
*) *)
;; ;;
esac esac

@ -0,0 +1,17 @@
#!/bin/bash -ex
. config/functions
. config/binary
if [ "${IMAGE_HAS_HARDCODED_PASSWORD:-}" != "1" ]; then
echo ".disk1.img.xz preinstalled image requested to be built"
echo "but the build is not generated with hardcoded password"
echo "the build is missconfigured"
exit 1
fi
if [ -f binary/boot/disk-uefi.ext4 ]; then
xz -T4 -c binary/boot/disk-uefi.ext4 > livecd.ubuntu-cpc.disk1.img.xz
elif [ -f binary/boot/disk.ext4 ]; then
xz -T4 -c binary/boot/disk.ext4 > livecd.ubuntu-cpc.disk1.img.xz
fi

@ -1,18 +1,5 @@
#!/bin/bash -ex #!/bin/bash -ex
case $ARCH:$SUBARCH in
# Not sure if any other cloud images use subarch for something that
# should take qcow2 format, so only skipping this on raspi2 for now.
armhf:raspi2)
xz -T4 -c binary/boot/disk.ext4 > livecd.ubuntu-cpc.disk1.img.xz
exit 0
;;
riscv64:hifive|riscv64:sifive_*)
xz -T4 -c binary/boot/disk-uefi.ext4 > livecd.ubuntu-cpc.disk1.img.xz
exit 0
;;
esac
. config/functions . config/functions
if [ -f binary/boot/disk-uefi.ext4 ]; then if [ -f binary/boot/disk-uefi.ext4 ]; then

@ -0,0 +1,3 @@
depends disk-image
base/disk1-img-xz.binary
provides livecd.ubuntu-cpc.disk1.img.xz
Loading…
Cancel
Save