simplify helper functions

This commit is contained in:
parazyd 2017-01-31 12:32:59 +01:00
parent 7bb47914c9
commit 5279fea73e
No known key found for this signature in database
GPG Key ID: F0CB28FCF78637DE
3 changed files with 47 additions and 77 deletions

View File

@ -1,4 +1,3 @@
This directory holds the build scripts and kernel configs for various boards.
An example script is aptly named `example.sh` and is a bit more commented
than the others. However, as each board is different, so is each build script,
so try and read as many as you can until you get the hang of it :)
As each board is different, so is each build script, so try and read as many
as you can until you get the hang of it :)

View File

@ -24,28 +24,29 @@ 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
#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
return 0
}
get-kernel-sources() {
@ -55,31 +56,21 @@ get-kernel-sources() {
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
if [[ $kernel = mainline ]]; then
clone-git "$linuxmainline" "$R/tmp/kernels/$device_name/${device_name}-linux"
else
git clone --depth 1 \
$gitkernel \
-b $gitbranch \
$R/tmp/kernels/$device_name/${device_name}-linux
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"
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 "$linuxfirmware" "$R/tmp/linux-firmware"
}
clone-git() {
@ -105,15 +96,6 @@ clone-git() {
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)
@ -124,21 +106,15 @@ copy-kernel-config() {
$R/tmp/kernels/$device_name/${device_name}-linux/.config
}
write-fstab() {
fn write-fstab
req=(strapdir)
copy-root-overlay() {
fn copy-root-overlay
req=(strapdir device_name R)
ckreq || return 1
cat <<EOF | sudo tee ${strapdir}/etc/fstab >/dev/null
## <file system> <mount point> <type> <options> <dump><pass>
## 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
[[ -d $R/extra/generic-root ]] && \
${=sudo} ${=cp} -rfl $R/extra/generic-root/* $strapdir
[[ -d $R/extra/$device_name ]] && \
${=sudo} ${=cp} -rfL $R/extra/$device_name/* $strapdir
}
postbuild-clean() {
@ -146,12 +122,6 @@ 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 <<EOF | sudo tee ${strapdir}/postbuild >/dev/null
#!/bin/sh
dpkg-divert --add --local \

19
sdk
View File

@ -1,5 +1,5 @@
#!/usr/bin/env zsh
# Copyright (c) 2016 Dyne.org Foundation
# Copyright (c) 2016-2017 Dyne.org Foundation
# arm-sdk is written and maintained by Ivan J. <parazyd@dyne.org>
#
# This file is part of arm-sdk
@ -56,20 +56,21 @@ load() {
if [[ -f /etc/init.d/binfmt-support ]]; then
sudo /etc/init.d/binfmt-support restart
else
[[ -d /proc/sys/fs/binfmt_misc ]] || sudo modprobe binfmt_misc
[[ -f /proc/sys/fs/binfmt_misc/register ]] || \
sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
[[ -d /proc/sys/fs/binfmt_misc ]] \
|| sudo modprobe binfmt_misc
[[ -f /proc/sys/fs/binfmt_misc/register ]] \
|| sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
fi
board_map=(
"bananapi" "$R/boards/bananapi.sh"
"bananapi-m2plus" "$R/boards/bananapi-m2plus.sh"
"bananapro" "$R/boards/bananapro.sh"
"beagleboneblack" "$R/boards/beaglebone-black.sh"
"chromeacer" "$R/boards/chromebook-acer.sh"
"chromeveyron" "$R/boards/chromebook-veyron.sh"
"cubieboard2" "$R/boards/cubieboard2.sh"
"cubietruck" "$R/boards/cubietruck.sh"
"m2plus" "$R/boards/bananapi-m2plus.sh"
"n900" "$R/boards/nokia-n900.sh"
"odroidxu" "$R/boards/odroid-xu.sh"
"ouya" "$R/boards/ouya.sh"
@ -93,7 +94,7 @@ load() {
[[ $blendlib =~ '^http' ]] && {
notice "grabbing blend from the internetz"
pushd $R/extra/blends
curl -Ls -O $blendlib
curl -Ls -O $blendlib
popd
blendlib="$R/extra/blends/$(basename $blendlib)"
}
@ -102,13 +103,13 @@ load() {
[[ -f $oslib ]] || { die "no valid distro specified"; exit 1 }
[[ -f $blendlib ]] || { warn "no valid blend specified" }
[[ -f $boardlib ]] && source $boardlib && act "$device_name build script loaded"
[[ -f $oslib ]] && source $oslib
source $boardlib && act "$device_name build script loaded"
source $oslib
[[ -f $blendlib ]] && source $blendlib && act "$os blend loaded" && export BLEND=1
workdir="$R/tmp/${os}-${arch}-build"
strapdir="$workdir/bootstrap"
mkdir -p $strapdir
${=mkdir} -p $strapdir
export LANG=C
export LC_ALL=C