From 391439d44c3b3a04a7f1e0b5531e8adb7a43c87c Mon Sep 17 00:00:00 2001 From: Michael Hudson-Doyle Date: Mon, 20 Sep 2021 13:14:50 +1200 Subject: [PATCH] Record information about locale support (in particular, whether to install langpacks and which languages have pre-baked squashfses). --- debian/changelog | 7 +++ live-build/auto/config | 53 ++++++++++++------- live-build/lb_binary_layered | 8 ++- .../ubuntu-server-minimal.catalog-in.yaml | 1 + ...rver-minimal.ubuntu-server.catalog-in.yaml | 1 + update-source-catalog | 3 ++ 6 files changed, 53 insertions(+), 20 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0744d5c3..97683374 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +livecd-rootfs (2.739) UNRELEASED; urgency=medium + + * Record information about locale support (in particular, whether to install + langpacks and which languages have pre-baked squashfses). + + -- Michael Hudson-Doyle Mon, 20 Sep 2021 10:31:41 +1200 + livecd-rootfs (2.737) impish; urgency=medium * Generate source catalogs for the desktop canary build. diff --git a/live-build/auto/config b/live-build/auto/config index 8f413397..be53bebb 100755 --- a/live-build/auto/config +++ b/live-build/auto/config @@ -204,12 +204,28 @@ add_snap () done } +get_seeded_languages () { + # We assume any seed name of the form ${no_lang_seed}-${foo} where + # ${foo} is only two or three characters long is a default language + # seed. + langs='' + for no_lang_seed in "$@"; do + seed_regex="${no_lang_seed}"'-[^-.]{2,3}$' + for seed in $(ls config/germinate-output | grep -E "${seed_regex}"); do + lang=$(echo "${seed}" | grep -oE '[^-.]{2,3}$') + langs="$langs $lang" + done + done + echo $langs | tr ' ' '\n' | sort -u | tr '\n' ' ' +} + derive_language_layers () { # create special layers for each default language # # $1 base pass # $2 base seed (without any languages) # $3 default language seed + # $4 space separated list of default languages # e.g.: # derive_language_layers minimal desktop-minimal desktop-minimal-default-languages # derive_language_layers minimal.standard desktop desktop-default-languages @@ -243,29 +259,26 @@ derive_language_layers () { # support for all languages from the base layer. We also create a # layer than has support for all languages removed, which can be used # for the base of an install for a non-default language. - local pass base_pass=$1 no_lang_seed=$2 def_lang_seed=$3 + local pass base_pass=$1 no_lang_seed=$2 def_lang_seed=$3 langs=$4 _check_immutable_passes_to_layers _check_layers_only_API "derive_language_layers" - pass=$base_pass.no-languages - _register_pass ${pass} - # Remove all packages from the default language seed that are not in - # the no_lang_seed from the no-languages layer. - subtract_package_lists ${def_lang_seed} ${no_lang_seed} >> config/package-lists/livecd-rootfs.removal-list.chroot_${pass} - - # We assume any seed name of the form ${no_lang_seed}-${foo} where - # ${foo} is only two or three characters long is a default language - # seed. - seed_regex="${no_lang_seed}"'-[^-.]{2,3}$' - - for seed in $(ls config/germinate-output | grep -E "${seed_regex}"); do - lang=$(echo "${seed}" | grep -oE '[^-.]{2,3}$') - pass="${1}.${lang}" + for lang in $langs; do + pass="${base_pass}.${lang}" _register_pass ${pass} # Remove packages from the default language seed that are not # in the language specific seed from the language specific layer. - subtract_package_lists ${def_lang_seed} ${seed} >> config/package-lists/livecd-rootfs.removal-list.chroot_$pass + # I find this expression helps a little to make this make sense: + # ((base) + (en fr de)) - ( (en fr de) - (fr)) == (base + fr) + # `layer will all langs' `def_lang_seed' `lang' `what we want to install' + subtract_package_lists ${def_lang_seed} ${no_lang_seed}-${lang} >> config/package-lists/livecd-rootfs.removal-list.chroot_$pass done + + no_lang_pass=$base_pass.no-languages + _register_pass ${no_lang_pass} + # Remove all packages from the default language seed that are not in + # the no_lang_seed from the no-languages layer. + subtract_package_lists ${def_lang_seed} ${no_lang_seed} >> config/package-lists/livecd-rootfs.removal-list.chroot_${no_lang_pass} } add_chroot_hook () @@ -650,8 +663,10 @@ case $PROJECT in remove_package minimal.standard.live ubiquity-frontend-gtk add_snap minimal.standard.live ubuntu-desktop-installer/classic - derive_language_layers minimal desktop-minimal desktop-minimal-default-languages - derive_language_layers minimal.standard desktop desktop-default-languages + seeded_langs="$(get_seeded_languages desktop-minimal desktop)" + echo "$seeded_langs" | tr ' ' ',' > config/seeded-languages + derive_language_layers minimal desktop-minimal desktop-minimal-default-languages "$seeded_langs" + derive_language_layers minimal.standard desktop desktop-default-languages "$seeded_langs" cat <<-EOF > config/minimal.catalog-in.yaml name: "Ubuntu Desktop (minimized)" description: >- @@ -659,6 +674,7 @@ case $PROJECT in id: ubuntu-desktop-minimal type: fsimage variant: desktop + locale_support: langpack EOF cat <<-EOF > config/minimal.standard.catalog-in.yaml name: "Ubuntu Desktop" @@ -667,6 +683,7 @@ case $PROJECT in id: ubuntu-desktop type: fsimage variant: desktop + locale_support: langpack default: yes EOF /usr/share/livecd-rootfs/checkout-translations-branch \ diff --git a/live-build/lb_binary_layered b/live-build/lb_binary_layered index 5777741a..424f7001 100755 --- a/live-build/lb_binary_layered +++ b/live-build/lb_binary_layered @@ -141,10 +141,14 @@ build_layered_squashfs () { if [ -f config/$pass.catalog-in.yaml ]; then echo "Expanding catalog entry template for $pass" - /usr/share/livecd-rootfs/update-source-catalog --output livecd.${PROJECT}.install-sources.yaml \ + usc_opts="--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 + --translations config/catalog-translations" + if [ -f config/seeded-languages ]; then + usc_opts="$usc_opts --langs $(cat config/seeded-languages)" + fi + /usr/share/livecd-rootfs/update-source-catalog $usc_opts else echo "No catalog entry template for $pass" fi 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 9400bf1e..d45ef488 100644 --- a/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml +++ b/live-build/ubuntu-server/ubuntu-server-minimal.catalog-in.yaml @@ -5,3 +5,4 @@ description: >- id: ubuntu-server-minimal type: fsimage variant: server +locale_support: none 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 index 722fc92a..4f8177f0 100644 --- 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 @@ -6,3 +6,4 @@ id: ubuntu-server default: yes type: fsimage-layered variant: server +locale_support: locale-only diff --git a/update-source-catalog b/update-source-catalog index 50aa3a16..6616d609 100755 --- a/update-source-catalog +++ b/update-source-catalog @@ -13,6 +13,7 @@ parser.add_argument('--size', required=True) parser.add_argument('--squashfs', required=True) parser.add_argument('--translations', required=True) parser.add_argument('--template', required=True) +parser.add_argument('--langs', default=None) opts = parser.parse_args(sys.argv[1:]) @@ -47,6 +48,8 @@ for mo in glob.glob(os.path.join(opts.translations, '*.mo')): if t_description != en_description: lang = os.path.splitext(os.path.basedescription(mo))[0] template['description'][lang] = t_description + if opts.langs is not None: + template['preinstalled_langs'] = opts.langs.split(',') output.append(template)