Patchwork [6,of,8,stable] packaging: make dockerrpm fedora target more generic

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 1, 2019, 2:40 p.m.
Message ID <0b31ec6e6e7e815a75dc.1572619234@madski>
Download mbox | patch
Permalink /patch/42642/
State Accepted
Headers show

Comments

Mads Kiilerich - Nov. 1, 2019, 2:40 p.m.
# HG changeset patch
# User Mads Kiilerich <mads@kiilerich.com>
# Date 1572618554 -3600
#      Fri Nov 01 15:29:14 2019 +0100
# Branch stable
# Node ID 0b31ec6e6e7e815a75dc465e133043582b3e4cb7
# Parent  dd589d02eba31ae40369d24bf3620863b4c86008
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.

Patch

diff --git a/contrib/packaging/docker/fedora29 b/contrib/packaging/docker/fedora.template
rename from contrib/packaging/docker/fedora29
rename to contrib/packaging/docker/fedora.template
--- a/contrib/packaging/docker/fedora29
+++ b/contrib/packaging/docker/fedora.template
@@ -1,4 +1,4 @@ 
-FROM fedora:29
+FROM fedora:%OS_RELEASE%
 
 RUN groupadd -g 1000 build && \
     useradd -u 1000 -g 1000 -s /bin/bash -d /build -m build
diff --git a/contrib/packaging/dockerrpm b/contrib/packaging/dockerrpm
--- a/contrib/packaging/dockerrpm
+++ b/contrib/packaging/dockerrpm
@@ -6,6 +6,14 @@  export ROOTDIR=$(cd $BUILDDIR/../..; pwd
 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 @@  else
     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