mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-05-11 02:41:33 +00:00
Backport adding snaps to image manifests (LP: #1805497)
This commit is contained in:
parent
c381065c00
commit
1f05fbea69
@ -441,6 +441,7 @@ fi
|
|||||||
|
|
||||||
# '--initramfs none' produces different manifest names.
|
# '--initramfs none' produces different manifest names.
|
||||||
if [ -e "binary/$INITFS/filesystem.packages" ]; then
|
if [ -e "binary/$INITFS/filesystem.packages" ]; then
|
||||||
|
./config/snap-seed-parse "chroot/" "binary/${INITFS}/filesystem.packages"
|
||||||
ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
|
ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
|
||||||
chmod 644 "$PREFIX.manifest"
|
chmod 644 "$PREFIX.manifest"
|
||||||
fi
|
fi
|
||||||
|
@ -35,6 +35,7 @@ fi
|
|||||||
|
|
||||||
mkdir -p config
|
mkdir -p config
|
||||||
cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
|
cp -af /usr/share/livecd-rootfs/live-build/functions config/functions
|
||||||
|
cp -af /usr/share/livecd-rootfs/live-build/snap-seed-parse.py config/snap-seed-parse
|
||||||
|
|
||||||
mkdir -p config/package-lists
|
mkdir -p config/package-lists
|
||||||
|
|
||||||
|
@ -43,6 +43,17 @@ create_empty_disk_image() {
|
|||||||
dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
|
dd if=/dev/zero of="$1" bs=1 count=0 seek="${imagesize}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
create_manifest() {
|
||||||
|
local chroot_root=${1}
|
||||||
|
local target_file=${2}
|
||||||
|
echo "create_manifest chroot_root: ${chroot_root}"
|
||||||
|
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
||||||
|
echo "create_manifest call to dpkg-query finished."
|
||||||
|
./config/snap-seed-parse "${chroot_root}" "${target_file}"
|
||||||
|
echo "create_manifest call to snap_seed_parse finished."
|
||||||
|
echo "create_manifest finished"
|
||||||
|
}
|
||||||
|
|
||||||
make_ext4_partition() {
|
make_ext4_partition() {
|
||||||
device="$1"
|
device="$1"
|
||||||
label=${fs_label:+-L "${fs_label}"}
|
label=${fs_label:+-L "${fs_label}"}
|
||||||
|
68
live-build/snap-seed-parse.py
Executable file
68
live-build/snap-seed-parse.py
Executable file
@ -0,0 +1,68 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
"""
|
||||||
|
Usage: snap-seed-parse [${chroot_dir}] <output file>
|
||||||
|
|
||||||
|
This script looks for a seed.yaml path in the given root directory, parsing
|
||||||
|
it and appending the parsed lines to the given output file.
|
||||||
|
|
||||||
|
The $chroot_dir argument is optional and will default to the empty string.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import os.path
|
||||||
|
import re
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def log(msg):
|
||||||
|
print("snap-seed-parse: {}".format(msg))
|
||||||
|
|
||||||
|
|
||||||
|
log("Parsing seed.yaml")
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('chroot', nargs='?', default='',
|
||||||
|
help='root dir for the chroot from which to generate the '
|
||||||
|
'manifest')
|
||||||
|
parser.add_argument('file', help='Output manifest to this file')
|
||||||
|
|
||||||
|
ARGS = parser.parse_args()
|
||||||
|
CHROOT_ROOT = ARGS.chroot
|
||||||
|
FNAME = ARGS.file
|
||||||
|
|
||||||
|
# Trim any trailing slashes for correct appending
|
||||||
|
log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
|
||||||
|
if len(CHROOT_ROOT) > 0 and CHROOT_ROOT[-1] == '/':
|
||||||
|
CHROOT_ROOT = CHROOT_ROOT[:-1]
|
||||||
|
|
||||||
|
# This is where we expect to find the seed.yaml file
|
||||||
|
YAML_PATH = CHROOT_ROOT + '/var/lib/snapd/seed/seed.yaml'
|
||||||
|
|
||||||
|
# Snaps are prepended with this string in the manifest
|
||||||
|
LINE_PREFIX = 'snap:'
|
||||||
|
|
||||||
|
log("yaml path: {}".format(YAML_PATH))
|
||||||
|
if not os.path.isfile(YAML_PATH):
|
||||||
|
log("WARNING: yaml path not found; no seeded snaps found.")
|
||||||
|
exit(0)
|
||||||
|
else:
|
||||||
|
log("yaml path found.")
|
||||||
|
|
||||||
|
with open(YAML_PATH, 'r') as fh:
|
||||||
|
yaml_lines = yaml.safe_load(fh)['snaps']
|
||||||
|
|
||||||
|
log('Writing manifest to {}'.format(FNAME))
|
||||||
|
|
||||||
|
with open(FNAME, 'a+') as fh:
|
||||||
|
for item in yaml_lines:
|
||||||
|
filestring = item['file']
|
||||||
|
# Pull the revision number off the file name
|
||||||
|
revision = filestring[filestring.rindex('_')+1:]
|
||||||
|
revision = re.sub(r'[^0-9]', '', revision)
|
||||||
|
fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX,
|
||||||
|
item['name'],
|
||||||
|
item['channel'],
|
||||||
|
revision,
|
||||||
|
))
|
||||||
|
log('Manifest output finished.')
|
@ -98,6 +98,12 @@ ${IMAGE_STR}
|
|||||||
GRUB_PRELOAD_MODULES="${GRUB_PRELOAD_MODULES:-$grub_modules}"
|
GRUB_PRELOAD_MODULES="${GRUB_PRELOAD_MODULES:-$grub_modules}"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
# This call to populate the package manifest is added here to capture
|
||||||
|
# grub-efi packages that otherwise would not make it into the base
|
||||||
|
# manifest. filesystem.packages is moved into place via symlinking to
|
||||||
|
# livecd.ubuntu-cpc.manifest by live-build/auto/build after lb_binary runs
|
||||||
|
create_manifest "mountpoint" "binary/boot/filesystem.packages"
|
||||||
|
|
||||||
chroot mountpoint grub-install "${loop_device}" \
|
chroot mountpoint grub-install "${loop_device}" \
|
||||||
--boot-directory=/boot \
|
--boot-directory=/boot \
|
||||||
--efi-directory=/boot/efi \
|
--efi-directory=/boot/efi \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user