mirror of
https://github.com/system76/firmware-open.git
synced 2025-07-02 20:33:24 +00:00
scripts: Split creating USB image to separate script
The USB image is not a required output, but becomes half of the total size of the build artifacts as it creates copies of the firmware images. Move the logic to a separate script so that CI will not contain it, but users can create the image after building the firmware. ./scripts/build.sh <model> ./scripts/usb.sh <model> Reduces the size of the ZIP archive created by Jenkins by ~50%. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
parent
8aa7244fe7
commit
618a266e70
2 changed files with 51 additions and 27 deletions
|
@ -32,7 +32,6 @@ mkdir -p "${BUILD}"
|
|||
|
||||
UEFIPAYLOAD="${BUILD}/UEFIPAYLOAD.fd"
|
||||
COREBOOT="${BUILD}/firmware.rom"
|
||||
USB="${BUILD}/usb.img"
|
||||
EDK2_ARGS=(
|
||||
-D SHELL_TYPE=NONE
|
||||
-D SOURCE_DEBUG_ENABLE=FALSE
|
||||
|
@ -91,30 +90,4 @@ then
|
|||
"${BUILD}/ec.rom"
|
||||
fi
|
||||
|
||||
if [ "${MODEL}" != "qemu" ]
|
||||
then
|
||||
# Rebuild firmware-update
|
||||
export BASEDIR="system76_${MODEL}_${VERSION}"
|
||||
pushd apps/firmware-update >/dev/null
|
||||
make "build/x86_64-unknown-uefi/boot.img"
|
||||
cp -v "build/x86_64-unknown-uefi/boot.img" "${USB}.partial"
|
||||
popd >/dev/null
|
||||
|
||||
# Copy firmware to USB image
|
||||
mmd -i "${USB}.partial@@1M" "::${BASEDIR}/firmware"
|
||||
mcopy -v -i "${USB}.partial@@1M" "${COREBOOT}" "::${BASEDIR}/firmware/firmware.rom"
|
||||
if [ -e "${BUILD}/ec.rom" ]
|
||||
then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${BUILD}/ec.rom" "::${BASEDIR}/firmware/ec.rom"
|
||||
elif [ -e "${MODEL_DIR}/ec.rom" ]
|
||||
then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${MODEL_DIR}/ec.rom" "::${BASEDIR}/firmware/ec.rom"
|
||||
fi
|
||||
if [ -e "${MODEL_DIR}/uecflash.efi" ]
|
||||
then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${MODEL_DIR}/uecflash.efi" "::${BASEDIR}/firmware/uecflash.efi"
|
||||
fi
|
||||
mv -v "${USB}.partial" "${USB}"
|
||||
fi
|
||||
|
||||
echo "Built '${VERSION}' for '${MODEL}'"
|
||||
|
|
51
scripts/usb.sh
Executable file
51
scripts/usb.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Create a USB image file that can be written to a USB flash drive to update
|
||||
# firmware on another computer.
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "$0 <model>" >&2
|
||||
exit 1
|
||||
fi
|
||||
MODEL="$1"
|
||||
|
||||
if [ "${MODEL}" = "qemu" ]; then
|
||||
echo "can't build USB image for flashing QEMU" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "models/${MODEL}" ]; then
|
||||
echo "model '${MODEL}' not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
MODEL_DIR="$(realpath "models/${MODEL}")"
|
||||
|
||||
DATE="$(git show --format="%cd" --date="format:%Y-%m-%d" --no-patch --no-show-signature)"
|
||||
REV="$(git describe --always --dirty --abbrev=7)"
|
||||
VERSION="${DATE}_${REV}"
|
||||
|
||||
BUILD="$(realpath "build/${MODEL}")"
|
||||
if [ ! -e "${BUILD}/firmware.rom" ]; then
|
||||
echo "'${BUILD}/firmware.rom' not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
USB="${BUILD}/usb.img"
|
||||
|
||||
# Rebuild firmware-update
|
||||
export BASEDIR="system76_${MODEL}_${VERSION}"
|
||||
make -C apps/firmware-update "build/x86_64-unknown-uefi/boot.img"
|
||||
cp -v "apps/firmware-update/build/x86_64-unknown-uefi/boot.img" "${USB}.partial"
|
||||
|
||||
# Copy firmware to USB image
|
||||
mmd -i "${USB}.partial@@1M" "::${BASEDIR}/firmware"
|
||||
mcopy -v -i "${USB}.partial@@1M" "${COREBOOT}" "::${BASEDIR}/firmware/firmware.rom"
|
||||
if [ -e "${BUILD}/ec.rom" ]; then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${BUILD}/ec.rom" "::${BASEDIR}/firmware/ec.rom"
|
||||
elif [ -e "${MODEL_DIR}/ec.rom" ]; then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${MODEL_DIR}/ec.rom" "::${BASEDIR}/firmware/ec.rom"
|
||||
fi
|
||||
if [ -e "${MODEL_DIR}/uecflash.efi" ]; then
|
||||
mcopy -v -i "${USB}.partial@@1M" "${MODEL_DIR}/uecflash.efi" "::${BASEDIR}/firmware/uecflash.efi"
|
||||
fi
|
||||
mv -v "${USB}.partial" "${USB}"
|
Loading…
Add table
Add a link
Reference in a new issue