Commit e920d21f authored by Guido Gunther's avatar Guido Gunther

Merge branch 'dk' into 'master'

Allow latest builds to fetch kernels from Jenkins to support devkits

See merge request Librem5/image-builder!57
parents d421431f 324ff239
Pipeline #2984 passed with stage
in 14 seconds
......@@ -4,7 +4,7 @@ node {
artifacts = "checksums,${params.board}.img.xz,tmp/*-report.log"
build_on_x86 = [ 'imx6', 'qemu-x86_64' ]
qcow2_builds = [ 'qemu-x86_64' ]
currentBuild.description = "${params.board} ${params.dist} image"
currentBuild.description = "${params.board} ${params.dist} ${build_type} image"
parameters {
string(name: 'board', defaultValue: "imx6", description: 'What board type to build for?')
......
......@@ -11,9 +11,10 @@ set -u
usage() {
echo "Usage : $1 "
echo " -h Display this help message."
echo " -b [imx6|imx8|qemu-x86_64] select the board type."
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,8 @@ build_tarball=
want_qcow2=
apt_sources=
debootstrap_dist=
kernel_deb=
custom_package_opt=
while getopts ":hb:d:T:B" opt; do
case ${opt} in
......@@ -89,7 +113,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,21 +127,41 @@ 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
[ -n "${kernel_deb}" ] || { echo "No kernel found."; exit 1; }
custom_package_opt=(--custom-package "${kernel_deb}")
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}"
custom_package_opt=(--custom-package "files/${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
escaped_apt_sources=$(echo "${apt_sources}" | sed 's/$/|/g')
set -x
# shellcheck disable=SC2086
sudo pureos_board="${pureos_board}" \
distro="${distro}" \
packages="${packages}" \
......@@ -139,6 +182,7 @@ sudo pureos_board="${pureos_board}" \
--root-password='root' --hostname='pureos' --user=purism/123456 --sudo \
--customize "${cwd}/root.sh" \
--owner "$(whoami)" \
"${custom_package_opt[@]}" \
"${vmdebootstrap_opts[@]}" \
${NULL}
set +x
......
......@@ -21,7 +21,6 @@ case ${pureos_board} in
--bootsize 200M
--boottype ext2
--bootoffset 1M
--custom-package "files/${kernel_deb}"
--no-kernel
--no-update-initramfs
--arch="${arch}"
......@@ -43,7 +42,6 @@ case ${pureos_board} in
--bootsize 200M
--boottype ext2
--bootoffset 5M
--custom-package "files/${kernel_deb}"
--no-kernel
--no-update-initramfs
--arch="${arch}"
......@@ -63,7 +61,6 @@ case ${pureos_board} in
--bootsize 200M
--boottype ext2
--bootoffset 5MiB
--custom-package "files/${kernel_deb}"
--no-kernel
--no-update-initramfs
--arch="${arch}"
......@@ -73,6 +70,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
......@@ -83,7 +82,6 @@ case ${pureos_board} in
--bootsize 200M
--boottype ext2
--bootoffset 5MiB
--custom-package "files/${kernel_deb}"
--no-kernel
--arch="${arch}"
)
......
boot-imx8.txt.in
\ No newline at end of file
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