Skip to content

Commit d875832

Browse files
authored
Merge pull request #2525 from xypron/riscv64
snap: enable riscv64 building
2 parents 23cbdf6 + 042b73d commit d875832

File tree

1 file changed

+44
-30
lines changed

1 file changed

+44
-30
lines changed

snap/snapcraft.yaml

Lines changed: 44 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ parts:
130130
DEB_URL="http://launchpadlibrarian.net/548325871/linux-libc-dev_5.8.0-63.71_armhf.deb"
131131
elif [ $ARCH = s390x ]; then
132132
DEB_URL="http://launchpadlibrarian.net/548279675/linux-libc-dev_5.8.0-63.71_s390x.deb"
133+
elif [ $ARCH = riscv64 ]; then
134+
DEB_URL="http://launchpadlibrarian.net/548280908/linux-libc-dev_5.8.0-63.71_riscv64.deb"
133135
fi
134136
wget --quiet ${DEB_URL} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
135137
echo -n "Unpacking kernel headers..."
@@ -194,27 +196,33 @@ parts:
194196
override-pull: |
195197
KERNEL_VER="4.18.0"
196198
ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
197-
if [ $ARCH = amd64 ] || [ $ARCH = ppc64el ] || [ $ARCH = arm64 ]; then
199+
if [ $ARCH = amd64 ] || [ $ARCH = ppc64el ] || [ $ARCH = arm64 ]; then
198200
DEB_URL="http://launchpadlibrarian.net/431512728/linux-libc-dev_4.18.0-26.27_amd64.deb"
199201
elif [ $ARCH = armhf ]; then
200202
DEB_URL="http://launchpadlibrarian.net/431525966/linux-libc-dev_4.18.0-26.27_armhf.deb"
201203
elif [ $ARCH = s390x ]; then
202204
DEB_URL="http://launchpadlibrarian.net/431485536/linux-libc-dev_4.18.0-26.27_s390x.deb"
203205
fi
204-
wget --quiet ${DEB_URL} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
205-
echo -n "Unpacking kernel headers..."
206-
dpkg -x ${SNAPCRAFT_STAGE}/linux-libc-dev.deb ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
207-
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
208-
rm -f ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
206+
# Ubuntu 18.10 Cosmic Cuttle had no riscv64 support
207+
if [ $ARCH != riscv64 ]; then
208+
wget --quiet ${DEB_URL} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
209+
echo -n "Unpacking kernel headers..."
210+
dpkg -x ${SNAPCRAFT_STAGE}/linux-libc-dev.deb ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
211+
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
212+
rm -f ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
213+
fi
209214
override-build: |
210215
snapcraftctl build
211-
# Move header from the part to the host
212-
ARCH_DIR=$(ls -d ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
213-
for d in linux asm-generic $ARCH_DIR/asm; do
214-
dest=/usr/include/$d
215-
rm -rf $dest
216-
mv ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/$d ${dest%/*}
217-
done
216+
ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
217+
if [ $ARCH != riscv64 ]; then
218+
# Move header from the part to the host
219+
ARCH_DIR=$(ls -d ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
220+
for d in linux asm-generic $ARCH_DIR/asm; do
221+
dest=/usr/include/$d
222+
rm -rf $dest
223+
mv ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/$d ${dest%/*}
224+
done
225+
fi
218226
rm -rf ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
219227
echo -n "Build kernel:"
220228
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
@@ -259,24 +267,30 @@ parts:
259267
ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
260268
if [ $ARCH = amd64 ]; then
261269
ARCHIVE_URL="http://security.ubuntu.com/ubuntu/pool/main/l/linux/"
262-
else
270+
elif [ $ARCH != riscv64 ]; then
263271
ARCHIVE_URL="http://ports.ubuntu.com/pool/main/l/linux/"
264272
fi
265-
DEB_SUFFIX=$(wget ${ARCHIVE_URL} -O - | grep linux-libc-dev | cut -d'_' -f2-3 | cut -d'"' -f1 | grep ${ARCH} | grep ${KERNEL_VER} | tail -n1)
266-
wget --quiet ${ARCHIVE_URL}/linux-libc-dev_${DEB_SUFFIX} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
267-
echo -n "Unpacking kernel headers..."
268-
dpkg -x ${SNAPCRAFT_STAGE}/linux-libc-dev.deb ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
269-
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
270-
rm -f ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
273+
# Ubuntu 18.40 (Bionic Beaver) had no riscv64 support
274+
if [ $ARCH != riscv64 ]; then
275+
DEB_SUFFIX=$(wget ${ARCHIVE_URL} -O - | grep linux-libc-dev | cut -d'_' -f2-3 | cut -d'"' -f1 | grep ${ARCH} | grep ${KERNEL_VER} | tail -n1)
276+
wget --quiet ${ARCHIVE_URL}/linux-libc-dev_${DEB_SUFFIX} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
277+
echo -n "Unpacking kernel headers..."
278+
dpkg -x ${SNAPCRAFT_STAGE}/linux-libc-dev.deb ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
279+
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
280+
rm -f ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
281+
fi
271282
override-build: |
272283
snapcraftctl build
273284
# Move header from the part to the host
274-
ARCH_DIR=$(ls -d ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
275-
for d in linux asm-generic $ARCH_DIR/asm; do
276-
dest=/usr/include/$d
277-
rm -rf $dest
278-
mv ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/$d ${dest%/*}
279-
done
285+
ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
286+
if [ $ARCH != riscv64]; then
287+
ARCH_DIR=$(ls -d ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
288+
for d in linux asm-generic $ARCH_DIR/asm; do
289+
dest=/usr/include/$d
290+
rm -rf $dest
291+
mv ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/$d ${dest%/*}
292+
done
293+
fi
280294
rm -rf ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
281295
echo -n "Build kernel:"
282296
printf " %d.%d.%d\n" $(printf "%6.6x" $(grep LINUX_VERSION_CODE /usr/include/linux/version.h | sed -e "s/.*CODE //") | sed -e "s/\(..\)\(..\)/0x\1 0x\2 0x/")
@@ -323,9 +337,9 @@ parts:
323337
elif [ $ARCH = armhf ]; then
324338
DEB_URL="http://launchpadlibrarian.net/422971427/linux-libc-dev_3.13.0-170.220_i386.deb"
325339
fi
326-
if [ $ARCH != s390x ]; then
327-
# s390x was not supported on Trusty, so there are no kernel headers for it.
328-
# Just let it build with the previous headers.
340+
if [ $ARCH != s390x ] && [ $ARCH != riscv64 ]; then
341+
# riscv64 and s390x were not supported on Trusty, so there are no kernel headers for them.
342+
# Just let them build with the previous headers.
329343
wget --quiet ${DEB_URL} -O ${SNAPCRAFT_STAGE}/linux-libc-dev.deb
330344
echo -n "Unpacking kernel headers..."
331345
dpkg -x ${SNAPCRAFT_STAGE}/linux-libc-dev.deb ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev
@@ -335,7 +349,7 @@ parts:
335349
override-build: |
336350
snapcraftctl build
337351
ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
338-
if [ $ARCH != s390x ]; then
352+
if [ $ARCH != s390x ] && [ $ARCH != riscv64]; then
339353
# Move header from the part to the host
340354
ARCH_DIR=$(ls -d ${SNAPCRAFT_STAGE}/keepalived-linux-libc-dev/usr/include/*/asm | sed -e "s:/asm$::" -e "s:.*/::")
341355
for d in linux asm-generic $ARCH_DIR/asm; do

0 commit comments

Comments
 (0)