-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
65 lines (53 loc) · 2.04 KB
/
Copy pathbuild.sh
File metadata and controls
65 lines (53 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
#!/usr/bin/env bash
# =========================================================
# FS25_TimeGuard - Build & Deploy Script
#
# Usage:
# bash build.sh Build zip only
# bash build.sh --deploy Build and copy to active mods directory
# =========================================================
set -euo pipefail
MOD_NAME="FS25_TimeGuard"
ZIP_NAME="${MOD_NAME}.zip"
DEPLOY_DIR="/c/Users/tison/Documents/My Games/FarmingSimulator2025/mods"
LOG_FILE="/c/Users/tison/Documents/My Games/FarmingSimulator2025/log.txt"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
VERSION=$(grep -m1 '<version>' modDesc.xml | sed 's/.*<version>\(.*\)<\/version>.*/\1/')
echo "============================================"
echo " ${MOD_NAME} v${VERSION}"
echo "============================================"
rm -f "$ZIP_NAME"
echo "Packing..."
# Python zipfile so paths inside the archive use forward slashes.
# PowerShell's Compress-Archive uses backslashes which break FS25 loading.
py -c "
import zipfile, os, sys
zip_name = sys.argv[1]
include = ['modDesc.xml', 'icon.dds', 'main.lua', 'src']
with zipfile.ZipFile(zip_name, 'w', zipfile.ZIP_DEFLATED) as zf:
for entry in include:
if os.path.isfile(entry):
zf.write(entry, entry.replace(os.sep, '/'))
elif os.path.isdir(entry):
for root, dirs, files in os.walk(entry):
for fname in files:
full_path = os.path.join(root, fname)
arc_name = full_path.replace(os.sep, '/')
zf.write(full_path, arc_name)
" "$ZIP_NAME"
SIZE=$(du -h "$ZIP_NAME" | cut -f1)
echo "Built: ${ZIP_NAME} (${SIZE})"
if [[ "${1:-}" == "--deploy" ]]; then
if [[ ! -d "$DEPLOY_DIR" ]]; then
echo "ERROR: Deploy directory not found:"
echo " $DEPLOY_DIR"
exit 1
fi
cp "$ZIP_NAME" "$DEPLOY_DIR/"
echo "Deployed to: ${DEPLOY_DIR}"
echo "Log: ${LOG_FILE}"
fi
echo "============================================"
echo " Done."
echo "============================================"