179 Commits

Author SHA1 Message Date
Gauthier Jolly
bbedffe6ec ubuntu-cpc: fix images for hardware devices
Canonical Public Cloud's project seems a bad place to build images for
hardware devices however this is how things were done a we now need to
maintain this.
The recent change to mount the ESP on /boot breaks those images, instead
of adding more hacky things in the hook, create a dedicated target for
those images and use a different hook to build UEFI images.
2023-06-23 13:55:59 +02:00
Gauthier Jolly
6a66666e0a ubuntu-cpc: Make the ESP 2GiB and mount it to /boot
This is driven by online encryption scenarios. In order to efficiently
encrypt the root filesystem without modifying the partition layout, the
kernel should sit in an un-encrypted /boot partition.  Instead of
creating a new partition that would change the default partition layout,
we mount the ESP on /boot. We also need to then bind mount /boot on
/boot/efi because that's where Grub expects the ESP to be located.
2023-06-13 10:48:35 +02:00
Steve Langasek
6fac77b481 Revert "Revert "Revert "Revert the recent kpartx->losetup changes, as we need to put some other changes on top. Let's try to re-introduce this for MM."""
This reverts commit 1931bbcb194febe241aa82f03a6730ba82a84409.
2023-05-26 09:41:41 -07:00
Łukasz 'sil2100' Zemczak
1931bbcb19 Revert "Revert "Revert the recent kpartx->losetup changes, as we need to put some other changes on top. Let's try to re-introduce this for MM.""
This reverts commit ada1f09b39332ec828369e0a30f2870df5c4dc3e.
2023-05-24 11:06:56 +02:00
Łukasz 'sil2100' Zemczak
4dbd985231 Revert "Try to use udevadm settle after losetup to resolve race in riscv64 image builds."
This reverts commit ef146db89529fc7fbc48052e0b684f7cb95f34ee.
2023-05-24 11:05:47 +02:00
Michael Hudson-Doyle
a65c181596 auto/config: Rewrite add_task to use a Python script that cribs the logic from lp:ubuntu-archive-publishing's generate_extra_overrides.py. This means we can avoid some dubious hacks around seeding snaps and no longer depend on the Task headers in the archive. 2023-05-12 13:19:47 +12:00
Steve Langasek
ef146db895 Try to use udevadm settle after losetup to resolve race in riscv64 image builds. 2023-05-08 15:47:04 -07:00
Steve Langasek
ada1f09b39 Revert "Revert the recent kpartx->losetup changes, as we need to put some other changes on top. Let's try to re-introduce this for MM."
This reverts commit 7b07db91110a3dda2723bc853a43f81c4e2a2f75.
2023-05-02 15:27:41 +02:00
Łukasz 'sil2100' Zemczak
7b07db9111 Revert the recent kpartx->losetup changes, as we need to put some other changes on top. Let's try to re-introduce this for MM. 2023-04-18 10:10:28 +01:00
Steve Langasek
1e0daf6af9 Clean up some remaining references to /dev/mapper. 2023-04-17 18:50:08 -07:00
Steve Langasek
6b40317404 Use the correct path for the loop device. 2023-04-17 16:11:50 -07:00
Steve Langasek
a130ee17c3 Call losetup -d properly. 2023-04-17 12:22:17 -07:00
Steve Langasek
5e4b2d3cc3 Use losetup instead of kpartx to set up loopback partitions
kpartx on riscv64 appears to be racy.  Rather than trying to debug these
fraught races somewhere between udev and libdevmapper, we can use losetup
which should be simpler and less error-prone.
2023-04-17 08:20:49 -07:00
Chad Smith
9a82720f1c cloud-init: prefer netplan to handle all network manager config
Cloud-init cannot write directly to
/etc/NetworkManager/system-connections because subiquity may
need to emit config to /etc/netplan/00-installer.yaml and call
netplan apply for autoinstall.network use-cases.

When cloud-init's config is written directly to
/etc/NetworkManager, neither netplan nor subiquity has knowledge of
this config and this results in namespace collisions in NetworkManager
due to `netplan-` named connections and `cloud-init` connection ids
fighting over which config own a given interface name.

Deleting this config overlay allows subiquity to manage all network
setup when it needs to with netplan directly.

Subiquity already has logic to rename any unwanted netplan
configuration when it intends to write cfg and run netplan apply[1].
This should allow subiquity full control of network config when needed.

