diff --git a/builder/builder.sh b/builder/builder.sh index 4957236..14013c0 100755 --- a/builder/builder.sh +++ b/builder/builder.sh @@ -1,8 +1,4 @@ -<<<<<<< HEAD #!/usr/bin/env bash -======= -#!/bin/bash ->>>>>>> parent of 0ac565d (start of builder :3) SCRIPT_DIR=$(dirname "$0") VERSION=1 @@ -10,7 +6,6 @@ source $SCRIPT_DIR/functions.sh echo "KVS Shim Builder v$VERSION" echo "-=-=-=-=-=-=-=-=-=-" -<<<<<<< HEAD echo "fdisk, e2fsprogs required. must be ran as root" echo "-=-=-=-=-=-=-=-=-=-" [ "$EUID" -ne 0 ] && error "Please run as root" @@ -76,57 +71,3 @@ fdisk -l "$IMG" log "Done building!" -======= -[ "$EUID" -ne 0 ] && error "Please run KVS builder as root" -[ "$1" == "" ] && error "Shim not specified, remember, usage is $0 " -echo "Requirements: cgpt, e2fsprogs, sgdisk" -echo "-=-=-=-=-=-=-=-=-=-" - -STATE_SIZE=$((4 * 1024 * 1024)) # 4MiB -STATE_MNT=$(mktemp -d) -LOOPDEV=$(losetup -f) - -create_stateful() { - log "Creating KVS/Stateful partition" - local final_sector=$(get_final_sector "$LOOPDEV") - local sector_size=$(get_sector_size "$LOOPDEV") - cgpt add "$LOOPDEV" -i 1 -b $((final_sector + 1)) -s $((STATE_SIZE / sector_size)) -t data -l KVS - partx -u -n 1 "$LOOPDEV" - mkfs.ext4 -F -L KVS "${LOOPDEV}p1" &> /dev/null - - sync - sleep 0.2 - - mount "${LOOPDEV}p1" "$STATE_MNT" - touch "$STATE_MNT/dev_image/etc/lsb-factory" - chmod -R +x "$STATE_MNT" - - umount "$STATE_MNT" - rmdir "$STATE_MNT" -} - -shrink_root() { - log "Shrinking ROOT" - - enable_rw_mount "${LOOPDEV}p3" - suppress e2fsck -fy "${LOOPDEV}p3" - suppress resize2fs -M "${LOOPDEV}p3" - disable_rw_mount "${LOOPDEV}p3" - - local sector_size=$(get_sector_size "$LOOPDEV") - local block_size=$(tune2fs -l "${LOOPDEV}p3" | grep "Block size" | awk '{print $3}') - local block_count=$(tune2fs -l "${LOOPDEV}p3" | grep "Block count" | awk '{print $3}') - - log_debug "sector size: ${sector_size}, block size: ${block_size}, block count: ${block_count}" - - local original_sectors=$("$CGPT" show -i 3 -s -n -q "$LOOPDEV") - local original_bytes=$((original_sectors * sector_size)) - - local resized_bytes=$((block_count * block_size)) - local resized_sectors=$((resized_bytes / sector_size)) - - log_info "Resizing ROOT from $(format_bytes ${original_bytes}) to $(format_bytes ${resized_bytes})" - "$CGPT" add -i 3 -s "$resized_sectors" "$LOOPDEV" - partx -u -n 3 "$LOOPDEV" -} ->>>>>>> parent of 0ac565d (start of builder :3) diff --git a/builder/functions.sh b/builder/functions.sh index f5c45ad..176c84e 100644 --- a/builder/functions.sh +++ b/builder/functions.sh @@ -2,16 +2,19 @@ COLOR_RESET="\033[0m" COLOR_BLACK_B="\033[1;30m" +COLOR_RED="\033[0;31m" COLOR_RED_B="\033[1;31m" COLOR_GREEN="\033[0;32m" COLOR_GREEN_B="\033[1;32m" COLOR_YELLOW="\033[0;33m" COLOR_YELLOW_B="\033[1;33m" +COLOR_BLUE="\033[0;34m" COLOR_BLUE_B="\033[1;34m" +COLOR_MAGENTA="\033[0;35m" COLOR_MAGENTA_B="\033[1;35m" +COLOR_CYAN="\033[0;36m" COLOR_CYAN_B="\033[1;36m" -<<<<<<< HEAD readlink /proc/$$/exe | grep -q bash || error "You MUST execute this with Bash!" safesync(){ @@ -35,16 +38,12 @@ cleanup(){ losetup -d "$LOOPDEV" losetup -D #in case of cmd above failing -======= -log(){ - printf '${COLOR_GREEN}Info: %b${COLOR_RESET}\n' "$*" ->>>>>>> parent of 0ac565d (start of builder :3) } error(){ - printf '${COLOR_RED_B}ERR: &b${COLOR_RESET}\n' "$*" + printf "${COLOR_RED_B}ERR: %b${COLOR_RESET}\n" "$*" >&2 || : + printf "${COLOR_RED}Exiting... ${COLOR_RESET}\n" >&2 || : exit 1 -<<<<<<< HEAD } suppress() { @@ -229,6 +228,3 @@ squash_partitions() { suppress sfdisk -N "$part" --move-data "$1" <<<"+,-" || : done } -======= -} ->>>>>>> parent of 0ac565d (start of builder :3)