Commit 2923d6bc authored by Guido Gunther's avatar Guido Gunther

build-image: Allow to fetch latest kernels from Jenkins

This is mostly based on Angus Ainslie's work for the devkit test images.
parent 5e369aee
......@@ -13,7 +13,8 @@ usage() {
echo " -h Display this help message."
echo " -b [imx6|imx8|devkit|qemu-x86_64] select the board type."
echo " -d <distro> distro to use. [ green, purple, buster, green+ci, buster+ci, purple+ci ]"
echo " -T [ci|unstable] use the artifacts from this build for the image"
# TODO: add stable and drop ci
echo " -T kernel/uboot build type (unstable/ci/latest)"
echo " -B build rootfs tarball as well"
}
......@@ -31,6 +32,27 @@ fetch_nitrogen_uboot_upgrade() {
echo "done."
}
fetch_latest_kernel() {
[ -n "${kernel_latest_url}" ] || { echo "kernel_latest_url not set in board config"; exit 1; }
rm -f files/archive.zip
echo "Fetching kernel from ${kernel_latest_url}"
wget -nv --no-glob -Pfiles/ "${kernel_latest_url}"
(cd files/ && unzip -ojq archive.zip)
}
fetch_latest_uboot() {
local dir="files/uboot-${1}"
[ -n "${uboot_latest_url}" ] || { echo "uboot_latest_url not set in board config"; exit 1; }
rm -f "${dir}/archive.zip"
echo "Fetching uboot from ${uboot_latest_url}"
wget -nv --no-glob -P"${dir}" "${uboot_latest_url}"
(cd "${dir}" && unzip -ojq archive.zip)
}
setup_loop() {
local image="$1"
set -x
......@@ -58,6 +80,7 @@ build_tarball=
want_qcow2=
apt_sources=
debootstrap_dist=
kernel_deb=
while getopts ":hb:d:T:B" opt; do
case ${opt} in
......@@ -89,7 +112,6 @@ done
[[ "${distro}" =~ \+ci ]] && ci_pkgs=1 || ci_pkgs=0
distro="${distro/+ci}"
kernel_url=https://storage.puri.sm/librem5/binaries/${build_type}/latest/files/
bootimg="${pureos_board}.img"
. conf/board
......@@ -104,15 +126,31 @@ echo "Installing extra packages ${packages}"
mkdir -p tmp/ files/
echo -n > files/meta.yml
if [ -n "${kernel_deb}" ] && [ ! -f "files/${kernel_deb}" ]; then
wget -Pfiles/ "${kernel_url}/${kernel_deb}"
fi
if [ "${build_type}" == "latest" ]; then
fetch_latest_kernel
fetch_latest_uboot "${uboot_type}"
kernel_deb=
for deb in files/linux-image-*-*_arm64.deb; do
! [[ "${deb}" =~ dbg ]] || continue
if [ -n "${kernel_deb}" ]; then
echo "Found more than one possible kernel deb in files/"
exit 1
fi
kernel_deb="$deb"
done
else
kernel_url=https://storage.puri.sm/librem5/binaries/${build_type}/latest/files/
if [ -n "${kernel_deb}" ] && [ ! -f "files/${kernel_deb}" ]; then
wget -Pfiles/ "${kernel_url}/${kernel_deb}"
fi
if [ -n "${uboot_bin}" ] && [ ! -f "files/uboot-${uboot_type}/${uboot_bin}" ]; then
wget -Pfiles/uboot-${uboot_type} "${kernel_url}/uboot-${uboot_type}/${uboot_bin}"
if [ -n "${uboot_bin}" ] && [ ! -f "files/uboot-${uboot_type}/${uboot_bin}" ]; then
wget -Pfiles/uboot-${uboot_type} "${kernel_url}/uboot-${uboot_type}/${uboot_bin}"
fi
[ "${board_type}" != "nitrogen6" ] || fetch_nitrogen_uboot_upgrade "${pureos_board}" "${kernel_url}" files/
fi
[ "${board_type}" != "nitrogen6" ] || fetch_nitrogen_uboot_upgrade "${pureos_board}" "${kernel_url}" files/
echo "Using kernel ${kernel_deb}"
# Preserve newlines as '|'
# shellcheck disable=SC2001
......
......@@ -73,6 +73,8 @@ case ${pureos_board} in
arch=arm64
kernel_arch=arm64
kernel_version=4.18.11-g73af4578_4.18.11-g73af4578-1
kernel_latest_url='https://arm01.puri.sm/job/Kernel_builds/job/Emcraft_Kernel_CI_build/lastSuccessfulBuild/artifact/*zip*/archive.zip'
uboot_latest_url='https://arm01.puri.sm/job/u-boot_builds/job/devkit_test_uboot_build/lastSuccessfulBuild/artifact/*zip*/archive.zip'
board_type=unknown
fdt_file=librem5-evk.dtb
qemu=/usr/bin/qemu-aarch64-static
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment