-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·308 lines (256 loc) · 9.83 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·308 lines (256 loc) · 9.83 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
#!/bin/bash
# =============================================================================
# DragonBornOS Build Script
# =============================================================================
# Automated build system for all supported devices
# =============================================================================
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
WHITE='\033[1;37m'
NC='\033[0m'
log() { echo -e "${CYAN}[*]${NC} $1"; }
success() { echo -e "${GREEN}[+]${NC} $1"; }
error() { echo -e "${RED}[!]${NC} $1"; }
warn() { echo -e "${YELLOW}[-]${NC} $1"; }
# =============================================================================
# CONFIGURATION
# =============================================================================
export DRAGONBORN_VERSION="13.0"
export DRAGONBORN_BUILD_TYPE="UNOFFICIAL"
export DRAGONBORN_MAINTAINER="methodwhite"
export OUT_DIR="$HOME/Projects/DragonBornOS/out"
# Device configurations
declare -A DEVICES=(
["neo"]="motorola/sm8250|DragonBorn-neo|Snapdragon 695"
["vayu"]="xiaomi/sm8250|DragonBorn-vayu|Snapdragon 860"
["HWSTK"]="huawei/kirin710|DragonBorn-HWSTK|Kirin 710"
)
# =============================================================================
# BANNER
# =============================================================================
show_banner() {
echo -e "${WHITE}"
cat << 'BANNER'
____ _ ____ __ _
| __ )| | __ _ _ __ _ __ _ _ / ___|___ _ __ / _(_) __ _
| _ \| |/ _` | '_ \| '_ \| | | | | / _ \| '_ \| |_| |/ _` |
| |_) | | (_| | | | | | | | |_| | |__| (_) | | | | _| | (_| |
|____/|_|\__,_|_| |_|_| |_|\__,_|\____\___/|_| |_|_| |_|\__, |
|___/
____ _ _
| __ )| | __ _ _| |__
| _ \| |/ _` || | '_ \
| |_) | | (_| || | |_) |
|____/|_|\__,_||_|_.__/
CUSTOM ROM BUILD SYSTEM
BANNER
echo -e "${NC}"
echo "============================================================================="
echo " DragonBornOS Build Script v1.0"
echo " Supported Devices: neo, vayu, HWSTK"
echo "============================================================================="
echo ""
}
# =============================================================================
# CHECK REQUIREMENTS
# =============================================================================
check_requirements() {
log "Checking build requirements..."
local missing=()
# Check disk space
local available=$(df -P "$OUT_DIR" | awk 'NR==2 {print $4}')
if [ "$available" -lt 100000000 ]; then
missing+=("Insufficient disk space (need 100GB+)")
fi
# Check RAM
local ram=$(free -m | awk 'NR==2 {print $2}')
if [ "$ram" -lt 16000 ]; then
warn "Low RAM detected (recommended 32GB+)"
fi
# Check Java
if ! command -v javac &> /dev/null; then
missing+=("OpenJDK 11")
fi
# Check repo
if ! command -v repo &> /dev/null; then
missing+=("repo tool")
fi
# Check build tools
for tool in make gcc g++ python3 curl git; do
if ! command -v $tool &> /dev/null; then
missing+=($tool)
fi
done
if [ ${#missing[@]} -gt 0 ]; then
error "Missing requirements: ${missing[*]}"
echo ""
echo "Install with:"
echo " sudo apt install -y bc bison build-essential ccache curl flex g++"
echo " gcc git gnupg liblz4-tool libncurses5 libncurses5-dev libssl-dev"
echo " libxml2 libxml2-utils lzop maven pngcrush python3 rsync schedtool"
echo " squashfs-tools xsltproc zip zlib1g-dev imagemagisk openjdk-11-jdk"
exit 1
fi
success "All requirements met!"
}
# =============================================================================
# SETUP ENVIRONMENT
# =============================================================================
setup_environment() {
log "Setting up build environment..."
# Source build setup
if [ -f build/envsetup.sh ]; then
source build/envsetup.sh
success "Environment loaded"
else
error "build/envsetup.sh not found. Run this from DragonBornOS root."
exit 1
fi
# Set output directory
export OUT_DIR_PRODUCT="$OUT_DIR"
success "Output directory: $OUT_DIR"
}
# =============================================================================
# SYNC SOURCES
# =============================================================================
sync_sources() {
log "Syncing sources..."
if [ ! -d ".repo" ]; then
warn "Repository not initialized. Initializing..."
repo init -u https://github.com/DragonBornOS/platform_manifest.git -b 13.0 --git-lfs
fi
repo sync -c --force-sync --optimized-fetch --no-tags --no-clone-bundle \
-j$(nproc --all)
success "Sources synced"
}
# =============================================================================
# CLONE DEVICE TREES
# =============================================================================
clone_device_trees() {
local device=$1
log "Cloning device trees for $device..."
case $device in
"neo")
git clone https://github.com/DragonBornOS/device_motorola_neo.git device/motorola/neo 2>/dev/null || true
git clone https://github.com/DragonBornOS/kernel_motorola_neo.git kernel/motorola/neo 2>/dev/null || true
git clone https://github.com/DragonBornOS/proprietary_vendor_motorola.git vendor/motorola 2>/dev/null || true
;;
"vayu")
git clone https://github.com/DragonBornOS/device_xiaomi_vayu.git device/xiaomi/vayu 2>/dev/null || true
git clone https://github.com/DragonBornOS/kernel_xiaomi_sm8250.git kernel/xiaomi/sm8250 2>/dev/null || true
git clone https://github.com/DragonBornOS/proprietary_vendor_xiaomi.git vendor/xiaomi 2>/dev/null || true
;;
"HWSTK")
git clone https://github.com/DragonBornOS/device_huawei_HWSTK-HF.git device/huawei/HWSTK-HF 2>/dev/null || true
git clone https://github.com/DragonBornOS/kernel_huawei_kirin710.git kernel/huawei/kirin710 2>/dev/null || true
git clone https://github.com/DragonBornOS/proprietary_vendor_huawei.git vendor/huawei 2>/dev/null || true
;;
esac
success "Device trees cloned for $device"
}
# =============================================================================
# BUILD ROM
# =============================================================================
build_rom() {
local device=$1
local build_type=${2:-userdebug}
log "Building DragonBornOS for $device..."
# Setup for device
lunch dragonborn_${device}-${build_type}
# Clean output
make clean
# Start build
mka bacon -j$(nproc --all)
if [ $? -eq 0 ]; then
success "Build completed for $device!"
echo ""
echo "Output: $OUT_DIR/target/product/$device/"
ls -lh "$OUT_DIR/target/product/$device/"*.zip 2>/dev/null || true
else
error "Build failed for $device"
exit 1
fi
}
# =============================================================================
# GENERATE OTA PACKAGE
# =============================================================================
generate_ota() {
local device=$1
log "Generating OTA package for $device..."
local out_zip="$OUT_DIR/target/product/$device/DragonBornOS-$device.zip"
local out_ota="$OUT_DIR/ota/$device/"
mkdir -p "$out_ota"
# Generate OTA metadata
cat > "$out_ota/ota_metadata.json" << EOF
{
"version": "$DRAGONBORN_VERSION",
"build_type": "$DRAGONBORN_BUILD_TYPE",
"device": "$device",
"timestamp": $(date +%s),
"zip_url": "https://dragonbornos.com/downloads/$device/latest.zip",
"changelog_url": "https://dragonbornos.com/changelog/$device"
}
EOF
success "OTA package generated"
}
# =============================================================================
# MAIN
# =============================================================================
main() {
show_banner
local device=${1:-all}
local action=${2:-build}
case $action in
"setup")
check_requirements
setup_environment
sync_sources
;;
"device")
clone_device_trees "$device"
;;
"build")
if [ "$device" = "all" ]; then
for dev in "${!DEVICES[@]}"; do
clone_device_trees "$dev"
build_rom "$dev"
generate_ota "$dev"
done
else
clone_device_trees "$device"
build_rom "$device"
generate_ota "$device"
fi
;;
"clean")
log "Cleaning build environment..."
make clobber
success "Clean complete"
;;
"help"|*)
echo "Usage: $0 [DEVICE] [ACTION]"
echo ""
echo "Devices:"
echo " neo - Moto Edge 30 Neo"
echo " vayu - Xiaomi POCO X3 Pro"
echo " HWSTK - Huawei P Smart 2019"
echo " all - All devices"
echo ""
echo "Actions:"
echo " setup - Setup build environment"
echo " device - Clone device trees"
echo " build - Build ROM"
echo " clean - Clean build"
echo ""
echo "Examples:"
echo " $0 neo setup"
echo " $0 vayu build"
echo " $0 all build"
;;
esac
}
main "$@"