Merge lp:~jibel/livecd-rootfs/add_multi_layered_squashfses_support into lp:livecd-rootfs

Proposed by Jean-Baptiste Lallement
Status: Merged
Merge reported by: Steve Langasek
Merged at revision: not available
Proposed branch: lp:~jibel/livecd-rootfs/add_multi_layered_squashfses_support
Merge into: lp:livecd-rootfs
Diff against target: 1242 lines (+808/-255)
7 files modified
debian/tests/default-bootstraps (+1/-0)
live-build/auto/build (+137/-185)
live-build/auto/clean (+2/-0)
live-build/auto/config (+92/-64)
live-build/functions (+198/-6)
live-build/lb_binary_layered (+132/-0)
live-build/lb_chroot_layered (+246/-0)
To merge this branch: bzr merge lp:~jibel/livecd-rootfs/add_multi_layered_squashfses_support
Reviewer Review Type Date Requested Status
Steve Langasek Needs Fixing
Review via email: mp+358490@code.launchpad.net

Description of the change

Adds support for multi layer filesystem by generating one squashfs per layer and adding a new 'live-layered' image format.
squashfs are numbered so the order is preserved and mounted in order by casper.

Seeding of snap packages and seeds corresponding to the layers are not
available yet and will be proposed in the subsequent merge proposal.

To post a comment you must log in.
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

In passes, how does one specify multiple branches of stacks? Or is only a linear stack allowed by this code?

Cause the current subiquity images do not have `live` as the top of the stack.... They do this:

+--> Base +-----> Live
          |
          +-----> Rack +---> Region

Because I am expecting to have the ability to somehow specify what each pass depends on. But it looks like the base for a subsequent pass, is always the previous one?!

It would be nice to extend PASS syntax to optionally accept an arbitrary `base`, e.g.

PASSES="base rack region base:live" to encode the above graph, and such that `base:live` pass uses base as the lowerdir, instead of region (i.e. the previous pass result).

Or something...

not sure if : is acceptable pair delimiter here, or not.

Also not sure if we want to always enforce specifying `base` such that we can construct multiple root nodes in one go. E.g. `base base:rack rack:region base:live` or `:base rack region base:live` for the above graph.

Or like maybe always list all layers?! but that violates donot-repeat-yourself principle... E.g. `base base:rack base:rack:region base:live`

===

When calling includes/hooks are they aware which pass they are for? what is the source dir for each pass, for e.g. binary.includes? I'm guessing that PASS variable is set, but not sure.

===

filesystem.squashfs is somewhat is a special name, so it would be nice to keep that as the base one. And also possibly adjust logic in casper as to what it mounts by default.... cause e.g. i think i hide maas squashfes in a subdir, to prevent casper from mounting those, which is kind of a hack. I wonder if we do need to write out the valid stacks (passes?!), which casper can then use to boot to whichever stack is valid. With subiquity image this could then result in "Live Server, Live MAAS Rack, Live MAAS Region, Live Server with Installer" boot options. As example, for better or worse.

====

No idea if SUBPROJECT and IMAGE_FORMAT are the right things to extend for this..... and if they are easily extendable like this in launchpad livefs builders & ubuntu-cdimage codes.

Cause I can see the potential for using layers in SUBPROJECT=minimized, if for example, cpc builds are converted to layers they would have full and minimized layered builds.... and SUBPROJECT=minimized-layered sounds ugly =)

====

manifest diffs for layers is nice; cause in cpc we have struggled to consitently represent manifests / changelogs of "it's just like that image, but has this stuff on it"

====

packaging layers as actual static filesystems might be interesting, but i guess hooks will be able to do that anyway.

====

Overall, this looks ok, and shouldn't break any existing stuff - as long as we can clear the top level new extensions of

   SUBPROJECT=layered
   IMAGEFORMAT=live-layered

and that needs like an architect review.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :
Download full text (5.9 KiB)

Thanks for the review

On 14/11/2018 00:35, Dimitri John Ledkov wrote:
>
> In passes, how does one specify multiple branches of stacks? Or is only a linear stack allowed by this code?

This code only allows linear stacks to avoid not make current code more
complex than it already is and diverging too much from existing logic.
Our approach is to define the stacking defining the live image in PASSES
and put the extra logic like “branched mounts” in hooks.

For instance with langpacks which is the use case for Desktop image, we
also have multiple branches of stacks. It is difficult to represent the
structure in a generic way and it adds extra complexity to the
maintenance of those definitions.

Following your proposal to represent the layers structure as a list, it
would be something like:
PASSES=“desktop-minimal:desktop:live desktop-minimal:lang-neg-min-fr
desktop-minimal:lang-neg-min-de desktop-minimal:desktop:lang-neg-fr
desktop-minimal:desktop:lang-neg-de …”

We thus have multiple “base” here, “desktop-minimal” or
“desktop-minimal:desktop”. Shortening the syntax doesn’t seem
appropriate here.

In a tree, it’s not better:
- desktop-min
   - desktop
     - Lang-neg-de
     - Lang-neg-fr
     - Lang-neg-es
     - …
     - Live
   - Lang-neg-min-de
   - Lang-neg-min-fr
   - Lang-neg-min-es
   - …

Addition or removal of any default language would be then error-prone.
This is to compare with a hook, where we just loop over “desktop-min”
and creates langpacks negative stacks, and then looping over “desktop”
as well to achieve the same. Besides, shell seems inappropriate to
implement this type of logic.

Note that the current implementation is similar than existing
ubuntu-server:live logic (just a little bit more generic) and we made
sure we didn’t break your use case. Note that though, you will be able
to remove your first hook, creating the “live” stack using the generic
code right now. However, the maas-* stacks will still be in hooks.

>
> Cause the current subiquity images do not have `live` as the top of the stack.... They do this:
>
> +--> Base +-----> Live
> |
> +-----> Rack +---> Region
>
> Because I am expecting to have the ability to somehow specify what each pass depends on. But it looks like the base for a subsequent pass, is always the previous one?!
>
>
> It would be nice to extend PASS syntax to optionally accept an arbitrary `base`, e.g.
>
> PASSES="base rack region base:live" to encode the above graph, and such that `base:live` pass uses base as the lowerdir, instead of region (i.e. the previous pass result).
>
> Or something...
>
> not sure if : is acceptable pair delimiter here, or not.
>
> Also not sure if we want to always enforce specifying `base` such that we can construct multiple root nodes in one go. E.g. `base base:rack rack:region base:live` or `:base rack region base:live` for the above graph.
>
> Or like maybe always list all layers?! but that violates donot-repeat-yourself principle... E.g. `base base:rack base:rack:region base:live`
>
> ===
>
> When calling includes/hooks are they aware which pass they are for? what is the source dir for each pass, for e.g. bina...

Read more...

Revision history for this message
Steve Langasek (vorlon) wrote :

Thanks for working on this, it will be nice to have cleaner handling of the desktop-minimal stuff included here in livecd-rootfs.

