forked from sl5net/autocivP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modBuildScript.sh
executable file
·185 lines (126 loc) · 5.96 KB
/
modBuildScript.sh
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
# how to start maybe when using fish-shell :
# alias cdCreateAutoCivPmodIOZip "cd ~/.local/share/0ad/mods/autocivp; pwd; ./modBuildScript.sh"
# links:
# https://wildfiregames.com/forum/topic/24333-guide-for-publishing-mods-on-modio/?do=findComment&comment=554945
# https://wildfiregames.com/forum/topic/24333-guide-for-publishing-mods-on-modio/#comment-554994
# may some interesting stuff also here: https://github.com/ModIO/
# alternative may you want create mods also by using this script that use pyrogenesis:
# rm ~/Downloads/autocivP.pyromod
# rm ~/game/0ad/a27/a27build/binaries/system/autocivP.pyromod
# cd ~/game/0ad/a27/a27build/binaries/system/
# ./pyrogenesis -mod=mod -mod=public -mod=autocivP -archivebuild=/home/seeh/.local/share/0ad/mods/autocivP -archivebuild-output=autocivP.pyromod -archivebuild-compress
# cp ~/game/0ad/a27/a27build/binaries/system/autocivP.pyromod ~/Downloads/autocivP.pyromod
# rm ~/game/0ad/a27/a27build/binaries/system/autocivP.pyromod
# cp ~/Downloads/autocivP.pyromod ~/Downloads/autocivP.zip
# doublecmd ~/game/0ad/a27/a27build/binaries/system/ ~/Downloads/
# This SH-script performs the following actions:
#
# Extracts the value of the mod_name variable from the mod.json file using the jq command-line tool.
# Removes the existing ${mod_name}_temp directory and creates a new one.
# Copies directories directly within the copy_dir_from directory to the ${mod_name}_temp directory.
# Copies non-hidden files from the copy_dir_from directory to the mod_temp directory, excluding specific files.
# Creates a zip file (${mod_name}_temp.zip) for the mod by compressing the contents of the ${mod_name}_temp directory.
# Creates a second temp directory (autocivP_temp2) and copies the mod.json file and the ${mod_name}_temp.zip file into it.
# Creates a zip file (${mod_name}.zip) for the mod by compressing the contents of the ${mod_name}_temp2 directory.
# Opens a web browser (Firefox) with a specific URL related to the mod.
# Note: The script assumes that the jq command-line tool is installed and its run inside your mod folder
# bit off-topic but impotand: debugging: https://trac.wildfiregames.com/wiki/Debugging , https://trac.wildfiregames.com/wiki/GameDataPaths
# cd ~/.config/0ad/logs/crashlog.txt
# kate ~/.config/0ad/logs/crashlog.txt
clear
# Extract the value of the mod_name variable from mod.json
mod_name=$(jq -r '.name' mod.json)
mod_version=$(jq -r '.version' mod.json)
ignoreChecks=$(jq -r '.ignoreInCompatibilityChecks' mod.json)
dir_mod="$PWD"
dir_mods="$PWD/.."
dir_temp="${dir_mods}/${mod_name}${mod_version}_igCoCheck${ignoreChecks}"
echo "41: dir_temp= $dir_temp"
dir_temp2="${dir_mods}/${mod_name}_temp2"
dir_temp_no_gamesetupmpJS="${dir_temp}_noMpJS"
# Clean the file path
dir_mod=$(realpath "$(readlink -f "$dir_mod")")
dir_mods=$(realpath "$(readlink -f "$dir_mods")")
echo "47: dir_temp= $dir_temp"
dir_temp=$(realpath "$(readlink -f "$dir_temp")")
dir_temp2=$(realpath "$(readlink -f "$dir_temp2")")
dir_temp_no_gamesetupmpJS=$(realpath "$(readlink -f "$dir_temp_no_gamesetupmpJS")")
echo "PWD= $PWD"
echo "dir_mod= $dir_mod"
echo "dir_mods= $dir_mods"
echo "53: dir_temp= $dir_temp"
echo "53: dir_temp2= $dir_temp2"
echo "mod_name=${mod_name}"
echo "mod_version=${mod_version}"
echo "ignoreChecks=${ignoreChecks}"
# clear
# exit
#!/bin/bash
# use this from inside your mod
# Remove existing autocivP_temp directory and create a new one
rm -rf $dir_temp
mkdir $dir_temp
rm -rf $dir_temp_no_gamesetupmpJS
mkdir $dir_temp_no_gamesetupmpJS
copy_dir_from="${dir_mod}" # Use absolute path of the source directory
echo "copy_dir_from= $copy_dir_from"
# Copy directories directly within $copy_dir_from
find $copy_dir_from/* -maxdepth 0 -type d -exec cp -r {} $dir_temp \;
# Copy non-hidden files, excluding tempList.text and tsconfig.json
find $copy_dir_from -maxdepth 1 -type f -not -name ".*" -not -name "tempList.text" -not -name "tsconfig.json" -not -name "error_unsolved.txt" -exec cp {} $dir_temp \;
# Display the directories within autocivP_temp
# find $dir_temp -type d
echo ${dir_mod}
echo ${dir_mods}
# Display the current working directory
pwd
# List the files and directories within autocivP_temp
# ls -l $dir_temp
# delete somme files from $dir_temp
rm $dir_temp/modBuildScript.*
rm -rf $dir_temp/*/__.*
rm -rf $dir_temp/*/Copy*.*
rm -rf $dir_temp/*/*.ahk
rm -rf $dir_temp/*/*.log
# Copy from $dir_temp to file ${dir_temp_no_gamesetupmpJS}
cp -r $dir_temp/* ${dir_temp_no_gamesetupmpJS}
# Remove this file then you could also save replays when you are host
rm -r $dir_temp_no_gamesetupmpJS/gui/gamesetup_mp/gamesetup_mp.js
# Count the number of files and folders in autocivP_temp (excluding the autocivP_temp directory itself)
num_files=$(find $dir_temp -type f | wc -l)
num_folders=$(find $dir_temp -type d | wc -l)
num_folders=$((num_folders - 1))
echo "Number of files in ${dir_temp}: $num_files"
echo "Number of folders in ${dir_temp}: $num_folders"
# Create a zip file for mod
# rm -rf ${dir_mods}/${mod_name}_temp.zip
rm -rf ${dir_mods}/${mod_name}.zip
rm -rf ${dir_mods}/${mod_name}_doubleZipedLikeMostModsWhenInUse.zip
cd ${dir_temp}
echo "zip -r ${dir_mods}/${mod_name}_temp.zip ."
zip -r ${dir_mods}/${mod_name}_temp.zip . # _readyForUploadToModIo.zip
# Create a zip file for mod without mpJS
rm -rf ${dir_temp_no_gamesetupmpJS}.zip
cd ${dir_temp_no_gamesetupmpJS}
echo "zip -r ${dir_temp_no_gamesetupmpJS}.zip ."
zip -r ${dir_temp_no_gamesetupmpJS}.zip .
exit
# _readyForUploadToModIo
# Create a second temp directory
rm -rf $dir_temp2
mkdir $dir_temp2
# Copy the mod.io file to the second temp directory
cp ${dir_mod}/mod.json $dir_temp2
# Copy the ${mod_name}_temp.zip
cp ${dir_mods}/${mod_name}_temp.zip $dir_temp2/${mod_name}.zip
cp ${dir_mods}/${mod_name}_temp.zip ${dir_mods}/${mod_name}.zip
sleep 1
cd ${pwd}
sleep 1
cd $dir_temp2
sleep 1
zip -r ${dir_mods}/${mod_name}_doubleZipedLikeMostModsWhenInUse.zip . # but not useful for upload in mod.io
# Sleep for 1 second before continuing
sleep 1
firefox https://mod.io/g/0ad/m/${mod_name}