#!/bin/bash # # Copyright (C) 2017 Purism SPC # # SPDX-License-Identifier: GPL-3.0+ # set -e set -u usage() { echo "Usage : $1 " echo " -h Display this help message." echo " -b [imx6|imx8|qemu] select the board type." echo " -d optional select the puros distro" } fetch_nitrogen_uboot_upgrade() { board=$1 url=$2 out="$3" dest="${out}/uboot-${pureos_board}" [ ! -d "${dest}" ] || return 0 echo -n "Fetching uboot upgrade..." wget -q -Ascr -Aupgrade -A"*nitrogen*" -P"${dest}" -nd -l 1 --mirror "${url}/uboot-${pureos_board}/" echo "done." } cwd=`pwd` distro=${DIST:-buster} mirror=${MIRROR:-"http://deb.debian.org/debian"} pureos_board=imx6 kernel_url=https://storage.puri.sm/librem5/binaries/unstable/latest/files/ NULL= image_options='' while getopts ":hb:d:" opt; do case ${opt} in b) pureos_board=$OPTARG ;; d) distro=$OPTARG ;; \?) echo "Invalid Option: -$OPTARG" 1>&2 usage $0 exit 0 ;; h ) usage $0 exit 0 ;; esac done bootimg="${pureos_board}.img" uboot=u-boot-${pureos_board}.imx . conf/board . conf/packages echo "Installing extra packages ${packages}" mkdir -p tmp/ files/ echo -n > files/meta.yml kernel_deb=linux-image-${kernel_version}_${kernel_arch}.deb [ -f "files/${kernel_deb}" ] || wget -Pfiles/ "${kernel_url}/${kernel_deb}" [ "${board_type}" != "nitrogen6" ] || fetch_nitrogen_uboot_upgrade ${pureos_board} ${kernel_url} files/ sudo pureos_board=${pureos_board} distro=${distro} packages="${packages}" \ http_proxy=${http_apt_proxy:-${http_proxy:-}} \ https_proxy=${https_apt_proxy:-${https_proxy:-}} vmdebootstrap \ --enable-dhcp --no-kernel \ --verbose --image $bootimg --log tmp/$bootimg.log --size 3G \ --bootoffset 1M \ --mirror "${mirror}" \ --arch=${arch} \ --foreign=/usr/bin/qemu-arm-static \ --configure-apt \ --no-extlinux \ --distribution "$distro" \ --serial-console-command "/sbin/getty -L ttymxc0 115200 vt100" \ --root-password='root' --hostname='pureos' --user=purism/purism --sudo \ --customize $cwd/root.sh \ --no-update-initramfs \ --custom-package "files/${kernel_deb}" \ --owner $(whoami) \ --bootsize 200M \ --boottype ext2 \ ${NULL} echo "gitrev: $(git log --format=format:%H -1)" >> files/meta.yml