-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
62 lines (54 loc) · 1.66 KB
/
build.sh
File metadata and controls
62 lines (54 loc) · 1.66 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
#!/bin/bash
log() {
local type=$1
local message=$2
local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
local log_message="[$timestamp] $type: $message"
echo "$log_message"
echo "$log_message" >> build.log
}
echo "=== Build Started $(date '+%Y-%m-%d %H:%M:%S') ===" > build.log
source /etc/os-release
if [ ! "$ID" == "debian" ]; then
log "ERROR" "This script is intended to run on a Debian-based system."
exit 1
fi
log "INFO" "Updating package list and installing required packages..."
if apt-get update >> build.log 2>&1; then
log "SUCCESS" "Package list updated successfully"
else
log "ERROR" "Failed to update package list"
exit 1
fi
if apt-get install -y live-build debootstrap >> build.log 2>&1; then
log "SUCCESS" "Required packages installed successfully"
else
log "ERROR" "Failed to install required packages"
exit 1
fi
if [ -d 'build/' ]; then
log "INFO" "Directory exists. Cleaning up existing build directory..."
if rm -rf build/*; then
log "SUCCESS" "Build directory cleaned successfully"
else
log "ERROR" "Failed to clean build directory"
exit 1
fi
else
log "INFO" "Directory does not exist. Creating build directory..."
if mkdir build; then
log "SUCCESS" "Build directory created successfully"
else
log "ERROR" "Failed to create build directory"
exit 1
fi
fi
log "INFO" "Building project..."
if sudo lb build >> build.log 2>&1; then
log "SUCCESS" "Project built successfully"
else
log "ERROR" "Project build failed"
exit 1
fi
log "INFO" "Build process completed"
echo "=== Build Finished $(date '+%Y-%m-%d %H:%M:%S') ===" >> build.log