-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoBuildO2.sh
More file actions
83 lines (72 loc) · 2.66 KB
/
autoBuildO2.sh
File metadata and controls
83 lines (72 loc) · 2.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
# --- Configuration ---
ALICE_WORK_DIR="$HOME/alice"
PACKAGE="O2Physics"
DEFAULTS="o2"
REQUIRED_SPACE_GB=200
echo "---------------------------------------------------"
echo " ALICE O2 & O2Physics Auto-Build"
echo " Status: Running..."
echo "---------------------------------------------------"
# 1. Directory Setup
# Create the directory if it doesn't exist and enter it
mkdir -p "$ALICE_WORK_DIR"
cd "$ALICE_WORK_DIR" || { echo "Error: Could not access $ALICE_WORK_DIR"; exit 1; }
# 2. Disk Space Check
AVAILABLE_SPACE=$(df -BG . | awk 'NR==2 {print $4}' | sed 's/G//')
echo "==> Checking storage: ${AVAILABLE_SPACE}GB available."
if [ "$AVAILABLE_SPACE" -lt "$REQUIRED_SPACE_GB" ]; then
echo "!!! WARNING: You are below the recommended ${REQUIRED_SPACE_GB}GB."
echo " Continuing in 3 seconds..."
sleep 3
fi
# 3. Sync Repositories (Fetch/Update)
sync_repo() {
if [ ! -d "$1" ]; then
echo "==> Cloning $1..."
git clone "https://github.com/alisw/$1.git"
else
echo "==> Updating $1..."
cd "$1" && git pull && cd ..
fi
}
sync_repo "alidist"
sync_repo "O2"
sync_repo "O2Physics"
# 4. Official Deep Cleanup (The Three Lines)
# Cleans broken links and orphans to prevent build corruption
echo "==> Running Deep Cleanup..."
ARCH=$(aliBuild architecture)
find sw/"$ARCH"/ -mindepth 2 -maxdepth 2 -type l -delete 2>/dev/null
find sw/BUILD/ -mindepth 1 -maxdepth 1 -type l -delete 2>/dev/null
aliBuild clean
# 5. Clang Check (Build only if missing)
# Required for Coding Guidelines (clang-format)
if [ ! -d "sw/$ARCH/Clang" ]; then
echo "==> Clang not found. Building for code formatting..."
aliBuild build Clang --defaults "$DEFAULTS" -j $(nproc)
else
echo "==> Clang already present. Skipping build."
fi
# 6. Main Build (O2Physics)
echo "---------------------------------------------------"
echo " Starting $PACKAGE Build..."
echo " Status: You will see the build progress below."
echo "---------------------------------------------------"
# We run this without redirection so you see the real-time status/progress
aliBuild build "$PACKAGE" --defaults "$DEFAULTS" -j $(nproc)
# 7. Final Notification
if [ $? -eq 0 ]; then
echo ""
echo "---------------------------------------------------"
echo " SUCCESS: Build Finished!"
echo " Enter environment: alienv enter $PACKAGE/latest"
echo "---------------------------------------------------"
else
echo ""
echo "---------------------------------------------------"
echo " ERROR: Build failed. Check the terminal output above."
echo " Detailed logs are also available in sw/BUILD/"
echo "---------------------------------------------------"
exit 1
fi