path: root/imgpkg/
diff options
authorRichard Maw <>2014-03-18 16:42:03 +0000
committerRichard Maw <>2014-03-20 16:33:34 +0000
commitfcf5150e927147bbce338a61101ccbb3d760f07c (patch)
tree371099eaffd417f61878f0c756a50964c35ba2b6 /imgpkg/
parent31aadea7e49617a783f924fe373e642c88157a2b (diff)
Add write extension for making a package that allows deferred instansiationbaserock/richardmaw/S10721-img-pkg
This is a write extension for making a package that can be used to install the produced system. Ideally we'd instead have Baserock everywhere to do the deployment, but we need to support this workflow until that is possible. It gets configured with a script templates that get filled in with the paths to the rootfs tarball as @@ROOTFS_TAR_PATH@@, script directory as @@SCRIPT_DIR@@ and copied boot-files as @@IMAGE_DIR@@. Scripts to include are specified as a relative path to your morphologies repository, separated by : characters in the INCLUDE_SCRIPTS variable. If another separator is convenient, it can be specified in the INCLUDE_SCRIPTS_SEPARATOR variable, which has the same semantics as the shell IFS variable. Other files needed to create the disk image, such as bootloader image files can be specified in BOOTLOADER_BLOBS, relative to the root of the rootfs, separated with similar rules to INCLUDE_SCRIPTS. The name of the rootfs tarball, the scripts subdirectory and the bootloader blobs subdirectory can be changed with the ROOTFS_TAR, SCRIPT_SUBDIR and IMAGE_SUBDIR variables, but the default should be sufficient. The compression of the rootfs tarball, and the package tarball can be specified by specifying a shell command that reads the uncompressed tarball from stdin and writes to stdout in the ROOTFS_COMPRESS and OUTPUT_COMPRESS variables.
Diffstat (limited to 'imgpkg/')
1 files changed, 47 insertions, 0 deletions
diff --git a/imgpkg/ b/imgpkg/
new file mode 100644
index 00000000..60b3f465
--- /dev/null
+++ b/imgpkg/
@@ -0,0 +1,47 @@
+set -eu
+ cat <<EOF
+usage: $0 DISK [TARGET_DISK]
+DISK: Where the disk appears on your development machine
+TARGET_DISK: What the disk will appear as on the target machine
+. @@SCRIPT_DIR@@/
+if [ "$#" -lt 1 -o "$#" -gt 2 ]; then
+ usage
+ exit 1
+status Formatting "$DISK" as ext4
+format_disk "$DISK"
+ info Mounting "$DISK"
+ MP="$(temp_mount -t ext4 "$DISK")"
+ info Mounted "$DISK" to "$MP"
+ set +e
+ (
+ set -e
+ info Copying rootfs onto disk
+ extract_rootfs "$MP"
+ info Configuring disk paths
+ install_fs_config "$MP" "$TARGET_DISK"
+ info Installing bootloader
+ install_bootloader "$DISK" "$MP"
+ )
+ ret="$?"
+ if [ "$ret" != 0 ]; then
+ warn Filling rootfs failed with "$ret"
+ fi
+ info Unmounting "$DISK" from "$MP" and removing "$MP"
+ untemp_mount "$MP"
+ exit "$ret"