Debian Codegraph @

builder/arm_builder.sh

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2
3 set -eu
4
5 PROGRAM="${1}"
6 shift
7 COMMAND="${*}"
8
9 IMAGE="https://downloads.raspberrypi.org/raspbian_lite/images/raspbian_lite-2020-02-14/2020-02-13-raspbian-buster-lite.zip"
10 GOLANG="https://golang.org/dl/go1.16.2.linux-armv6l.tar.gz"
11
12 REPO_DIR="${PWD}"
13 TMP_DIR="/tmp/builderscip-shell filesystem . . `/tmp/builder`."
14 MNT_DIR="${TMP_DIR}/mnt"
15
16 if ! systemctl is-active systemd-binfmt.service >/dev/nullscip-shell filesystem . . `/dev/null`. 2>&1; then
17 mkdirscip-shell system . . mkdir. -p "/lib/binfmt.dscip-shell filesystem . . `/lib/binfmt.d`."
18 echoscip-shell system . . echo. ':qemu-arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:F' > /lib/binfmt.d/qemu-arm-static.confscip-shell filesystem . . `/lib/binfmt.d/qemu-arm-static.conf`.
19 systemctl restart systemd-binfmt.service
20 fi
21
22 mkdirscip-shell system . . mkdir. -p "${TMP_DIR}"
23 wget --show-progress -qcO "${TMP_DIR}/raspbian.zip" "${IMAGE}"
24 gunzipscip-shell system . . gunzip. -c "${TMP_DIR}/raspbian.zip" > "${TMP_DIR}/raspbian.img"
25 truncatescip-shell system . . truncate. "${TMP_DIR}/raspbian.img" --size=+2G
26 parted --script "${TMP_DIR}/raspbian.img" resizepart 2 100%
27
28 LOOP_PATH="$(losetupscip-shell system . . losetup. --find --partscan --show "${TMP_DIR}/raspbian.img")"
29 e2fsck -y -f "${LOOP_PATH}p2"
30 resize2fs "${LOOP_PATH}p2"
31 partprobe "${LOOP_PATH}"
32
33 mkdirscip-shell system . . mkdir. -p "${MNT_DIR}"
34 mountpointscip-shell system . . mountpoint. -q "${MNT_DIR}" && umountscip-shell system . . umount. -R "${MNT_DIR}"
35 mountscip-shell system . . mount. -o rw "${LOOP_PATH}p2" "${MNT_DIR}"
36 mountscip-shell system . . mount. -o rw "${LOOP_PATH}p1" "${MNT_DIR}/boot"
37
38 mountscip-shell system . . mount. --bind /devscip-shell filesystem . . `/dev`. "${MNT_DIR}/dev/"
39 mountscip-shell system . . mount. --bind /sysscip-shell filesystem . . `/sys`. "${MNT_DIR}/sys/"
40 mountscip-shell system . . mount. --bind /procscip-shell filesystem . . `/proc`. "${MNT_DIR}/proc/"
41 mountscip-shell system . . mount. --bind /dev/ptsscip-shell filesystem . . `/dev/pts`. "${MNT_DIR}/dev/pts"
42 mountscip-shell system . . mount. | grepscip-shell system . . grep. "${MNT_DIR}"
43 dfscip-shell system . . df. -h
44
45 cpscip-shell system . . cp. /usr/bin/qemu-arm-staticscip-shell filesystem . . `/usr/bin/qemu-arm-static`. "${MNT_DIR}/usr/bin"
46 cpscip-shell system . . cp. /etc/resolv.confscip-shell filesystem . . `/etc/resolv.conf`. "${MNT_DIR}/etc/resolv.conf"
47
48 mkdirscip-shell system . . mkdir. -p "${MNT_DIR}/root/src/${PROGRAM}"
49 mountscip-shell system . . mount. --bind "${REPO_DIR}" "${MNT_DIR}/root/src/${PROGRAM}"
50
51 cpscip-shell system . . cp. "${MNT_DIR}/etc/ld.so.preload" "${MNT_DIR}/etc/_ld.so.preload"
52 touchscip-shell system . . touch. "${MNT_DIR}/etc/ld.so.preload"
53
54 chrootscip-shell system . . chroot. "${MNT_DIR}" bin/bash -x <<EOF
55 set -eu
56
57 export LANG="C"
58 export LC_ALL="C"
59 export LC_CTYPE="C"
60 export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/root/bin"
61
62 wget --show-progress -qcO /tmp/golang.tar.gz "${GOLANG}"
63 tar -C /usr/local -xzf /tmp/golang.tar.gz
64 export GOROOT="/usr/local/go"
65 export GOPATH="/root"
66
67 apt-get -y update
68 apt-get install wget libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev build-essential git
69
70 cd "/root/src/${PROGRAM}"
71 ${COMMAND}
72 EOF
73 echoscip-shell system . . echo. "Build finished"