aboutsummaryrefslogtreecommitdiff
path: root/packages/build
diff options
context:
space:
mode:
authorSébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>2020-10-26 19:42:20 +0100
committerDavid Oberhollenzer <goliath@infraroot.at>2020-10-27 11:49:57 +0100
commit93d5f138025b09a4b1093001f33b9dc4c807603d (patch)
tree7f90a91f229a7ec254a9a8333f6b2bd5790983c6 /packages/build
parent51c0c5694f6d8c752663f0a515f3b9e1cf081c66 (diff)
Build package using Docker images
Docker image can now be used to build packages for following distributions: * alpine * archlinux * centos * fedora * debian * ubuntu * opensuse Signed-off-by: Sébastien Gross <seb•ɑƬ•chezwam•ɖɵʈ•org>
Diffstat (limited to 'packages/build')
-rwxr-xr-xpackages/build57
1 files changed, 57 insertions, 0 deletions
diff --git a/packages/build b/packages/build
new file mode 100755
index 0000000..21327d6
--- /dev/null
+++ b/packages/build
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+# Build a package for a specific distribution using a Docker image.
+#
+# ./build DISTRO RELEASE
+#
+# From a given DISTRO:RELEASE it create a new local Docker image named
+# DISTRO-builder:RELEASE and installs tools required to build a
+# package (it does not install package build depends).
+#
+# It also creates a builder user to prevent from building packages as
+# root.
+#
+# Once the image is setup, it starts a docker image and run
+# build-helper to build the packages. The packages files are stored in
+# _OUT/DISTRO/RELEASE.
+#
+
+
+vendor="$1"
+release="$2"
+
+if test -z "$vendor" -o -z "$release"; then
+ cat<<EOF >&2
+$0 VENDOR RELEASE
+EOF
+ exit 1
+fi
+
+source_dir=$(git rev-parse --show-toplevel)
+output_dir=$source_dir/_out
+empty_dir=$output__dir/_empty
+
+if test "$vendor" = "opensuse"; then
+ vendor=opensuse/leap
+ pkg_dir=$output_dir/$vendor-$release
+else
+ pkg_dir=$output_dir/$vendor/$release
+fi
+
+image=$vendor-builder:$release
+
+mkdir -p $pkg_dir
+mkdir -p $output_dir/_empty
+
+# Build docker image
+docker build -t $image -f packages/Dockerfile \
+ --build-arg vendor="$vendor" \
+ --build-arg release="$release" \
+ .
+
+docker_args="-v $source_dir:/source-ro:ro -v $empty_dir:/source-ro/_out:ro"
+docker_args="$docker_args -v $pkg_dir:/output:rw"
+docker_args="$docker_args -v $source_dir/packages/build-helper:/build-helper"
+docker_args="$docker_args --rm"
+
+docker run -it $docker_args $image /build-helper