summaryrefslogtreecommitdiff
path: root/packages/build
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-11-02 11:33:44 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-11-02 11:49:44 +0100
commit072890e9b0ec5af1b28b3c1b213554c5b16ab50e (patch)
tree2d5eeb6bd59601516c9e3d39c93aa932e95a2267 /packages/build
parent7c4b2a289cab34e4ec1b966663530a7babf08707 (diff)
Backport changes to package scripts
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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