build-image 2.32 KB
Newer Older
Pedro Vicente's avatar
Pedro Vicente committed
1
#!/bin/bash
2 3 4 5 6
#
# Copyright (C) 2017 Purism SPC
#
# SPDX-License-Identifier: GPL-3.0+
#
Pedro Vicente's avatar
Pedro Vicente committed
7 8

set -e
Guido Gunther's avatar
Guido Gunther committed
9
set -u
Pedro Vicente's avatar
Pedro Vicente committed
10

11 12 13
usage() {
  echo "Usage : $1 "
  echo "    -h Display this help message."
14
  echo "    -b [imx6|imx8|qemu] select the board type."
15 16 17
  echo "    -d <distro> optional select the puros distro"
}

18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

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."
}


33
cwd=`pwd`
Pedro Vicente's avatar
Pedro Vicente committed
34

35
distro=${DIST:-buster}
36
mirror=${MIRROR:-"http://deb.debian.org/debian"}
37
pureos_board=imx6
Guido Gunther's avatar
Guido Gunther committed
38
kernel_url=https://storage.puri.sm/librem5/binaries/unstable/latest/files/
Guido Gunther's avatar
Guido Gunther committed
39
NULL=
40
image_options=''
Pedro Vicente's avatar
Pedro Vicente committed
41

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
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

62
bootimg="${pureos_board}.img"
63
uboot=u-boot-${pureos_board}.imx
64

65
. conf/board
66 67
. conf/packages

68
echo "Installing extra packages ${packages}"
69

70
mkdir -p tmp/ files/
71
echo -n > files/meta.yml
72

73
kernel_deb=linux-image-${kernel_version}_${kernel_arch}.deb
74
[ -f "files/${kernel_deb}" ] || wget -Pfiles/ "${kernel_url}/${kernel_deb}"
Guido Gunther's avatar
Guido Gunther committed
75

76 77
[ "${board_type}" != "nitrogen6" ] || fetch_nitrogen_uboot_upgrade ${pureos_board} ${kernel_url} files/

78
sudo pureos_board=${pureos_board} distro=${distro} packages="${packages}" \
79 80
    http_proxy=${http_apt_proxy:-${http_proxy:-}} \
    https_proxy=${https_apt_proxy:-${https_proxy:-}} vmdebootstrap \
81
    --enable-dhcp --no-kernel \
82
    --verbose --image $bootimg --log tmp/$bootimg.log --size 3G  \
83
    --bootoffset 1M \
84
    --mirror "${mirror}" \
85
    --arch=${arch} \
Pedro Vicente's avatar
Pedro Vicente committed
86
    --foreign=/usr/bin/qemu-arm-static \
Pedro Vicente's avatar
Pedro Vicente committed
87
    --configure-apt \
Pedro Vicente's avatar
Pedro Vicente committed
88
    --no-extlinux \
89
    --distribution "$distro" \
Pedro Vicente's avatar
Pedro Vicente committed
90 91
    --serial-console-command "/sbin/getty -L ttymxc0 115200 vt100" \
    --root-password='root' --hostname='pureos' --user=purism/purism --sudo \
92
    --customize $cwd/root.sh \
93
    --no-update-initramfs \
94
    --custom-package "files/${kernel_deb}" \
95
    --owner $(whoami) \
96 97
    --bootsize 200M \
    --boottype ext2 \
98
    ${NULL}
99

100
echo "gitrev: $(git log --format=format:%H -1)" >> files/meta.yml
101