Missing changes.

ui-by-default-debug
Łukasz 'sil2100' Zemczak 2 years ago
parent 71b7bed6ce
commit e06c03f4a8

@ -0,0 +1,86 @@
#!/usr/bin/python3
import argparse
import glob
import os
import re
p = argparse.ArgumentParser()
p.add_argument('output_dir')
p.add_argument('flavour')
p.add_argument('task')
p.add_argument('what', choices=['packages', 'snaps'])
args = p.parse_args()
if args.what == 'snaps':
ext = '.snaps'
else:
ext = ''
# begin copy/paste from ubuntu-archive-publishing's generate_extra_overrides.
def parseTaskHeaders(seedtext):
"""Parse a seed for Task headers.
seedtext is a file-like object. Return a dictionary of Task headers,
with keys canonicalised to lower-case.
"""
task_headers = {}
task_header_regex = re.compile(
r"task-(.*?):(.*)", flags=re.IGNORECASE)
for line in seedtext:
match = task_header_regex.match(line)
if match is not None:
key, value = match.groups()
task_headers[key.lower()] = value.strip()
return task_headers
def getTaskSeeds(task_headers, seedname):
"""Return the list of seeds used to generate a task from this seed.
The list of packages in this task comes from this seed plus any
other seeds listed in a Task-Seeds header.
"""
scan_seeds = set([seedname])
if "seeds" in task_headers:
scan_seeds.update(task_headers["seeds"].split())
return sorted(scan_seeds)
# end copy/paste from ubuntu-archive-publishing's generate_extra_overrides.
# This is not quite the same as the one in generate_extra_overrides,
# because for seeds that do not have flavour specific names, the Task
# override is only generated for the Ubuntu flavour rather than
# redundantly doing it for each flavour.
def getTaskName(task_headers, flavour, seedname):
"""Work out the name of the Task to be generated from this seed.
If there is a Task-Name header, it wins; otherwise, seeds with a
Task-Per-Derivative get put in an appropriate namespace. Other seeds
have a task name that matches the seed name.
"""
if "name" in task_headers:
return task_headers["name"]
elif "per-derivative" in task_headers:
return "%s-%s" % (flavour, seedname)
else:
return seedname
for seedtext in glob.glob(f'{args.output_dir}/*.seedtext'):
hs = parseTaskHeaders(open(seedtext))
if not hs:
continue
seedname = os.path.splitext(os.path.basename(seedtext))[0]
tn = getTaskName(hs, args.flavour, seedname)
if tn != args.task:
continue
for seed in getTaskSeeds(hs, seedname):
for line in open(f'{args.output_dir}/{seed}{ext}'):
if re.match('^[a-z0-9]', line):
name = line.split()[0]
if args.what == 'snaps' and '(classic)' in line:
name += '/classic'
print(name)
break
else:
raise Exception("did not find task %r" % (args.task,))

