-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·256 lines (213 loc) · 9.03 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·256 lines (213 loc) · 9.03 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
#!/bin/bash
# =============================================================================
# DragonBornOS Setup Script
# =============================================================================
# Inicializa el entorno de desarrollo para todos los dispositivos
# =============================================================================
set -e
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"; exit 1; }
warn() { echo -e "${YELLOW}[-]${NC} $1"; }
echo -e "${WHITE}"
cat << 'BANNER'
____ _ ____ __ _
| __ )| | __ _ _ __ _ __ _ _ / ___|___ _ __ / _(_) __ _
| _ \| |/ _` | '_ \| '_ \| | | | | / _ \| '_ \| |_| |/ _` |
| |_) | | (_| | | | | | | | |_| | |__| (_) | | | | _| | (_| |
|____/|_|\__,_|_| |_|_| |_|\__,_|\____\___/|_| |_|_| |_|\__, |
|___/
____ _ _
| __ )| | __ _ _| |__
| _ \| |/ _` || | '_ \
| |_) | | (_| || | |_) |
|____/|_|\__,_||_|_.__/
SETUP SCRIPT
BANNER
echo -e "${NC}"
echo "============================================================================="
echo " DragonBornOS Development Environment Setup"
echo "============================================================================="
echo ""
# =============================================================================
# CHECK SYSTEM REQUIREMENTS
# =============================================================================
check_system() {
log "Checking system requirements..."
# Check OS
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ ! "$ID" =~ ^(ubuntu|debian|linuxmint)$ ]]; then
warn "You're not using Ubuntu/Debian. Some commands may fail."
fi
log "OS: $NAME $VERSION"
fi
# Check architecture
ARCH=$(uname -m)
if [ "$ARCH" != "x86_64" ]; then
error "DragonBornOS requires x86_64 architecture. You have: $ARCH"
fi
log "Architecture: $ARCH"
# Check disk space
AVAILABLE=$(df -P . | awk 'NR==2 {print $4}')
AVAILABLE_GB=$((AVAILABLE / 1024 / 1024))
if [ $AVAILABLE_GB -lt 100 ]; then
error "Insufficient disk space. Need 100GB+, have: ${AVAILABLE_GB}GB"
fi
log "Available disk space: ${AVAILABLE_GB}GB"
# Check RAM
RAM=$(free -m | awk 'NR==2 {print $2}')
RAM_GB=$((RAM / 1024))
if [ $RAM_GB -lt 16 ]; then
warn "Low RAM detected. Recommended: 32GB+, have: ${RAM_GB}GB"
fi
log "RAM: ${RAM_GB}GB"
success "System check passed!"
}
# =============================================================================
# INSTALL DEPENDENCIES
# =============================================================================
install_dependencies() {
log "Installing build dependencies..."
if [ -f /etc/debian_version ]; then
sudo apt update
sudo apt install -y \
bc bison build-essential ccache curl flex g++ \
gcc git gnupg liblz4-tool libncurses5 libncurses5-dev \
libssl-dev libxml2 libxml2-utils lzop maven \
pngcrush python3 rsync schedtool squashfs-tools \
xsltproc zip zlib1g-dev imagemagick \
openjdk-11-jdk wget libtinfo5 libncurses5 \
adb fastboot
success "Dependencies installed!"
else
warn "Not a Debian-based system. Install dependencies manually."
echo ""
echo "Required packages:"
echo " bc bison build-essential ccache curl flex g++ gcc git"
echo " gnupg liblz4-tool libncurses5 libncurses5-dev libssl-dev"
echo " libxml2 libxml2-utils lzop maven pngcrush python3 rsync"
echo " schedtool squashfs-tools xsltproc zip zlib1g-dev imagemagick"
echo " openjdk-11-jdk wget libtinfo5 libncurses5 adb fastboot"
fi
}
# =============================================================================
# SETUP REPO TOOL
# =============================================================================
setup_repo() {
log "Setting up repo tool..."
if [ ! -f ~/bin/repo ]; then
mkdir -p ~/bin
curl -s https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
success "Repo tool installed"
else
success "Repo tool already exists"
fi
# Add to PATH
if [[ ":$PATH:" != *":$HOME/bin:"* ]]; then
echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
log "Added ~/bin to PATH"
fi
}
# =============================================================================
# INITIALIZE REPOSITORY
# =============================================================================
init_repo() {
log "Initializing DragonBornOS repository..."
if [ ! -d ".repo" ]; then
repo init -u https://github.com/DragonBornOS/platform_manifest.git -b 13.0 --git-lfs
# Add local manifest for devices
mkdir -p .repo/local_manifests
cat > .repo/local_manifests/devices.xml << 'EOF'
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<!-- Moto Edge 30 Neo -->
<project name="DragonBornOS/device_motorola_neo" path="device/motorola/neo" remote="github" revision="13.0"/>
<project name="DragonBornOS/kernel_motorola_neo" path="kernel/motorola/neo" remote="github" revision="13.0"/>
<project name="DragonBornOS/proprietary_vendor_motorola" path="vendor/motorola" remote="github" revision="13.0"/>
<!-- Xiaomi POCO X3 Pro -->
<project name="DragonBornOS/device_xiaomi_vayu" path="device/xiaomi/vayu" remote="github" revision="13.0"/>
<project name="DragonBornOS/kernel_xiaomi_sm8250" path="kernel/xiaomi/sm8250" remote="github" revision="13.0"/>
<project name="DragonBornOS/proprietary_vendor_xiaomi" path="vendor/xiaomi" remote="github" revision="13.0"/>
<!-- Huawei P Smart 2019 -->
<project name="DragonBornOS/device_huawei_HWSTK-HF" path="device/huawei/HWSTK-HF" remote="github" revision="13.0"/>
<project name="DragonBornOS/kernel_huawei_kirin710" path="kernel/huawei/kirin710" remote="github" revision="13.0"/>
<project name="DragonBornOS/proprietary_vendor_huawei" path="vendor/huawei" remote="github" revision="13.0"/>
</manifest>
EOF
success "Repository initialized with local manifest"
else
success "Repository already initialized"
fi
}
# =============================================================================
# SYNC SOURCES
# =============================================================================
sync_sources() {
log "Syncing sources..."
repo sync -c --force-sync --optimized-fetch --no-tags --no-clone-bundle \
-j$(nproc --all)
success "Sources synced!"
}
# =============================================================================
# SETUP DEVICE TREES
# =============================================================================
setup_devices() {
log "Setting up device trees..."
for device in neo vayu HWSTK-HF; do
if [ -d "device/*/$device" ]; then
success "Device tree found: $device"
else
warn "Device tree not found: $device"
fi
done
}
# =============================================================================
# BUILD ENVIRONMENT
# =============================================================================
setup_build_env() {
log "Setting up build environment..."
if [ -f build/envsetup.sh ]; then
source build/envsetup.sh
success "Build environment loaded"
else
warn "build/envsetup.sh not found. Run 'repo sync' first."
fi
# Show lunch options
echo ""
log "Available DragonBornOS devices:"
lunch | grep dragonborn || true
}
# =============================================================================
# MAIN
# =============================================================================
main() {
check_system
install_dependencies
setup_repo
init_repo
sync_sources
setup_devices
setup_build_env
echo ""
success "╔═══════════════════════════════════════════════════════════════════╗"
success "║ DragonBornOS SETUP COMPLETE ║"
success "╚═══════════════════════════════════════════════════════════════════╝"
echo ""
echo "Next steps:"
echo " 1. Build ROM: ./build.sh {device} build"
echo " 2. Available devices: neo, vayu, HWSTK-HF"
echo ""
echo "Example:"
echo " ./build.sh neo build"
echo ""
}
main "$@"