arm-sdk/sdk

126 lines
3.1 KiB
Bash
Executable File

#!/usr/bin/env zsh
# Copyright (c) 2016 Dyne.org Foundation
# arm-sdk is written and maintained by Ivan J. <parazyd@dyne.org>
#
# 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 <http://www.gnu.org/licenses/>.
armsdk_version="1.0"
R=${ARM_SDK:-$PWD}
DEBUG=0
QUIET=0
[[ $DEBUG = 1 ]] && {
CPVERBOSE="-v"
#LOG="armsdk.log"
} || [[ $DEBUG = 0 ]] && {
CPVERBOSE=""
setopt pushdsilent
}
source $R/lib/zuper/zuper
## global vars
vars+=(armsdk_version)
vars+=(R workdir strapdir)
vars+=(os boardlib oslib)
vars+=(MAKEOPTS)
## global arrs
arrs+=(extra_packages)
## global maps
maps+=(board_map os_map)
source $R/config
source $R/lib/helpers
## conclude zuper initialization
source $R/lib/zuper/zuper.init
load() {
fn load "$@"
os="$1"
dev="$2"
blend="$3"
req=(os dev)
ckreq || return 1
## initialize binfmt_misc if not already, needed to run qemu
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
fi
board_map=(
"bananapi" "$R/boards/bananapi.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"
"n900" "$R/boards/nokia-n900.sh"
"odroidxu" "$R/boards/odroid-xu.sh"
"ouya" "$R/boards/ouya.sh"
"raspi2" "$R/boards/raspberry-pi2.sh"
"raspi3" "$R/boards/raspberry-pi3.sh"
)
os_map=(
"devuan" "$R/lib/libdevuansdk/libdevuansdk"
)
blend_map=(
"dowse" "$R/extra/blends/dowse.blend"
)
boardlib="${board_map[$dev]}"
oslib="${os_map[$os]}"
[[ -f $boardlib ]] || { die "no valid boards specified"; exit 1 }
[[ -f $oslib ]] || { die "no valid distro specified"; exit 1 }
[[ -n $blend ]] && { blendlib="${blend_map[$blend]}" }
[[ -f $boardlib ]] && source $boardlib \
&& act "$device_name build script loaded"
[[ -f $oslib ]] && source $oslib
[[ -f $blendlib ]] && source $blendlib \
&& act "blend $os loaded"
workdir="$R/tmp/${os}-${arch}-build"
strapdir="$workdir/bootstrap"
mkdir -p $strapdir
export LANG=C
export LC_ALL=C
export ARCH=arm
export CROSS_COMPILE=$compiler
source $R/lib/zuper/zuper.init
}
TRAPZERR() { zerr; return $? }
notice "arm-sdk loaded"
export RPROMPT=":: arm-sdk"