]> git.ipfire.org Git - location/libloc.git/commitdiff
debian: Setup build environment only once per release
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2020 11:28:11 +0000 (11:28 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 19 May 2020 11:28:11 +0000 (11:28 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
debian/build.sh

index 0c2391cfed4b073bdaa956a51f9e2024e7f5aeaa..f8e39f0f0b864cf4a57e114682bc9de975a8609f 100644 (file)
@@ -13,6 +13,13 @@ main() {
         return 2
     fi
 
+    # Get host architecture
+    local host_arch="$(dpkg --print-architecture)"
+    if [ -z "${host_arch}" ]; then
+        echo "Could not discover host architecture" >&2
+        return 1
+    fi
+
     local package="${1}"
     local sources="${2}"
 
@@ -37,20 +44,20 @@ main() {
     # Build the package for each release
     local release
     for release in ${RELEASES[@]}; do
+        local chroot="${release}-${host_arch}-sbuild"
+
+        # Create a chroot environment
+        if [ ! -d "/etc/sbuild/chroot/${chroot}" ]; then
+            if ! sbuild-createchroot --arch="${host_arch}" "${release}" \
+                    "${CHROOT_PATH}/${chroot}"; then
+                echo "Could not create chroot for ${release} on ${host_arch}" >&2
+                return 1
+            fi
+        fi
+
         # 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