[1] https://github.com/canonical/subiquity/blob/
    92ac6544cdfedfd332d8cd94dbcfad0aab994575/subiquitycore/
        controllers/network.py#L267

LP: #2015605
2023-04-07 17:09:11 -06:00
Dave Jones
6a804b7b2c Don't add 01-network-manager-all.yaml to preinstalled desktop images 2023-03-28 14:55:33 +01:00
Chad Smith
fba5be17fd cloud-init.service: systemd ordering after after NetworkManager
Autoinstall directives can be provided on the grub cmdline to
cloud-init via kernel parameters like the following:
 autoinstall 'ds=nocloud-net;s=http://somedomain/'

In order to support DNS resolution for NoCloud datasource at
datasource discovery time, cloud-init.service needs to be
orderered after NetworkManager.service and
NetworkManager-wait-online.service
which will have brought up applicable NICs.

Since NetworkManager is After=dbus.service, the cloud-init.service
avoids systemd ordering cycles by also dropping
Before=sysinit.target when it adds, After=NetworkManager.service and
After=NetworkManager-wait-online.service

Add this file overlay for /lib/systemd/system/cloud-init.service
because systemd drop-in files can only add constraints and not
drop prexisting service constraints.

Also add an AUTOMATION_HEADER comment to any generated files to
add discoverability in the event of future bugs/concerns.

LP: #2008952
2023-03-23 17:05:30 -06:00
Łukasz 'sil2100' Zemczak
c335e6ed8b Merge branch 'cloud-init-and-u-d-i' of git+ssh://git.launchpad.net/~dbungert/livecd-rootfs into ubuntu/master 2023-03-10 12:21:22 +01:00
Utkarsh Gupta
e04ea00f1f Remove whitespaces 2022-11-14 15:28:02 +05:30
Samir Akarioh
8b8ad2e0ac feat: Add Ubuntu user
We add a ubuntu user inside the image because we
want to have a operational nonroot user and also
be aligned with the other Ubuntu images.

Signed-off-by: Samir Akarioh <samir.akarioh@canonical.com>
2022-11-08 12:01:35 +01:00
Samir Akarioh
105acdebc7 feat: Add metadata on ubuntu-oci image
Add a file build.info on etc/cloud
with the serial information

Signed-off-by: Samir Akarioh <samir.akarioh@canonical.com>
2022-10-27 09:03:38 +02:00
John Chittum
e11d091106
Revert "Disable the snap-preseed"
This reverts commit 31d42bfd2ff86d175f389ee5bbed6f275597c185.

