|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# check for root permissions |
| 6 | +if [[ "$(id -u)" != 0 ]]; then |
| 7 | + echo "E: Requires root permissions" > /dev/stderr |
| 8 | + exit 1 |
| 9 | +fi |
| 10 | + |
| 11 | +# get config |
| 12 | +if [ -n "$1" ]; then |
| 13 | + CONFIG_FILE="$1" |
| 14 | +else |
| 15 | + CONFIG_FILE="etc/terraform.conf" |
| 16 | +fi |
| 17 | +BASE_DIR="$PWD" |
| 18 | +source "$BASE_DIR"/"$CONFIG_FILE" |
| 19 | + |
| 20 | +echo -e " |
| 21 | +#----------------------# |
| 22 | +# INSTALL DEPENDENCIES # |
| 23 | +#----------------------# |
| 24 | +" |
| 25 | + |
| 26 | +apt-get update |
| 27 | +apt-get install -y live-build patch gnupg2 binutils zstd |
| 28 | + |
| 29 | +# The Debian repositories don't seem to have the `ubuntu-keyring` or `ubuntu-archive-keyring` packages |
| 30 | +# anymore, so we add the archive keys manually. This may need to be updated if Ubuntu changes their signing keys |
| 31 | +# To get the current key ID, find `ubuntu-keyring-xxxx-archive.gpg` in /etc/apt/trusted.gpg.d on a running |
| 32 | +# system and run `gpg --keyring /etc/apt/trusted.gpg.d/ubuntu-keyring-xxxx-archive.gpg --list-public-keys ` |
| 33 | +gpg --homedir /tmp --no-default-keyring --keyring /etc/apt/trusted.gpg --recv-keys --keyserver keyserver.ubuntu.com F6ECB3762474EDA9D21B7022871920D1991BC93C |
| 34 | + |
| 35 | +# TODO: Remove this once debootstrap can natively build noble images: |
| 36 | +ln -sfn /usr/share/debootstrap/scripts/gutsy /usr/share/debootstrap/scripts/noble |
| 37 | + |
| 38 | +build () { |
| 39 | + BUILD_ARCH="$1" |
| 40 | + |
| 41 | + mkdir -p "$BASE_DIR/tmp/$BUILD_ARCH" |
| 42 | + cd "$BASE_DIR/tmp/$BUILD_ARCH" || exit |
| 43 | + |
| 44 | + # remove old configs and copy over new |
| 45 | + rm -rf config auto |
| 46 | + cp -r "$BASE_DIR"/etc/* . |
| 47 | + # Make sure conffile specified as arg has correct name |
| 48 | + cp -f "$BASE_DIR"/"$CONFIG_FILE" terraform.conf |
| 49 | + |
| 50 | + # copy appcenter list & key |
| 51 | + if [ "$INCLUDE_APPCENTER" = "yes" ]; then |
| 52 | + cp "config/appcenter/appcenter.list.binary" "config/archives/appcenter.list.binary" |
| 53 | + cp "config/appcenter/appcenter.key.binary" "config/archives/appcenter.key.binary" |
| 54 | + fi |
| 55 | + |
| 56 | + echo -e " |
| 57 | +#------------------# |
| 58 | +# LIVE-BUILD CLEAN # |
| 59 | +#------------------# |
| 60 | +" |
| 61 | + lb clean |
| 62 | + |
| 63 | + echo -e " |
| 64 | +#-------------------# |
| 65 | +# LIVE-BUILD CONFIG # |
| 66 | +#-------------------# |
| 67 | +" |
| 68 | + lb config |
| 69 | + |
| 70 | + echo -e " |
| 71 | +#------------------# |
| 72 | +# LIVE-BUILD BUILD # |
| 73 | +#------------------# |
| 74 | +" |
| 75 | + lb build |
| 76 | + |
| 77 | + echo -e " |
| 78 | +#---------------------------# |
| 79 | +# MOVE OUTPUT TO BUILDS DIR # |
| 80 | +#---------------------------# |
| 81 | +" |
| 82 | + |
| 83 | + YYYYMMDD="$(date +%Y%m%d)" |
| 84 | + OUTPUT_DIR="$BASE_DIR/builds/$BUILD_ARCH" |
| 85 | + mkdir -p "$OUTPUT_DIR" |
| 86 | + FNAME="elementaryos-$VERSION-$CHANNEL-$BUILD_ARCH.$YYYYMMDD$OUTPUT_SUFFIX" |
| 87 | + mv "$BASE_DIR/tmp/$BUILD_ARCH/live-image-$BUILD_ARCH.hybrid.iso" "$OUTPUT_DIR/${FNAME}.iso" |
| 88 | + |
| 89 | + # cd into output to so {FNAME}.sha256.txt only |
| 90 | + # includes the filename and not the path to |
| 91 | + # our file. |
| 92 | + cd $OUTPUT_DIR |
| 93 | + md5sum "${FNAME}.iso" | tee "${FNAME}.md5.txt" |
| 94 | + sha256sum "${FNAME}.iso" | tee "${FNAME}.sha256.txt" |
| 95 | + cd $BASE_DIR |
| 96 | +} |
| 97 | + |
| 98 | +# remove old builds before creating new ones |
| 99 | +rm -rf "$BASE_DIR"/builds |
| 100 | + |
| 101 | +if [[ "$ARCH" == "all" ]]; then |
| 102 | + build amd64 |
| 103 | + build i386 |
| 104 | +else |
| 105 | + build "$ARCH" |
| 106 | +fi |
0 commit comments