mirror of
https://git.launchpad.net/livecd-rootfs
synced 2025-04-01 13:21:14 +00:00
Fix snap-seed-parse to take filename argument instead of printing to
stdout
This commit is contained in:
parent
44f8ddaa25
commit
f661d400a1
7
debian/changelog
vendored
7
debian/changelog
vendored
@ -1,3 +1,10 @@
|
|||||||
|
livecd-rootfs (2.542.1) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
|
* Fix snap-seed-parse to take filename argument instead of printing to
|
||||||
|
stdout
|
||||||
|
|
||||||
|
-- Cody Shepherd <cody.shepherd@canonical.com> Tue, 13 Nov 2018 10:44:19 -0700
|
||||||
|
|
||||||
livecd-rootfs (2.542.1) UNRELEASED; urgency=medium
|
livecd-rootfs (2.542.1) UNRELEASED; urgency=medium
|
||||||
|
|
||||||
* Ensure pre-seeded snaps are now published in the image manifests.
|
* Ensure pre-seeded snaps are now published in the image manifests.
|
||||||
|
@ -551,7 +551,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"
|
./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
|
||||||
|
@ -49,7 +49,7 @@ create_manifest() {
|
|||||||
echo "create_manifest chroot_root: ${chroot_root}"
|
echo "create_manifest chroot_root: ${chroot_root}"
|
||||||
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
dpkg-query --show --admindir="${chroot_root}/var/lib/dpkg" > ${target_file}
|
||||||
echo "create_manifest call to dpkg-query finished."
|
echo "create_manifest call to dpkg-query finished."
|
||||||
./config/snap-seed-parse "${chroot_root}" >> ${target_file}
|
./config/snap-seed-parse "${chroot_root}" "${target_file}"
|
||||||
echo "create_manifest call to snap_seed_parse finished."
|
echo "create_manifest call to snap_seed_parse finished."
|
||||||
echo "create_manifest finished"
|
echo "create_manifest finished"
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,35 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Usage: snap-seed-parse ${chroot_dir} > somefile.manifest
|
Usage: snap-seed-parse [${chroot_dir}] <output file>
|
||||||
|
|
||||||
This script looks for a seed.yaml path in the given root directory, parsing
|
This script looks for a seed.yaml path in the given root directory, parsing
|
||||||
it and printing generated manifest lines to stdout for easy redirection.
|
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 re
|
import argparse
|
||||||
import sys
|
|
||||||
import yaml
|
|
||||||
import os.path
|
import os.path
|
||||||
|
import re
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
sys.stderr.write("snap-seed-parse: {}\n".format(msg))
|
print("snap-seed-parse: {}".format(msg))
|
||||||
|
|
||||||
|
|
||||||
log("Parsing seed.yaml")
|
log("Parsing seed.yaml")
|
||||||
|
|
||||||
CHROOT_ROOT = sys.argv[1] if len(sys.argv) > 1 and len(sys.argv[1]) > 0 \
|
parser = argparse.ArgumentParser()
|
||||||
else ''
|
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
|
# Trim any trailing slashes for correct appending
|
||||||
log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
|
log("CHROOT_ROOT: {}".format(CHROOT_ROOT))
|
||||||
@ -43,14 +52,17 @@ else:
|
|||||||
with open(YAML_PATH, 'r') as fh:
|
with open(YAML_PATH, 'r') as fh:
|
||||||
yaml_lines = yaml.safe_load(fh)['snaps']
|
yaml_lines = yaml.safe_load(fh)['snaps']
|
||||||
|
|
||||||
# Loop over dict items, outputting one manifest line from each triplet
|
log('Writing manifest to {}'.format(FNAME))
|
||||||
|
|
||||||
|
with open(FNAME, 'a+') as fh:
|
||||||
for item in yaml_lines:
|
for item in yaml_lines:
|
||||||
filestring = item['file']
|
filestring = item['file']
|
||||||
# Pull the revision number off the file name
|
# Pull the revision number off the file name
|
||||||
revision = filestring[filestring.rindex('_')+1:]
|
revision = filestring[filestring.rindex('_')+1:]
|
||||||
revision = re.sub(r'[^0-9]', '', revision)
|
revision = re.sub(r'[^0-9]', '', revision)
|
||||||
print("{}{}\t{}\t{}".format(LINE_PREFIX,
|
fh.write("{}{}\t{}\t{}\n".format(LINE_PREFIX,
|
||||||
item['name'],
|
item['name'],
|
||||||
item['channel'],
|
item['channel'],
|
||||||
revision,
|
revision,
|
||||||
))
|
))
|
||||||
|
log('Manifest output finished.')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user