-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_dist.sh
More file actions
executable file
·132 lines (109 loc) · 4.13 KB
/
build_dist.sh
File metadata and controls
executable file
·132 lines (109 loc) · 4.13 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
#
# Bundle code to a distributable package (ready to be uploaded to Steam workshop)
# This will NOT upload to steam, so is useful for testing.
# Define "here" as the directory this script is in
HERE="$(realpath "$(dirname "$0")")"
# Load settings
source "$HERE/settings.sh"
if [ ! -e "$HERE/DESCRIPTION.bbcode" ]; then
echo "ERROR: Please create a DESCRIPTION.bbcode with the contents of the mod description"
exit 1
fi
# Set target directory for local testing
if [ -n "$MOD_VERSION" ]; then
DIST="$HERE/dist/$MOD_NAME-$MOD_VERSION"
else
DIST="$HERE/dist/$MOD_NAME-$(date +%Y%m%d.%H%M)"
fi
DEST="$DIST/Contents/mods"
# Ensure a clean working directory
if [ -n "$DIST" -a -d "$DIST" ]; then
rm -rf "$DIST"
fi
# The mod contents is now contained inside DESCRIPTION
# it was getting too unwieldy to be in a simple variable.
# Run through sed to replace quotes with HTML quote characters, (since it is passed to a simple VDF file)
MOD_DESCRIPTION="$(cat "$HERE/DESCRIPTION.bbcode" | sed 's:":\":g')"
[ -d "$DEST" ] || mkdir -p "$DEST"
# Sync local mod code
rsync "$HERE/src/" "$DEST/" -r --delete
# Install any tiles (if present)
if [ -n "$TILES" ]; then
for TILE in $TILES; do
# Split tile line by a colon for mod:tile file
PARTS=(${TILE//:/ })
[ -d "$DEST/${PARTS[1]}/media" ] || mkdir -p "$DEST/${PARTS[1]}/media"
if [ ${#PARTS[@]} -eq 3 ]; then
# Allow the user to define SOURCE:DEST:NEW_FILENAME
# Allows the dev to specify a different filename for the source vs destination,
# useful when having multiple tiles for different versions of the game which should
# all get generated to the same base filename inside the respective versions.
cp "$HERE/designs/Tiles/${PARTS[0]}" "$DEST/${PARTS[1]}/media/${PARTS[2]}"
else
# Normal behaviour; SOURCE:DEST
cp "$HERE/designs/Tiles/${PARTS[0]}" "$DEST/${PARTS[1]}/media/${PARTS[0]}"
fi
done
fi
# Install any packs (if present)
if [ -n "$PACKS" ]; then
for PACK in $PACKS; do
# Split tile line by a colon for mod:tile file
PARTS=(${PACK//:/ })
[ -d "$DEST/${PARTS[1]}/media/texturepacks" ] || mkdir -p "$DEST/${PARTS[1]}/media/texturepacks"
if [ ${#PARTS[@]} -eq 3 ]; then
# Allow the user to define SOURCE:DEST:NEW_FILENAME
# Allows the dev to specify a different filename for the source vs destination,
# useful when having multiple tiles for different versions of the game which should
# all get generated to the same base filename inside the respective versions.
cp "$HERE/designs/Packs/${PARTS[0]}" "$DEST/${PARTS[1]}/media/texturepacks/${PARTS[2]}"
else
# Normal behaviour; SOURCE:DEST
cp "$HERE/designs/Packs/${PARTS[0]}" "$DEST/${PARTS[1]}/media/texturepacks/${PARTS[0]}"
fi
done
fi
# Deploy Steam-specific content
cp "$HERE/src/preview.png" "$DIST/preview.png"
# Build the metadata VDF file, this is what steamcmd uses to know where everything is located
cat > "$DIST/metadata.vdf" << EOD
"workshopitem" {
"appid" "108600"
"publishedfileid" "$WORKSHOP_ID"
"contentfolder" "$DIST/Contents"
"previewfile" "$DIST/preview.png"
"visibility" "0"
"title" "$MOD_TITLE"
"description" "$MOD_DESCRIPTION"
}
EOD
# Build a workshop.txt file for publishing mod tags
cat > "$DIST/workshop.txt" << EOD
version=1
title=$MOD_TITLE
tags=$MOD_TAGS
visibility=$MOD_VISIBILITY
EOD
if [ -n "$WORKSHOP_ID" -a "$WORKSHOP_ID" -ne 0 ]; then
# If we have a workshop ID, add it to the workshop.txt file
echo "id=$WORKSHOP_ID" >> "$DIST/workshop.txt"
fi
cat DESCRIPTION.bbcode | sed 's:^:description=:g' >> "$DIST/workshop.txt"
# Set the mod version inside the PZ mod files
# The user could manually set this within the files, but this allows
# them to set it once in settings.sh and have it applied automatically.
if [ -n "$MOD_VERSION" ]; then
find "$DEST" -type f -name "mod.info" | while read FILE; do
# Check if "modversion=" is already present in the file
if grep -qi "modversion=" "$FILE"; then
# If it is, replace it with the new version
sed -i "s/modversion=.*/modversion=$MOD_VERSION/" "$FILE"
else
# If not, append it to the end of the file
echo "" >> "$FILE"
echo "modversion=$MOD_VERSION" >> "$FILE"
fi
done
fi
echo "Bundled mod in $DIST"