]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
debian: Add script to build package for various arches
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2020 14:54:24 +0000 (14:54 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 18 May 2020 15:00:48 +0000 (15:00 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
debian/build.sh [new file with mode: 0644]

index 5a6904fb19bd7f6a2a8a18a1cae85f041dc8abe9..9dd5e9c78d52f1f3eb3df9757264d8b2350f2515 100644 (file)
@@ -9,11 +9,6 @@ BINDINGS =
 
 OS = $(shell uname -s)
 
-DEBIAN_TARBALL_NAME = $(PACKAGE_NAME)_$(PACKAGE_VERSION).orig.tar.xz
-
-CLEANFILES += \
-       $(DEBIAN_TARBALL_NAME)
-
 if ENABLE_PERL
 BINDINGS += perl
 endif
@@ -444,9 +439,22 @@ man/%.html: man/%.txt man/asciidoc.conf
 upload-man: $(MANPAGES_HTML)
        rsync -avHz --delete --progress $(MANPAGES_HTML) ms@fs01.haj.ipfire.org:/pub/man-pages/$(PACKAGE_NAME)/
 
-$(DEBIAN_TARBALL_NAME): dist
-       cp -v $(distdir).tar.xz $@
+EXTRA_DIST += \
+       debian/autoreconf.after \
+       debian/autoreconf.before \
+       debian/build.sh \
+       debian/changelog \
+       debian/compat \
+       debian/control \
+       debian/copyright \
+       debian/libloc-dev.install \
+       debian/libloc.install \
+       debian/libloc.lintian-overrides \
+       debian/libloc.manpages \
+       debian/libloc-perl.install \
+       debian/rules \
+       debian/source/format
 
 .PHONY: debian
-debian: $(DEBIAN_TARBALL_NAME)
-       debuild -i -us -uc -b
+debian: dist
+       $(SHELL) debian/build.sh $(PACKAGE_NAME)-$(PACKAGE_VERSION) $(distdir).tar.xz
diff --git a/debian/build.sh b/debian/build.sh
new file mode 100644 (file)
index 0000000..0c2391c
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+set -x
+
+ARCHITECTURES=( amd64 arm64 i386 armhf riscv64 )
+RELEASES=( buster )
+
+CHROOT_PATH="/var/tmp"
+
+main() {
+    if [ $# -lt 2 ]; then
+        echo "Not enough arguments" >&2
+        return 2
+    fi
+
+    local package="${1}"
+    local sources="${2}"
+
+    # Create some temporary directory
+    local tmp="$(mktemp -d)"
+
+    # Extract the sources into it
+    tar xvfa "${sources}" -C "${tmp}"
+
+    # Copy the tarball under the correct Debian name
+    cp -vf "${sources}" "${tmp}/${package//-/_}.orig.tar.xz"
+
+    # Change into source directory
+    pushd "${tmp}/${package}"
+
+    # Prepare the build environment
+    #if ! debuild -us -uc; then
+    #    echo "Could not prepare build environment" >&2
+    #    return 1
+    #fi
+
+    # Build the package for each release
+    local release
+    for release in ${RELEASES[@]}; do
+        # And for each architecture we want to support
+        local arch
+        for arch in ${ARCHITECTURES[@]}; do
+            local chroot="${release}-${arch}-sbuild"
+
+            # Create a chroot environment
+            if [ ! -d "/etc/sbuild/chroot/${chroot}" ]; then
+                if ! sbuild-createchroot --arch="${arch}" "${release}" \
+                        "${CHROOT_PATH}/${chroot}"; then
+                    echo "Could not create chroot for ${release} on ${arch}" >&2
+                    return 1
+                fi
+            fi
+
+            # Run the build process
+            if ! sbuild --dist="${release}" --host="${arch}"; then
+                echo "Could not build package for ${release} on ${arch}" >&2
+                return 1
+            fi
+        done
+    done
+
+    popd
+
+    # Cleanup
+    rm -rf "${tmp}"
+}
+
+main "$@" || exit $?