diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..754f7c9 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,28 @@ +# Build Scripts + +## build.sh + +``` +This script builds a bootable ubuntu ISO image + +Supported commands : setup_host debootstrap run_chroot build_iso + +Syntax: ./build.sh [start_cmd] [-] [end_cmd] + run from start_cmd to end_end + if start_cmd is omitted, start from first command + if end_cmd is omitted, end with last command + enter single cmd to run the specific command + enter '-' as only argument to run all commands +``` + +## How to Customize + +1. Copy the `default_config.sh` file to `config.sh` in the scripts directory. +2. Make any necessary edits there, the script will pick up `config.sh` over `default_config.sh`. + +## How to Update + +The configuration script is versioned with the variable CONFIG_FILE_VERSION. Any time that the configuration +format is changed in `default_config.sh`, this value is bumped. Once this happens `config.sh` must be updated manually +from the default file to ensure the new/changed variables are as desired. Once the merge is complete the `config.sh` file's +CONFIG_FILE_VERSION should match the default and the build will run. \ No newline at end of file diff --git a/scripts/build.sh b/scripts/build.sh index 59593f5..18fdbc7 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -88,7 +88,7 @@ function load_config() { # Verify that necessary configuration values are set and they are valid function check_config() { local expected_config_version - expected_config_version="0.1" + expected_config_version="0.2" if [[ "$CONFIG_FILE_VERSION" != "$expected_config_version" ]]; then >&2 echo "Invalid or old config version $CONFIG_FILE_VERSION, expected $expected_config_version. Please update your configuration file from the default." @@ -105,7 +105,7 @@ function setup_host() { function debootstrap() { echo "=====> running debootstrap ... will take a couple of minutes ..." - sudo debootstrap --arch=amd64 --variant=minbase focal chroot http://us.archive.ubuntu.com/ubuntu/ + sudo debootstrap --arch=amd64 --variant=minbase $TARGET_UBUNTU_VERSION chroot http://us.archive.ubuntu.com/ubuntu/ } function run_chroot() { @@ -257,7 +257,7 @@ EOF -as mkisofs \ -iso-level 3 \ -full-iso9660-filenames \ - -volid "Ubuntu from scratch" \ + -volid "$TARGET_NAME" \ -eltorito-boot boot/grub/bios.img \ -no-emul-boot \ -boot-load-size 4 \ @@ -269,7 +269,7 @@ EOF -e EFI/efiboot.img \ -no-emul-boot \ -append_partition 2 0xef isolinux/efiboot.img \ - -output "../ubuntu-from-scratch.iso" \ + -output "$SCRIPT_DIR/$TARGET_NAME.iso" \ -m "isolinux/efiboot.img" \ -m "isolinux/bios.img" \ -graft-points \ diff --git a/scripts/chroot_build.sh b/scripts/chroot_build.sh index a46e93e..7a1a8fd 100755 --- a/scripts/chroot_build.sh +++ b/scripts/chroot_build.sh @@ -56,17 +56,17 @@ function setup_host() { echo "=====> running setup_host ..." cat < /etc/apt/sources.list -deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse -deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse +deb http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION main restricted universe multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION main restricted universe multiverse -deb http://us.archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse -deb-src http://us.archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse +deb http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION-security main restricted universe multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION-security main restricted universe multiverse -deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse -deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse +deb http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION-updates main restricted universe multiverse +deb-src http://us.archive.ubuntu.com/ubuntu/ $TARGET_UBUNTU_VERSION-updates main restricted universe multiverse EOF - echo "ubuntu-fs-live" > /etc/hostname + echo "$TARGET_NAME" > /etc/hostname # we need to install systemd first, to configure machine id apt-get update @@ -98,7 +98,7 @@ function install_pkg() { echo "=====> running install_pkg ... will take a long time ..." apt-get -y upgrade - # install live linux packages + # install live packages apt-get install -y \ sudo \ ubuntu-standard \ @@ -112,8 +112,10 @@ function install_pkg() { net-tools \ wireless-tools \ wpagui \ - locales \ - linux-generic + locales + + # install kernel + apt-get install -y --install-recommends $TARGET_KERNEL_PACKAGE # graphic installer - ubiquity apt-get install -y \ diff --git a/scripts/default_config.sh b/scripts/default_config.sh index 45cec5b..d76a0c3 100644 --- a/scripts/default_config.sh +++ b/scripts/default_config.sh @@ -5,9 +5,17 @@ # Usage: Copy this file to config.sh and make changes there. Keep this file (default_config.sh) as-is # so that subsequent changes can be easily merged from upstream. Keep all customiations in config.sh -# Used to version the configuration. If breaking changes occur, manual -# updates to this file from the default may be necessary. -export CONFIG_FILE_VERSION="0.1" +# The version of Ubuntu to generate. Successfully tested: focal, groovy +# See https://wiki.ubuntu.com/DevelopmentCodeNames for details +export TARGET_UBUNTU_VERSION="focal" + +# The packaged version of the Linux kernel to install on target image. +# See https://wiki.ubuntu.com/Kernel/LTSEnablementStack for details +export TARGET_KERNEL_PACKAGE="linux-generic" + +# The file (no extension) of the ISO containing the generated disk image, +# the volume id, and the hostname of the live environment are set from this name. +export TARGET_NAME="ubuntu-from-scratch" # The text label shown in GRUB for booting into the live environment export GRUB_LIVEBOOT_LABEL="Try Ubuntu FS without installing" @@ -43,4 +51,8 @@ function customize_image() { gnome-sudoku \ aisleriot \ hitori -} \ No newline at end of file +} + +# Used to version the configuration. If breaking changes occur, manual +# updates to this file from the default may be necessary. +export CONFIG_FILE_VERSION="0.2"