2017-10-04 18:52:03 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
[ $# -ge 1 ] || exit 1
|
|
|
|
CONTROL="$1"; shift
|
2019-10-14 18:58:13 +02:00
|
|
|
IMAGEBUILDER_URL=${IMAGEBUILDER_URL:-https://downloads.openwrt.org/snapshots/targets/ar71xx/generic/openwrt-imagebuilder-ar71xx-generic.Linux-x86_64.tar.xz}
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
TOPDIR="$PWD"
|
|
|
|
DLDIR=${DLDIR:-"dl"}
|
|
|
|
BUILDDIR=${BUILDDIR:-"build"}
|
2018-09-02 21:28:01 +02:00
|
|
|
IMAGESDIR=${IMAGEDIR:-"images"}
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
mkdir -p "$DLDIR"
|
|
|
|
mkdir -p "$BUILDDIR"; rm -rf "$BUILDDIR"/*
|
2018-09-02 21:28:01 +02:00
|
|
|
mkdir -p "$IMAGESDIR"
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
VERSION="$(basename "$(git describe --always --tags --dirty --match 'access-points/*')")"
|
2018-09-02 21:28:01 +02:00
|
|
|
IMAGEDIR="$IMAGESDIR"/"$VERSION"
|
2018-04-13 23:57:13 +02:00
|
|
|
mkdir -p "$IMAGEDIR"
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
imagebuilder="$(basename "$IMAGEBUILDER_URL")"
|
2019-10-14 18:58:47 +02:00
|
|
|
checksums_url="$(dirname "$IMAGEBUILDER_URL")/sha256sums"
|
|
|
|
trustedkeys=$PWD/keys/trustedkeys.kbx
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
(
|
|
|
|
cd "$DLDIR"
|
|
|
|
wget --continue "$IMAGEBUILDER_URL" -O "$imagebuilder"
|
2019-10-14 18:58:47 +02:00
|
|
|
wget "${checksums_url}" -O "${imagebuilder}.sha256sums"
|
|
|
|
wget "${checksums_url}.asc" -O "${imagebuilder}.sha256sums.asc"
|
|
|
|
|
|
|
|
gpgv --keyring="$trustedkeys" \
|
|
|
|
"${imagebuilder}.sha256sums.asc" "${imagebuilder}.sha256sums" \
|
|
|
|
|| exit 42
|
|
|
|
|
|
|
|
sha256sum --ignore-missing --check ${imagebuilder}.sha256sums || exit 43
|
|
|
|
) || exit 50
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
tar -C "$BUILDDIR" -axf "$DLDIR"/"$imagebuilder"
|
|
|
|
|
|
|
|
IMAGEBUILDER_DIR="$BUILDDIR"/"$(tar -atf "$DLDIR"/"$imagebuilder" | head -n1)"
|
|
|
|
|
2018-09-02 21:27:01 +02:00
|
|
|
# source control file and extract variables
|
2018-04-13 23:57:13 +02:00
|
|
|
profile=$(. "$CONTROL"; echo "${PROFILE}")
|
2018-08-03 21:31:55 +02:00
|
|
|
target=$(. "$CONTROL"; echo "${TARGET}")
|
|
|
|
subtarget=$(. "$CONTROL"; echo "${SUBTARGET}")
|
2017-10-04 18:52:03 +02:00
|
|
|
|
|
|
|
(
|
2018-09-02 21:27:01 +02:00
|
|
|
# `make` below consumes these
|
2017-10-04 18:52:03 +02:00
|
|
|
export PROFILE PACKAGES
|
2018-04-13 23:57:13 +02:00
|
|
|
|
2017-10-04 18:52:03 +02:00
|
|
|
. "$CONTROL"
|
|
|
|
|
2018-09-02 21:29:10 +02:00
|
|
|
tmp="$(mktemp --tmpdir -d files.XXXXXXXXX)"
|
2017-10-04 18:52:03 +02:00
|
|
|
|
2018-04-13 23:57:13 +02:00
|
|
|
mkdir -p "$tmp"/etc
|
2018-09-02 21:29:24 +02:00
|
|
|
mkdir -p "$tmp"/etc/its-access-point/
|
|
|
|
printf '%s\n' "$VERSION" > "$tmp"/etc/its-access-point-version # legacy
|
|
|
|
printf '%s\n' "$VERSION" > "$tmp"/etc/its-access-point/version
|
|
|
|
printf '%s\n' "$IMAGEBUILDER_URL" \
|
|
|
|
> "$tmp"/etc/its-access-point/imagebuilder-url
|
|
|
|
sha512sum "$imagebuilder" > "$tmp"/etc/its-access-point/imagebuilder-hash
|
|
|
|
cat "$CONTROL" > "$tmp"/etc/its-access-point/control
|
2017-10-04 18:52:03 +02:00
|
|
|
|
2018-04-13 23:57:13 +02:00
|
|
|
if [ -n "$COMMON_FILES" ]; then
|
|
|
|
cp -aLTv "$TOPDIR/$COMMON_FILES" "$tmp"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "$FILES" ]; then
|
|
|
|
cp -aLTv "$TOPDIR/$FILES" "$tmp"
|
|
|
|
fi
|
|
|
|
|
2017-10-04 18:52:03 +02:00
|
|
|
cd "$IMAGEBUILDER_DIR"
|
2018-04-13 23:57:13 +02:00
|
|
|
unset COMMON_FILES
|
|
|
|
make image FILES="$tmp" 1>&2
|
2017-10-04 18:52:03 +02:00
|
|
|
)
|
|
|
|
|
2018-08-03 21:31:55 +02:00
|
|
|
cp "$IMAGEBUILDER_DIR"/bin/targets/ar71xx/"${subtarget}"/openwrt*-"${target}-${subtarget}-${profile}"-squashfs-sysupgrade.bin "$IMAGEDIR"/
|
2017-10-04 18:52:03 +02:00
|
|
|
|
2018-09-02 21:27:01 +02:00
|
|
|
ln -snf "$VERSION" images/latest
|
|
|
|
|
2017-10-04 18:52:03 +02:00
|
|
|
{
|
|
|
|
printf '%s\n' "Date: $(date -R)"
|
|
|
|
printf '%s\n' "Image-Builder: $IMAGEBUILDER_URL"
|
|
|
|
printf '%s\n'
|
|
|
|
printf 'Checksums-Sha512:\n'
|
|
|
|
{
|
|
|
|
( cd "$DLDIR" ; sha512sum "$imagebuilder" )
|
2018-08-03 21:31:55 +02:00
|
|
|
( cd "$IMAGEDIR"; sha512sum openwrt*-"${target}-${subtarget}-${profile}"-squashfs-sysupgrade.bin )
|
2017-10-04 18:52:03 +02:00
|
|
|
} | sed 's/^/ /'
|
2018-04-14 01:00:40 +02:00
|
|
|
} > "$IMAGEDIR"/"${profile}".image-manifest
|
2018-09-02 21:27:01 +02:00
|
|
|
|
|
|
|
echo
|
|
|
|
echo
|
|
|
|
echo "Wrote images to $IMAGEDIR"
|
|
|
|
echo
|