gnupg2: update to 2.2.0
[openadk.git] / scripts / install.sh
blob09baffcdcab6c13b18af163e9a5027e2423f4501
1 #!/usr/bin/env bash
2 #-
3 # Copyright © 2010-2016
4 # Waldemar Brodkorb <wbx@openadk.org>
5 # Thorsten Glaser <tg@mirbsd.org>
7 # Provided that these terms and disclaimer and all copyright notices
8 # are retained or reproduced in an accompanying document, permission
9 # is granted to deal in this work without restriction, including un‐
10 # limited rights to use, publicly perform, distribute, sell, modify,
11 # merge, give away, or sublicence.
13 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
14 # the utmost extent permitted by applicable law, neither express nor
15 # implied; without malicious intent or gross negligence. In no event
16 # may a licensor, author or contributor be held liable for indirect,
17 # direct, other damage, loss, or other issues arising in any way out
18 # of dealing in the work, even if advised of the possibility of such
19 # damage or existence of a defect, except proven that it results out
20 # of said person’s immediate fault when using the work as intended.
22 # Alternatively, this work may be distributed under the terms of the
23 # General Public License, any version, as published by the Free Soft-
24 # ware Foundation.
26 # Prepare a USB stick or CF/SD/MMC card or hard disc for installation
27 # of OpenADK
29 ADK_TOPDIR=$(pwd)
30 HOST=$(gcc -dumpmachine)
31 me=$0
33 case :$PATH: in
34 (*:$ADK_TOPDIR/host_$HOST/usr/bin:*) ;;
35 (*) export PATH=$PATH:$ADK_TOPDIR/host_$HOST/usr/bin ;;
36 esac
38 test -n "$KSH_VERSION" || exec mksh "$me" "$@"
39 if test -z "$KSH_VERSION"; then
40 echo >&2 Fatal error: could not run myself with mksh!
41 exit 255
44 ### run with mksh from here onwards ###
46 me=${me##*/}
48 if (( USER_ID )); then
49 print -u2 Installation is only possible as root!
50 exit 1
53 ADK_TOPDIR=$(realpath .)
54 ostype=$(uname -s)
56 fs=ext4
57 cfgfs=1
58 datafssz=0
59 noformat=0
60 quiet=0
61 serial=0
62 speed=115200
63 panicreboot=10
64 keep=0
65 grub=0
67 function usage {
68 cat >&2 <<EOF
69 Syntax: $me [-f filesystem] [-c cfgfssize] [-d datafssize] [-k] [-n] [-g]
70 [-p panictime] [±q] [-s serialspeed] [±t] <target> <device> <archive>
71 Partition sizes are in MiB. Filesystem type is currently ignored (ext4).
72 To keep filesystem on data partition use -k.
73 Use -n to not format boot/root partition.
74 Defaults: -c 1 -p 10 -s 115200; -t = enable serial console
75 EOF
76 exit $1
79 while getopts "c:d:f:ghknp:qs:t" ch; do
80 case $ch {
81 (c) if (( (cfgfs = OPTARG) < 0 || cfgfs > 16 )); then
82 print -u2 "$me: -c $OPTARG out of bounds"
83 exit 1
84 fi ;;
85 (d) if (( (datafssz = OPTARG) < 0 )); then
86 print -u2 "$me: -d $OPTARG out of bounds"
87 exit 1
88 fi ;;
89 (f) if [[ $OPTARG != @(ext2|ext3|ext4|xfs) ]]; then
90 print -u2 "$me: filesystem $OPTARG invalid"
91 exit 1
93 fs=$OPTARG ;;
94 (h) usage 0 ;;
95 (k) keep=1 ;;
96 (g) grub=1 ;;
97 (p) if (( (panicreboot = OPTARG) < 0 || panicreboot > 300 )); then
98 print -u2 "$me: -p $OPTARG out of bounds"
99 exit 1
100 fi ;;
101 (q) quiet=1 ;;
102 (+q) quiet=0 ;;
103 (s) if [[ $OPTARG != @(96|192|384|576|1152)00 ]]; then
104 print -u2 "$me: serial speed $OPTARG invalid"
105 exit 1
107 speed=$OPTARG ;;
108 (n) noformat=1 ;;
109 (t) serial=1 ;;
110 (+t) serial=0 ;;
111 (*) usage 1 ;;
113 done
114 shift $((OPTIND - 1))
116 (( $# == 3 )) || usage 1
119 case $ostype {
120 (Linux)
121 tools="bc mkfs.$fs tune2fs partprobe"
123 (Darwin)
124 tools="bc diskutil"
127 print -u2 Sorry, not ported to the OS "'$ostype'" yet.
128 exit 1
131 for tool in $tools; do
132 print -n Checking if $tool is installed...
133 if whence -p $tool >/dev/null; then
134 print " okay"
135 else
136 print " failed"
139 done
140 (( f )) && exit 1
142 target=$1
143 tgt=$2
144 src=$3
146 case $target {
147 (banana-pro|orange-pi0|pcengines-apu|raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64|solidrun-imx6|solidrun-clearfog|default) ;;
149 print -u2 "Unknown target '$target', exiting"
150 exit 1 ;;
152 if [[ ! -b $tgt ]]; then
153 print -u2 "'$tgt' is not a block device, exiting"
154 exit 1
156 if [[ ! -f $src ]]; then
157 print -u2 "'$src' is not a file, exiting"
158 exit 1
160 (( quiet )) || print "Installing $src on $tgt."
162 case $ostype {
163 (Darwin)
164 R=/Volumes/ADKROOT; diskutil unmount $R
165 B=/Volumes/ADKBOOT; diskutil unmount $B
166 D=/Volumes/ADKDATA; diskutil unmount $D
167 basedev=$tgt
168 rootpart=${basedev}s1
169 datapart=${basedev}s2
170 if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 ]]; then
171 bootpart=${basedev}s1
172 rootpart=${basedev}s2
173 datapart=${basedev}s3
175 match=\'${basedev}\''?(s+([0-9]))'
176 function mount_fs {
178 function umount_fs {
179 diskutil unmount "$1"
181 function create_fs {
182 if [[ $3 = ext4 ]]; then
183 fstype=UFSD_EXTFS4
185 if [[ $3 = vfat ]]; then
186 fstype=fat32
188 diskutil eraseVolume $fstype "$2" "$1"
190 function tune_fs {
193 (Linux)
194 basedev=$tgt
195 partitionsep=""
196 if [[ $basedev = /dev/loop* ]]; then
197 (( quiet )) || print "${tgt} is a loop device"
198 partitionsep=p
201 rootpart=${basedev}${partitionsep}1
202 datapart=${basedev}${partitionsep}2
203 if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 ]]; then
204 bootpart=${basedev}${partitionsep}1
205 rootpart=${basedev}${partitionsep}2
206 datapart=${basedev}${partitionsep}3
209 match=\'${basedev}${partitionsep}\''+([0-9])'
210 function mount_fs {
211 mount -t "$3" "$1" "$2"
213 function umount_fs {
214 umount "$1"
216 function create_fs {
217 (( quiet )) || print "Creating filesystem on ${1}..."
218 mkfs.$3 "$1"
220 function tune_fs {
221 tune2fs -c 0 -i 0 "$1"
226 mount |&
227 while read -p dev rest; do
228 eval [[ \$dev = $match ]] || continue
229 print -u2 "Block device $tgt is in use, please umount first."
230 exit 1
231 done
233 if (( !quiet )); then
234 print "WARNING: This will overwrite $basedev - type Yes to continue!"
235 read x
236 [[ $x = Yes ]] || exit 0
239 if ! T=$(mktemp -d /tmp/openadk.XXXXXXXXXX); then
240 print -u2 Error creating temporary directory.
241 exit 1
243 if [[ $ostype != Darwin ]]; then
244 R=$T/rootmnt
245 B=$T/bootmnt
246 D=$T/datamnt
247 mkdir -p "$R" "$B" "$D"
250 # get disk size
251 dksz=$(dkgetsz "$tgt")
253 # partition layouts:
254 # n̲a̲m̲e̲ p̲a̲r̲t̲#̲0̲ p̲̲a̲r̲t̲#̲1̲ p̲̲a̲r̲t̲#̲2̲ p̲̲a̲r̲t̲#̲3̲
255 # default: 0x83(system) 0x83(?data) -(unused) 0x88(cfgfs)
256 # raspberry: 0x0B(boot) 0x83(system) 0x83(?data) 0x88(cfgfs)
258 syspartno=0
260 # sizes:
261 # boot(raspberry) - fixed (100 MiB)
262 # cfgfs - fixed (parameter, max. 16 MiB)
263 # data - flexible (parameter)
264 # system - everything else
266 if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 ]]; then
267 syspartno=1
268 bootfssz=100
269 if (( grub )); then
270 print -u2 "Cannot combine GRUB with $target"
271 rm -rf "$T"
272 exit 1
274 else
275 bootfssz=0
278 heads=64
279 secs=32
280 (( cyls = dksz / heads / secs ))
281 if (( cyls < (bootfssz + cfgfs + datafssz + 2) )); then
282 print -u2 "Size of $tgt is $dksz, this looks fishy?"
283 rm -rf "$T"
284 exit 1
287 if stat -qs .>/dev/null 2>&1; then
288 statcmd='stat -f %z' # BSD stat (or so we assume)
289 else
290 statcmd='stat -c %s' # GNU stat
293 if (( grub )); then
294 tar -xOf "$src" boot/grub/core.img >"$T/core.img"
295 integer coreimgsz=$($statcmd "$T/core.img")
296 else
297 coreimgsz=65024
299 if (( coreimgsz < 1024 )); then
300 print -u2 core.img is probably too small: $coreimgsz
301 rm -rf "$T"
302 exit 1
304 if (( coreimgsz > 65024 )); then
305 print -u2 core.img is larger than 64K-512: $coreimgsz
306 rm -rf "$T"
307 exit 1
309 (( coreendsec = (coreimgsz + 511) / 512 ))
310 if [[ $basedev = /dev/svnd+([0-9]) ]]; then
311 # BSD svnd0 mode: protect sector #1
312 corestartsec=2
313 (( ++coreendsec ))
314 corepatchofs=$((0x614))
315 else
316 corestartsec=1
317 corepatchofs=$((0x414))
319 # partition offset: at least coreendsec+1 but aligned on a multiple of secs
320 #(( partofs = ((coreendsec / secs) + 1) * secs ))
321 # we just use 2048 all the time, since some loaders are longer
322 partofs=2048
323 if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 ]]; then
324 (( spartofs = partofs + (100 * 2048) ))
325 else
326 spartofs=$partofs
329 (( quiet )) || if (( grub )); then
330 print Preparing MBR and GRUB2...
331 else
332 print Preparing MBR...
334 dd if=/dev/zero of="$T/firsttrack" count=$partofs 2>/dev/null
335 # add another MiB to clear the first partition
336 dd if=/dev/zero bs=1048576 count=1 >>"$T/firsttrack" 2>/dev/null
337 echo $corestartsec $coreendsec | mksh "$ADK_TOPDIR/scripts/bootgrub.mksh" \
338 -A -g $((cyls - bootfssz - cfgfs - datafssz)):$heads:$secs -M 1:0x83 \
339 -O $spartofs | dd of="$T/firsttrack" conv=notrunc 2>/dev/null
340 (( grub )) && dd if="$T/core.img" of="$T/firsttrack" conv=notrunc \
341 seek=$corestartsec 2>/dev/null
342 # set partition where it can find /boot/grub
343 (( grub )) && print -n '\0\0\0\0' | \
344 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$corepatchofs 2>/dev/null
346 # create cfgfs partition (mostly taken from bootgrub.mksh)
347 set -A thecode
348 typeset -Uui8 thecode
349 mbrpno=0
350 set -A g_code $cyls $heads $secs
351 (( psz = g_code[0] * g_code[1] * g_code[2] ))
352 (( pofs = (cyls - cfgfs) * g_code[1] * g_code[2] ))
353 set -A o_code # g_code equivalent for partition offset
354 (( o_code[2] = pofs % g_code[2] + 1 ))
355 (( o_code[1] = pofs / g_code[2] ))
356 (( o_code[0] = o_code[1] / g_code[1] + 1 ))
357 (( o_code[1] = o_code[1] % g_code[1] + 1 ))
358 # boot flag; C/H/S offset
359 thecode[mbrpno++]=0x00
360 (( thecode[mbrpno++] = o_code[1] - 1 ))
361 (( cylno = o_code[0] > 1024 ? 1023 : o_code[0] - 1 ))
362 (( thecode[mbrpno++] = o_code[2] | ((cylno & 0x0300) >> 2) ))
363 (( thecode[mbrpno++] = cylno & 0x00FF ))
364 # partition type; C/H/S end
365 (( thecode[mbrpno++] = 0x88 ))
366 (( thecode[mbrpno++] = g_code[1] - 1 ))
367 (( cylno = g_code[0] > 1024 ? 1023 : g_code[0] - 1 ))
368 (( thecode[mbrpno++] = g_code[2] | ((cylno & 0x0300) >> 2) ))
369 (( thecode[mbrpno++] = cylno & 0x00FF ))
370 # partition offset, size (LBA)
371 (( thecode[mbrpno++] = pofs & 0xFF ))
372 (( thecode[mbrpno++] = (pofs >> 8) & 0xFF ))
373 (( thecode[mbrpno++] = (pofs >> 16) & 0xFF ))
374 (( thecode[mbrpno++] = (pofs >> 24) & 0xFF ))
375 (( pssz = psz - pofs ))
376 (( thecode[mbrpno++] = pssz & 0xFF ))
377 (( thecode[mbrpno++] = (pssz >> 8) & 0xFF ))
378 (( thecode[mbrpno++] = (pssz >> 16) & 0xFF ))
379 (( thecode[mbrpno++] = (pssz >> 24) & 0xFF ))
380 # write partition table entry
381 ostr=
382 curptr=0
383 while (( curptr < 16 )); do
384 ostr=$ostr\\0${thecode[curptr++]#8#}
385 done
386 print -n "$ostr" | \
387 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1EE)) 2>/dev/null
389 if (( datafssz )); then
390 # create data partition (copy of the above :)
391 set -A thecode
392 typeset -Uui8 thecode
393 mbrpno=0
394 set -A g_code $cyls $heads $secs
395 (( psz = (cyls - cfgfs) * g_code[1] * g_code[2] ))
396 (( pofs = (cyls - cfgfs - datafssz) * g_code[1] * g_code[2] ))
397 set -A o_code # g_code equivalent for partition offset
398 (( o_code[2] = pofs % g_code[2] + 1 ))
399 (( o_code[1] = pofs / g_code[2] ))
400 (( o_code[0] = o_code[1] / g_code[1] + 1 ))
401 (( o_code[1] = o_code[1] % g_code[1] + 1 ))
402 # boot flag; C/H/S offset
403 thecode[mbrpno++]=0x00
404 (( thecode[mbrpno++] = o_code[1] - 1 ))
405 (( cylno = o_code[0] > 1024 ? 1023 : o_code[0] - 1 ))
406 (( thecode[mbrpno++] = o_code[2] | ((cylno & 0x0300) >> 2) ))
407 (( thecode[mbrpno++] = cylno & 0x00FF ))
408 # partition type; C/H/S end
409 (( thecode[mbrpno++] = 0x83 ))
410 (( thecode[mbrpno++] = g_code[1] - 1 ))
411 (( cylno = (g_code[0] - cfgfs) > 1024 ? 1023 : g_code[0] - cfgfs - 1 ))
412 (( thecode[mbrpno++] = g_code[2] | ((cylno & 0x0300) >> 2) ))
413 (( thecode[mbrpno++] = cylno & 0x00FF ))
414 # partition offset, size (LBA)
415 (( thecode[mbrpno++] = pofs & 0xFF ))
416 (( thecode[mbrpno++] = (pofs >> 8) & 0xFF ))
417 (( thecode[mbrpno++] = (pofs >> 16) & 0xFF ))
418 (( thecode[mbrpno++] = (pofs >> 24) & 0xFF ))
419 (( pssz = psz - pofs ))
420 (( thecode[mbrpno++] = pssz & 0xFF ))
421 (( thecode[mbrpno++] = (pssz >> 8) & 0xFF ))
422 (( thecode[mbrpno++] = (pssz >> 16) & 0xFF ))
423 (( thecode[mbrpno++] = (pssz >> 24) & 0xFF ))
424 # write partition table entry
425 ostr=
426 curptr=0
427 while (( curptr < 16 )); do
428 ostr=$ostr\\0${thecode[curptr++]#8#}
429 done
430 print -n "$ostr" | \
431 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1CE)) 2>/dev/null
434 if [[ $target = raspberry-pi || $target = raspberry-pi0 || $target = raspberry-pi2 || $target = raspberry-pi3 || $target = raspberry-pi3-64 ]]; then
435 # move system and data partition from #0/#1 to #1/#2
436 dd if="$T/firsttrack" bs=1 skip=$((0x1BE)) count=32 of="$T/x" 2>/dev/null
437 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1CE)) if="$T/x" 2>/dev/null
438 # create boot partition (copy of the above :)
439 set -A thecode
440 typeset -Uui8 thecode
441 mbrpno=0
442 set -A g_code $cyls $heads $secs
443 psz=$spartofs
444 pofs=$partofs
445 set -A o_code # g_code equivalent for partition offset
446 (( o_code[2] = pofs % g_code[2] + 1 ))
447 (( o_code[1] = pofs / g_code[2] ))
448 (( o_code[0] = o_code[1] / g_code[1] + 1 ))
449 (( o_code[1] = o_code[1] % g_code[1] + 1 ))
450 # boot flag; C/H/S offset
451 thecode[mbrpno++]=0x00
452 (( thecode[mbrpno++] = o_code[1] - 1 ))
453 (( cylno = o_code[0] > 1024 ? 1023 : o_code[0] - 1 ))
454 (( thecode[mbrpno++] = o_code[2] | ((cylno & 0x0300) >> 2) ))
455 (( thecode[mbrpno++] = cylno & 0x00FF ))
456 # partition type; C/H/S end
457 (( thecode[mbrpno++] = 0x0B ))
458 (( thecode[mbrpno++] = g_code[1] - 1 ))
459 (( cylno = (spartofs / 2048) > 1024 ? 1023 : (spartofs / 2048) - 1 ))
460 (( thecode[mbrpno++] = g_code[2] | ((cylno & 0x0300) >> 2) ))
461 (( thecode[mbrpno++] = cylno & 0x00FF ))
462 # partition offset, size (LBA)
463 (( thecode[mbrpno++] = pofs & 0xFF ))
464 (( thecode[mbrpno++] = (pofs >> 8) & 0xFF ))
465 (( thecode[mbrpno++] = (pofs >> 16) & 0xFF ))
466 (( thecode[mbrpno++] = (pofs >> 24) & 0xFF ))
467 (( pssz = psz - pofs ))
468 (( thecode[mbrpno++] = pssz & 0xFF ))
469 (( thecode[mbrpno++] = (pssz >> 8) & 0xFF ))
470 (( thecode[mbrpno++] = (pssz >> 16) & 0xFF ))
471 (( thecode[mbrpno++] = (pssz >> 24) & 0xFF ))
472 # write partition table entry
473 ostr=
474 curptr=0
475 while (( curptr < 16 )); do
476 ostr=$ostr\\0${thecode[curptr++]#8#}
477 done
478 print -n "$ostr" | \
479 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1BE)) 2>/dev/null
482 # disk signature
483 rnddev=/dev/urandom
484 [[ -c /dev/arandom ]] && rnddev=/dev/arandom
485 dd if=$rnddev bs=4 count=1 2>/dev/null | \
486 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1B8)) 2>/dev/null
487 print -n '\0\0' | \
488 dd of="$T/firsttrack" conv=notrunc bs=1 seek=$((0x1BC)) 2>/dev/null
489 partuuid=$(dd if="$T/firsttrack" bs=1 count=4 skip=$((0x1B8)) 2>/dev/null | \
490 hexdump -e '1/4 "%08x"')-0$((syspartno+1))
492 ((keep)) || if (( datafssz )); then
493 (( quiet )) || print Cleaning out data partition...
494 dd if=/dev/zero of="$tgt" bs=1048576 count=1 seek=$((cyls - cfgfs - datafssz)) > /dev/null 2>&1
496 (( quiet )) || print Cleaning out root partition...
497 dd if=/dev/zero bs=1048576 of="$tgt" count=1 seek=$((spartofs / 2048)) > /dev/null 2>&1
499 (( quiet )) || if (( grub )); then
500 print Writing MBR and GRUB2 to target device... system PARTUUID=$partuuid
501 else
502 print Writing MBR to target device... system PARTUUID=$partuuid
504 dd if="$T/firsttrack" of="$tgt" > /dev/null 2>&1
506 if [[ $ostype = Linux ]]; then
507 partprobe $tgt
508 sync
511 fwdir=$(dirname "$src")
513 case $target {
514 (banana-pro|orange-pi0)
515 dd if="$fwdir/u-boot-sunxi-with-spl.bin" of="$tgt" bs=1024 seek=8 > /dev/null 2>&1
517 (solidrun-clearfog)
518 dd if="$fwdir/u-boot-spl.kwb" of="$tgt" bs=512 seek=1 > /dev/null 2>&1
520 (solidrun-imx6)
521 dd if="$fwdir/SPL" of="$tgt" bs=1024 seek=1 > /dev/null 2>&1
522 dd if="$fwdir/u-boot.img" of="$tgt" bs=1024 seek=69 > /dev/null 2>&1
524 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64)
525 (( noformat )) || create_fs "$bootpart" ADKBOOT vfat
529 (( noformat )) || create_fs "$rootpart" ADKROOT ext4
530 (( noformat )) || tune_fs "$rootpart"
532 (( quiet )) || print Extracting installation archive...
533 mount_fs "$rootpart" "$R" ext4
534 xz -dc "$src" | (cd "$R"; tar -xpf -)
536 if (( datafssz )); then
537 mkdir -m0755 "$R"/data
538 ((keep)) || create_fs "$datapart" ADKDATA ext4
539 ((keep)) || tune_fs "$datapart"
540 case $target {
541 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64)
542 echo "/dev/mmcblk0p3 /data ext4 rw 0 0" >> "$R"/etc/fstab
544 (banana-pro|orange-pi0|solidrun-imx6|solidrun-clearfog)
545 echo "/dev/mmcblk0p2 /data ext4 rw 0 0" >> "$R"/etc/fstab
550 case $target {
551 (raspberry-pi|raspberry-pi0|raspberry-pi2|raspberry-pi3|raspberry-pi3-64)
552 mount_fs "$bootpart" "$B" vfat
553 for x in "$R"/boot/*; do
554 [[ -e "$x" ]] && mv -f "$R"/boot/* "$B/"
555 break
556 done
557 for x in "$fwdir"/*.dtb; do
558 [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$B/"
559 break
560 done
561 # use static dtoverlay, rename to *.dtb
562 mkdir "$B/"overlays
563 for x in "$fwdir"/overlays/*.dtbo; do
564 y=$(basename ${x} .dtbo)
565 [[ -e "$x" ]] && cp "$fwdir"/overlays/${y}.dtbo "$B/"overlays/${y}.dtb
566 done
567 umount_fs "$B"
569 (solidrun-clearfog)
570 for x in "$fwdir"/*.dtb; do
571 [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/"
572 break
573 done
574 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
575 -n "SolidrunClearfog" \
576 -d $fwdir/boot.script.clearfog $R/boot/boot.scr.uimg
578 (solidrun-imx6)
579 for x in "$fwdir"/*.dtb; do
580 [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/"
581 break
582 done
583 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
584 -n "SolidrunImx6" \
585 -d $fwdir/boot.script.imx6 $R/boot/boot.scr.uimg
587 (orange-pi0)
588 for x in "$fwdir"/*.dtb; do
589 [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/"
590 break
591 done
592 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
593 -n "OrangePI Zero" \
594 -d $fwdir/boot.script.opi $R/boot/boot.scr.uimg
596 (banana-pro)
597 for x in "$fwdir"/*.dtb; do
598 [[ -e "$x" ]] && cp "$fwdir"/*.dtb "$R/boot/"
599 break
600 done
601 mkimage -A arm -O linux -T script -C none -a 0 -e 0 \
602 -n "BananaPro" \
603 -d $fwdir/boot.script.bpi $R/boot/boot.scr.uimg
607 cd "$R"
608 dd if=$rnddev bs=16 count=1 >>etc/.rnd 2>/dev/null
609 (( quiet )) || print Fixing up permissions...
610 chown 0:0 tmp
611 chmod 1777 tmp
612 [[ -f usr/bin/sudo ]] && chmod 4755 usr/bin/sudo
614 if (( grub )); then
615 (( quiet )) || print Configuring GRUB2 bootloader...
616 mkdir -p boot/grub
618 print set default=0
619 print set timeout=1
620 if (( serial )); then
621 print serial --unit=0 --speed=$speed
622 print terminal_output serial
623 print terminal_input serial
624 consargs="console=ttyS0,$speed console=tty0"
625 else
626 print terminal_output console
627 print terminal_input console
628 consargs="console=tty0"
630 print
631 print 'menuentry "GNU/Linux (OpenADK)" {'
632 linuxargs="root=PARTUUID=$partuuid $consargs"
633 (( panicreboot )) && linuxargs="$linuxargs panic=$panicreboot"
634 print "\tlinux /boot/kernel $linuxargs"
635 print '}'
636 ) >boot/grub/grub.cfg
639 (( quiet )) || print Finishing up...
640 cd "$ADK_TOPDIR"
641 umount_fs "$R"
642 if (( datafssz )); then
643 umount_fs $datapart
645 rm -rf "$T"
646 exit 0