This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathunibuild.sh
executable file
·138 lines (112 loc) · 4.38 KB
/
unibuild.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/bash
#
# Copyright 2018 (c) Capuccino <[email protected]>
#
#
# Feel free to improve this script on GitHub
set -eo pipefail
BASE_DIR="$(cd "$(dirname "$0")" && pwd)"
CHROOT_DIR="$BASE_DIR/chroot"
CHROMEOS_VERSION=
BOARD_ARCH=
case "$1" in
amd64)
BOARD_ARCH="amd64"
;;
aarch64)
echo "Warning: aarch64 builds are experimental. Build success is not guranteed."
BOARD_ARCH="aarch64"
sleep 2
;;
--help | -h)
echo "$0 <board_arch|[-h][--help]> <cros_version>"
echo ""
echo "$0 builds the CrOS image from a maru overlay architecture defined in the first argument."
echo "This script is created by Kibo Hikari, Licensed under MIT."
exit 0;
;;
*)
echo "Invalid arch $1. Either its not supported yet or its not coded in $0 at the moment."
echo "Run --help for more info."
exit 1
;;
esac
if [ -z "$2" ]; then
CHROMEOS_VERSION="release-R76-12239.B"
else
CHROMEOS_VERSION="$2"
fi
if [[ ! "$CHROMEOS_VERSION" =~ ^release-R[0-9]{2}-[0-9]{5}\.B$ ]]; then
echo "$CHROMEOS_VERSION is not a valid ChromeOS version."
echo "CrOS versions look like this : release-R[chromium_version]-[cros_build].B"
echo "eg. release-R76-12239.B. For reference, go to https://cros-updates-serving.appspot.com"
exit 3;
fi
if [ "$(uname -m)" != "x86_64" ]; then
echo "Error: Unsupported architecture. Most CrOS build tools were built for x86_64 machines."
exit 1
fi
if [ -z "$(command -v proot)" ]; then
echo "Error: proot is required to use this script!"
exit 3
fi
if [ -z "$(command -v debootstrap)" ]; then
echo "Error: debootstrap is required to use this script!"
exit 3
fi
if [ -z "$(command -v git)" ]; then
echo "Error: Git not found! You can't build Maru or Chromium OS from source without Git!"
exit 3
fi
proot_exec() {
# HACK: workaround for seccomp bug for non-Debian release proot packages
PROOT_NO_SECCOMP=1 \
proot -S "$CHROOT_DIR" -0 /usr/bin/env -i HOME=/root TERM="xterm-256color" PATH='PATH=/bin:/usr/bin:/sbin:/usr/sbin:/bin:/usr/local/repo' /bin/bash -c "$@" | while read -r line; do
echo "[CHROOT] $line"
done
}
echo "Welcome to $0! This script builds maru using proot and debootstrap"
echo "Make sure you set your git credentials accordingly. Happy coding!"
sleep 5
if [ -z "$(command -v repo)" ]; then
echo "repo not installed. Installing from Google Sources..."
sleep 2
sudo mkdir -p /usr/local/repo
sudo chmod -R 777 /usr/local/repo
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git /usr/local/repo/depot_tools
export PATH="/usr/local/repo/depot_tools:$PATH"
echo 'export PATH=/usr/local/repo/depot_tools:$PATH' >> "$HOME/.profile";
else
echo "repo found in path. Nothing to do in the host side :)"
sleep 2
fi
echo "Setting up environment. Please be patient."
sleep 2
if [ ! -d "$CHROOT_DIR" ]; then
mkdir "$CHROOT_DIR"
# TODO: Figure out the non-PH mirror link to Ubuntu sources.
sudo debootstrap --arch amd64 xenial "$CHROOT_DIR" http://mirror.rise.ph/ubuntu/
sudo cp -vRf /usr/local/repo "$CHROOT_DIR/usr/local/"
# Fix permissions so proot can get permissions to use the thing with extreme prejudice
sudo chown -R 1000:1000 "$CHROOT_DIR"
proot_exec apt-get -y install git-core gitk git-gui subversion curl lvm2 thin-provisioning-tools python-pkg-resources python-virtualenv python-oauth2client
else
echo "$CHROOT_DIR is already setup. Nothing left to do."
fi
echo "Chroot setup done. Mounting directory."
mkdir "$CHROOT_DIR/mnt/cros"
sudo mount --bind "$BASE_DIR" "$CHROOT_DIR/mnt/cros"
echo "Initial Setup done, now building ChromiumOS."
proot_exec git config --global user.name "UbuntuChroot"
proot_exec git config --global user.email "[email protected]"
proot_exec git config --global color.ui true
proot_exec cd /mnt/cros && mkdir build && \
cd build && \
repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git -b "$CHROMEOS_VERSION" && \
repo sync -j 100
proot_exec cd /mnt/cros && cp -vRf overlay-* build/src/overlays/
proot_exec cd /mnt/cros/build && cros_sdk --download -- setup_board --board=maru-"$BOARD_ARCH";
proot_exec cd /mnt/cros/build && cros_sdk -- ./build_packages --withtest --board=maru-"$BOARD_ARCH";
proot_exec cd /mnt/cros/build && cros_sdk -- ./build_image --board=maru-"$BOARD_ARCH" base;
echo "Image has been built. Check $BASE_DIR/src/images/maru-$CHROMEOS_VERSION."
exit 0