Commit 948e9cb2 authored by Angus Ainslie's avatar Angus Ainslie
Browse files

Merge branch 'cleanups' into 'master'

Cleanups to make shellcheck pass on root.sh

See merge request Librem5/image-builder!101
parents 406961a5 0ef7c90c
......@@ -28,6 +28,7 @@ DEPS=\
SHELLCHECK_SCRIPTS=\
./build-image \
./root.sh \
build/build_kernel_deb.sh \
$(NULL)
......@@ -56,7 +57,6 @@ clean:
check:
shellcheck -x $(SHELLCHECK_SCRIPTS)
bash -n root.sh
publish: $(CHECKSUM)
bin/sign-checksum
......
......@@ -5,6 +5,20 @@
# SPDX-License-Identifier: GPL-3.0+
#
# Parmeters passed in via image builder:
# Mandatory
: "${apt_sources:?'apt_sources' not set}"
: "${distro:?'distro' not set}"
: "${packages:?'packages' not set}"
: "${pureos_board:?'pureos_board' not set}"
# Optional
: "${build_tarball:-}"
: "${ci_pkgs:-}"
: "${fdt_file:-}"
: "${kernel_deb:-}"
: "${patched:-}"
: "${qemu:-}"
# distro and basedir set by calling script
basedir="$1"
......@@ -36,13 +50,15 @@ function setup_qemu()
function setup_kernel()
{
local link
local fdt_source
fdt_source=""
mkdir -p tmp/
mkdir -p "${basedir}/boot/dtbs"
case "${pureos_board}" in
imx6)
fdt_source="${basedir}"/usr/lib/linux-image-*/"${fdt_file}"
fdt_source="${basedir}/usr/lib/linux-image-*/${fdt_file}"
link=$(basename "${basedir}"/boot/vmlinuz-*)
rm -f "${basedir}/boot/zImage"
ln -s "${link}" "${basedir}/boot/zImage"
......@@ -50,18 +66,16 @@ function setup_kernel()
cp "${basedir}/boot/zImage" "tmp/"
;;
ec-som|imx8)
fdt_source="${basedir}"/usr/lib/linux-image-*/freescale/"${fdt_file}"
fdt_source="${basedir}/usr/lib/linux-image-*/freescale/${fdt_file}"
cp "${basedir}/boot/${link}" "${basedir}/boot/Image.gz"
gunzip "${basedir}/boot/Image.gz"
;;
devkit*)
fdt_source="${basedir}"/usr/lib/linux-image-*/freescale/"${fdt_file}"
# Reconfigure kernel package to trigger kernel hooks
chroot "${basedir}" dpkg-reconfigure $(basename ${kernel_deb%%_*})
chroot "${basedir}" dpkg-reconfigure "$(basename "${kernel_deb%%_*}")"
;;
esac
cp ${fdt_source} "${basedir}/boot/dtbs/"
# Make sure we have the kernel available for tests
[ -z "${fdt_source}" ] || cp "${fdt_source}" "${basedir}/boot/dtbs/"
}
......@@ -108,8 +122,8 @@ function check_patched()
for pkg in ${patched}; do
# Not all architectures have all packages, so check this first
if chroot "${basedir}" dpkg -s ${pkg}; then
if ! chroot "${basedir}" dpkg -s ${pkg} | grep -qs "^Version: .*pureos"; then
if chroot "${basedir}" dpkg -s "${pkg}"; then
if ! chroot "${basedir}" dpkg -s "${pkg}" | grep -qs "^Version: .*pureos"; then
echo "${pkg} is not a patched version."
exit 1
fi
......@@ -201,8 +215,11 @@ function setup_locale()
function install_pkgs()
{
chroot "${basedir}" apt-get -y update
# Need to split package list
# shellcheck disable=SC2086
if ! chroot "${basedir}" apt -y install ${packages}; then
echo "Package installation failed, this might help to diagnose the problem:"
# shellcheck disable=SC2086
chroot "${basedir}" apt -y -o Debug::pkgProblemResolver=yes install -y --simulate ${packages}
fi
}
......@@ -210,6 +227,7 @@ function install_pkgs()
function setup_apt()
{
# shellcheck disable=SC2001
echo "${apt_sources}" | sed 's/|/\n/g' > "${basedir}/etc/apt/sources.list"
echo "Set sources list to:"
cat "${basedir}/etc/apt/sources.list"
......@@ -224,7 +242,7 @@ EOF
cat << EOF > "${basedir}/etc/apt/sources.list.d/ci.list"
deb http://ci.puri.sm/ scratch librem5
EOF
cat data/ci-repo.key | chroot ${basedir} apt-key add -
chroot "${basedir}" apt-key add - < data/ci-repo.key
fi
}
......
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