-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathpackage.sh
More file actions
101 lines (86 loc) · 2.07 KB
/
package.sh
File metadata and controls
101 lines (86 loc) · 2.07 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
#!/bin/bash
# Dry run (preview only):
# bash ./package.sh --dry-run
# Real packaging (creates archives):
# ./package.sh
set -euo pipefail
VERSION=$(cat VERSION)
DRYRUN=false
RELEASE_DIR="release"
# Parse optional args
if [[ "${1:-}" == "--dry-run" ]]; then
DRYRUN=true
fi
# Whitelist files for packaging
WINDOWS_FILES=(
"LICENSE"
"README.md"
"README.zh-CN.md"
"VERSION"
"win-helper-functions.cmd"
"win-install.cmd"
"win-uninstall.cmd"
"win-update-tools.cmd"
"dumpsmc.exe"
"gettools.exe"
"unlocker.exe"
)
LINUX_FILES=(
"LICENSE"
"README.md"
"README.zh-CN.md"
"VERSION"
"lnx-helper-functions.sh"
"lnx-install.sh"
"lnx-uninstall.sh"
"lnx-update-tools.sh"
"dumpsmc.py"
"gettools.py"
"unlocker.py"
)
# Function to check files existence
check_files() {
local files=("$@")
local missing=0
for f in "${files[@]}"; do
if [[ ! -e "$f" ]]; then
echo "⚠️ Missing file: $f"
missing=1
fi
done
if [[ $missing -ne 0 ]]; then
echo "❌ One or more whitelisted files are missing. Aborting."
exit 1
fi
}
# Function to package files
package() {
local name="$1"
shift
local files=("$@")
# Check all files exist
check_files "${files[@]}"
if $DRYRUN; then
echo "👉 Would create $name containing:"
for f in "${files[@]}"; do
echo " - $f"
done
echo
else
# Ensure release folder exists
mkdir -p "$RELEASE_DIR"
case "$name" in
*.zip) zip -r "$RELEASE_DIR/$name" "${files[@]}" ;;
*.tar.gz) tar -czvf "$RELEASE_DIR/$name" "${files[@]}" ;;
esac
echo "✅ Created $RELEASE_DIR/$name"
fi
}
# Clean previous release folder if it exists
if [[ -d "$RELEASE_DIR" && "$DRYRUN" = false ]]; then
echo "🗑️ Removing previous release folder..."
rm -rf "$RELEASE_DIR"
fi
# Run packaging
package "Unlocker-Windows-${VERSION}.zip" "${WINDOWS_FILES[@]}"
package "Unlocker-Linux-${VERSION}.tar.gz" "${LINUX_FILES[@]}"