summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfunctions/packagelists.sh27
-rwxr-xr-xscripts/build/chroot_install-packages32
-rwxr-xr-xscripts/build/chroot_package-lists11
3 files changed, 70 insertions, 0 deletions
diff --git a/functions/packagelists.sh b/functions/packagelists.sh
index 906697264..8470d9af9 100755
--- a/functions/packagelists.sh
+++ b/functions/packagelists.sh
@@ -118,3 +118,30 @@ Expand_packagelist ()
done
done
}
+
+Discover_package_architectures ()
+{
+ _LB_EXPANDED_PKG_LIST="${1}"
+ _LB_DISCOVERED_ARCHITECTURES=""
+
+ shift
+
+ if [ -e "${_LB_EXPANDED_PKG_LIST}" ] && [ -s "${_LB_EXPANDED_PKG_LIST}" ]
+ then
+ while read _LB_PACKAGE_LINE
+ do
+ # Lines from the expanded package list may have multiple, space-separated packages
+ for _LB_PACKAGE_LINE_PART in ${_LB_PACKAGE_LINE}
+ do
+ # Looking for <package>:<architecture>
+ if [ -n "$(echo ${_LB_PACKAGE_LINE_PART} | awk -F':' '{print $2}')" ]
+ then
+ _LB_DISCOVERED_ARCHITECTURES="${_LB_DISCOVERED_ARCHITECTURES} $(echo ${_LB_PACKAGE_LINE_PART} | awk -F':' '{print $2}')"
+ fi
+ done
+ done < "${_LB_EXPANDED_PKG_LIST}"
+
+ # Output unique architectures, alpha-sorted, one per line
+ echo "${_LB_DISCOVERED_ARCHITECTURES}" | tr -s '[:space:]' '\n' | sort | uniq
+ fi
+}
diff --git a/scripts/build/chroot_install-packages b/scripts/build/chroot_install-packages
index 930ececf0..a578a659a 100755
--- a/scripts/build/chroot_install-packages
+++ b/scripts/build/chroot_install-packages
@@ -42,6 +42,38 @@ Check_lockfile .lock
# Creating lock file
Create_lockfile .lock
+# Check for packages specified with foreign architecture
+_FOREIGN_ARCHITECTURES_FILE="chroot/root/packages.foreign-architectures"
+if [ -e "${_FOREIGN_ARCHITECTURES_FILE}" ] && [ -s "${_FOREIGN_ARCHITECTURES_FILE}" ]
+then
+ _APT_ARCHITECTURES_ADDED="0"
+
+ # Check if version of dpkg in chroot supports multiarch
+ if Chroot chroot dpkg --print-foreign-architectures > /dev/null 2>&1
+ then
+ # Add foregin architectures
+ while read _ARCHITECTURES_LINE
+ do
+ Echo_message "Adding foreign architecture ${_ARCHITECTURES_LINE} to dpkg"
+ Chroot chroot dpkg --add-architecture ${_ARCHITECTURES_LINE}
+
+ _APT_ARCHITECTURES_ADDED="1"
+ done < "${_FOREIGN_ARCHITECTURES_FILE}"
+
+ # Tidy up
+ rm -f "${_FOREIGN_ARCHITECTURES_FILE}"
+ else
+ Echo_error "Version of dpkg in chroot does not support foreign architectures."
+ fi
+
+ # Update apt if foreign architectures were added
+ if [ "${_APT_ARCHITECTURES_ADDED}" -ne "0" ]
+ then
+ Echo_message "Added foreign architectures, updating apt..."
+ Apt chroot update
+ fi
+fi
+
if [ -e chroot/root/packages.chroot ] && [ -s chroot/root/packages.chroot ]
then
# Restoring cache
diff --git a/scripts/build/chroot_package-lists b/scripts/build/chroot_package-lists
index 52f972881..ba808bd92 100755
--- a/scripts/build/chroot_package-lists
+++ b/scripts/build/chroot_package-lists
@@ -89,6 +89,17 @@ do
fi
done
+# Discover unique package architectures in fully-expanded package list
+for _PACKAGE_ARCHITECTURE in $(Discover_package_architectures "chroot/root/packages.chroot")
+do
+ # If this is a foreign architecture, append to packages.foreign-architectures
+ if [ "${_PACKAGE_ARCHITECTURE}" != "${LIVE_IMAGE_ARCHITECTURE}" ]
+ then
+ Echo_message "Accepting foreign architecture: ${_PACKAGE_ARCHITECTURE}, live image architecture is: ${LIVE_IMAGE_ARCHITECTURE}"
+ echo "${_PACKAGE_ARCHITECTURE}" >> chroot/root/packages.foreign-architectures
+ fi
+done
+
rm -f chroot/bin/Packages
case "${LB_BUILD_WITH_CHROOT}" in