]> git.ipfire.org Git - people/ms/libloc.git/blame - debian/build.sh
debian: unstable is called bullseye
[people/ms/libloc.git] / debian / build.sh
CommitLineData
40507036
MT
1#!/bin/bash
2
3set -x
4
94dab5bb 5ARCHITECTURES=( amd64 arm64 i386 armhf )
7f261d34 6RELEASES=( buster bullseye )
40507036
MT
7
8CHROOT_PATH="/var/tmp"
9
10main() {
11 if [ $# -lt 2 ]; then
12 echo "Not enough arguments" >&2
13 return 2
14 fi
15
8791dbb6
MT
16 # Get host architecture
17 local host_arch="$(dpkg --print-architecture)"
18 if [ -z "${host_arch}" ]; then
19 echo "Could not discover host architecture" >&2
20 return 1
21 fi
22
40507036
MT
23 local package="${1}"
24 local sources="${2}"
25
26 # Create some temporary directory
27 local tmp="$(mktemp -d)"
28
29 # Extract the sources into it
748ea080
MT
30 mkdir -p "${tmp}/sources"
31 tar xvfa "${sources}" -C "${tmp}/sources"
40507036
MT
32
33 # Copy the tarball under the correct Debian name
748ea080 34 cp -vf "${sources}" "${tmp}/sources/${package//-/_}.orig.tar.xz"
40507036 35
748ea080
MT
36 # Change into temporary directory
37 pushd "${tmp}"
40507036 38
40507036
MT
39 # Build the package for each release
40 local release
41 for release in ${RELEASES[@]}; do
8791dbb6
MT
42 local chroot="${release}-${host_arch}-sbuild"
43
748ea080
MT
44 mkdir -p "${release}"
45 pushd "${release}"
46
8791dbb6
MT
47 # Create a chroot environment
48 if [ ! -d "/etc/sbuild/chroot/${chroot}" ]; then
49 if ! sbuild-createchroot --arch="${host_arch}" "${release}" \
50 "${CHROOT_PATH}/${chroot}"; then
51 echo "Could not create chroot for ${release} on ${host_arch}" >&2
52 return 1
53 fi
54 fi
55
40507036
MT
56 # And for each architecture we want to support
57 local arch
58 for arch in ${ARCHITECTURES[@]}; do
748ea080
MT
59 mkdir -p "${arch}"
60 pushd "${arch}"
61
62 # Copy sources
63 cp -r "${tmp}/sources" .
64
40507036 65 # Run the build process
161246f2 66 if ! sbuild --dist="${release}" --host="${arch}" --source "sources/${package}"; then
40507036
MT
67 echo "Could not build package for ${release} on ${arch}" >&2
68 return 1
69 fi
748ea080
MT
70
71 # Remove the sources
72 rm -rf "sources/${package}"
73 popd
40507036 74 done
748ea080 75 popd
40507036
MT
76 done
77
748ea080
MT
78 # Remove sources
79 rm -rf "${tmp}/sources"
40507036
MT
80 popd
81
82 # Cleanup
83 rm -rf "${tmp}"
84}
85
86main "$@" || exit $?