Disable the snap-preseed calls in the interest of
getting images built for the 22.10 beta. (LP: #1990884)"
2022-10-13 12:39:17 -05:00
Brian Murray
31d42bfd2f Disable the snap-preseed calls in the interest of getting images built for the 22.10 beta. (LP: #1990884) 2022-09-26 15:55:19 -07:00
Dan Bungert
ef834c2e7d functions: let cloud-init clean inform about NM 2022-08-01 14:57:37 -06:00
Dan Bungert
eb0530b7a7 functions: inform cloud-init about network manager
LP: #1982855
Co-authored-by: Chad Smith <chad.smith@canonical.com>
2022-08-01 14:57:37 -06:00
Brian Murray
995295964b Use default compat for qcow2 images.
This will cause images to be created with more moderm features which
will make our images faster and provide better sparse handling.
2022-07-28 13:57:05 -07:00
Thomas Bechtold
34735684d5 Allow to install core snap optionally
Commit 245f7772bdb74 added code to abort the build if a snap wants to
install "core" (the 16.04 runtime). That's great but there are still
some CPC maintained image builds that use snaps based on "core". So
make it possible to continue the build if the "ALLOW_CORE_SNAP" env
variable is set.
2022-03-09 07:04:06 +01:00
Ivan Kapelyukhin
50e32d93c0
fix: unset initrdless_boot_fallback_triggered instead of setting it to 0
This fixes GCE shielded VM instances integrity monitoring failures on
focal and later. Our images are built with an empty /boot/grub/grubenv
file, however after the first boot `initrdless_boot_fallback_triggered`
is set to 0. This change in `grubenv` results in integrity monitoring
`lateBootReportEvent` error.

It seems that the only thing that's checking for this `grubenv` variable
is `grub-common.service`, and it is looking specifically for a `1`
value:

  if grub-editenv /boot/grub/grubenv list | grep -q
  initrdless_boot_fallback_triggered=1; then echo "grub:
  GRUB_FORCE_PARTUUID set, initrdless boot paniced, fallback triggered.";
  fi

Unsetting this variable instead of setting it to 0 would prevent issues
with integrity monitoring.
2022-02-14 13:10:04 +01:00
John Chittum
ce5dd6f411 Add sleep to workaround e2fsck errors
LP: 1960537 illustrates an issue where the calls to e2fsck in the
umount_partition call are failing due to an open file handle. At this
time, we are unable to find a root cause, and it's causing many builds
to fail for CPC. Adding a sleep 30 as a workaround as the file handle
releases within  that timeframe. This does not address root cause.
2022-02-10 13:53:23 -08:00
Thomas Bechtold
14a628e3c8 Disable APT periodic update for OCI/docker images
When cron-like services are installed in the OCI/docker image, APT
should not do periodic updates by default. LP: #1810451
2022-02-04 11:44:05 +01:00
Steve Langasek
5474af17df Remove references to archive.canonical.com, which is no longer used and should not be included in the default sources.list. 2022-01-27 14:32:09 -08:00
William Wilson
2312c08d26 Revert change for local builds as it is breaking autopkgtests 2022-01-12 18:19:57 -06:00
Steve Langasek
245f7772bd Treat it as a fatal error if we are asked to install a snap that would pull in the core snap. Ubuntu 20.04 and Ubuntu 22.04 official images should never require snaps that depend on an Ubuntu 16.04 runtime, this indicates a misconfiguration that will bloat the install. 2022-01-11 16:32:51 -08:00
Steve Langasek
bcfad43fd4 We don't pipe grep to awk in this house, young man 2022-01-11 16:29:32 -08:00
Steve Langasek
0b4811f7a9 Do not look for a base snap on snaps of type base, because recursive dependencies are not allowed for snaps. LP: #1957123. 2022-01-11 16:26:57 -08:00
Heinrich Schuchardt
d65af891f3 functions: fix unmounting for local builds
livecd-rootfs creates non-private mounts. When building locally using
the auto/build script unmounting fails.

To unmount dev/pts it is insufficient to make the mount private. Its
parents must be private too. Change teardown_mountpoint() accordingly.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-12-01 18:11:57 +01:00
John Chittum
9c3851d401
Mount cgroup2 type for snapd
LP: 1944004 described an issue where a libc transition caused snapd
seccomp profiles to reference a path that no longer existed, leading to
permission denied errors. The committed fix for snapd then raised an
issue where running `snapd debug seeding` would present a
preseed-system-key and seed-restart-system-key due to a mismatch
between the running kernel capabilities and the profiles being loaded by
snapd. By mounting a cgroup2 type to /sys/fs/cgroup, the capabilities
match for snapd as mounted in the chroot. This is done similarly to
live-build/functions:138-140 where apparmour and seccomp actions are
mounted after updating the buildd.
2021-09-28 16:08:55 -05:00
Łukasz 'sil2100' Zemczak
2dc48a1687 Make the UBUNTU_STORE_ARCH adjustment more fool-proof 2021-08-17 12:02:39 +02:00
Ethan Hsieh
f4312118cc functions: download snap packages with correct architecture
Have to set UBUNTU_STORE_ARCH when the architecture of host machine is
different from target machine
2021-07-08 15:16:43 +08:00
Dimitri John Ledkov
20f76e7cf8
Merge branch 'preinstalled' of git+ssh://git.launchpad.net/~xnox/livecd-rootfs into ubuntu/master 2021-04-30 17:46:20 +01:00
Dimitri John Ledkov
d5a8116428
Add support for generic preinstalled images. LP: #1923832 2021-04-26 11:04:37 +01:00
Thomas Bechtold
a81972a58b
add configure_oci function and use it in ubuntu-oci
With that, the Dockerfile modifications[0] currently done externally
are done now here. That means that the created rootfs tarball can be
directly used within a Dockerfile to create a container from scratch:

FROM scratch
ADD livecd.ubuntu-oci.rootfs.tar.gz /
CMD ["/bin/bash"]

[0]
https://github.com/tianon/docker-brew-ubuntu-core/blob/master/update.sh
2021-04-22 08:48:00 +02:00
Thomas Bechtold
ac4a95b931
Add new ubuntu-oci project
This is a copy of the ubuntu-base project.
Currently ubuntu-base is used as a base for the docker/OCI container
images. The rootfs tarball that is created with ubuntu-base is
published under [0]. That tarball is used in the FROM statement of the
Dockerfile as base and then a couple of modifications are done inside
of the Dockerfile[1].
The ubuntu-oci project will include the changes that are currently
done in the Dockerfile. With that:

1) a Dockerfile using that tarball will be just a 2 line thing:

   FROM scratch
   ADD ubuntu-hirsute-core-cloudimg-amd64-root.tar.gz /
   CMD ["/bin/bash"]

2) Ubuntu has the full control about the build process of the
docker/OCI container. No external sources (like [1]) need to be
modified anymore.
3) Ubuntu can publish containers without depending on the official
dockerhub containers[2]. Currently the containers for the AWS ECR
registry[3] use as a base[4] the official dockerhub containers. That's
no longer needed because a container just needs a Dockerfile described
in 1)

