URI: 
       thelpers - arm-sdk - os build toolkit for various embedded devices
  HTML git clone https://git.parazyd.org/arm-sdk
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
       thelpers (3695B)
       ---
            1 #!/usr/bin/env zsh
            2 # Copyright (c) 2016-2021 Ivan J. <parazyd@dyne.org>
            3 # This file is part of arm-sdk
            4 #
            5 # This source code is free software: you can redistribute it and/or modify
            6 # it under the terms of the GNU General Public License as published by
            7 # the Free Software Foundation, either version 3 of the License, or
            8 # (at your option) any later version.
            9 #
           10 # This software is distributed in the hope that it will be useful,
           11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
           12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           13 # GNU General Public License for more details.
           14 #
           15 # You should have received a copy of the GNU General Public License
           16 # along with this source code. If not, see <http://www.gnu.org/licenses/>.
           17 
           18 ## helper functions for arm-sdk
           19 
           20 get-kernel-sources() {
           21         fn get-kernel-sources
           22         req=(R device_name gitkernel gitbranch)
           23         ckreq || return 1
           24 
           25         notice "grabbing kernel sources"
           26 
           27         if [[ $gitkernel = mainline ]]; then
           28                 clone-git "$linuxmainline" "$R/tmp/kernels/$device_name/${device_name}-linux"
           29         else
           30                 clone-git "$gitkernel" "$R/tmp/kernels/$device_name/${device_name}-linux" "$gitbranch"
           31         fi
           32 }
           33 
           34 get-kernel-firmware() {
           35         fn get-kernel-firmware
           36         req=(linuxfirmware R)
           37         ckreq || return 1
           38 
           39         notice "grabbing latest linux-firmware"
           40 
           41         clone-git "$linuxfirmware" "$R/tmp/linux-firmware"
           42 }
           43 
           44 install-kernel-mods() {
           45         fn install-kernel-mods
           46         req=(MAKEOPTS PATH compiler strapdir)
           47         ckreq || return 1
           48 
           49         # We need this function to avoid sudo -E calls, which are
           50         # forbidden by jenkins.
           51         cat <<EOF > install_mods
           52 #!/bin/sh
           53 export PATH="${PATH}"
           54 make \
           55         ${MAKEOPTS} \
           56         ARCH="${1}" \
           57         CROSS_COMPILE=${compiler} \
           58         INSTALL_MOD_PATH=${strapdir} \
           59                 modules_install || exit 1
           60 EOF
           61         chmod +x install_mods || zerr
           62         sudo ./install_mods   || zerr
           63 }
           64 
           65 clone-git() {
           66         fn clone-git "$@"
           67         req=(giturl clonepath)
           68         local giturl="$1"
           69         local clonepath="$2"
           70         local gitbr="$3"
           71         ckreq || return 1
           72 
           73         notice "grabbing $(basename $clonepath)"
           74 
           75         if [[ -d $clonepath ]]; then
           76                 pushd $clonepath
           77                         git pull
           78                 popd
           79         else
           80                 [[ -n $gitbr ]] && gitbr="$gitbr" || gitbr="master"
           81                 git clone --depth 1 -b "$gitbr" "$giturl" "$clonepath"
           82         fi
           83 }
           84 
           85 copy-kernel-config() {
           86         fn copy-kernel-config
           87         req=(device_name)
           88         ckreq || return 1
           89 
           90         notice "copying available kernel config"
           91         cp -f $R/boards/kernel-configs/${device_name}.config \
           92                 $R/tmp/kernels/$device_name/${device_name}-linux/.config
           93 }
           94 
           95 vars+=(skip_arm_generic_root skip_arm_device_root)
           96 copy-root-overlay() {
           97         fn copy-root-overlay
           98         req=(strapdir device_name R)
           99         ckreq || return 1
          100 
          101         if [ -z "$skip_arm_generic_root" ]; then
          102                 if [ -d "$R/extra/generic-root" ]; then
          103                         notice "copying generic-root"
          104                         sudo cp -rfv "$R/extra/generic-root"/* "$strapdir"
          105                 fi
          106         fi
          107 
          108         if [ -z "$skip_arm_device_root" ]; then
          109                 if [ -d "$R/extra/$device_name" ]; then
          110                         notice "copyring ${device_name}-root"
          111                         sudo cp -rfv "$R/extra/$device_name"/* "$strapdir"
          112                 fi
          113         fi
          114 
          115         sudo sed -e "s/{{{BOOTFS}}}/$bootfs/" -i "$strapdir/etc/fstab"
          116 
          117         return 0
          118 }
          119 
          120 postbuild-clean() {
          121         fn postbuild-clean
          122         req=(strapdir release)
          123         ckreq || return 1
          124 
          125         case "$release" in
          126                 jessie)
          127                         cat <<EOF | sudo tee ${strapdir}/postbuild >/dev/null
          128 #!/bin/sh
          129 # jessie-backports e2fsprogs because 4.x kernels
          130 apt-get update
          131 apt-get --yes --force-yes -t jessie-backports install e2fsprogs
          132 EOF
          133                         chroot-script -d postbuild || zerr
          134                         ;;
          135         esac
          136 
          137         cat <<EOF | sudo tee ${strapdir}/postbuild >/dev/null
          138 #!/bin/sh
          139 apt-get update
          140 apt-get --yes --force-yes upgrade
          141 apt-get --yes --force-yes autoremove
          142 apt-get clean
          143 EOF
          144 
          145         chroot-script -d postbuild || zerr
          146         [[ -n "$BLEND" ]] || sudo rm -f \
          147                 "$strapdir/$armel_qemu_bin" \
          148                 "$strapdir/$armhf_qemu_bin" \
          149                 "$strapdir/$arm64_qemu_bin"
          150 
          151         return 0
          152 }