-
Notifications
You must be signed in to change notification settings - Fork 457
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
repo: default to target arch for stage package cache (#3416)
- Add interface to project to define which arch should be used for staging packages. - Add target_arch parameter to fetch_stage_packages(). - Update apt_cache to support specifying the default architecture for the stage package cache. If running with an existing cache, check if <cache>/etc/apt is a symlink (how it was done up until now) and unlink it. Then copy the /etc/apt tree instead of linking it. Finally, add a config file to specify the default target architecture. Write that config file out every time the stage cache is (re)initialized. - Update all usage of fetch_stage_packages() to comply with new interface. Signed-off-by: Chris Patterson <[email protected]>
- Loading branch information
Chris Patterson
authored
Jan 14, 2021
1 parent
104c6a8
commit 8f418e3
Showing
22 changed files
with
216 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tests/spread/cross-compile/stage-packages/snap/snapcraft.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: cross-compile-stage-package-test | ||
base: core20 | ||
version: '0.1' | ||
summary: Test | ||
description: | | ||
Test xcompile stage-packages behavior for core20. | ||
grade: stable | ||
confinement: strict | ||
|
||
parts: | ||
my-part: | ||
plugin: nil | ||
stage-packages: | ||
- jq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
summary: Cross-compiliation stage-package test | ||
|
||
systems: | ||
- ubuntu-20.04* | ||
|
||
environment: | ||
SNAP_DIR: . | ||
|
||
prepare: | | ||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
set_base "$SNAP_DIR/snap/snapcraft.yaml" | ||
# For gcc and dpkg-architecture. | ||
apt-get install -y dpkg-dev gcc | ||
apt-mark auto dpkg-dev gcc | ||
# Add architecture to sources. | ||
codename="$(lsb_release -cs)" | ||
echo "deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports $codename main restricted universe multiverse" > /etc/apt/sources.list.d/armhf.list | ||
# Save original sources, but specify to host arch only. | ||
host_arch="$(dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d =)" | ||
cp /etc/apt/sources.list /etc/apt/sources.list.save | ||
sed -i "s|^deb |deb [arch=$host_arch] |g" /etc/apt/sources.list | ||
# Add armhf arch and update apt cache. | ||
dpkg --add-architecture armhf | ||
apt-get update | ||
restore: | | ||
cd "$SNAP_DIR" | ||
snapcraft clean | ||
rm -f ./*.snap | ||
# Remove architecture from sources. | ||
mv /etc/apt/sources.list.save /etc/apt/sources.list | ||
rm -f /etc/apt/sources.list.d/armhf.list | ||
rm -f /etc/apt/sources.list.d/main.list | ||
# Remove arch and update apt cache. | ||
dpkg --remove-architecture armhf | ||
apt-get update | ||
#shellcheck source=tests/spread/tools/snapcraft-yaml.sh | ||
. "$TOOLS_DIR/snapcraft-yaml.sh" | ||
restore_yaml "snap/snapcraft.yaml" | ||
execute: | | ||
cd "$SNAP_DIR" | ||
host_arch="$(dpkg-architecture | grep DEB_BUILD_ARCH= | cut -f 2 -d =)" | ||
host_arch_triplet="$(gcc -dumpmachine)" | ||
# First build for armhf. | ||
snapcraft --target-arch armhf --enable-experimental-target-arch | ||
[ -f cross-compile-stage-package-test_0.1_armhf.snap ] | ||
[ -f prime/usr/lib/arm-linux-gnueabihf/libjq.so.1 ] | ||
[ "$(ls prime/usr/lib/)" == "arm-linux-gnueabihf" ] | ||
rm cross-compile-stage-package-test_0.1_armhf.snap | ||
# Re-spin as native. | ||
snapcraft | ||
[ -f "cross-compile-stage-package-test_0.1_$host_arch.snap" ] | ||
[ -f "prime/usr/lib/$host_arch_triplet/libjq.so.1" ] | ||
[ "$(ls prime/usr/lib/)" == "$host_arch_triplet" ] | ||
rm "cross-compile-stage-package-test_0.1_$host_arch.snap" | ||
# Re-build for armhf. | ||
snapcraft --target-arch armhf --enable-experimental-target-arch | ||
[ -f cross-compile-stage-package-test_0.1_armhf.snap ] | ||
[ -f prime/usr/lib/arm-linux-gnueabihf/libjq.so.1 ] | ||
[ "$(ls prime/usr/lib/)" == "arm-linux-gnueabihf" ] | ||
rm cross-compile-stage-package-test_0.1_armhf.snap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.