When the ubuntu-oci project has the modifications from [1] included,
we'll also update [1] to use the ubuntu-oci rootfs tarball as a base
and drop the modifications done at [1].

Note: Creating a new ubuntu-oci project instead of using ubuntu-base
will make sure that we don't break users who are currently using
ubuntu-base rootfs tarballs for doing their own thing.

[0] https://partner-images.canonical.com/core/
[1]
https://github.com/tianon/docker-brew-ubuntu-core/blob/master/update.sh
[2] https://hub.docker.com/_/ubuntu
[3] https://gallery.ecr.aws/ubuntu/ubuntu
[4]
https://launchpad.net/~ubuntu-docker-images/ubuntu-docker-images/+oci/ubuntu/+recipe/ubuntu-20.04
2021-04-22 07:39:15 +02:00
Dimitri John Ledkov
096a00f404
functions: stop removing systemd-detect-virt unconditionally in undivert_grub
One can call divert_grub; replace_kernel; undivert_grub. And
replace_kernel will call into force_boot_without_initramfs, which
under certain conditions can call divert_grub &
undivert_grub. Resulting in undivert_grub called twice in a row.

When undivert_grub is called twice in a row it wipes
systemd-detect-virt binary from disk, as the rm call is unguarded to
check that there is something to divert if systemd package is
installed. And if the systemd package is not installed, it does not
check that systemd-detect-virt file is in-fact what divert_grub has
created.

Add a guard to check that systemd-detect-virt is the placeholder one,
before removing it.

LP: #1902260
2021-02-03 14:45:54 +00:00
Dimitri John Ledkov
a808b28d47
riscv64: build preinstalled riscv64 image with uboot SPL and CIDATA. 2020-12-01 17:14:40 +00:00
Sebastien Bacher
79e8f3b53e Use the target realpath to do the unmounting 2020-11-24 11:36:13 +01:00
Dimitri John Ledkov
f53a681d8a
Merge remote-tracking branch 'patviafore/use_ftpmaster_instead_of_archive_in_binary_hooks' into ubuntu/master 2020-11-19 17:36:39 +00:00
John Chittum
4f1df739f6
Debug logging information
Added context lines for debugging lines.
2020-10-26 09:22:32 -05:00
John Chittum
201addb317
Remove sed and move size check
There was a question on if the comment removals in the `sed` were
required. The comments (`#`) are created by vmdk-stream-converter and
seem to cause no issues. `ddb.comment` is no longer being written by the
tool anymore. Moved the check earlier to ensure the new header isn't too
large before running truncate (otherwise it may be too long, and we
remove bits we want)
2020-10-19 13:22:32 -05:00
John Chittum
24ee4b8c4d
vmtools version in vmdk header (LP: #1893898)
LP: #1893898 describes missing vmtools version from the vmdk headers.
The version should be added as ddb.toolsVersion = "2147483647" however
the sed was no longer replacing a ddb.comment field with the tools
version. Rather than subbing ddb.comment with toolsVersion, this commit
deletes ddb.comment (which the comment mentions could cause errors),
and adds the correct value. There was no visibility into the descriptor
during hook creation, so debug statements were added. This allows us to
quickly verify in the logs that bad statements are removed (the possibly
offending commetns), as well as ensuring that the toolsVersion is added
2020-10-19 10:51:44 -05:00
Pat Viafore
78ced6b26e
Rename function to be shorter 2020-09-21 12:10:08 -05:00