From 10288220fc4497080d2c7af29c3730651419b9d7 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 9 Aug 2021 13:57:07 +1200 Subject: [PATCH 1/4] add a script to checkout a translations branch and compile the po files into mo files --- checkout-translations-branch | 22 ++++++++++++++++++++++ debian/control | 2 ++ debian/install | 1 + 3 files changed, 25 insertions(+) create mode 100755 checkout-translations-branch diff --git a/checkout-translations-branch b/checkout-translations-branch new file mode 100755 index 00000000..cd235f8b --- /dev/null +++ b/checkout-translations-branch @@ -0,0 +1,22 @@ +#!/bin/sh + +set -eux + +branch=$1 +target="$(readlink -f "${2}")" + +tmpdir="$(mktemp -d)" +cd "${tmpdir}" + +cleanup () { + rm -rf "${tmpdir}" +} + +trap cleanup EXIT + +mkdir -p $target + +bzr branch $branch checkout +for po in checkout/*.po; do + msgfmt "${po}" -o "${target}/$(basename "${po}" .po).mo" +done diff --git a/debian/control b/debian/control index 45dcf710..ecbec401 100644 --- a/debian/control +++ b/debian/control @@ -11,6 +11,7 @@ Architecture: any Depends: ${misc:Depends}, apt-utils, attr, + bzr, debootstrap, distro-info, dosfstools, @@ -18,6 +19,7 @@ Depends: ${misc:Depends}, gdisk, genisoimage, germinate (>= 1.25.1), + gettext, git, gnupg, grep-dctrl, diff --git a/debian/install b/debian/install index 818c3d11..500ef28d 100644 --- a/debian/install +++ b/debian/install @@ -4,3 +4,4 @@ get-ppa-fingerprint usr/share/livecd-rootfs minimize-manual usr/share/livecd-rootfs magic-proxy usr/share/livecd-rootfs lp-in-release usr/share/livecd-rootfs +checkout-translations-branch usr/share/livecd-rootfs From fb8c69453044f7518b6480e66a734217dc039bda Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 9 Aug 2021 13:58:05 +1200 Subject: [PATCH 2/4] add script to fill out a template install source description --- debian/install | 1 + update-source-catalog | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100755 update-source-catalog diff --git a/debian/install b/debian/install index 500ef28d..d2e56bb2 100644 --- a/debian/install +++ b/debian/install @@ -5,3 +5,4 @@ minimize-manual usr/share/livecd-rootfs magic-proxy usr/share/livecd-rootfs lp-in-release usr/share/livecd-rootfs checkout-translations-branch usr/share/livecd-rootfs +update-source-catalog usr/share/livecd-rootfs diff --git a/update-source-catalog b/update-source-catalog new file mode 100755 index 00000000..63e53e6d --- /dev/null +++ b/update-source-catalog @@ -0,0 +1,65 @@ +#!/usr/bin/python3 + +import argparse +import gettext +import glob +import os +import sys +import yaml + +parser = argparse.ArgumentParser() +parser.add_argument('--output', required=True) +parser.add_argument('--size', required=True) +parser.add_argument('--squashfs', required=True) +parser.add_argument('--translations', required=True) +parser.add_argument('--template', required=True) + +opts = parser.parse_args(sys.argv[1:]) + +if os.path.exists(opts.output): + with open(opts.output) as fp: + output = yaml.safe_load(fp) +else: + output = [] + + +with open(opts.template) as fp: + template = yaml.safe_load(fp) + + +template['size'] = int(opts.size) +template['path'] = opts.squashfs + +en_name = template['name'] +en_description = template['description'] + +template['name'] = {'en': en_name} +template['description'] = {'en': en_description} + +for mo in glob.glob(os.path.join(opts.translations, '*.mo')): + with open(mo, 'rb') as fp: + t = gettext.GNUTranslations(fp=fp) + t_name = t.gettext(en_name) + if t_name != en_name: + lang = os.path.splitext(os.path.basename(mo))[0] + template['name'][lang] = t_name + t_description = t.gettext(en_description) + if t_description != en_description: + lang = os.path.splitext(os.path.basedescription(mo))[0] + template['description'][lang] = t_description + +output.append(template) + +default_count = 0 +for entry in output: + if entry.get('default', False): + default_count += 1 + + +if default_count > 1: + print("Too many defaults in source catalog!") + sys.exit(1) + + +with open(opts.output, 'w') as fp: + yaml.dump(output, fp) From cda8c920dd10796b9b1fe8faa53273ff4888d737 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 9 Aug 2021 13:59:23 +1200 Subject: [PATCH 3/4] create source catalogs for live server install sources --- debian/changelog | 6 ++++++ live-build/auto/config | 4 ++++ live-build/lb_binary_layered | 7 +++++++ .../ubuntu-server/ubuntu-server-minimal.catalog-in.yaml | 8 ++++++++ .../ubuntu-server-minimal.ubuntu-server.catalog-in.yaml | 8 ++++++++ 5 files changed, 33 insertions(+) create mode 100644 live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml create mode 100644 live-build/ubuntu-server/ubuntu-server-minimal.ubuntu-server.catalog-in.yaml diff --git a/debian/changelog b/debian/changelog index 4e464bd0..a9ce8096 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +livecd-rootfs (2.734) UNRELEASED; urgency=medium + + * Create source catalogs for the installable live server layers. + + -- Michael Hudson-Doyle Tue, 03 Aug 2021 16:34:57 +1200 + livecd-rootfs (2.733) impish; urgency=medium [ Michael Hudson-Doyle ] diff --git a/live-build/auto/config b/live-build/auto/config index 45bf095d..32cebd0b 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -810,6 +810,10 @@ case $PROJECT in add_package ubuntu-server-minimal.ubuntu-server.installer.$flavor $kernel_metapkg LIVE_PASSES="${LIVE_PASSES:+$LIVE_PASSES }ubuntu-server-minimal.ubuntu-server.installer.$flavor" done + + /usr/share/livecd-rootfs/checkout-translations-branch \ + lp:~canonical-foundations/subiquity/translations-export \ + config/catalog-translations ;; *) echo "unrecognized subproject for server: '$SUBPROJECT'" diff --git a/live-build/lb_binary_layered b/live-build/lb_binary_layered index acd6f591..af029c05 100755 --- a/live-build/lb_binary_layered +++ b/live-build/lb_binary_layered @@ -138,6 +138,13 @@ build_layered_squashfs () { fi create_squashfs "overlay.${pass}/" ${squashfs_f} + + if [ -f config/$pass.catalog-in.yaml ]; then + /usr/share/livecd-rootfs/update-source-catalog --output livecd.${PROJECT}.install-sources.yaml \ + --template config/$pass.catalog-in.yaml \ + --size $(du -B 1 -s chroot/ | cut -f1) --squashfs ${pass}.squashfs \ + --translations config/catalog-translations + fi fi if [ -n "$lowerdirs" ]; then diff --git a/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml b/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml new file mode 100644 index 00000000..7e092963 --- /dev/null +++ b/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml @@ -0,0 +1,8 @@ +name: "Ubuntu Server (minimized)" +description: >- + This version has been customized to have a small runtime footprint + in order to increase workload density in environments where humans + are not expected to log in. +id: ubuntu-server-minimal +type: fsimage +variant: server diff --git a/live-build/ubuntu-server/ubuntu-server-minimal.ubuntu-server.catalog-in.yaml b/live-build/ubuntu-server/ubuntu-server-minimal.ubuntu-server.catalog-in.yaml new file mode 100644 index 00000000..722fc92a --- /dev/null +++ b/live-build/ubuntu-server/ubuntu-server-minimal.ubuntu-server.catalog-in.yaml @@ -0,0 +1,8 @@ +name: "Ubuntu Server" +description: >- + The default install contains a curated set of packages that provide + a comfortable experience for operating your server. +id: ubuntu-server +default: yes +type: fsimage-layered +variant: server From 021c8e063cec50efb8adbb376d83716cce04a2b1 Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Wed, 18 Aug 2021 08:15:14 +1200 Subject: [PATCH 4/4] better minimal ubuntu server description --- live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml b/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml index 7e092963..03e60fd1 100644 --- a/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml +++ b/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml @@ -1,8 +1,7 @@ name: "Ubuntu Server (minimized)" description: >- This version has been customized to have a small runtime footprint - in order to increase workload density in environments where humans - are not expected to log in. + in environments where humans are not expected to log in id: ubuntu-server-minimal type: fsimage variant: server