forked from shaderecker/lineage_build_env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·153 lines (123 loc) · 3.69 KB
/
setup.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/bin/bash
# Force default language for output (for 18.04)
export LC_ALL=C
# Import settings
source settings.sh
# Disable update dialogues
export DEBIAN_FRONTEND=noninteractive
if ! grep -q confdef /etc/apt/apt.conf.d/50unattended-upgrades; then
echo "Dpkg::Options {
"--force-confdef";
"--force-confold";
}" | sudo tee -a /etc/apt/apt.conf.d/50unattended-upgrades
fi
# Add Ubuntu Xenial sources
if ! grep -q xenial /etc/apt/sources.list; then
echo "deb http://us.archive.ubuntu.com/ubuntu/ xenial main universe
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main universe" | sudo tee -a /etc/apt/sources.list
fi
# Install banner packages
sudo apt install -y figlet toilet boxes
# Banner function
function losBANNER {
toilet -f ivrit "$1" | boxes -d stone
}
losBANNER "LineageOS"
echo
losBANNER "Build: $device"
cd ~/
# Update installed packages
echo
echo
losBANNER "Updating..."
sudo apt update
sudo apt upgrade -y --allow-unauthenticated
sudo apt autoremove -y
# Install new required packages
losBANNER "Installing..."
sudo apt install -y bc bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk3.0-dev libxml2 libxml2-utils lzop maven openjdk-8-jdk pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-dev lib32z1-dev imagemagick python
# Set gitconfig
git config --global user.name "$git_name"
git config --global user.email "$git_email"
git config --global color.ui true
# Create directories
mkdir -p ~/bin
mkdir -p ~/android/system/
# Install repo tool
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
# Initialize repo
cd ~/android/lineageos/
repo init -u git://github.com/aossp-roms/aossp-repos.git -b $lineage_version
# Switch to our custom local_manifest
if [[ $custom_local_manifest = "true" ]]
then
cd ~/android/system/.repo
rm -rf local_manifests
git clone $custom_local_manifest_url
cd ~/android/system/
fi
# Sync repo
losBANNER "Syncing Repo..."
repo sync --no-clone-bundle --force-sync --no-tags --optimized-fetch -j$(nproc --all) -c
# Environment setup
source build/envsetup.sh
losBANNER "Init: $device"
# Initialize our device
breakfast $device
# Get device specific vendor files
if [[ $custom_local_manifest != "true" ]]
then
cd ~/android/system/vendor
mkdir -p $vendor_path
mkdir -p temp
cd ~/android/system/vendor/$vendor_path
git clone $vendor_files_git
cp -r ~/android/system/vendor/$vendor_path/*/* ~/android/system/vendor/temp
cd ~/android/system/vendor
rm -rf ~/android/system/vendor/$vendor_path
mkdir -p $vendor_path
cp -r ~/android/system/vendor/temp/* ~/android/system/vendor/$vendor_path
rm -rf ~/android/system/vendor/temp
cd ~/android/system/
# Repeating breakfast after vendor files in case sth went wrong previously
breakfast $device
fi
# Setup environment variables
losBANNER "Env Variables..."
export USE_CCACHE=1
export ANDROID_CCACHE_SIZE="$ccache"
if [[ $low_ram = "true" ]]
then
export USE_NINJA=false
export JACK_SERVER_VM_ARGUMENTS="-Dfile.encoding=UTF-8 -XX:+TieredCompilation -Xmx$ram"
fi
if [[ $super_user = "true" ]]
then
export WITH_SU=true
fi
printenv | grep "CCACHE\|WITH_SU\|NINJA\|JACK"
# Clean build environment
losBANNER "Cleanup..."
make clean
# Repopick personal changes
if [[ $personal_repopicks = "true" ]]
then
losBANNER "Repopicking..."
repopick -f -t $repopick_topic
fi
# Actually start build
losBANNER "Building..."
brunch $device
# Copy the LineageOS installer zip file to a remote server via scp
if [[ $scp_copy = "true" ]]
then
losBANNER "Copying..."
source copy.sh
fi
# Shuts the machine down after the build
if [[ $shutdown = "true" ]]
then
losBANNER "Goodbye..."
sudo shutdown -h
fi