From 4888a20eb6bd6643364fdcbe3564cd94687bbaf4 Mon Sep 17 00:00:00 2001 From: Botspot <54716352+Botspot@users.noreply.github.com> Date: Thu, 5 Oct 2023 14:55:39 -0500 Subject: [PATCH] Allow installing local packages of foreign architecture --- api | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/api b/api index f1d55a8ba6..ace1f86263 100755 --- a/api +++ b/api @@ -401,11 +401,20 @@ install_packages() { #Make some packages dependencies of the $app app. Package-n [ -f "$package" ] || error "install_packages(): Local package does not exist! ($package)" - #determine the package name from the filename - packagename="$(dpkg-deb -I "$package" | grep "^ Package:" | awk '{print $2}')" - packageversion="$(dpkg-deb -I "$package" | grep "^ Version:" | awk '{print $2}')" - [ -z "$packagename" ] && error "install_packages(): failed to determine a package-name for the file '$package'" - [ -z "$packageversion" ] && error "install_packages(): failed to determine a package-version for the file '$package'" + #determine the package name, package version, and architecture from the file + local dpkg_deb_output="$(dpkg-deb -I "$filename")" + local packagename="$(echo "$dpkg_deb_output" | grep "^ Package:" | awk '{print $2}')" + local packageversion="$(echo "$dpkg_deb_output" | grep "^ Version:" | awk '{print $2}')" + local packagearch="$(echo "$dpkg_deb_output" | grep "^ Architecture:" | awk '{print $2}')" + [ -z "$packagename" ] && error "install_packages(): failed to determine a package-name for the file '$filename'" + [ -z "$packageversion" ] && error "install_packages(): failed to determine a package-version for the file '$filename'" + [ -z "$packagearch" ] && error "install_packages(): failed to determine a package-architecture for the file '$filename'" + unset dpkg_deb_output + + #foreign arch: add :armhf or :arm64 to the packagename if this local package is of a foreign architecture + if [ "$packagearch" != "$(dpkg --print-architecture)" ];then + packagename+=":$packagearch" + fi #add this local package to the pi-apps-local-packages repository repo_add "$package" || return 1 @@ -429,11 +438,20 @@ install_packages() { #Make some packages dependencies of the $app app. Package-n wget -O "$filename" "$package" || return 1 - #determine the package name from the filename - packagename="$(dpkg-deb -I "$filename" | grep "^ Package:" | awk '{print $2}')" - packageversion="$(dpkg-deb -I "$filename" | grep "^ Version:" | awk '{print $2}')" + #determine the package name, package version, and architecture from the file + local dpkg_deb_output="$(dpkg-deb -I "$filename")" + local packagename="$(echo "$dpkg_deb_output" | grep "^ Package:" | awk '{print $2}')" + local packageversion="$(echo "$dpkg_deb_output" | grep "^ Version:" | awk '{print $2}')" + local packagearch="$(echo "$dpkg_deb_output" | grep "^ Architecture:" | awk '{print $2}')" [ -z "$packagename" ] && error "install_packages(): failed to determine a package-name for the file '$filename'" [ -z "$packageversion" ] && error "install_packages(): failed to determine a package-version for the file '$filename'" + [ -z "$packagearch" ] && error "install_packages(): failed to determine a package-architecture for the file '$filename'" + unset dpkg_deb_output + + #foreign arch: add :armhf or :arm64 to the packagename if this local package is of a foreign architecture + if [ "$packagearch" != "$(dpkg --print-architecture)" ];then + packagename+=":$packagearch" + fi #add this local package to the pi-apps-local-packages repository repo_add "$filename" || return 1