tsdk - 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
---
tsdk (4244B)
---
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 armsdk_version="1.0"
19
20 R=${ARM_SDK:-$PWD}
21
22 DEBUG=0
23 QUIET=0
24
25 source $R/lib/zuper/zuper
26
27 # Global vars
28 vars+=(armsdk_version)
29 vars+=(R workdir strapdir)
30 vars+=(os boardlib oslib blendlib)
31 vars+=(MAKEOPTS)
32
33 # Global arrs
34 arrs+=(extra_packages)
35
36 # Global maps
37 maps+=(board_map os_map blend_map)
38
39 source $R/config
40 source $R/lib/helpers
41
42 # Conclude zuper initialization
43 source $R/lib/zuper/zuper.init
44
45 load() {
46 fn load "$@"
47 os="$1"
48 dev="$2"
49 blend="$3"
50 req=(os dev)
51 ckreq || return 1
52
53 ## initialize binfmt_misc if not already, needed to run qemu
54 if [[ -f /etc/init.d/binfmt-support ]]; then
55 sudo /etc/init.d/binfmt-support restart
56 elif [[ -f /etc/init.d/qemu-binfmt ]]; then
57 sudo /etc/init.d/qemu-binfmt restart
58 else
59 [[ -d /proc/sys/fs/binfmt_misc ]] \
60 || sudo modprobe binfmt_misc
61 [[ -f /proc/sys/fs/binfmt_misc/register ]] \
62 || sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
63 fi
64
65 board_map=(
66 "beagleboneblack" "$R/boards/beaglebone-black.sh"
67 "chromeacer" "$R/boards/chromebook-acer.sh"
68 "chromeveyron" "$R/boards/chromebook-veyron.sh"
69 "n900" "$R/boards/nokia-n900.sh"
70 "n950" "$R/boards/nokia-n950.sh"
71 "n9" "$R/boards/nokia-n9.sh"
72 "droid3" "$R/boards/droid3.sh"
73 "droid4" "$R/boards/droid4.sh"
74 "bionic" "$R/boards/bionic.sh"
75 "odroidxu" "$R/boards/odroid-xu.sh"
76 "odroidxu4" "$R/boards/odroid-xu4.sh"
77 "ouya" "$R/boards/ouya.sh"
78 "pocophone-f1" "$R/boards/pocophone-f1.sh"
79 "raspi1" "$R/boards/raspberry-pi1.sh"
80 "raspi2" "$R/boards/raspberry-pi2.sh"
81 "raspi3" "$R/boards/raspberry-pi3.sh"
82 "raspi4" "$R/boards/raspberry-pi4.sh"
83 "rock64" "$R/boards/rock64.sh"
84 "pinephone-dontbeevil" "$R/boards/pinephone-dontbeevil.sh"
85 "pinephone" "$R/boards/pinephone.sh"
86 "pinetab" "$R/boards/pinetab.sh"
87 "sunxi" "$R/boards/sunxi.sh"
88 "turbox-twister" "$R/boards/turbox-twister.sh"
89 )
90
91 os_map=(
92 "devuan" "$R/lib/libdevuansdk/libdevuansdk"
93 "alpine" "$R/lib/libalpine/libalpine"
94 )
95
96 blend_map=(
97 "decode" "../decode.blend"
98 "maemo" "../maemo.blend"
99 "cobox" "../cobox.blend"
100 )
101
102 boardlib="${board_map[$dev]}"
103 [[ -f $boardlib ]] || { die "no valid boards specified"; return 1 }
104 source $boardlib ## XXX: remove this line
105
106 oslib="${os_map[$os]}"
107 [[ -f $oslib ]] || { die "no valid distro specified"; return 1 }
108 source $oslib
109
110 blendlib="${blend_map[$blend]}"
111 [[ -f $blendlib ]] || { act "no blend specified" }
112 source $boardlib && act "$device_name build script loaded"
113
114 [[ -f $blendlib ]] && {
115 source $blendlib || zerr
116 act "$(basename $blend) blend loaded"
117 export BLEND=1
118 }
119
120 workdir="$R/tmp/${os}-${arch}-build"
121 strapdir="$workdir/bootstrap"
122 mkdir -p $strapdir
123
124 case "$arch" in
125 armhf) export compiler="$armhftc";;
126 armel) export compiler="$armeltc";;
127 arm64) export compiler="$arm64tc";;
128 *) die "invalid architecture in board script"; exit 1;;
129 esac
130
131 export LANG=C
132 export LC_ALL=C
133
134 source $R/lib/zuper/zuper.init
135 }
136
137 TRAPZERR() { zerr; return $? }
138
139 notice "arm-sdk loaded"
140 export PROMPT="%F{yellow}%(?..%? )%{$reset_color%}armsdk@%{$fg[red]%}%m %{$reset_color%} %{$fg[blue]%}%#%{$fg_bold[blue]%}%{$reset_color%} "