@ -12,16 +12,13 @@ loop_raw=
backing_img=
clean_loops() {
local kpartx_ret
local kpartx_stdout
if [ -n "${backing_img}" ]; then
if [ -n "${loop_device}" ]; then
# If something just finished writing to the device or a
# partition (e.g. the zerofree in umount_partition) udev might
# still be processing the device.
udevadm settle
sync
kpartx -v -d "${backing_img}"
losetup -v -d "${loop_device}"
unset backing_img
fi
@ -65,18 +62,17 @@ mount_image() {
trap clean_loops EXIT
backing_img="$1"
local rootpart="$2"
kpartx_mapping="$(kpartx -s -v -a ${backing_img})"
loop_device=$(losetup --show -f -P -v ${backing_img})
udevadm settle
# Find the loop device
loop_p1="$(echo -e ${kpartx_mapping} | head -n1 | awk '{print$3}')"
loop_device="/dev/${loop_p1%p[0-9]*}"
if [ ! -b ${loop_device} ]; then
echo "unable to find loop device for ${backing_img}"
exit 1
fi
# Find the rootfs location
rootfs_dev_mapper="/dev/mapper/${loop_p1%%[0-9]}${rootpart}"
rootfs_dev_mapper="${loop_device}p${rootpart}"
if [ ! -b "${rootfs_dev_mapper}" ]; then
echo "${rootfs_dev_mapper} is not a block device";
exit 1
@ -213,7 +209,7 @@ mount_disk_image() {
mount_image ${disk_image} 1
mount_partition "${rootfs_dev_mapper}" $mountpoint
local uefi_dev="/dev/mapper${loop_device///dev/}p15"
local uefi_dev="${loop_device}p15"
if [ -b ${uefi_dev} -a -e $mountpoint/boot/efi ]; then
mount "${uefi_dev}" $mountpoint/boot/efi
fi
@ -254,7 +250,7 @@ umount_partition() {
umount_disk_image() {
mountpoint="$1"
local uefi_dev="/dev/mapper${loop_device///dev/}p15"
local uefi_dev="${loop_device}p15"
if [ -e "$mountpoint/boot/efi" -a -b "$uefi_dev" ]; then
# zero fill free space in UEFI partition
cat < /dev/zero > "$mountpoint/boot/efi/bloat_file" 2> /dev/null || true
@ -770,56 +766,6 @@ snap_validate_seed() {
fi
}
snap_from_seed() {
local base_seed=$1
local out=$2
local all_snaps
local seeds_expanded
seeds_expanded=$(inheritance ${base_seed})
for seed in ${seeds_expanded}; do
echo "snap: considering ${seed}"
file=config/germinate-output/${seed}.snaps
[ -e "${file}" ] || continue
# extract the first column (snap package name) from germinate's output
# translate the human-readable "foo (classic)" into a
# more machine readable "foo/classic"
seed_snaps=$(sed -rn '1,/-----/d;/-----/,$d; s/(.*) \|.*/\1/; s, \(classic\),/classic,; p' "${file}")
for snap in ${seed_snaps}; do
echo "snap: found ${snap}"
all_snaps="${all_snaps:+${all_snaps} }${snap}"
done
done
if [ -n "${all_snaps}" ]; then
echo "${all_snaps}" > $out
fi
}
seed_from_task ()
{
# Retrieve the name of the seed from a task name
local task=$1
local seed
local seedfile
local seedfiles
seedfile="$(grep -lE "^Task-Key: +${task}\$" config/germinate-output/*seedtext|head -1)"
if [ -n "$seedfile" ]; then
basename $seedfile .seedtext
return
fi
seedfiles="$(grep -lE "^Task-Per-Derivative: *1\$" config/germinate-output/*seedtext)"
if [ -n "$seedfiles" ]; then
for seed in $(echo $seedfiles | xargs basename -s .seedtext); do
if [ ${PROJECT}-${seed} = $task ]; then
echo ${seed}
return
fi
done
fi
}
list_packages_from_seed () {
# Store all packages for a given seed, including its seed dependency
# $1: Name of the seed to expand to a package list
@ -999,7 +945,7 @@ configure_network_manager() {
# default. Installing NM on an existing system only manages wifi and wwan via
# /usr/lib/NetworkManager/conf.d/10-globally-managed-devices.conf. When setting
# the global backend to NM, netplan overrides that file.
if [ -e chroot/usr/sbin/NetworkManager -a ! -f chroot/etc/netplan/01-network-manager-all.yaml ]; then
if [ -e chroot/usr/sbin/NetworkManager -a ! -f chroot/etc/netplan/01-network-manager-all.yaml -a "$SUBPROJECT" != "desktop-preinstalled" ]; then
echo "===== Enabling all devices in NetworkManager ===="
mkdir -p chroot/etc/netplan
cat <<EOF > chroot/etc/netplan/01-network-manager-all.yaml
@ -1008,17 +954,18 @@ network:
version: 2
renderer: NetworkManager
EOF
# inform cloud-init of the same (LP: #1982855)
mkdir -p chroot/etc/cloud/cloud.cfg.d
cat <<EOF > chroot/etc/cloud/cloud.cfg.d/99-installer-use-networkmanager.cfg
${AUTOMATION_HEADER}
# Let NetworkManager manage all devices on this system
system_info:
network:
renderers: ['network-manager']
activators: ['network-manager']
EOF
# Do not limit cloud-init renderers to network-manager as suggested
# in LP: #1982855 because subiquity needs to render full networking
# in ephemeral boot time when autoinstall.network is provided.
# Neither subiquity nor netplan is aware of /etc/NetworkManager config
# artifacts emmitted by cloud-init. It's best if cloud-init reports
# network config directly to /etc/netplan with the configured netplan
# backend: NetworkManager per 01-network-manager-all.yaml above.
# cloud-init's default renderer discovery will prefer netplan.
# Any time subiquity needs to write and apply network config
# it disables all previous network config in /etc/netplan so
# any previous 50-cloud-init.yaml will be rendered inert.
# Position cloud-init.service After=NetworkManager.service.
# (LP: #2008952).

@ -116,7 +116,9 @@ build_layered_squashfs () {
create_manifest "chroot" "${squashfs_f_manifest}.full"
# Delta manifest
diff -NU0 ${PWD}/livecd.${PROJECT_FULL}.$(get_parent_pass $pass).manifest.full ${squashfs_f_manifest}.full|grep -v ^@ > $squashfs_f_manifest
diff -NU0 ${PWD}/livecd.${PROJECT_FULL}.$(get_parent_pass $pass).manifest.full ${squashfs_f_manifest}.full|grep -v ^@ > $squashfs_f_manifest || true
echo "Delta manifest:"
cat $squashfs_f_manifest
squashfs_f_size="${base}.size"
du -B 1 -s "overlay.${pass}/" | cut -f1 > "${squashfs_f_size}"

Loading…
Cancel
Save