I would like to see this converged with the ubuntu-server-live handling as part of landing of this branch (see also Dimitri's review comments). You've gone to some length to implement this in a way that's generalizable across projects, so we ought to make sure the implementation is actually reusable by the only other image that currently uses layered squashfs.

review: Needs Fixing
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

We intended to propose several MP for snap and “sub-layers” to reduce the complexity of the review, but we’ll finally merge them into this one so you’ll have a good understanding of the full implementation.

Supporting the server-live use case adds makes the implementation more complex due to its specific requirements (hooks and includes). But we agree that a more generalizable implementation is better, so let’s spend some time to ensure those 2 additional requirements are supported, and once foundation/server team want to switch to it, that they will not encounter any major limitations.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Following previous comments, this MP has been updated with these changes:
- Merged preseeding of snap packages and adds snap packages to the image manifest.
- Added lb_binary_layered to handle multi branches of squashfses with sublayers.
- Factorized several helpers called by lb_chroot_layered
- Removed obsolete chroot helpers from lb_chroot_layered and minor cleanup.
- Renamed subproject layered -> ubiquity-ng
- Use PASSES instead of IMAGEFORMAT to detect a multilayer project. Defining PASSES switches the image build into layered build.
- Adds includes by pass to customize chroot for specific passes.
- Moved back specific helpers and functions from functions to config.
- For Ubuntu Desktop:ubiquity-ng, build negative language packs and corresponding squashfs.

These changes have been tested against ubuntu-server live which still uses its current implementation (with maas-region and maas-rack squashfses built in hooks).
All the requirements of ubuntu-server:live can be ported from the current hooks to the new implementation of the layered images.
To do so:
- The project have to define PASSES.
- Snaps and packages for sublayers added to separated seeds and referenced in auto/config.
- Layers must be customized with chroot hooks (eg to modify existing files) and chroot includes (eg to add new files) depending on PASS.

Ubuntu Desktop (standard disco) has been modified to use layered images as requested. As a consequence the following MPs must be reviewed together with this one and released before uploading livecd-rootfs:
- debian-cd: https://code.launchpad.net/~jibel/debian-cd/support_for_multilayer_images/+merge/359228
- ubuntu-cdimage: https://code.launchpad.net/~jibel/ubuntu-cdimage/support_for_multilayer/+merge/359512

The subproject ubiquity-ng must be created for building the ubuntu-desktop:ubiquity-ng rootfs and match https://launchpad.net/~ubuntu-cdimage/+livefs/ubuntu/disco/ubuntu-desktop-ubiquity-ng/
This whole set of changes (livecd-rootfs, ubuntu-cdimage and debian-cd) have been tested with the following projects:
- Ubuntu Desktop layered (iso) (disco) -> test new set of layers
- Ubuntu Desktop unlayered (iso) (disco) -> test previous image format (one squashfs)
- Ubuntu Desktop ubiquity-ng (iso) -> test new set of layers + sublayers
- Ubuntu Server live (iso) (bionic and disco) -> test backward compatibility with current server image and hooks impacts.
- Lubuntu (rootfs only, no local archive with universe for building iso, similar build to ubuntu-desktop/unlayered) (disco) -> test traditional one squashfs image
- Ubuntu Mate (rootfs only, no local archive with universe for building iso, similar build to ubuntu-desktop/unlayered) (bionic) -> test traditional one squashfs image + snaps

Revision history for this message
Adam Conrad (adconrad) wrote :

I don't have time for a full review this morning, but unless we intend to keep these forked from the "real" ISOs for testing for a while, and then converge, I really don't like the SUBPROJECT use here. I'd expect the real 'ubuntu' project to be building these, not some ubuntu-random-subproject project.

As noted, you already can decide if you're building this type of image based on PASSES being defined, so it seems a bit odd to then also key on a subproject name.

1758. By Jean-Baptiste Lallement

configure network manager _after_ installing network-manager

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

> I don't have time for a full review this morning, but unless we intend to keep
> these forked from the "real" ISOs for testing for a while, and then converge,
> I really don't like the SUBPROJECT use here. I'd expect the real 'ubuntu'
> project to be building these, not some ubuntu-random-subproject project.
>
> As noted, you already can decide if you're building this type of image based
> on PASSES being defined, so it seems a bit odd to then also key on a
> subproject name.
We need a subproject because the real 'ubuntu' and the new installer work will diverge quickly. Note that Ubuntu Desktop uses the layer system on Disco with this merge proposal without defining a subproject.

Revision history for this message
Balint Reczey (rbalint) wrote :

The target Bazaar branch is not active anymore.
Please resubmit the merge proposal against https://code.launchpad.net/~ubuntu-core-dev/livecd-rootfs/+git/livecd-rootfs/+ref/ubuntu/master .

Revision history for this message
Steve Langasek (vorlon) wrote :

This is done now in git.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/tests/default-bootstraps'
--- debian/tests/default-bootstraps 2018-05-09 02:12:15 +0000
+++ debian/tests/default-bootstraps 2018-11-28 08:47:44 +0000
@@ -23,6 +23,7 @@
23 lubuntu::23 lubuntu::
24 mythbuntu::24 mythbuntu::
25 ubuntu::25 ubuntu::
26 ubuntu:ubiquity-ng:
26 ubuntu-base::27 ubuntu-base::
27 ubuntu-budgie::28 ubuntu-budgie::
28 ubuntu-budgie-desktop::29 ubuntu-budgie-desktop::
2930
=== modified file 'live-build/auto/build'
--- live-build/auto/build 2018-11-26 12:03:24 +0000
+++ live-build/auto/build 2018-11-28 08:47:44 +0000
@@ -252,107 +252,57 @@
252dpkg-divert --quiet --remove --rename /usr/sbin/update-initramfs252dpkg-divert --quiet --remove --rename /usr/sbin/update-initramfs
253EOF253EOF
254254
255 lb chroot "$@"255 if [ -n "${PASSES}" ]; then
256256 PATH="config/:$PATH" lb chroot_layered "$@"
257 if [ "${SUBPROJECT:-}" = minimized ]; then257 else
258 # force removal of initramfs-tools, which we assert is not258 lb chroot "$@"
259 # required for any minimized images but is still pulled in by259 fi
260 # default260
261 # also remove landscape-common, which is heavyweight and261 # Let all configuration non multi-layered project here.
262 # in the server seed only to provide /etc/motd content which262 # If those are moving to a multi-layer layout, this needs to be
263 # would only be seen by humans263 # done in chroot hooks.
264 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \264 if [ -z "$PASSES" ]; then
265 apt-get -y purge initramfs-tools busybox-initramfs \265 if [ "${SUBPROJECT:-}" = minimized ]; then
266 busybox-static landscape-common"266 # force removal of initramfs-tools, which we assert is not
267 # and if initramfs-tools was configured before our kernel,267 # required for any minimized images but is still pulled in by
268 # /etc/kernel/postinst.d/initramfs-tools will have created268 # default
269 # an initramfs despite the generic dpkg-divert; so remove it269 # also remove landscape-common, which is heavyweight and
270 # here.270 # in the server seed only to provide /etc/motd content which
271 rm -f chroot/boot/initrd.img-*271 # would only be seen by humans
272272 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \
273 # temporary workaround: don't remove linux-base which273 apt-get -y purge initramfs-tools busybox-initramfs \
274 # may have no other reverse-depends currently274 busybox-static landscape-common"
275 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \275 # and if initramfs-tools was configured before our kernel,
276 apt-mark manual linux-base"276 # /etc/kernel/postinst.d/initramfs-tools will have created
277 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \277 # an initramfs despite the generic dpkg-divert; so remove it
278 apt-get -y --purge autoremove"278 # here.
279 fi279 rm -f chroot/boot/initrd.img-*
280280
281 # remove crufty files that shouldn't be left in an image281 # temporary workaround: don't remove linux-base which
282 rm -f chroot/var/cache/debconf/*-old chroot/var/lib/dpkg/*-old282 # may have no other reverse-depends currently
283 Chroot chroot apt clean283 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \
284 if [ "${PROJECT}:${SUBPROJECT:-}" = "ubuntu-base:minimized" ]; then284 apt-mark manual linux-base"
285 # Save even more size by removing apt lists (that are currently removed285 Chroot chroot "env DEBIAN_FRONTEND=noninteractive \
286 # downstream anyway)286 apt-get -y --purge autoremove"
287 rm -rf chroot/var/lib/apt/lists/*287 fi
288 # Having device notes in the docker image can cause problems288
289 # (https://github.com/tianon/docker-brew-ubuntu-core/issues/62)289 clean_debian_chroot
290 # so remove them. We only do this for docker out of an290
291 # abundance of caution.291 if [ "${PROJECT}:${SUBPROJECT:-}" = "ubuntu-base:minimized" ]; then
292 rm -rf chroot/dev/*292 # Save even more size by removing apt lists (that are currently removed
293 fi293 # downstream anyway)
294294 rm -rf chroot/var/lib/apt/lists/*
295 if [ -f config/universe-enabled ]; then295 # Having device notes in the docker image can cause problems
296296 # (https://github.com/tianon/docker-brew-ubuntu-core/issues/62)
297# This is cargo-culted almost verbatim (with some syntax changes for297 # so remove them. We only do this for docker out of an
298# preinstalled being slightly different in what it doesn't ask) from298 # abundance of caution.
299# debian-installer's apt-setup:299 rm -rf chroot/dev/*
300300 fi
301cat > chroot/etc/apt/sources.list << EOF301
302# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to302 configure_universe
303# newer versions of the distribution.303
304deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted304 if [ -d chroot/var/lib/preinstalled-pool ]; then
305# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted305 cat > config/indices/apt.conf <<-EOF
306
307## Major bug fix updates produced after the final release of the
308## distribution.
309deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
310# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
311
312## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
313## team. Also, please note that software in universe WILL NOT receive any
314## review or updates from the Ubuntu security team.
315deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
316# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
317deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
318# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
319
320## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
321## team, and may not be under a free licence. Please satisfy yourself as to
322## your rights to use the software. Also, please note that software in
323## multiverse WILL NOT receive any review or updates from the Ubuntu
324## security team.
325deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
326# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
327deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
328# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
329
330## N.B. software from this repository may not have been tested as
331## extensively as that contained in the main release, although it includes
332## newer versions of some applications which may provide useful features.
333## Also, please note that software in backports WILL NOT receive any review
334## or updates from the Ubuntu security team.
335deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
336# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
337
338## Uncomment the following two lines to add software from Canonical's
339## 'partner' repository.
340## This software is not part of Ubuntu, but is offered by Canonical and the
341## respective vendors as a service to Ubuntu users.
342# deb http://archive.canonical.com/ubuntu $LB_DISTRIBUTION partner
343# deb-src http://archive.canonical.com/ubuntu $LB_DISTRIBUTION partner
344
345deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
346# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
347deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
348# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
349deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
350# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
351EOF
352
353 fi
354 if [ -d chroot/var/lib/preinstalled-pool ]; then
355 cat > config/indices/apt.conf <<-EOF
356Dir {306Dir {
357 ArchiveDir "chroot/var/lib/preinstalled-pool";307 ArchiveDir "chroot/var/lib/preinstalled-pool";
358 OverrideDir "config/indices";308 OverrideDir "config/indices";
@@ -369,11 +319,11 @@
369 Contents " ";319 Contents " ";
370}320}
371EOF321EOF
372 for component in $LB_PARENT_ARCHIVE_AREAS; do322 for component in $LB_PARENT_ARCHIVE_AREAS; do
373 mkdir -p chroot/var/lib/preinstalled-pool/dists/$LB_DISTRIBUTION/$component/binary-$LB_ARCHITECTURES323 mkdir -p chroot/var/lib/preinstalled-pool/dists/$LB_DISTRIBUTION/$component/binary-$LB_ARCHITECTURES
374 done324 done
375 apt-ftparchive generate config/indices/apt.conf325 apt-ftparchive generate config/indices/apt.conf
376 cat << @@EOF > chroot/etc/apt/sources.list.preinstall326 cat << @@EOF > chroot/etc/apt/sources.list.preinstall
377# This is a sources.list entry for a small pool of packages327# This is a sources.list entry for a small pool of packages
378# provided on your preinstalled filesystem for your convenience.328# provided on your preinstalled filesystem for your convenience.
379#329#
@@ -385,93 +335,89 @@
385#335#
386@@EOF336@@EOF
387337
388 cp chroot/etc/apt/sources.list chroot/etc/apt/sources.list.orig338 cp chroot/etc/apt/sources.list chroot/etc/apt/sources.list.orig
389 cp chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list339 cp chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list
390340
391 echo "Waiting on gnupg ("$GPG_PROCESS") to finish generating a key."341 echo "Waiting on gnupg ("$GPG_PROCESS") to finish generating a key."
392 wait $GPG_PROCESS342 wait $GPG_PROCESS
393343
394 R_ORIGIN=$(lsb_release -i -s)344 R_ORIGIN=$(lsb_release -i -s)
395 R_CODENAME=$(lsb_release -c -s)345 R_CODENAME=$(lsb_release -c -s)
396 R_VERSION=$(lsb_release -r -s)346 R_VERSION=$(lsb_release -r -s)
397 R_PRETTYNAME=$(echo $R_CODENAME | sed -e 's/^\(.\)/\U\1/')347 R_PRETTYNAME=$(echo $R_CODENAME | sed -e 's/^\(.\)/\U\1/')
398348
399 apt-ftparchive -o APT::FTPArchive::Release::Origin=$R_ORIGIN \349 apt-ftparchive -o APT::FTPArchive::Release::Origin=$R_ORIGIN \
400 -o APT::FTPArchive::Release::Label=$R_ORIGIN \350 -o APT::FTPArchive::Release::Label=$R_ORIGIN \
401 -o APT::FTPArchive::Release::Suite=$R_CODENAME-local \351 -o APT::FTPArchive::Release::Suite=$R_CODENAME-local \
402 -o APT::FTPArchive::Release::Version=$R_VERSION \352 -o APT::FTPArchive::Release::Version=$R_VERSION \
403 -o APT::FTPArchive::Release::Codename=$R_CODENAME \353 -o APT::FTPArchive::Release::Codename=$R_CODENAME \
404 -o APT::FTPArchive::Release::Description="$R_ORIGIN $R_PRETTYNAME Local" \354 -o APT::FTPArchive::Release::Description="$R_ORIGIN $R_PRETTYNAME Local" \
405 release chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/ \355 release chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/ \
406 > config/gnupg/Release356 > config/gnupg/Release
407357
408 gpg --home config/gnupg --detach-sign --armor config/gnupg/Release358 gpg --home config/gnupg --detach-sign --armor config/gnupg/Release
409 mv config/gnupg/Release \359 mv config/gnupg/Release \
410 chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/Release360 chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/Release
411 mv config/gnupg/Release.asc \361 mv config/gnupg/Release.asc \
412 chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/Release.gpg362 chroot/var/lib/preinstalled-pool/dists/$R_CODENAME/Release.gpg
413 apt-key --keyring chroot/etc/apt/trusted.gpg add config/gnupg/pubring.gpg363 apt-key --keyring chroot/etc/apt/trusted.gpg add config/gnupg/pubring.gpg
414 find chroot/var/lib/preinstalled-pool/ -name Packages | xargs rm364 find chroot/var/lib/preinstalled-pool/ -name Packages | xargs rm
415365
416 Chroot chroot "apt-get update"366 Chroot chroot "apt-get update"
417 cat chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig \367 cat chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig \
418 > chroot/etc/apt/sources.list368 > chroot/etc/apt/sources.list
419 rm chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig369 rm chroot/etc/apt/sources.list.preinstall chroot/etc/apt/sources.list.orig
420 fi370 fi
421 case $PROJECT:$SUBPROJECT in371 case $PROJECT:$SUBPROJECT in
422 *)372 ubuntu-server:live)
423 if [ -e "config/seeded-snaps" ]; then373 lb chroot_resolv install
424 snap_list=$(cat config/seeded-snaps)374 snap_prepare chroot
425 preinstall_snaps $snap_list375 lb chroot_resolv remove
426 fi376 ;;
427 ;;377 *)
428 esac378 if [ -e "config/seeded-snaps" ]; then
429379 snap_list=$(cat config/seeded-snaps)
430 if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then380 preinstall_snaps $snap_list
431 if [ "$ARCH" = "armhf" ]; then381 fi
432 INFO_DESC="$(lsb_release -d -s)"382 ;;
433 echo "$INFO_DESC - $ARCH ($BUILDSTAMP)" >chroot/etc/media-info383 esac
434 mkdir -p chroot/var/log/installer384
435 Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info"385 if [ "$PROJECT" = "ubuntu-touch" ] || [ "$PROJECT" = "ubuntu-touch-custom" ]; then
436 fi386 if [ "$ARCH" = "armhf" ]; then
437 fi387 INFO_DESC="$(lsb_release -d -s)"
438 if [ "$PROJECT" = "ubuntu-cpc" ]; then388 echo "$INFO_DESC - $ARCH ($BUILDSTAMP)" >chroot/etc/media-info
439 if [ "${SUBPROJECT:-}" = minimized ]; then389 mkdir -p chroot/var/log/installer
440 BUILD_NAME=minimal390 Chroot chroot "ln -s /etc/media-info /var/log/installer/media-info"
441 else391 fi
442 BUILD_NAME=server392 fi
443 fi393 if [ "$PROJECT" = "ubuntu-cpc" ]; then
444 cat > chroot/etc/cloud/build.info << EOF394 if [ "${SUBPROJECT:-}" = minimized ]; then
395 BUILD_NAME=minimal
396 else
397 BUILD_NAME=server
398 fi
399 cat > chroot/etc/cloud/build.info << EOF
445build_name: $BUILD_NAME400build_name: $BUILD_NAME
446serial: $BUILDSTAMP401serial: $BUILDSTAMP
447EOF402EOF
403 fi
404
405 configure_network_manager
406
407 echo "===== Checking size of /usr/share/doc ====="
408 echo BEGIN docdirs
409 (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr)
410 echo END docdirs
411
412 /usr/share/livecd-rootfs/minimize-manual chroot
448 fi413 fi
449414
450 # If the image pre-installs network-manager, let it manage all devices by415 if [ -n "${PASSES}" ]; then
451 # default. Installing NM on an existing system only manages wifi and wwan via416 PATH="config/:$PATH" lb binary_layered "$@"
452 # /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf. When setting
453 # the global backend to NM, netplan overrides that file.
454 if [ -d chroot/usr/lib/NetworkManager ]; then
455 echo "===== Enabling all devices in NetworkManager ===="
456 mkdir -p chroot/etc/netplan
457 cat <<EOF > chroot/etc/netplan/01-network-manager-all.yaml
458# Let NetworkManager manage all devices on this system
459network:
460 version: 2
461 renderer: NetworkManager
462EOF
463 else417 else
464 echo "==== NetworkManager not installed ===="418 lb binary "$@"
465 fi419 fi
466420
467 echo "===== Checking size of /usr/share/doc ====="
468 echo BEGIN docdirs
469 (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr)
470 echo END docdirs
471
472 /usr/share/livecd-rootfs/minimize-manual chroot
473
474 lb binary "$@"
475 touch binary.success421 touch binary.success
476) 2>&1 | tee binary.log422) 2>&1 | tee binary.log
477423
@@ -504,6 +450,12 @@
504 chmod 644 "$PREFIX.$OUTPUT"450 chmod 644 "$PREFIX.$OUTPUT"
505done451done
506452
453# we don't need a manifest-remove for a layered-aware installer
454if [ "$SUBPROJECT" = "ubiquity-ng" ]; then
455 rm -f livecd.${PROJECT}-manifest-remove
456 rm -f config/manifest-minimal-remove
457fi
458
507if [ -e config/manifest-minimal-remove ]; then459if [ -e config/manifest-minimal-remove ]; then
508 cp config/manifest-minimal-remove "$PREFIX.manifest-minimal-remove"460 cp config/manifest-minimal-remove "$PREFIX.manifest-minimal-remove"
509fi461fi
510462
=== modified file 'live-build/auto/clean'
--- live-build/auto/clean 2012-11-19 18:49:31 +0000
+++ live-build/auto/clean 2018-11-28 08:47:44 +0000
@@ -8,3 +8,5 @@
8rm -f binary.manifest binary.manifest-desktop binary.log8rm -f binary.manifest binary.manifest-desktop binary.log
9rm -f livecd.*9rm -f livecd.*
10rm -rf userdata10rm -rf userdata
11rm -rf chroot.*
12rm -rf *.manifest.full
1113
=== modified file 'live-build/auto/config'
--- live-build/auto/config 2018-11-23 16:39:40 +0000
+++ live-build/auto/config 2018-11-28 08:47:44 +0000
@@ -33,15 +33,40 @@
3333
34mkdir -p config34mkdir -p config
35cp -af /usr/share/livecd-rootfs/live-build/functions config/functions35cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
36cp -af /usr/share/livecd-rootfs/live-build/lb_*_layered config/
36cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse37cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse
3738
38mkdir -p config/package-lists39mkdir -p config/package-lists
3940
41. config/functions
42
43OPTS=
44COMPONENTS=
45BINARY_REMOVE_LINUX=:
46BINARY_IMAGES=none
47MEMTEST=none
48SOURCE='--source false'
49BOOTLOADER=none
50BOOTAPPEND_LIVE=
51LIVE_TASK=
52PREINSTALLED=false
53PREINSTALL_POOL=
54PREINSTALL_POOL_SEEDS=
55PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
56
57CHROOT_HOOKS=
58BINARY_HOOKS=
59
60APT_OPTIONS=" --yes -oDebug::pkgDepCache::AutoInstall=yes "
61
40add_task ()62add_task ()
41{63{
42 local pass="$1"64 local pass="$1"
43 shift65 shift
44 local task66 local task
67 local snap_list_file
68 local snap_list_files
69 local curseed
4570
46 # The removal of direct task installation support from live-build71 # The removal of direct task installation support from live-build
47 # poses some problems. If the chroot has multiarch configured - for72 # poses some problems. If the chroot has multiarch configured - for
@@ -58,12 +83,32 @@
58 # probably a lurking timebomb that we need to fix. In the meantime,83 # probably a lurking timebomb that we need to fix. In the meantime,
59 # the Architecture restriction at least saves us from abject84 # the Architecture restriction at least saves us from abject
60 # failure.85 # failure.
86 #
87 # We want as well to grab the snap list for each PASS. Resolve for all
88 # given task, and deduplicate them to generate snaps for the PASS.
6189
62 for task; do90 for task; do
63 # We need a ridiculous number of backslashes to protect91 # We need a ridiculous number of backslashes to protect
64 # parentheses from eval.92 # parentheses from eval.
65 echo "!chroot chroot apt-cache dumpavail | grep-dctrl -nsPackage \\\\\\( -XFArchitecture $ARCH -o -XFArchitecture all \\\\\\) -a -wFTask $task" >> "config/package-lists/livecd-rootfs.list.chroot_$pass"93 echo "!chroot chroot apt-cache dumpavail | grep-dctrl -nsPackage \\\\\\( -XFArchitecture $ARCH -o -XFArchitecture all \\\\\\) -a -wFTask $task" >> "config/package-lists/livecd-rootfs.list.chroot_$pass"
94
95 curseed=$(seed_from_task ${task})
96 if [ -z "${curseed}" ]; then
97 echo "W: No seed matching task ${task}"
98 continue
99 fi
100 snap_list_file="config/package-lists/seed.${curseed}.snaplist.full"
101 snap_from_seed "${curseed}" $snap_list_file
102 if [ -e "$snap_list_file" ]; then
103 snap_list_files="${snap_list_files} $snap_list_file"
104 fi
66 done105 done
106 # The snap list is one line, and could be duplicated between seeds via inheritance.
107 # Uniquely sort them and store them back in one line.
108 if [ -n "${snap_list_files}" ]; then
109 cat ${snap_list_files}|xargs -n1|sort -u > "config/package-lists/livecd-rootfs.snaplist.chroot_${pass}.full"
110 rm ${snap_list_files}
111 fi
67}112}
68113
69add_package ()114add_package ()
@@ -77,24 +122,34 @@
77 done122 done
78}123}
79124
80OPTS=125add_layered_pass() {
81COMPONENTS=126 # Add a layer to an existing pass based on seeds matching a regexp
82BINARY_REMOVE_LINUX=:127 # $1 base pass
83BINARY_IMAGES=none128 # $2 seeds (regexp)
84MEMTEST=none129
85SOURCE='--source false'130 for seed in $(ls config/germinate-output/|grep -P "$2"); do
86BOOTLOADER=none131 pass=${1}_${seed}
87BOOTAPPEND_LIVE=132 list_packages_from_seed ${seed} >> config/package-lists/livecd-rootfs.list.chroot_$pass
88LIVE_TASK=133 done
89PREINSTALLED=false134}
90PREINSTALL_POOL=135
91PREINSTALL_POOL_SEEDS=136add_layered_pass_delta() {
92PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"137 # Add a layer to an existing pass based on delta between seeds matching a regexp and a base seed
93138 # $1 base pass
94CHROOT_HOOKS=139 # $2 base seed
95BINARY_HOOKS=140 # $3 seeds to remove from base seed (regexp). If empty, a no-<base-seed> sublayer is generated.
96141
97APT_OPTIONS=" --yes -oDebug::pkgDepCache::AutoInstall=yes "142 local seed_regexp="$3"
143 if [ -z "${seed_regexp}" ]; then
144 substract_package_lists ${2} "" >> config/package-lists/livecd-rootfs.removal-list.chroot_${1}_no-${2}
145 return
146 fi
147
148 for seed in $(ls config/germinate-output/|grep -P "$seed_regexp"); do
149 pass=${1}_${seed}
150 substract_package_lists ${2} ${seed} >> config/package-lists/livecd-rootfs.removal-list.chroot_$pass
151 done
152}
98153
99add_chroot_hook ()154add_chroot_hook ()
100{155{
@@ -288,30 +343,6 @@
288 OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal --linux-packages=linux-image"343 OPTS="${OPTS:+$OPTS }--bootstrap-flavour=minimal --linux-packages=linux-image"
289fi344fi
290345
291# cribbed from cdimage, perhaps this should be a small helper script in germinate?
292add_inheritance () {
293 case " $inherit " in
294 *" $1 "*)
295 ;;
296 *)
297 inherit="${inherit:+$inherit }$1"
298 ;;
299 esac
300}
301
302expand_inheritance () {
303 for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
304 expand_inheritance "$seed"
305 done
306 add_inheritance "$1"
307}
308
309inheritance () {
310 inherit=
311 expand_inheritance "$1"
312 echo "$inherit"
313}
314
315mkdir -p config/germinate-output346mkdir -p config/germinate-output
316case $PROJECT in347case $PROJECT in
317 kubuntu-active*)348 kubuntu-active*)
@@ -358,8 +389,21 @@
358389
359case $PROJECT in390case $PROJECT in
360 ubuntu|ubuntu-dvd)391 ubuntu|ubuntu-dvd)
361 add_task install minimal standard ubuntu-desktop392 PASSES="install-minimal install live"
393 add_task install-minimal minimal standard ubuntu-desktop-minimal ubuntu-desktop-minimal-default-languages
394 add_task install ubuntu-desktop ubuntu-desktop-default-languages
362 LIVE_TASK='ubuntu-live'395 LIVE_TASK='ubuntu-live'
396
397 case ${SUBPROJECT:-} in
398 ubiquity-ng)
399 # LANG PASS for minimal and install
400 add_layered_pass_delta install-minimal desktop-minimal-default-languages '^desktop-minimal-(?!default-languages)[^.]+$'
401 add_layered_pass_delta install-minimal desktop-minimal-default-languages '' # none (if no default langpack is selected)
402 add_layered_pass_delta install desktop-default-languages '^desktop-(?!default-languages|minimal|common)[^.]+$'
403 add_layered_pass_delta install desktop-default-languages '' # none (if no default langpack is selected)
404 ;;
405 esac
406
363 case $ARCH in407 case $ARCH in
364 amd64) add_package live $SIGNED_KERNEL_PACKAGE ;;408 amd64) add_package live $SIGNED_KERNEL_PACKAGE ;;
365 esac409 esac
@@ -728,30 +772,11 @@
728 ;;772 ;;
729 ubuntu-server:live)773 ubuntu-server:live)
730 BASE_SEED='server'774 BASE_SEED='server'
731 # subiquity is seeded but in a separate squashfs via hooks; set HOOK_SNAPS and ALL_SNAPS.
732 HOOK_SNAPS='subiquity'
733 ALL_SNAPS=''
734 ;;775 ;;
735esac776esac
736777
737if [ -n "${BASE_SEED}" ]; then778if [ -z "$PASSES" ] && [ -n "${BASE_SEED}" ]; then
738 SEEDS_EXPANDED=$(inheritance ${BASE_SEED})779 snap_from_seed "${BASE_SEED}" config/seeded-snaps
739 for seed in ${SEEDS_EXPANDED}; do
740 echo "snap: considering ${seed}"
741 file=config/germinate-output/${seed}.snaps
742 [ -e "${file}" ] || continue
743 # extract the first column (snap package name) from germinate's output
744 # translate the human-readable "foo (classic)" into a
745 # more machine readable "foo/classic"
746 seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
747 for snap in ${seed_snaps}; do
748 echo "snap: found ${snap}"
749 ALL_SNAPS="${ALL_SNAPS:+${ALL_SNAPS} }${snap}"
750 done
751 done
752 if [ -n "${ALL_SNAPS}" ] || [ -n "${HOOK_SNAPS}" ]; then
753 echo "${ALL_SNAPS}" > config/seeded-snaps
754 fi
755fi780fi
756781
757# grab a list of packags to remove for a "minimal" installation from the seed782# grab a list of packags to remove for a "minimal" installation from the seed
@@ -890,6 +915,9 @@
890echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot915echo "LB_CHROOT_HOOKS=\"$CHROOT_HOOKS\"" >> config/chroot
891echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/chroot916echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/chroot
892echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/chroot917echo "LB_DISTRIBUTION=\"$SUITE\"" >> config/chroot
918if [ -n "$PASSES" ]; then
919 echo "PASSES=\"$PASSES\"" >> config/common
920fi
893echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary921echo "LB_BINARY_HOOKS=\"$BINARY_HOOKS\"" >> config/binary
894echo "BUILDSTAMP=\"$NOW\"" >> config/binary922echo "BUILDSTAMP=\"$NOW\"" >> config/binary
895echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary923echo "SUBPROJECT=\"${SUBPROJECT:-}\"" >> config/binary
896924
=== modified file 'live-build/functions'
--- live-build/functions 2018-11-13 19:21:19 +0000
+++ live-build/functions 2018-11-28 08:47:44 +0000
@@ -373,6 +373,30 @@
373 distro-info --series="$LB_DISTRIBUTION" -r | awk '{ print $1 }'373 distro-info --series="$LB_DISTRIBUTION" -r | awk '{ print $1 }'
374}374}
375375
376# cribbed from cdimage, perhaps this should be a small helper script in germinate?
377add_inheritance () {
378 case " $inherit " in
379 *" $1 "*)
380 ;;
381 *)
382 inherit="${inherit:+$inherit }$1"
383 ;;
384 esac
385}
386
387expand_inheritance () {
388 for seed in $(grep "^$1:" config/germinate-output/structure | cut -d: -f2); do
389 expand_inheritance "$seed"
390 done
391 add_inheritance "$1"
392}
393
394inheritance () {
395 inherit=
396 expand_inheritance "$1"
397 echo "$inherit"
398}
399
376_snap_preseed() {400_snap_preseed() {
377 # Download the snap/assertion and add to the preseed401 # Download the snap/assertion and add to the preseed
378 local CHROOT_ROOT=$1402 local CHROOT_ROOT=$1
@@ -387,6 +411,12 @@
387411
388 # Download the snap & assertion412 # Download the snap & assertion
389 local snap_download_failed=0413 local snap_download_failed=0
414
415 # Preseed a snap only once
416 if [ -f ${snaps_dir}/${SNAP_NAME}_[0-9]*.snap ]; then
417 return
418 fi
419
390 chroot $CHROOT_ROOT sh -c "420 chroot $CHROOT_ROOT sh -c "
391 set -x;421 set -x;
392 cd /var/lib/snapd/seed;422 cd /var/lib/snapd/seed;
@@ -432,6 +462,10 @@
432 local account_key_assertion="$assertions_dir/account-key"462 local account_key_assertion="$assertions_dir/account-key"
433 local account_assertion="$assertions_dir/account"463 local account_assertion="$assertions_dir/account"
434464
465 if [ -d "$assertions_dir" ]; then
466 return
467 fi
468
435 mkdir -p "$assertions_dir"469 mkdir -p "$assertions_dir"
436 mkdir -p "$snaps_dir"470 mkdir -p "$snaps_dir"
437471
@@ -476,15 +510,10 @@
476 # used for the image's model assertion510 # used for the image's model assertion
477 local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic}511 local CUSTOM_BRAND_MODEL=${2:-generic:generic-classic}
478512
479 local seed_dir="$CHROOT_ROOT/var/lib/snapd/seed"
480 local snaps_dir="$seed_dir/snaps"
481
482 snap_prepare_assertions "$CHROOT_ROOT" "$CUSTOM_BRAND_MODEL"513 snap_prepare_assertions "$CHROOT_ROOT" "$CUSTOM_BRAND_MODEL"
483514
484 # Download the core snap515 # Download the core snap
485 if ! [ -f $snaps_dir/core_[0-9]*.snap ] ; then516 _snap_preseed $CHROOT_ROOT core stable
486 _snap_preseed $CHROOT_ROOT core stable
487 fi
488}517}
489518
490snap_preseed() {519snap_preseed() {
@@ -501,3 +530,166 @@
501 fi530 fi
502 _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL531 _snap_preseed $CHROOT_ROOT $SNAP $CHANNEL
503}532}
533
534snap_from_seed() {
535 local base_seed=$1
536 local out=$2
537 local all_snaps
538 local seeds_expanded
539
540 seeds_expanded=$(inheritance ${base_seed})
541 for seed in ${seeds_expanded}; do
542 echo "snap: considering ${seed}"
543 file=config/germinate-output/${seed}.snaps
544 [ -e "${file}" ] || continue
545 # extract the first column (snap package name) from germinate's output
546 # translate the human-readable "foo (classic)" into a
547 # more machine readable "foo/classic"
548 seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
549 for snap in ${seed_snaps}; do
550 echo "snap: found ${snap}"
551 all_snaps="${all_snaps:+${all_snaps} }${snap}"
552 done
553 done
554 if [ -n "${all_snaps}" ]; then
555 echo "${all_snaps}" > $out
556 fi
557}
558
559seed_from_task ()
560{
561 # Retrieve the name of the seed from a task name
562 local task=$1
563 local seed
564 local seedfile
565 local seedfiles
566
567 seedfile="$(grep -lE "^Task-Key: +${task}\$" config/germinate-output/*seedtext|head -1)"
568 if [ -n "$seedfile" ]; then
569 basename $seedfile .seedtext
570 return
571 fi
572
573 seedfiles="$(grep -lE "^Task-Per-Derivative: *1\$" config/germinate-output/*seedtext)"
574 if [ -n "$seedfiles" ]; then
575 for seed in $(echo $seedfiles | xargs basename -s .seedtext); do
576 if [ ${PROJECT}-${seed} = $task ]; then
577 echo ${seed}
578 return
579 fi
580 done
581 fi
582}
583
584list_packages_from_seed () {
585 # Store all packages for a given seed, including its seed dependency
586 # $1: Name of the seed to expand to a package list
587
588 local all_seeds="$(inheritance $1)"
589
590 for seed in $all_seeds; do
591 head -n-2 config/germinate-output/${seed}.seed|tail -n+3|awk '{print $1}'
592 done|sort -u
593}
594
595substract_package_lists() {
596 # Substract a package list from another
597 #
598 # $1 source package list
599 # $2 Package list to substract from source package list
600 local list1=$(mktemp)
601 local list2=$(mktemp)
602
603 list_packages_from_seed $1 > list1
604 list_packages_from_seed $2 > list2
605 comm -23 list1 list2
606
607 rm list1
608 rm list2
609}
610
611clean_debian_chroot() {
612 # remove crufty files that shouldn't be left in an image
613 rm -f chroot/var/cache/debconf/*-old chroot/var/lib/dpkg/*-old
614 Chroot chroot apt clean
615}
616
617configure_universe() {
618 if [ -f config/universe-enabled ]; then
619 # This is cargo-culted almost verbatim (with some syntax changes for
620 # preinstalled being slightly different in what it doesn't ask) from
621 # debian-installer's apt-setup:
622
623 cat > chroot/etc/apt/sources.list << EOF
624# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
625# newer versions of the distribution.
626deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted
627# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION main restricted
628
629## Major bug fix updates produced after the final release of the
630## distribution.
631deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
632# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates main restricted
633
634## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
635## team. Also, please note that software in universe WILL NOT receive any
636## review or updates from the Ubuntu security team.
637deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
638# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION universe
639deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
640# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates universe
641
642## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
643## team, and may not be under a free licence. Please satisfy yourself as to
644## your rights to use the software. Also, please note that software in
645## multiverse WILL NOT receive any review or updates from the Ubuntu
646## security team.
647deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
648# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION multiverse
649deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
650# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-updates multiverse
651
652## N.B. software from this repository may not have been tested as
653## extensively as that contained in the main release, although it includes
654## newer versions of some applications which may provide useful features.
655## Also, please note that software in backports WILL NOT receive any review
656## or updates from the Ubuntu security team.
657deb $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
658# deb-src $LB_PARENT_MIRROR_BINARY $LB_DISTRIBUTION-backports main restricted universe multiverse
659
660## Uncomment the following two lines to add software from Canonical's
661## 'partner' repository.
662## This software is not part of Ubuntu, but is offered by Canonical and the
663## respective vendors as a service to Ubuntu users.
664# deb http://archive.canonical.com/ubuntu $LB_DISTRIBUTION partner
665# deb-src http://archive.canonical.com/ubuntu $LB_DISTRIBUTION partner
666
667deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
668# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security main restricted
669deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
670# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security universe
671deb $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
672# deb-src $LB_PARENT_MIRROR_BINARY_SECURITY $LB_DISTRIBUTION-security multiverse
673EOF
674
675fi
676}
677
678configure_network_manager() {
679 # If the image pre-installs network-manager, let it manage all devices by
680 # default. Installing NM on an existing system only manages wifi and wwan via
681 # /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf. When setting
682 # the global backend to NM, netplan overrides that file.
683 if [ -d chroot/usr/lib/NetworkManager ]; then
684 echo "===== Enabling all devices in NetworkManager ===="
685 mkdir -p chroot/etc/netplan
686 cat <<EOF > chroot/etc/netplan/01-network-manager-all.yaml
687# Let NetworkManager manage all devices on this system
688network:
689 version: 2
690 renderer: NetworkManager
691EOF
692 else
693 echo "==== NetworkManager not installed ===="
694 fi
695}
504696
=== added file 'live-build/lb_binary_layered'
--- live-build/lb_binary_layered 1970-01-01 00:00:00 +0000
+++ live-build/lb_binary_layered 2018-11-28 08:47:44 +0000
@@ -0,0 +1,132 @@
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7## This is free software, and you are welcome to redistribute it
8## under certain conditions; see COPYING for details.
9
10
11set -e
12
13# Including common functions
14( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
15
16
17# Automatically populating config tree
18if [ -x auto/config ] && [ ! -e .build/config ]
19then
20 Echo_message "Automatically populating config tree."
21 lb config
22fi
23
24# Setting static variables
25DESCRIPTION="$(Echo 'build binary images')"
26HELP=""
27USAGE="${PROGRAM} [--force]"
28
29Arguments "${@}"
30
31# Reading configuration files
32Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
33Set_defaults
34
35# Setup cleanup function
36Setup_cleanup
37
38. config/functions
39
40build_layered_squashfs() {
41 local pass=$1 # install|install_subpass|install_subpass_subsubpass|…
42 local prevpass=$2 # install|install_subpass|…
43 local prefix=$3 # 01-|02-|…
44 local lowerlayers=$4
45 shift 4 # restore ${*}
46
47 # Cleanup root filesystem
48 lb binary_chroot ${*}
49
50 # Building squashfs filesystem & manifest
51 base="${PWD}/livecd.${PROJECT}.${prefix}${pass}"
52 squashfs_f="${base}.squashfs"
53
54 # We have already treated that pass
55 if [ -f "${squashfs_f}" ]; then
56 return
57 fi
58
59 if [ -n "${lowerlayers}" ]; then
60 mount_overlay ${lowerlayers} "chroot.${pass}/" chroot/
61 else
62 # first pass
63 rmdir chroot 2>/dev/null||true
64 ln -s "chroot.${pass}/" chroot
65 fi
66
67 # Full manifest until that PASS
68 squashfs_f_manifest="${base}.manifest"
69 create_manifest "chroot" "${squashfs_f_manifest}.full"
70
71 # Delta manifest
72 diff -NU0 ${PWD}/livecd.${PROJECT}.[0-9][0-9]-${prevpass}.manifest.full ${squashfs_f_manifest}.full|grep -v ^@ > $squashfs_f_manifest
73
74 squashfs_f_size="${base}.size"
75 du -B 1 -s "chroot.${pass}/" | cut -f1 > "${squashfs_f_size}"
76
77 (cd "chroot.${pass}/" &&
78 mksquashfs . ${squashfs_f} \
79 -no-progress -xattrs -comp xz )
80
81 if [ -n "${lowerlayers}" ]; then
82 umount chroot
83 else
84 rm chroot
85 mkdir chroot/
86 fi
87
88 # Handle direct sublayer of current one
89 # Extract the name of the pass corresponding to the sublayer
90 for subpass in $(ls -d chroot.${pass}_* 2>/dev/null | sed -e "s/chroot\.\(${pass}_[^_]\+\).*/\1/"); do
91 lowerlayers_for_subpass="chroot.${pass}:${lowerlayers}"
92 lowerlayers_for_subpass="${lowerlayers_for_subpass%:}"
93 build_layered_squashfs "${subpass}" "${pass}" "${prefix}" "${lowerlayers_for_subpass}" ${*}
94 done
95}
96
97CURPASS=1
98PREVPASS=""
99PASSPREFIX=""
100LOWER_LAYERS=""
101for _PASS in $PASSES
102do
103 PASSPREFIX="$(printf "%02g" $CURPASS)-"
104
105 build_layered_squashfs "${_PASS}" "${PREVPASS}" "$PASSPREFIX" "${LOWER_LAYERS}" ${*}
106
107 LOWER_LAYERS="chroot.${_PASS}:$LOWER_LAYERS"
108 LOWER_LAYERS="${LOWER_LAYERS%:}"
109 PREVPASS=${_PASS}
110 CURPASS=$(( CURPASS + 1 ))
111done
112
113# remount last "main" pass on chroot for lb binary
114mount_overlay "${LOWER_LAYERS}" "chroot.${_PASS}/" chroot/
115
116# Prepare initrd + kernel
117lb binary_linux-image ${*}
118
119umount chroot/
120
121# Full ISO manifest & size from last main PASS
122PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
123cp "livecd.${PROJECT}.${PASSPREFIX}${_PASS}.size" "$PREFIX.size"
124cp "livecd.${PROJECT}.${PASSPREFIX}${_PASS}.manifest.full" "$PREFIX.manifest"
125
126# Ubiquity-compatible removal manifest for ISO not using a layered-aware installer
127if [ -n "$(ls livecd.${PROJECT}.[0-9][0-9]-live.manifest.full 2>/dev/null)" ] && \
128 [ -n "$(ls livecd.${PROJECT}.[0-9][0-9]-install.manifest.full 2>/dev/null)" ]; then
129 echo "$(diff livecd.${PROJECT}.[0-9][0-9]-live.manifest.full livecd.${PROJECT}.[0-9][0-9]-install.manifest.full | awk '/^< / { print $2 }')" > livecd.${PROJECT}-manifest-remove
130fi
131
132chmod 644 *.squashfs *.manifest* *.size
0133
=== added file 'live-build/lb_chroot_layered'
--- live-build/lb_chroot_layered 1970-01-01 00:00:00 +0000
+++ live-build/lb_chroot_layered 2018-11-28 08:47:44 +0000
@@ -0,0 +1,246 @@
1#!/bin/sh
2
3## live-build(7) - System Build Scripts
4## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
5##
6## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7## This is free software, and you are welcome to redistribute it
8## under certain conditions; see COPYING for details.
9
10## This is a fork of lb_chroot for layered live system.
11## We don't want leaking host configuratino in each layer, and so,
12## we clean and setup the chroot each time.
13## In addition, we create the squashfs for each layer, but top one (live)
14## which still can be configured after lb chroot call.
15
16set -e
17
18# Including common functions
19( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
20
21# Automatically populating config tree
22if [ -x auto/config ] && [ ! -e .build/config ]
23then
24 Echo_message "Automatically populating config tree."
25 lb config
26fi
27
28# Setting static variables
29DESCRIPTION="$(Echo 'customize the Debian system')"
30HELP=""
31USAGE="${PROGRAM} [--force]"
32
33Arguments "${@}"
34
35# Reading configuration files
36Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
37Set_defaults
38
39# Setup cleanup function
40Setup_cleanup
41
42. config/functions
43
44lb_chroot_remove_packages() {
45 # Remove packages from the chroot specific to this layer
46 #
47 # $1: Name of the pass*
48 local pass=$1
49
50 Expand_packagelist "$(basename config/package-lists/*.removal-list.chroot_${pass})" "config/package-lists" \
51 >> chroot/root/packages.chroot.removal
52 Chroot chroot "xargs --arg-file=/root/packages.chroot.removal apt-get ${APT_OPTIONS} autoremove --purge"
53 rm -f chroot/root/packages.chroot.removal
54}
55
56# Create the snap list specific to this layer
57lb_chroot_snap_lists() {
58 local pass=$1
59 local prevpass=$2
60
61 # This assumes that the prefix is unique for a given project
62 local snap_for_pass=$(ls config/package-lists/*.snaplist.chroot_${pass}.full 2>/dev/null || true)
63 local snap_for_prevpass=$(ls config/package-lists/*.snaplist.chroot_${prevpass}.full 2>/dev/null || true)
64
65 if [ -z "${snap_for_pass}" ]; then
66 return
67 fi
68
69 if [ -z "${snap_for_prevpass}" ]; then
70 cp ${snap_for_pass} ${snap_for_pass%.full}
71 return
72 fi
73
74 # Generate a list of snaps added to a layer.
75 diff -NU0 ${snap_for_prevpass} ${snap_for_pass}|grep -Ev '^(---|\+\+\+|@@)'|cut -c2- > ${snap_for_pass%.full}
76}
77
78lb_chroot_install_snaps() {
79 # Prepare the snap environment and install snaps into a chroot
80 #
81 # $1: Name of the pass
82
83 local snaplist_file=$(ls config/package-lists/*.snaplist.chroot_${1} 2>/dev/null || true)
84
85 if [ -z "${snaplist_file}" ]; then
86 return
87 fi
88
89 snap_prepare chroot
90
91 while read snap; do
92 snap_preseed chroot "${snap}"
93 done < $snaplist_file
94}
95
96lb_chroot_includes() {
97 # Copying includes from pass subdirectory
98 local pass="$1"
99
100 if [ ! -d config/includes.chroot.${pass} ]; then
101 return
102 fi
103
104 cd config/includes.chroot.${pass}
105 find . | cpio -dmpu --no-preserve-owner "${OLDPWD}"/chroot
106 cd "${OLDPWD}"
107}
108
109create_chroot_pass() {
110 local pass=$1
111 local prevpass=$2
112 local lowerlayers=$3
113 local passtype=$4 # "first"|"last"|"" empty string
114 shift 4 # restore ${*}
115
116 # We have already treated that pass
117 if [ -d "chroot.${pass}/" ]; then
118 return
119 fi
120
121 export PASS=${pass}
122
123 if [ "${passtype}" != "first" ]; then
124 mkdir chroot.${pass}
125 mount_overlay ${lowerlayers} "chroot.${pass}/" chroot/
126 fi
127
128 # Configuring chroot
129 lb chroot_cache restore ${*}
130 lb chroot_devpts install ${*}
131 lb chroot_proc install ${*}
132 lb chroot_sysfs install ${*}
133 lb chroot_debianchroot install ${*}
134 lb chroot_dpkg install ${*}
135 lb chroot_tmpfs install ${*}
136 lb chroot_hosts install ${*}
137 lb chroot_resolv install ${*}
138 lb chroot_hostname install ${*}
139 lb chroot_apt install ${*}
140 # Note: this triggers an upgrade + dist-ugprade; which may impact sublayers with more
141 # diff content than desired. However, we still need to setup the archive and teardown
142 # for each layer.
143 # We could modify livebuild if necessary to have conditional upgrade (first pass only).
144 lb chroot_archives chroot install ${*}
145
146 if [ "${passtype}" = "first" ]; then
147 configure_universe
148 fi
149
150 # Customizing chroot
151 lb chroot_linux-image ${*}
152 lb chroot_preseed ${*}
153 lb chroot_early_hooks ${*}
154
155 lb chroot_package-lists ${pass} ${*}
156 lb chroot_install-packages ${pass} ${*}
157 lb_chroot_remove_packages ${pass} ${*}
158
159 # Snap management
160 lb_chroot_snap_lists ${pass} ${prevpass}
161 lb_chroot_install_snaps ${pass} ${*}
162
163 # Kernel should be in first layer
164 if [ "${passtype}" = "first" ]; then
165 configure_network_manager
166 Chroot chroot "dpkg -l linux-headers-3* linux-headers-4*" 2>/dev/null \
167 | awk '/^i/ {print $2}' > chroot.headers
168 for i in $(cat chroot.headers); do
169 Chroot chroot "apt-mark auto $i"
170 done
171 fi
172
173 Chroot chroot "apt-get --purge -y autoremove"
174
175 # Add live packages to top layer
176 if [ "${passtype}" = "last" ]; then
177 lb chroot_live-packages ${*}
178 fi
179
180 # Run includes by pass
181 lb_chroot_includes ${pass} ${*}
182
183 lb chroot_hooks ${*}
184 lb chroot_hacks ${*}
185 lb chroot_interactive ${*}
186
187 # Misc ubuntu cleanup and post-layer configuration
188 clean_debian_chroot
189 /usr/share/livecd-rootfs/minimize-manual chroot
190
191 Chroot chroot "dpkg-query -W" > chroot.packages.${pass}
192
193 # Deconfiguring chroot
194 lb chroot_archives chroot remove ${*}
195 lb chroot_apt remove ${*}
196 lb chroot_hostname remove ${*}
197 lb chroot_resolv remove ${*}
198 lb chroot_hosts remove ${*}
199 lb chroot_tmpfs remove ${*}
200 lb chroot_dpkg remove ${*}
201 lb chroot_debianchroot remove ${*}
202 lb chroot_sysfs remove ${*}
203 lb chroot_proc remove ${*}
204 lb chroot_devpts remove ${*}
205 lb chroot_cache save ${*}
206
207 if [ "${passtype}" = "first" ]; then
208 mv chroot chroot.${pass}
209 mkdir chroot
210 else
211 umount chroot
212 fi
213
214 # Handle direct sublayer of current one
215 # Extract the name of the pass corresponding to the sublayer
216 for subpass in $(ls config/package-lists/*list.chroot_${pass}_* 2>/dev/null | sed -e "s/.*list\.chroot_\(${pass}_[^_]\+\).*/\1/"); do
217 lowerlayers_for_subpass="chroot.${pass}:${lowerlayers}"
218 lowerlayers_for_subpass="${lowerlayers_for_subpass%:}"
219 create_chroot_pass "${subpass}" "${pass}" "${lowerlayers_for_subpass}" "" ${*}
220 done
221}
222
223PASSES="${PASSES:-install live}"
224CURPASS=1
225PREVPASS=""
226LASTPASS=$(echo $PASSES|wc -w)
227LOWER_LAYERS=""
228for _PASS in $PASSES
229do
230 PASSTYPE=""
231 if [ $CURPASS -eq 1 ]; then
232 PASSTYPE="first"
233 elif [ $CURPASS -eq $LASTPASS ]; then
234 PASSTYPE="last"
235 fi
236
237 create_chroot_pass "$_PASS" "$PREVPASS" "$LOWER_LAYERS" "$PASSTYPE" ${*}
238
239 LOWER_LAYERS="chroot.${_PASS}:$LOWER_LAYERS"
240 LOWER_LAYERS="${LOWER_LAYERS%:}"
241 PREVPASS=${_PASS}
242
243 CURPASS=$(( CURPASS + 1 ))
244done
245
246rmdir chroot

Subscribers

People subscribed via source and target branches