build: replace hardcoded paths with overridable variables

Signed-off-by: Petr Štetiar <ynezz@true.cz>
This commit is contained in:
Petr Štetiar 2018-10-23 17:48:22 +02:00 committed by Matthias Schiffer
parent 1c1ccc3c2f
commit 9dc1ac7f58
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C
12 changed files with 42 additions and 37 deletions

View File

@ -4,15 +4,6 @@ LC_ALL:=C
LANG:=C
export LC_ALL LANG
# initialize (possibly already user set) directory variables
GLUON_SITEDIR ?= site
GLUON_TMPDIR ?= tmp
GLUON_OUTPUTDIR ?= output
GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
# check for spaces & resolve possibly relative paths
define mkabspath
ifneq (1,$(words [$($(1))]))
@ -21,14 +12,8 @@ define mkabspath
override $(1) := $(abspath $($(1)))
endef
GLUON_SITEDIR ?= site
$(eval $(call mkabspath,GLUON_SITEDIR))
$(eval $(call mkabspath,GLUON_TMPDIR))
$(eval $(call mkabspath,GLUON_OUTPUTDIR))
$(eval $(call mkabspath,GLUON_IMAGEDIR))
$(eval $(call mkabspath,GLUON_PACKAGEDIR))
export GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR GLUON_DEVICES
$(GLUON_SITEDIR)/site.mk:
$(error No site configuration was found. Please check out a site configuration to $(GLUON_SITEDIR))
@ -37,11 +22,27 @@ include $(GLUON_SITEDIR)/site.mk
GLUON_RELEASE ?= $(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line)
# initialize (possibly already user set) directory variables
GLUON_TMPDIR ?= tmp
GLUON_OUTPUTDIR ?= output
GLUON_IMAGEDIR ?= $(GLUON_OUTPUTDIR)/images
GLUON_PACKAGEDIR ?= $(GLUON_OUTPUTDIR)/packages
GLUON_TARGETSDIR ?= targets
GLUON_PATCHESDIR ?= patches
$(eval $(call mkabspath,GLUON_TMPDIR))
$(eval $(call mkabspath,GLUON_OUTPUTDIR))
$(eval $(call mkabspath,GLUON_IMAGEDIR))
$(eval $(call mkabspath,GLUON_PACKAGEDIR))
$(eval $(call mkabspath,GLUON_TARGETSDIR))
$(eval $(call mkabspath,GLUON_PATCHESDIR))
GLUON_MULTIDOMAIN ?= 0
GLUON_WLAN_MESH ?= 11s
GLUON_DEBUG ?= 0
export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_WLAN_MESH GLUON_DEBUG
export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_WLAN_MESH GLUON_DEBUG GLUON_DEVICES \
GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR
show-release:
@echo '$(GLUON_RELEASE)'
@ -70,7 +71,7 @@ GLUON_TARGET_$$(gluon_target)_BOARD := $(1)
GLUON_TARGET_$$(gluon_target)_SUBTARGET := $(2)
endef
include targets/targets.mk
include $(GLUON_TARGETSDIR)/targets.mk
OPENWRTMAKE = $(MAKE) -C openwrt

View File

