diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2016-04-11 16:34:21 +0100 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2016-05-12 08:32:41 +0200 |
commit | 2d294eb4fc9e36a083be880eb29e3d98bf83610f (patch) | |
tree | 525c26f616b4669c8ca8a2a81f75342e0733e832 | |
parent | 2da5f5df4ee0b4809192567b03b1cb9902ce1b00 (diff) |
Generate metadata from make variables.
This allows one to use the same makefiles when
building for other (host compatible) arches.
One can build i386 on an x86_64 machine with:
make ARCH=i386
The metadata files will be regenerated on every
invocation of make.
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | metadata.platform | 4 | ||||
-rw-r--r-- | metadata.platform.in | 4 | ||||
-rw-r--r-- | metadata.sdk | 4 | ||||
-rw-r--r-- | metadata.sdk.in | 4 |
5 files changed, 27 insertions, 15 deletions
@@ -1,9 +1,21 @@ +# Override the arch with `make ARCH=i386` +VERSION = 1.5 +ARCH ?= $(shell flatpak --default-arch) + +# Canned recipe for generating metadata +# $1 = the input file to substitute +# $2 = the output to create +define subst-metadata + @echo -n "Generating ${2}... "; \ + sed -e 's/@@ARCH@@/${ARCH}/g' \ + -e 's/@@VERSION@@/${VERSION}/g' \ + ${1} > ${2}.tmp && mv ${2}.tmp ${2} || exit 1; + @echo "Done."; +endef + srcdir = $(CURDIR) builddir = $(CURDIR) - NULL= -ARCH=x86_64 -VERSION=1.5 HASH:=$(shell git rev-parse HEAD) IMAGEDIR=images/${ARCH} SDK_IMAGE=${IMAGEDIR}/freedesktop-contents-sdk-${ARCH}-${HASH}.tar.gz @@ -29,24 +41,24 @@ ${IMAGES} allimages: sdk: ${FILE_REF_SDK} -${FILE_REF_SDK}: metadata.sdk ${SDK_IMAGE} +${FILE_REF_SDK}: metadata.sdk.in ${SDK_IMAGE} if [ ! -d repo ]; then ostree init --mode=archive-z2 --repo=repo; fi rm -rf sdk mkdir sdk (cd sdk; tar --transform 's,^./usr,files,S' --transform 's,^./etc,files/etc,S' --exclude="./[!eu]*" -xvf ../${SDK_IMAGE} > /dev/null) - cp metadata.sdk sdk/metadata + $(call subst-metadata,metadata.sdk.in,sdk/metadata) ostree commit ${COMMIT_ARGS} ${GPG_ARGS} --branch=${REF_SDK} -s "build of ${HASH}" sdk ostree summary -u --repo=repo ${GPG_ARGS} rm -rf sdk platform: ${FILE_REF_PLATFORM} -${FILE_REF_PLATFORM}: metadata.platform ${PLATFORM_IMAGE} +${FILE_REF_PLATFORM}: metadata.platform.in ${PLATFORM_IMAGE} if [ ! -d repo ]; then ostree init --mode=archive-z2 --repo=repo; fi rm -rf platform mkdir platform (cd platform; tar --transform 's,^./usr,files,S' --transform 's,^./etc,files/etc,S' --exclude="./[!eu]*" -xvf ../${PLATFORM_IMAGE} > /dev/null) - cp metadata.platform platform/metadata + $(call subst-metadata,metadata.platform.in,platform/metadata) ostree commit ${COMMIT_ARGS} ${GPG_ARGS} --branch=${REF_PLATFORM} -s "build of ${HASH}" platform ostree summary -u --repo=repo ${GPG_ARGS} rm -rf platform diff --git a/metadata.platform b/metadata.platform deleted file mode 100644 index c2ca72e..0000000 --- a/metadata.platform +++ /dev/null @@ -1,4 +0,0 @@ -[Runtime] -name=org.freedesktop.BasePlatform -runtime=org.freedesktop.BasePlatform/x86_64/1.5 -sdk=org.freedesktop.BaseSdk/x86_64/1.5 diff --git a/metadata.platform.in b/metadata.platform.in new file mode 100644 index 0000000..b46703a --- /dev/null +++ b/metadata.platform.in @@ -0,0 +1,4 @@ +[Runtime] +name=org.freedesktop.BasePlatform +runtime=org.freedesktop.BasePlatform/@@ARCH@@/@@VERSION@@ +sdk=org.freedesktop.BaseSdk/@@ARCH@@/@@VERSION@@ diff --git a/metadata.sdk b/metadata.sdk deleted file mode 100644 index a0b520e..0000000 --- a/metadata.sdk +++ /dev/null @@ -1,4 +0,0 @@ -[Runtime] -name=org.freedesktop.BaseSdk -runtime=org.freedesktop.BasePlatform/x86_64/1.5 -sdk=org.freedesktop.BaseSdk/x86_64/1.5 diff --git a/metadata.sdk.in b/metadata.sdk.in new file mode 100644 index 0000000..f69621d --- /dev/null +++ b/metadata.sdk.in @@ -0,0 +1,4 @@ +[Runtime] +name=org.freedesktop.BaseSdk +runtime=org.freedesktop.BasePlatform/@@ARCH@@/@@VERSION@@ +sdk=org.freedesktop.BaseSdk/@@ARCH@@/@@VERSION@@ |