its-ap-builder/access-points/build-image.sh

70 lines
1.7 KiB
Bash
Raw Normal View History

2017-10-04 18:52:03 +02:00
#!/bin/sh
[ $# -ge 1 ] || exit 1
CONTROL="$1"; shift
IMAGEBUILDER_URL=${IMAGEBUILDER_URL:-http://downloads.lede-project.org/snapshots/targets/ar71xx/generic/lede-imagebuilder-ar71xx-generic.Linux-x86_64.tar.xz}
TOPDIR="$PWD"
DLDIR=${DLDIR:-"dl"}
BUILDDIR=${BUILDDIR:-"build"}
IMAGEDIR=${IMAGEDIR:-"images"}
mkdir -p "$DLDIR"
mkdir -p "$BUILDDIR"; rm -rf "$BUILDDIR"/*
mkdir -p "$IMAGEDIR"
VERSION="$(basename "$(git describe --always --tags --dirty --match 'access-points/*')")"
IMAGEDIR="$IMAGEDIR"/"$VERSION"
2018-04-13 23:57:13 +02:00
mkdir -p "$IMAGEDIR"
2017-10-04 18:52:03 +02:00
imagebuilder="$(basename "$IMAGEBUILDER_URL")"
(
cd "$DLDIR"
wget --continue "$IMAGEBUILDER_URL" -O "$imagebuilder"
)
tar -C "$BUILDDIR" -axf "$DLDIR"/"$imagebuilder"
IMAGEBUILDER_DIR="$BUILDDIR"/"$(tar -atf "$DLDIR"/"$imagebuilder" | head -n1)"
2018-04-13 23:57:13 +02:00
profile=$(. "$CONTROL"; echo "${PROFILE}")
2017-10-04 18:52:03 +02:00
(
IFS='
'
export PROFILE PACKAGES
2018-04-13 23:57:13 +02:00
2017-10-04 18:52:03 +02:00
. "$CONTROL"
tmp=$(mktemp --tmpdir -d files.XXXXXXXXX)
2018-04-13 23:57:13 +02:00
mkdir -p "$tmp"/etc
2017-10-04 18:52:03 +02:00
echo "$VERSION" > "$tmp"/etc/its-access-point-version
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-04-13 23:57:13 +02:00
cp "$IMAGEBUILDER_DIR"/bin/targets/ar71xx/generic/lede*-ar71xx-generic-"${profile}"-squashfs-sysupgrade.bin "$IMAGEDIR"/
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-04-13 23:57:13 +02:00
( cd "$IMAGEDIR"; sha512sum lede*-ar71xx-generic-"${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