packaging: make dockerrpm fedora target more generic stable
authorMads Kiilerich <mads@kiilerich.com>
Fri, 01 Nov 2019 15:29:14 +0100
branchstable
changeset 43359 e66a3bfcb19b
parent 43358 518655314fc5
child 43360 0b65f18edc4f
packaging: make dockerrpm fedora target more generic Fedora moves fast in version numbers, and often with Mercurial packaging being backwards compatible. Thus, only aim for providing built-in support for latest Fedora version, and make it easy to update. With this refactoring, 'dockerrpm fedora31' also works. 'dockerrpm fedora' will use the 'fedora:latest' Docker image.
contrib/packaging/docker/fedora.template
contrib/packaging/docker/fedora29
contrib/packaging/dockerrpm
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/packaging/docker/fedora.template	Fri Nov 01 15:29:14 2019 +0100
@@ -0,0 +1,15 @@
+FROM fedora:%OS_RELEASE%
+
+RUN groupadd -g 1000 build && \
+    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
+
+RUN dnf install -y \
+	gcc \
+	gettext \
+	make \
+	python3-devel \
+	python3-docutils \
+	rpm-build
+
+# For creating repo meta data
+RUN dnf install -y createrepo
--- a/contrib/packaging/docker/fedora29	Fri Nov 01 12:59:22 2019 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-FROM fedora:29
-
-RUN groupadd -g 1000 build && \
-    useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
-
-RUN dnf install -y \
-	gcc \
-	gettext \
-	make \
-	python3-devel \
-	python3-docutils \
-	rpm-build
-
-# For creating repo meta data
-RUN dnf install -y createrepo
--- a/contrib/packaging/dockerrpm	Fri Nov 01 12:59:22 2019 +0100
+++ b/contrib/packaging/dockerrpm	Fri Nov 01 15:29:14 2019 +0100
@@ -6,6 +6,14 @@
 PLATFORM="$1"
 shift # extra params are passed to buildrpm
 
+DOCKERFILE="$PLATFORM"
+OS_RELEASE="${PLATFORM//[a-z]/}"
+case "$PLATFORM" in
+fedora*)
+    DOCKERFILE="${PLATFORM//[0-9]/}.template"
+    ;;
+esac
+
 DOCKER=$($BUILDDIR/hg-docker docker-path)
 
 CONTAINER=hg-docker-$PLATFORM
@@ -18,7 +26,11 @@
     DOCKERGID=$(id -g)
 fi
 
-$BUILDDIR/hg-docker build --build-arg UID=$DOCKERUID --build-arg GID=$DOCKERGID $BUILDDIR/docker/$PLATFORM $CONTAINER
+$BUILDDIR/hg-docker build \
+    --build-arg UID=$DOCKERUID \
+    --build-arg GID=$DOCKERGID \
+    --build-arg OS_RELEASE=${OS_RELEASE:-latest} \
+    $BUILDDIR/docker/$DOCKERFILE $CONTAINER
 
 RPMBUILDDIR=$ROOTDIR/packages/$PLATFORM
 mkdir -p $RPMBUILDDIR