#!/usr/bin/env zsh # Copyright (c) 2016-2017 Dyne.org Foundation # arm-sdk is written and maintained by Ivan J. # # This file is part of arm-sdk # # This source code is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This software is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this source code. If not, see . ## helper functions for arm-sdk get-kernel-sources() { fn get-kernel-sources req=(R device_name gitkernel gitbranch) ckreq || return 1 notice "grabbing kernel sources" if [[ $gitkernel = mainline ]]; then clone-git "$linuxmainline" "$R/tmp/kernels/$device_name/${device_name}-linux" else clone-git "$gitkernel" "$R/tmp/kernels/$device_name/${device_name}-linux" "$gitbranch" fi } get-kernel-firmware() { fn get-kernel-firmware req=(linuxfirmware R) ckreq || return 1 notice "grabbing latest linux-firmware" clone-git "$linuxfirmware" "$R/tmp/linux-firmware" } install-kernel-mods() { fn install-kernel-mods req=(MAKEOPTS PATH compiler strapdir) ckreq || return 1 # We need this function to avoid sudo -E calls, which are # forbidden by jenkins. cat < install_mods #!/bin/sh export PATH="${PATH}" make \ ${MAKEOPTS} \ ARCH="${1}" \ CROSS_COMPILE=${compiler} \ INSTALL_MOD_PATH=${strapdir} \ modules_install || exit 1 EOF chmod +x install_mods || zerr sudo ./install_mods || zerr } clone-git() { fn clone-git "$@" req=(giturl clonepath) local giturl="$1" local clonepath="$2" local gitbr="$3" ckreq || return 1 notice "grabbing $(basename $clonepath)" if [[ -d $clonepath ]]; then pushd $clonepath git pull popd else [[ -n $gitbr ]] && gitbr="$gitbr" || gitbr="master" git clone --depth 1 -b "$gitbr" "$giturl" "$clonepath" fi } copy-kernel-config() { fn copy-kernel-config req=(device_name) ckreq || return 1 notice "copying available kernel config" cp -f $R/boards/kernel-configs/${device_name}.config \ $R/tmp/kernels/$device_name/${device_name}-linux/.config } copy-root-overlay() { fn copy-root-overlay req=(strapdir device_name R) ckreq || return 1 [[ -d $R/extra/generic-root ]] && \ notice "copying generic-root" && \ sudo cp -rfv $R/extra/generic-root/* $strapdir sudo sed -e "s/{{{BOOTFS}}}/$bootfs/" -i "$strapdir/etc/fstab" [[ -d $R/extra/$device_name ]] && \ notice "copying ${device_name}-root" && \ sudo cp -rfv $R/extra/$device_name/* $strapdir return 0 } postbuild-clean() { fn postbuild-clean req=(strapdir release) ckreq || return 1 case "$release" in jessie) cat </dev/null #!/bin/sh # jessie-backports e2fsprogs because 4.x kernels apt-get update apt-get --yes --force-yes -t jessie-backports install e2fsprogs EOF chroot-script -d postbuild || zerr ;; esac cat </dev/null #!/bin/sh apt-get update apt-get --yes --force-yes upgrade apt-get --yes --force-yes autoremove apt-get clean updatedb EOF chroot-script -d postbuild || zerr sudo rm -f \ "$strapdir/$armel_qemu_bin" \ "$strapdir/$armhf_qemu_bin" \ "$strapdir/$arm64_qemu_bin" }