summaryrefslogtreecommitdiff
path: root/extensions/image-package-example
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/image-package-example')
-rw-r--r--extensions/image-package-example/README9
-rw-r--r--extensions/image-package-example/common.sh.in72
-rw-r--r--extensions/image-package-example/disk-install.sh.in51
-rw-r--r--extensions/image-package-example/make-disk-image.sh.in36
4 files changed, 0 insertions, 168 deletions
diff --git a/extensions/image-package-example/README b/extensions/image-package-example/README
deleted file mode 100644
index f6b66cd9..00000000
--- a/extensions/image-package-example/README
+++ /dev/null
@@ -1,9 +0,0 @@
-Image package example scripts
-=============================
-
-These are scripts used to create disk images or install the system onto
-an existing disk.
-
-This is also implemented independently for the rawdisk.write write
-extension; see writeexts.WriteExtension.create_local_system() for
-a similar, python implementation.
diff --git a/extensions/image-package-example/common.sh.in b/extensions/image-package-example/common.sh.in
deleted file mode 100644
index 9a7389a7..00000000
--- a/extensions/image-package-example/common.sh.in
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/false
-# Script library to be used by disk-install.sh and make-disk-image.sh
-
-status(){
- echo "$@"
-}
-
-info(){
- echo "$@" >&2
-}
-
-warn(){
- echo "$@" >&2
-}
-
-extract_rootfs(){
- tar -C "$1" -xf @@ROOTFS_TAR_PATH@@ .
-}
-
-make_disk_image(){
- truncate --size "$1" "$2"
-}
-
-format_disk(){
- local disk="$1"
- mkfs.ext4 -F -L rootfs "$disk"
-}
-
-install_fs_config(){
- local mountpoint="$1"
- local rootdisk="${2-/dev/vda}"
- cat >>"$mountpoint/etc/fstab" <<EOF
-$rootdisk / ext4 rw,errors=remount-ro 0 0
-EOF
- install -D -m 644 /proc/self/fd/0 "$mountpoint/boot/extlinux.conf" <<EOF
-DEFAULT baserock
-LABEL baserock
-SAY Booting Baserock
-LINUX /boot/vmlinuz
-APPEND root=$rootdisk
-EOF
-}
-
-install_bootloader(){
- local disk="$1"
- local mountpoint="$2"
- dd if=@@IMAGE_DIR@@/mbr.bin conv=notrunc bs=440 count=1 of="$disk"
- extlinux --install "$mountpoint/boot"
-}
-
-loop_file(){
- losetup --show --find "$1"
-}
-unloop_file(){
- #losetup --detach "$1"
- # unlooping handled by umount -d, for busybox compatibility
- true
-}
-
-temp_mount(){
- local mp="$(mktemp -d)"
- if ! mount "$@" "$mp"; then
- rmdir "$mp"
- return 1
- fi
- echo "$mp"
-}
-untemp_mount(){
- # Unmount and detach in one step for busybox compatibility
- umount -d "$1"
- rmdir "$1"
-}
diff --git a/extensions/image-package-example/disk-install.sh.in b/extensions/image-package-example/disk-install.sh.in
deleted file mode 100644
index bc8e0e67..00000000
--- a/extensions/image-package-example/disk-install.sh.in
+++ /dev/null
@@ -1,51 +0,0 @@
-#!/bin/sh
-# Script for writing the system to an existing disk.
-# This formats the disk, extracts the rootfs to it, installs the
-# bootloader, and ensures there's appropriate configuration for the
-# bootloader, kernel and userland to agree what the rootfs is.
-
-set -eu
-
-usage(){
- 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
-EOF
-}
-
-. @@SCRIPT_DIR@@/common.sh
-
-if [ "$#" -lt 1 -o "$#" -gt 2 ]; then
- usage
- exit 1
-fi
-
-DISK="$1"
-TARGET_DISK="${1-/dev/sda}"
-
-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"
-)
diff --git a/extensions/image-package-example/make-disk-image.sh.in b/extensions/image-package-example/make-disk-image.sh.in
deleted file mode 100644
index 61264fa0..00000000
--- a/extensions/image-package-example/make-disk-image.sh.in
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-# Script for writing the system to a disk image file.
-# This creates a file of the right size, attaches it to a loop device,
-# then hands the rest of the work off to disk-install.sh
-
-usage(){
- cat <<EOF
-usage: $0 FILENAME SIZE [TARGET_DISK]
-
-FILENAME: Location to write the disk image to
-SIZE: Size to create the disk image with
-TARGET_DISK: What the disk will appear as on the target machine
-EOF
-}
-
-. @@SCRIPT_DIR@@/common.sh
-
-if [ "$#" -lt 2 -o "$#" -gt 3 ]; then
- usage
- exit 1
-fi
-
-DISK_IMAGE="$1"
-DISK_SIZE="$2"
-TARGET_DISK="${3-/dev/vda}"
-
-make_disk_image "$DISK_SIZE" "$DISK_IMAGE"
-
-(
- LOOP="$(loop_file "$DISK_IMAGE")"
- set +e
- @@SCRIPT_DIR@@/disk-install.sh "$DISK_IMAGE" "$TARGET_DISK"
- ret="$?"
- unloop_file "$LOOP"
- exit "$ret"
-)