1259994Sgjb#!/bin/sh 2262810Sgjb#- 3262810Sgjb# Copyright (c) 2013, 2014 The FreeBSD Foundation 4262810Sgjb# All rights reserved. 5259994Sgjb# 6262810Sgjb# This software was developed by Glen Barber 7262810Sgjb# under sponsorship from the FreeBSD Foundation. 8262810Sgjb# 9262810Sgjb# Redistribution and use in source and binary forms, with or without 10262810Sgjb# modification, are permitted provided that the following conditions 11262810Sgjb# are met: 12262810Sgjb# 1. Redistributions of source code must retain the above copyright 13262810Sgjb# notice, this list of conditions and the following disclaimer. 14262810Sgjb# 2. Redistributions in binary form must reproduce the above copyright 15262810Sgjb# notice, this list of conditions and the following disclaimer in the 16262810Sgjb# documentation and/or other materials provided with the distribution. 17262810Sgjb# 18262810Sgjb# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19262810Sgjb# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20262810Sgjb# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21262810Sgjb# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22262810Sgjb# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23262810Sgjb# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24262810Sgjb# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25262810Sgjb# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26262810Sgjb# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27262810Sgjb# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28262810Sgjb# SUCH DAMAGE. 29262810Sgjb# 30259994Sgjb# $FreeBSD$ 31259994Sgjb# 32259994Sgjb 33259994Sgjb# This script is intended to be called by release/release.sh to build ARM 34259994Sgjb# images for release. It is not intended to be run directly. This sets up 35259994Sgjb# the software needed within a build chroot, then runs crochet to provide 36259994Sgjb# downloadable images for embedded devices. 37259994Sgjb 38259994Sgjbset -e 39259994Sgjb 40262314Sgjbbefore_build() { 41262314Sgjb WANT_UBOOT= 42262314Sgjb KNOWNHASH= 43262314Sgjb UBOOT_VERSION= 44262314Sgjb case ${KERNEL} in 45262314Sgjb BEAGLEBONE) 46262314Sgjb WANT_UBOOT=1 47262314Sgjb KNOWNHASH="4150e5a4480707c55a8d5b4570262e43af68d8ed3bdc0a433d8e7df47989a69e" 48262314Sgjb UBOOT_VERSION="u-boot-2013.04" 49262314Sgjb ;; 50262314Sgjb PANDABOARD) 51262314Sgjb WANT_UBOOT=1 52262314Sgjb KNOWNHASH="e08e20a6979bfca6eebb9a2b0e42aa4416af3d796332fd63a3470495a089d496" 53262314Sgjb UBOOT_VERSION="u-boot-2012.07" 54262314Sgjb ;; 55262314Sgjb WANDBOARD-QUAD) 56262314Sgjb WANT_UBOOT=1 57262314Sgjb KNOWNHASH="0d71e62beb952b41ebafb20a7ee4df2f960db64c31b054721ceb79ff14014c55" 58262314Sgjb UBOOT_VERSION="u-boot-2013.10" 59262314Sgjb ;; 60262314Sgjb *) 61262314Sgjb # Fallthrough. 62262314Sgjb ;; 63262314Sgjb esac 64262314Sgjb if [ ! -z ${WANT_UBOOT} ]; then 65262314Sgjb chroot ${CHROOTDIR} fetch -o /tmp/crochet/${UBOOT_VERSION}.tar.bz2 \ 66262314Sgjb http://people.freebsd.org/~gjb/${UBOOT_VERSION}.tar.bz2 67262314Sgjb UBOOT_HASH="$(sha256 -q ${CHROOTDIR}/tmp/crochet/${UBOOT_VERSION}.tar.bz2)" 68262314Sgjb if [ "${UBOOT_HASH}" != "${KNOWNHASH}" ]; then 69262314Sgjb echo "Checksum mismatch! Exiting now." 70262314Sgjb exit 1 71262314Sgjb fi 72262314Sgjb chroot ${CHROOTDIR} tar xf /tmp/crochet/${UBOOT_VERSION}.tar.bz2 \ 73262314Sgjb -C /tmp/crochet/ 74262314Sgjb fi 75262314Sgjb} 76262314Sgjb 77259994Sgjbinstall_crochet() { 78259994Sgjb chroot ${CHROOTDIR} svn co -q ${CROCHETSRC}/${CROCHETBRANCH} \ 79259994Sgjb /tmp/crochet 80259994Sgjb} 81259994Sgjb 82259994Sgjbinstall_uboot() { 83259994Sgjb # Only fetch u-boot sources if UBOOTSRC is set; otherwise it is 84259994Sgjb # not needed. 85262810Sgjb if [ -n "${UBOOTSRC}" ]; then 86259994Sgjb continue 87259994Sgjb else 88259994Sgjb return 0 89259994Sgjb fi 90259994Sgjb chroot ${CHROOTDIR} svn co -q ${UBOOTSRC}/${UBOOTBRANCH} \ 91259994Sgjb /${UBOOTDIR} 92259994Sgjb} 93259994Sgjb 94259994Sgjbmain() { 95262314Sgjb # Build gcc for use in the chroot for arm builds. 96262314Sgjb # This is not '-j'-safe, so force '-j1' to allow using 97262314Sgjb # additional, non-'-j' options specified in WORLD_FLAGS. 98262314Sgjb eval chroot ${CHROOTDIR} make -C /usr/src/gnu/usr.bin/cc \ 99262314Sgjb WITH_GCC=1 ${WORLD_FLAGS} -j1 obj depend all install 100259994Sgjb # Build the 'xdev' target for crochet. 101259994Sgjb eval chroot ${CHROOTDIR} make -C /usr/src \ 102264960Sgjb ${XDEV_FLAGS} XDEV=${XDEV} XDEV_ARCH=${XDEV_ARCH} \ 103262314Sgjb ${WORLD_FLAGS} xdev 104259994Sgjb 105259994Sgjb # Run the ldconfig(8) startup script so /var/run/ld-elf*.so.hints 106259994Sgjb # is created. 107259994Sgjb eval chroot ${CHROOTDIR} /etc/rc.d/ldconfig forcerestart 108259994Sgjb # Install security/ca_root_nss since we need to check the https 109259994Sgjb # certificate of github. 110259994Sgjb eval chroot ${CHROOTDIR} make -C /usr/ports/security/ca_root_nss \ 111259994Sgjb OPTIONS_SET="ETCSYMLINK" BATCH=1 FORCE_PKG_REGISTER=1 \ 112259994Sgjb install clean distclean 113259994Sgjb EMBEDDEDPORTS="${EMBEDDEDPORTS} devel/subversion" 114259994Sgjb for _PORT in ${EMBEDDEDPORTS}; do 115259994Sgjb eval chroot ${CHROOTDIR} make -C /usr/ports/${_PORT} \ 116259994Sgjb BATCH=1 FORCE_PKG_REGISTER=1 install clean distclean 117259994Sgjb done 118259994Sgjb 119262314Sgjb mkdir -p ${CHROOTDIR}/tmp/crochet/work 120262314Sgjb before_build 121259994Sgjb install_crochet 122259994Sgjb install_uboot 123259994Sgjb eval chroot ${CHROOTDIR} /bin/sh /tmp/crochet/crochet.sh \ 124262314Sgjb -c /tmp/external/${XDEV}/crochet-${KERNEL}.conf 125262314Sgjb mkdir -p ${CHROOTDIR}/R/ 126262314Sgjb cp -p ${CHROOTDIR}/usr/obj/*.img ${CHROOTDIR}/R/ 127262314Sgjb bzip2 ${CHROOTDIR}/R/FreeBSD*.img 128262314Sgjb cd ${CHROOTDIR}/R/ && sha256 FreeBSD*.img.bz2 > CHECKSUM.SHA256 129262314Sgjb cd ${CHROOTDIR}/R/ && md5 FreeBSD*.img.bz2 > CHECKSUM.MD5 130259994Sgjb} 131259994Sgjb 132259994Sgjbmain "$@" 133259994Sgjbexit 0 134