]>
Commit | Line | Data |
---|---|---|
40507036 MT |
1 | #!/bin/bash |
2 | ||
3 | set -x | |
4 | ||
5 | ARCHITECTURES=( amd64 arm64 i386 armhf riscv64 ) | |
6 | RELEASES=( buster ) | |
7 | ||
8 | CHROOT_PATH="/var/tmp" | |
9 | ||
10 | main() { | |
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 | |
30 | tar xvfa "${sources}" -C "${tmp}" | |
31 | ||
32 | # Copy the tarball under the correct Debian name | |
33 | cp -vf "${sources}" "${tmp}/${package//-/_}.orig.tar.xz" | |
34 | ||
35 | # Change into source directory | |
36 | pushd "${tmp}/${package}" | |
37 | ||
38 | # Prepare the build environment | |
39 | #if ! debuild -us -uc; then | |
40 | # echo "Could not prepare build environment" >&2 | |
41 | # return 1 | |
42 | #fi | |
43 | ||
44 | # Build the package for each release | |
45 | local release | |
46 | for release in ${RELEASES[@]}; do | |
8791dbb6 MT |
47 | local chroot="${release}-${host_arch}-sbuild" |
48 | ||
49 | # Create a chroot environment | |
50 | if [ ! -d "/etc/sbuild/chroot/${chroot}" ]; then | |
51 | if ! sbuild-createchroot --arch="${host_arch}" "${release}" \ | |
52 | "${CHROOT_PATH}/${chroot}"; then | |
53 | echo "Could not create chroot for ${release} on ${host_arch}" >&2 | |
54 | return 1 | |
55 | fi | |
56 | fi | |
57 | ||
40507036 MT |
58 | # And for each architecture we want to support |
59 | local arch | |
60 | for arch in ${ARCHITECTURES[@]}; do | |
40507036 MT |
61 | # Run the build process |
62 | if ! sbuild --dist="${release}" --host="${arch}"; then | |
63 | echo "Could not build package for ${release} on ${arch}" >&2 | |
64 | return 1 | |
65 | fi | |
66 | done | |
67 | done | |
68 | ||
69 | popd | |
70 | ||
71 | # Cleanup | |
72 | rm -rf "${tmp}" | |
73 | } | |
74 | ||
75 | main "$@" || exit $? |