Merge ~alfonsosanchezbeato/ondras-snaps/+git/linux-kernel:cross-compile into ~ondrak/ondras-snaps/+git/linux-kernel:ubuntu-focal-imx

Proposed by Alfonso Sanchez-Beato
Status: Needs review
Proposed branch: ~alfonsosanchezbeato/ondras-snaps/+git/linux-kernel:cross-compile
Merge into: ~ondrak/ondras-snaps/+git/linux-kernel:ubuntu-focal-imx
Diff against target: 106 lines (+52/-6)
2 files modified
snap-tools/get-packages.sh (+43/-0)
snap/snapcraft.yaml (+9/-6)
Reviewer Review Type Date Requested Status
Ondrej Kubik Pending
Review via email: mp+403679@code.launchpad.net

Commit message

Some changes to allow cross-compiling the snap

Description of the change

Some changes to allow cross-compiling the snap

To post a comment you must log in.

Unmerged commits

fc1fe79... by Alfonso Sanchez-Beato

Specify the kernel-run-on field for the kernel plugin

Specify the kernel-run-on field for the (custom) kernel plugin so it
will cross-compile.

37a184e... by Alfonso Sanchez-Beato

Clean-up architectures field

fc09f28... by Alfonso Sanchez-Beato

Make test-keys pullable for all

741d862... by Alfonso Sanchez-Beato

Pull libjson directly instead of from build-packages

Otherwise cross-compilation will not work unless we run
"dpkg --add-architecture arm64", which can be problematic.

d2d9eb2... by Alfonso Sanchez-Beato

Add script to stage debian packages

Add script to stage debian packages from a part, written originally by
Oliver Grawert.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/snap-tools/get-packages.sh b/snap-tools/get-packages.sh
2new file mode 100755
3index 0000000..7c38f86
4--- /dev/null
5+++ b/snap-tools/get-packages.sh
6@@ -0,0 +1,43 @@
7+#! /bin/sh
8+
9+# dowloads and unpacks .deb packages for defined arch
10+# this needs coreutils, dctrl-tools and wget added to
11+# build-packages when used via snapcraft.yaml
12+
13+ARCH=arm64
14+SERIES=focal
15+
16+PKGLIST="$*"
17+echo "$(basename "$0"): obtaining packages for $ARCH: $PKGLIST"
18+
19+case $ARCH in
20+ armhf|arm64)
21+ SERVER="http://ports.ubuntu.com"
22+ ;;
23+ *)
24+ SERVER="http://archive.ubuntu.com/ubuntu"
25+ ;;
26+esac
27+
28+for pkg in $PKGLIST; do
29+ PKGPATH=""
30+ for POCKET in universe main; do
31+ PACKAGES="$SERVER/dists/$SERIES/$POCKET/binary-$ARCH/Packages.gz"
32+ UPACKAGES="$SERVER/dists/$SERIES-updates/$POCKET/binary-$ARCH/Packages.gz"
33+ if wget -q -O- $UPACKAGES | zcat | grep-dctrl -P "${pkg}" |
34+ grep Filename | grep -q "/${pkg}_"; then
35+ PKGPATH="$(wget -q -O- $UPACKAGES | zcat | grep-dctrl -P "${pkg}" |
36+ grep Filename | grep "${pkg}_" | sed 's/^Filename: //')"
37+ elif wget -q -O- $PACKAGES | zcat | grep-dctrl -P "${pkg}" |
38+ grep Filename | grep -q "/${pkg}_"; then
39+ PKGPATH="$(wget -q -O- $PACKAGES | zcat | grep-dctrl -P "${pkg}" |
40+ grep Filename | grep "${pkg}_" | sed 's/^Filename: //')"
41+ else
42+ PKGPATH=""
43+ fi
44+ if [ -n "$PKGPATH" ]; then
45+ echo "unpacking $pkg from $SERVER/$PKGPATH"
46+ wget -q -O- $SERVER/$PKGPATH | dpkg -x - .
47+ fi
48+ done
49+done
50diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
51index f061384..9bbe800 100644
52--- a/snap/snapcraft.yaml
53+++ b/snap/snapcraft.yaml
54@@ -11,10 +11,6 @@ build-base: core18
55
56 architectures:
57 - build-on: amd64
58- run-on: armhf, arm64
59- - build-on: armhf
60- run-on: armhf
61- - build-on: arm64
62 run-on: arm64
63
64 # environment to run fde-setup hook
65@@ -40,6 +36,7 @@ parts:
66 kernel-initrd-core-base: core20
67 kernel-initrd-flavour: edge-splash
68 kernel-initrd-compression: gz
69+ kernel-run-on: arm64
70 kernel-initrd-addons:
71 - usr/bin/fde-reveal-key
72 - usr/lib/libteec.so*
73@@ -222,12 +219,19 @@ parts:
74 echo "Cross building for arm64"
75 export CROSS_COMPILE="aarch64-linux-gnu-"
76 fi
77+ $SNAPCRAFT_PROJECT_DIR/snap-tools/get-packages.sh libjson-c4 libjson-c-dev
78 export ARCH="arm64"
79 export TA_DEV_KIT_DIR="${SNAPCRAFT_STAGE}/export-ta_arm64"
80 export CFG_TEE_CLIENT_LOG_LEVEL="1"
81 export OPTEE_CLIENT_EXPORT="${SNAPCRAFT_STAGE}/usr"
82 export DESTDIR=${SNAPCRAFT_PART_INSTALL}
83 export O="${SNAPCRAFT_PART_BUILD}/out"
84+ inc_d1=-I"$SNAPCRAFT_STAGE"/usr/include/
85+ inc_d2=-I"$SNAPCRAFT_STAGE"/export-ta_arm64/host_include/
86+ inc_d3=-I"$PWD"/ta/fde_key_handler/include/
87+ inc_d4=-I"$PWD"/usr/include/
88+ export CFLAGS="$inc_d1 $inc_d2 $inc_d3 $inc_d4"
89+ export LDFLAGS="-L$PWD/usr/lib/aarch64-linux-gnu/"
90 make -j$(nproc)
91 make install
92 organize:
93@@ -240,7 +244,7 @@ parts:
94
95 test-keys:
96 plugin: dump
97- source: git+ssh://ondrak@git.launchpad.net/~ondrak/+git/dev-keys
98+ source: https://git.launchpad.net/~ondrak/+git/dev-keys
99 source-type: git
100 source-branch: master
101 organize:
102@@ -267,4 +271,3 @@ build-packages:
103 - bison
104 - initramfs-tools-core
105 - wget
106- - libjson-c-dev:arm64

Subscribers

People subscribed via source and target branches