mkimage.sh: fixed for new json standard

This commit is contained in:
Harald Hoyer 2018-11-20 11:07:20 +01:00
parent 1e5e5bd550
commit 46e37e8993

View file

@ -74,20 +74,15 @@ done
SOURCE=$(readlink -e "$1") SOURCE=$(readlink -e "$1")
IMAGE=$(readlink -f "$2") IMAGE=$(readlink -f "$2")
BASEURL=${SOURCE%/*}
if ! [[ -d $SOURCE ]]; then NAME="$(jq -r '.name' "$SOURCE")"
NAME="$(jq -r '.name' "$SOURCE")"
SOURCE="${SOURCE%/*}/$(jq -r '.name' "$SOURCE")-$(jq -r '.version' "$SOURCE")"
else
NAME="$(jq -r '.name' "$SOURCE"/release.json)"
fi
if ! [[ -d $SOURCE ]] || ! [[ $IMAGE ]]; then if ! [[ -f $SOURCE ]] || ! [[ $IMAGE ]]; then
usage usage
exit 1 exit 1
fi fi
[[ $TMPDIR ]] || TMPDIR=/var/tmp [[ $TMPDIR ]] || TMPDIR=/var/tmp
readonly TMPDIR="$(realpath -e "$TMPDIR")" readonly TMPDIR="$(realpath -e "$TMPDIR")"
[ -d "$TMPDIR" ] || { [ -d "$TMPDIR" ] || {
@ -115,11 +110,11 @@ trap '
# clean up after ourselves no matter how we die. # clean up after ourselves no matter how we die.
trap 'exit 1;' SIGINT trap 'exit 1;' SIGINT
ROOT_HASH=$(jq -r '.roothash' "$SOURCE"/release.json) ROOT_HASH=$(jq -r '.roothash' "$SOURCE")
ROOT_UUID=${ROOT_HASH:32:8}-${ROOT_HASH:40:4}-${ROOT_HASH:44:4}-${ROOT_HASH:48:4}-${ROOT_HASH:52:12} ROOT_UUID=${ROOT_HASH:32:8}-${ROOT_HASH:40:4}-${ROOT_HASH:44:4}-${ROOT_HASH:48:4}-${ROOT_HASH:52:12}
ROOT_IMG="${BASEURL}/$(jq -r '.name' "$SOURCE")-${ROOT_HASH}.img"
EFITAR="${BASEURL}/$(jq -r '.name' "$SOURCE")-${ROOT_HASH}-efi.tgz"
# ------------------------------------------------------------------------------
# Testdisk
# create GPT table with EFI System Partition # create GPT table with EFI System Partition
if ! [[ -b "${IMAGE}" ]]; then if ! [[ -b "${IMAGE}" ]]; then
@ -164,27 +159,32 @@ fi
if ! [[ $UPDATE ]]; then if ! [[ $UPDATE ]]; then
mkfs.fat -nEFI -F32 ${DEV_PART}1 mkfs.fat -nEFI -F32 ${DEV_PART}1
fi fi
mkdir "$MY_TMPDIR"/boot mkdir "$MY_TMPDIR"/efi
mount "${DEV_PART}1" "$MY_TMPDIR"/boot mount "${DEV_PART}1" "$MY_TMPDIR"/efi
mkdir -p "$MY_TMPDIR"/boot/EFI/Boot pushd "$MY_TMPDIR"
mkdir -p "$MY_TMPDIR"/boot/EFI/FedoraBook
tar xzf "${EFITAR}"
mkdir -p efi/EFI/Boot
if [[ $USE_EFISHELL ]]; then if [[ $USE_EFISHELL ]]; then
[[ -e "${SOURCE}"/efi/startup.nsh ]] && cp "${SOURCE}"/efi/startup.nsh "$MY_TMPDIR"/boot/ [[ -e efi/efi/${NAME}/startup.nsh ]] && cp efi/efi/${NAME}/startup.nsh efi/
[[ -e "${SOURCE}"/efi/LockDown.efi ]] && cp "${SOURCE}"/efi/LockDown.efi "$MY_TMPDIR"/boot/ [[ -e efi/efi/${NAME}/LockDown.efi ]] && cp efi/efi/${NAME}/LockDown.efi efi/
cp "${SOURCE}"/efi/Shell.efi "$MY_TMPDIR"/boot/EFI/Boot/bootx64.efi cp efi/efi/${NAME}/Shell.efi efi/EFI/Boot/bootx64.efi
cp "$SOURCE"/efi/EFI/${NAME}/bootx64-$ROOT_HASH.efi "$MY_TMPDIR"/boot/EFI/FedoraBook/1.efi cp efi/efi/${NAME}/bootx64-${ROOT_HASH}.efi efi/efi/${NAME}/1.efi
else else
cp "$SOURCE"/efi/EFI/${NAME}/bootx64-$ROOT_HASH.efi "$MY_TMPDIR"/boot/EFI/Boot/bootx64.efi cp efi/efi/${NAME}/bootx64-${ROOT_HASH}.efi efi/efi/${NAME}/1.efi
cp "$SOURCE"/efi/EFI/${NAME}/bootx64-$ROOT_HASH.efi "$MY_TMPDIR"/boot/EFI/FedoraBook/1.efi cp efi/efi/${NAME}/bootx64-${ROOT_HASH}.efi efi/EFI/Boot/bootx64.efi
fi fi
umount "$MY_TMPDIR"/boot umount "$MY_TMPDIR"/efi
popd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# root1 # root1
dd bs=4096 conv=fsync if="$SOURCE"/root.img of=${DEV_PART}2 status=progress dd bs=4096 conv=fsync if="$ROOT_IMG" of=${DEV_PART}2 status=progress
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# data # data