#!/usr/bin/env zsh # Copyright (c) 2016 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 install-custom-packages() { fn install-custom-packages req=(R os device_name strapdir) ckreq || return 1 case $os in devuan) notice "checking for custom debs" mkdir -p $R/extra/custom-packages pushd $R/extra/custom-packages local pkgs="$(find ../$device_name -name '*.deb')" [[ -n $pkgs ]] && { notice "found!" for deb in $pkgs; do act "installing $deb" ln -sf $deb . done install-custdebs } popd rm -rf $R/extra/custom-packages ;; *) warn "skipping custom packages. os unsupported." ;; esac } get-kernel-sources() { fn get-kernel-sources req=(R device_name gitkernel gitbranch) ckreq || return 1 notice "grabbing kernel sources" if [[ -d $R/tmp/kernels/$device_name/${device_name}-linux ]]; then pushd $R/tmp/kernels/$device_name/${device_name}-linux git pull popd else git clone --depth 1 \ $gitkernel \ -b $gitbranch \ $R/tmp/kernels/$device_name/${device_name}-linux fi } get-kernel-firmware() { fn get-kernel-firmware notice "grabbing latest linux-firmware" local gitsource="https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git" if [[ -d $R/tmp/linux-firmware ]]; then pushd $R/tmp/linux-firmware git pull popd else git clone $gitsource $R/tmp/linux-firmware fi } 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="-b $gitbr" git clone --depth 1 \ $giturl \ $gitbr \ $clonepath fi } copy-zram-init() { fn copy-zram-init req=(R strapdir) ckreq || return 1 notice "installing zram init" sudo ${=cp} $R/extra/zram $strapdir/root/ } copy-kernel-config() { fn copy-kernel-config req=(device_name) ckreq || return 1 notice "copying available kernel config" ${=cp} $R/boards/kernel-configs/${device_name}.config \ $R/tmp/kernels/$device_name/${device_name}-linux/.config } write-fstab() { fn write-fstab req=(strapdir) ckreq || return 1 cat </dev/null ## ## proc proc /proc proc nodev,noexec,nosuid 0 0 ## rootfs /dev/mmcblk0p2 / ext4 errors=remount-ro 0 1 ## bootfs /dev/mmcblk0p1 /boot vfat defaults 0 0 EOF } postbuild-clean() { fn postbuild-clean req=(qemu_bin strapdir) ckreq || return 1 conf_print_rclocal | sudo tee ${strapdir}/etc/rc.local # add -s to forcefully sync from 1970 sed -i /etc/default/openntpd \ -e 's:DAEMON_OPTS.*:DAEMON_OPTS="-f /etc/openntpd/ntpd.conf -s":' cat </dev/null #!/bin/sh dpkg-divert --add --local \ --divert /usr/sbin/invoke-rc.d.chroot \ --rename /usr/sbin/invoke-rc.d cp /bin/true /usr/sbin/invoke-rc.d echo -e "#!/bin/sh\nexit 101" > /usr/sbin/policy-rc.d chmod +x /usr/sbin/policy-rc.d apt-get update apt-get --yes --force-yes upgrade apt-get --yes --force-yes autoremove apt-get clean rm -f /usr/sbin/policy-rc.d rm -f /usr/sbin/invoke-rc.d dpkg-divert --remove --rename /usr/sbin/invoke-rc.d rm -f postbuild rm -f ${qemu_bin} EOF chroot-script postbuild || zerr }