@ -2,7 +2,7 @@
set -e
[ "$GLUON_IMAGEDIR" -a "$GLUON_PACKAGEDIR" -a "$OPENWRT_TARGET" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" ] || exit 1
[ "$GLUON_IMAGEDIR" -a "$GLUON_PACKAGEDIR" -a "$OPENWRT_TARGET" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" -a "$GLUON_TARGETSDIR" ] || exit 1
default_factory_ext='.bin'
@ -191,7 +191,7 @@ no_opkg() {
}
. targets/"$1"; copy
. "${GLUON_TARGETSDIR}/$1"; copy
# Copy opkg repo
if [ -z "$no_opkg" -a -z "$GLUON_DEVICES" ]; then

View File

@ -2,7 +2,7 @@
set -e
[ "$GLUON_IMAGEDIR" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" ] || exit 1
[ "$GLUON_IMAGEDIR" -a "$GLUON_RELEASE" -a "$GLUON_SITEDIR" -a "$GLUON_TARGETSDIR" ] || exit 1
default_sysupgrade_ext='.bin'
@ -110,4 +110,4 @@ sysupgrade() {
fi
}
. targets/"$1"; generate
. "${GLUON_TARGETSDIR}/$1"; generate

View File

@ -3,6 +3,8 @@
set -e
shopt -s nullglob
[ "$GLUON_TMPDIR" -a "$GLUON_PATCHESDIR" ] || exit 1
. scripts/modules.sh
@ -19,7 +21,7 @@ for module in $GLUON_MODULES; do
git clone -s -b base --single-branch "$GLUONDIR/$module" "$PATCHDIR" 2>/dev/null
cd "$PATCHDIR"
for patch in "$GLUONDIR/patches/$module"/*.patch; do
for patch in "${GLUON_PATCHESDIR}/$module"/*.patch; do
git -c user.name='Gluon Patch Manager' -c user.email='gluon@void.example.com' -c commit.gpgsign=false am --whitespace=nowarn --committer-date-is-author-date "$patch"
done

View File

@ -2,7 +2,7 @@
set -e
[ "$OPENWRT_TARGET" ] || exit 1
[ "$OPENWRT_TARGET" -a "$GLUON_TARGETSDIR" ] || exit 1
target="$1"
packages=$2
@ -74,9 +74,9 @@ packages() {
# The sort will not only remove duplicate entries,
# but also magically make =y entries override =m ones
(
. targets/generic
. "${GLUON_TARGETSDIR}/generic"
packages $packages
. targets/"$target"
. "${GLUON_TARGETSDIR}/$target"
emit
) | sort -u

View File

@ -2,7 +2,7 @@
set -e
[ "$OPENWRT_TARGET" ] || exit 1
[ "$OPENWRT_TARGET" -a "$GLUON_TARGETSDIR" ] || exit 1
target="$1"
packages=$2
@ -92,10 +92,10 @@ packages() {
}
. targets/generic
. "${GLUON_TARGETSDIR}/generic"
packages $packages
. targets/"$target"
. "${GLUON_TARGETSDIR}/$target"
check_devices

View File

@ -3,6 +3,8 @@
set -e
shopt -s nullglob
[ "$GLUON_PATCHESDIR" ] || exit 1
. scripts/modules.sh
@ -11,14 +13,14 @@ GLUONDIR="$(pwd)"
for module in $GLUON_MODULES; do
echo "--- Updating patches for module '$module' ---"
rm -rf "$GLUONDIR"/patches/"$module"
rm -rf "${GLUON_PATCHESDIR}/$module"
cd "$GLUONDIR"/"$module"
n=0
for commit in $(git rev-list --reverse --no-merges base..patched); do
let n=n+1
mkdir -p "$GLUONDIR"/patches/"$module"
git -c core.abbrev=40 show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames --binary "$commit" > "$GLUONDIR/patches/$module/$(printf '%04u' $n)-$(git show -s --pretty=format:%f "$commit").patch"
mkdir -p "${GLUON_PATCHESDIR}/$module"
git -c core.abbrev=40 show --pretty=format:'From: %an <%ae>%nDate: %aD%nSubject: %B' --no-renames --binary "$commit" > "${GLUON_PATCHESDIR}/$module/$(printf '%04u' $n)-$(git show -s --pretty=format:%f "$commit").patch"
done
done

View File

@ -1,4 +1,4 @@
. targets/brcm2708.inc
. "${GLUON_TARGETSDIR}/brcm2708.inc"
device raspberry-pi rpi
manifest_alias raspberry-pi-model-b-rev-2

View File

@ -1,4 +1,4 @@
. targets/brcm2708.inc
. "${GLUON_TARGETSDIR}/brcm2708.inc"
device raspberry-pi-2 rpi-2
manifest_alias raspberry-pi-2-model-b-rev-1.1

View File

@ -1,3 +1,3 @@
. targets/brcm2708.inc
. "${GLUON_TARGETSDIR}/brcm2708.inc"
device raspberry-pi-3 rpi-3

View File

@ -1,4 +1,4 @@
. targets/x86.inc
. "${GLUON_TARGETSDIR}/x86.inc"
factory_image x86-64 combined-squashfs .img.gz
factory_image x86-64 combined-squashfs .vdi

View File

@ -1,4 +1,4 @@
. targets/x86.inc
. "${GLUON_TARGETSDIR}/x86.inc"
factory_image x86-generic combined-squashfs .img.gz
factory_image x86-generic combined-squashfs .vdi