-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbuild_zip.sh
More file actions
executable file
·81 lines (66 loc) · 2.04 KB
/
build_zip.sh
File metadata and controls
executable file
·81 lines (66 loc) · 2.04 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
#!/bin/bash
set -e
# Check for required dependencies
deps=("rsync" "python3")
for dep in "${deps[@]}"; do
if ! command -v "$dep" >/dev/null 2>&1; then
echo "$dep is required but not installed."
exit 1
fi
done
VARIANT=$(echo "$1" | tr '[:upper:]' '[:lower:]')
TAG=${2:-dev}
UPDATE_FLAG=$3
# Validate TAG format
if [[ "$TAG" != "dev" && ! "$TAG" =~ ^v[0-9] ]]; then
echo "Tag must start with 'v' followed by a number, e.g., v3 or v2.5"
exit 1
fi
if [ "$VARIANT" = "cli" ]; then
SUFFIX="-CLI"
elif [ "$VARIANT" = "gui" ]; then
SUFFIX="-GUI"
else
echo "Usage: $0 <cli|gui> [tag] [--update]"
exit 1
fi
DATE=$(date +%Y%m%d)
if [ "$UPDATE_FLAG" = "--update" ]; then
ZIP_NAME="out/update${SUFFIX}.zip"
else
ZIP_NAME="out/Ubuntu-Chroot-${TAG}-${DATE}${SUFFIX}.zip"
fi
# Create output directory
mkdir -p out
# Remove any existing ZIP files
rm -f "$ZIP_NAME"
TMP_DIR=$(mktemp -d)
# Copy all files except excluded
rsync -a --exclude='.git*' --exclude='Screenshots' --exclude='Docker' --exclude='CHANGELOG.md' --exclude='out' --exclude='update-*.json' --exclude='update_meta.sh' --exclude='build_zip.sh' "$PWD/" "$TMP_DIR/"
# For update builds, remove tar.gz files and add update marker
if [ "$UPDATE_FLAG" = "--update" ]; then
rm -f "$TMP_DIR"/*.tar.gz
touch "$TMP_DIR/.is_update"
fi
# Update update JSON
VERSION_CODE=$(echo "$TAG" | sed 's/v//' | awk '{print int($1 * 1000)}')
cp "update${SUFFIX}.json" "$TMP_DIR/update.json"
printf '%s\n' \
"version=${TAG}" \
"versionCode=${VERSION_CODE}" \
"updateJson=https://raw.githubusercontent.com/ravindu644/Ubuntu-Chroot/main/update${SUFFIX}.json" \
>> "$TMP_DIR/module.prop"
# Update update.json
python3 -c "
import json
with open('$TMP_DIR/update.json') as f: data = json.load(f)
data['version'] = '$TAG'
data['versionCode'] = $VERSION_CODE
with open('$TMP_DIR/update.json', 'w') as f: json.dump(data, f, indent=2)"
# Create ZIP
ORIGINAL_PWD=$PWD
cd "$TMP_DIR"
zip -r -9 "$ORIGINAL_PWD/$ZIP_NAME" .
cd "$ORIGINAL_PWD"
rm -rf "$TMP_DIR"
echo "Created $ZIP_NAME"