From 4d28b63ed8f777b9a760bb4fa51555e40e065d19 Mon Sep 17 00:00:00 2001 From: CloudBuilder Date: Mon, 25 Jan 2021 12:18:42 +0000 Subject: [PATCH] Imported 2.664.12 No reason for CPC update specified. --- debian/changelog | 7 ++ debian/control | 4 +- live-build/auto/config | 5 + live-build/cidata/meta-data.sample | 8 ++ live-build/cidata/network-config.sample | 52 ++++++++++ live-build/cidata/user-data.sample | 84 ++++++++++++++++ live-build/functions | 13 +++ live-build/make-lxd-metadata.py | 1 + .../hooks.d/base/disk-image-uefi.binary | 97 ++++++++++++++++++- .../ubuntu-cpc/hooks.d/base/disk-image.binary | 8 +- .../hooks.d/base/qcow2-image.binary | 4 + .../hooks.d/chroot/999-cpc-fixes.chroot | 4 +- 12 files changed, 278 insertions(+), 9 deletions(-) create mode 100644 live-build/cidata/meta-data.sample create mode 100644 live-build/cidata/network-config.sample create mode 100644 live-build/cidata/user-data.sample diff --git a/debian/changelog b/debian/changelog index 82c3163c..1f0a7ddf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.664.12) focal; urgency=medium + + * riscv64: backport HiFive unleashed & cloud-image building support + (LP: #1903034) + + -- Dimitri John Ledkov Fri, 15 Jan 2021 17:07:20 +0000 + livecd-rootfs (2.664.10) focal; urgency=medium * Do not hard-code the UC20 amd64 image size to 8GB as now ubuntu-image diff --git a/debian/control b/debian/control index 8025b061..2d50be95 100644 --- a/debian/control +++ b/debian/control @@ -32,9 +32,9 @@ Depends: ${misc:Depends}, python3-apt, python3-software-properties, python3-yaml, - qemu-utils [!i386 !riscv64], + qemu-utils [!i386], rsync, - snapd (>= 2.39) [!i386 !riscv64], + snapd (>= 2.39) [!i386], squashfs-tools (>= 1:3.3-1), sudo, u-boot-tools [armhf arm64], diff --git a/live-build/auto/config b/live-build/auto/config index c64d83ad..1a867311 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -819,6 +819,11 @@ case $PROJECT in arm64) add_package install flash-kernel ;; + riscv64) + if [ -n "$SUBARCH" ]; then + KERNEL_FLAVOURS=generic + fi + ;; esac OPTS="${OPTS:+$OPTS }--system=normal" OPTS="${OPTS:+$OPTS }--hdd-label=cloudimg-rootfs" diff --git a/live-build/cidata/meta-data.sample b/live-build/cidata/meta-data.sample new file mode 100644 index 00000000..11802477 --- /dev/null +++ b/live-build/cidata/meta-data.sample @@ -0,0 +1,8 @@ +# NB! This is a sample, copy to "meta-data" and modify to take effect +# NB! Also see user-data.sample and network-config.sample + +# This is the meta-data configuration file for cloud-init. Typically this just +# contains the instance_id. Please refer to the cloud-init documentation for +# more information: +# +# https://cloudinit.readthedocs.io/ diff --git a/live-build/cidata/network-config.sample b/live-build/cidata/network-config.sample new file mode 100644 index 00000000..13c172d8 --- /dev/null +++ b/live-build/cidata/network-config.sample @@ -0,0 +1,52 @@ +# NB! This is a sample, copy to "network-config" and mofiy to take effect +# NB! Also see user-data.sample and meta-data.sample + +# This file contains a netplan-compatible configuration which cloud-init will +# apply on first-boot (note: it will *not* update the config after the first +# boot). Please refer to the cloud-init documentation and the netplan reference +# for full details: +# +# https://cloudinit.readthedocs.io/en/latest/topics/network-config.html +# https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html +# https://netplan.io/reference +# +# Please note that the YAML format employed by this file is sensitive to +# differences in whitespace; if you are editing this file in an editor (like +# Notepad) which uses literal tabs, take care to only use spaces for +# indentation. See the following link for more details: +# +# https://en.wikipedia.org/wiki/YAML +# +# +# The image has stock nocloud-net configuration that will attemp dhcp +# v4 on all ethernet devices, similar to zz-all-en / zz-all-eth +# stanzas below. Hence this file is optional. +# +#version: 2 +#ethernets: +# zz-all-en: +# match: +# name: "en*" +# dhcp4: true +# optional: true +# zz-all-eth: +# match: +# name: "eth*" +# dhcp4: true +# optional: true +#wifis: +# wlan0: +# dhcp4: true +# optional: true +# access-points: +# myhomewifi: +# password: "S3kr1t" +# myworkwifi: +# password: "correct battery horse staple" +# workssid: +# auth: +# key-management: eap +# method: peap +# identity: "me@example.com" +# password: "passw0rd" +# ca-certificate: /etc/my_ca.pem diff --git a/live-build/cidata/user-data.sample b/live-build/cidata/user-data.sample new file mode 100644 index 00000000..82704538 --- /dev/null +++ b/live-build/cidata/user-data.sample @@ -0,0 +1,84 @@ +#cloud-config + +# NB! This is a sample, copy to "user-data" and modify to take effect + +# NB! meta-data is required too! See "meta-data.sample" + +# NB! For networking see "network-config.sample" + +# This is the user-data configuration file for cloud-init. This image +# has a default nocloud-net metadata available on the first +# partition. By default it sets up an initial user called "ubuntu" +# with password "ubuntu", which must be changed at first +# login. However, one can override and provide many additional actions +# to be initiated on first boot from this file. The cloud-init +# documentation has more details: https://cloudinit.readthedocs.io/ +# Some additional examples are provided in comments below the default +# configuration. + +# On first boot, set the (default) ubuntu user's password to "ubuntu" and +# expire user passwords +#chpasswd: +# expire: true +# list: +# - ubuntu:ubuntu + +# Enable password authentication with the SSH daemon +#ssh_pwauth: true + +## On first boot, use ssh-import-id to give the specific users SSH access to +## the default user +#ssh_import_id: +#- lp:my_launchpad_username +#- gh:my_github_username + +## Add users and groups to the system, and import keys with the ssh-import-id +## utility +#groups: +#- robot: [robot] +#- robotics: [robot] +# +#users: +#- default +#- name: robot +# gecos: Mr. Robot +# primary_group: robot +# groups: users +# ssh_import_id: foobar +# lock_passwd: false +# passwd: $5$hkui88$nvZgIle31cNpryjRfO9uArF7DYiBcWEnjqq7L1AQNN3 + +## Update apt database and upgrade packages on first boot +#package_update: true +#package_upgrade: true + +## Install additional packages on first boot +#packages: +#- pwgen +#- pastebinit +#- [libpython2.7, 2.7.3-0ubuntu3.1] + +## Write arbitrary files to the file-system (including binaries!) +#write_files: +#- path: /etc/default/keyboard +# content: | +# # KEYBOARD configuration file +# # Consult the keyboard(5) manual page. +# XKBMODEL="pc105" +# XKBLAYOUT="gb" +# XKBVARIANT="" +# XKBOPTIONS="ctrl: nocaps" +# permissions: '0644' +# owner: root:root +#- encoding: gzip +# path: /usr/bin/hello +# content: !!binary | +# H4sIAIDb/U8C/1NW1E/KzNMvzuBKTc7IV8hIzcnJVyjPL8pJ4QIA6N+MVxsAAAA= +# owner: root:root +# permissions: '0755' + +## Run arbitrary commands at rc.local like time +#runcmd: +#- [ ls, -l, / ] +#- [ sh, -xc, "echo $(date) ': hello world!'" ] +#- [ wget, "http://ubuntu.com", -O, /run/mydir/index.html ] diff --git a/live-build/functions b/live-build/functions index d69adddd..e3a06593 100644 --- a/live-build/functions +++ b/live-build/functions @@ -958,6 +958,19 @@ is_live_layer () { return 1 } +setup_cidata() { + local cidata_dev=$1 + local mountpoint=$(mktemp -d) + mkfs.vfat -F 32 -n CIDATA ${cidata_dev} + mount ${cidata_dev} ${mountpoint} + cp /usr/share/livecd-rootfs/live-build/cidata/* ${mountpoint} + cat >>${mountpoint}/meta-data.sample <mountpoint/var/lib/cloud/seed/nocloud-net/meta-data +instance-id: iid-$(openssl rand -hex 8) +EOF + cat <mountpoint/var/lib/cloud/seed/nocloud-net/user-data +#cloud-config +chpasswd: + expire: True + list: + - ubuntu:ubuntu +ssh_pwauth: True +EOF + cat <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 + ## TODO remove below once we have grub-efi-riscv64 + rm mountpoint/tmp/device.map + umount mountpoint/boot/efi + mount + umount_partition mountpoint + rmdir mountpoint + return + ## + ;; esac chroot mountpoint apt-get autoremove --purge --assume-yes diff --git a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary index 74d30aaa..502860e2 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/disk-image.binary @@ -19,10 +19,6 @@ case $ARCH:$SUBARCH in echo "POWER disk images are handled separately" exit 0 ;; - amd64|arm64|armhf) - echo "We only create EFI images for $ARCH." - exit 0 - ;; armhf:raspi2) # matches the size of the snappy image IMAGE_SIZE=$((4*1000*1000*1000)) @@ -31,6 +27,10 @@ case $ARCH:$SUBARCH in BOOTPART_END=138M BOOT_MOUNTPOINT=/boot/firmware ;; + arm64:*|armhf:*|riscv64:*) + echo "We only create EFI images for $ARCH." + exit 0 + ;; *) ;; esac diff --git a/live-build/ubuntu-cpc/hooks.d/base/qcow2-image.binary b/live-build/ubuntu-cpc/hooks.d/base/qcow2-image.binary index c827a2a6..a4851e26 100755 --- a/live-build/ubuntu-cpc/hooks.d/base/qcow2-image.binary +++ b/live-build/ubuntu-cpc/hooks.d/base/qcow2-image.binary @@ -7,6 +7,10 @@ case $ARCH:$SUBARCH in xz -T4 -c binary/boot/disk.ext4 > livecd.ubuntu-cpc.disk1.img.xz exit 0 ;; + riscv64:hifive) + xz -T4 -c binary/boot/disk-uefi.ext4 > livecd.ubuntu-cpc.disk1.img.xz + exit 0 + ;; esac . config/functions diff --git a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot index bc516092..7817c430 100755 --- a/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot +++ b/live-build/ubuntu-cpc/hooks.d/chroot/999-cpc-fixes.chroot @@ -116,8 +116,8 @@ fi case $arch in - # ARM, ppc and s390 images are special - armhf|arm64|powerpc|ppc64el|s390x) + # ARM, ppc, riscv64 and s390x images are special + armhf|arm64|powerpc|ppc64el|s390x|riscv64) exit 0 ;; esac