Skip to content

Commit 9b927b7

Browse files
illwieckzslipher
authored andcommitted
make-unizip: extend unvanquished_0.zip with macos-amd64.zip
Make possible to run make-unizip again and again to add missing parts to existing release zip, for example to extend the unvanquished_0.zip produced by the docker file and shipping Linux and Windows build with the macOS engine build produced separately. Also do not add useless symbols/ folder in symbols_0.zip: - we don't need it, - it makes easier to extend existing unvanquished_0.zip as we can reuse the code extracting symbols from engine and vm builds that do not have symbols/ folder, - it produces smaller symbols_0.zip.
1 parent 80c8e7b commit 9b927b7

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

make-unizip

+30-10
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,20 @@ fi
3636
release_dir="$(sed -E 's!/+!/!g; s!(.)/$!\1!' <<< "$1")" # 7z chokes on extra slashes
3737
version='0' # TODO
3838
work_dir="${release_dir}/unizip_staging"
39-
content_dir="${work_dir}/unvanquished_${version}"
39+
40+
release_basename="unvanquished_${version}"
41+
release_zip="${release_basename}.zip"
42+
symbols_basename="symbols_${version}"
43+
symbols_zip="symbols_${version}.zip"
44+
45+
content_dir="${work_dir}/${release_basename}"
4046

4147
extractSymbols () {
4248
local archive="$1"
43-
if symbol_archive=$(7z l "${archive}" | grep -oE 'symbol.*7z')
49+
if symbol_archive=$(7z l "${archive}" | grep -oE 'symbols.*\.7z|unvanquished_.*/symbols_.*\.zip')
4450
then
4551
echo "extracting ${symbol_archive}"
52+
mkdir -p "${work_dir}/symbols"
4653
7z x -o"${work_dir}" "${archive}" "${symbol_archive}" >/dev/null
4754
7z x -o"${work_dir}/symbols" "${work_dir}/${symbol_archive}" >/dev/null
4855
echo "deleting ${symbol_archive} from ${archive}"
@@ -54,9 +61,21 @@ if [ -d "${work_dir}" ]
5461
then
5562
rm -rv "${work_dir}"
5663
fi
64+
5765
mkdir -v "${work_dir}"
5866
mkdir -v "${content_dir}"
5967

68+
# If there is already a supposedly incomplete release zip, for example
69+
# an unvanquished_0.zip containing linux-amd64.zip, windows-i386.zip
70+
# and windows-amd64.zip, and a lone macos-amd64.zip build next to it,
71+
# extend unvanquished_0.zip with macos-amd64.zip.
72+
if [ -f "${release_dir}/${release_zip}" ]
73+
then
74+
extractSymbols "${release_dir}/${release_zip}"
75+
76+
7z x -o"${work_dir}" "${release_dir}/${release_zip}" >/dev/null
77+
fi
78+
6079
if cp --preserve=timestamps "$0" "${work_dir}/timestamp-test"
6180
then
6281
alias cp='cp --preserve=timestamps'
@@ -65,25 +84,26 @@ fi
6584
cp -v "$(dirname $0)/unizip-readme.txt" "${content_dir}/README.txt"
6685

6786
# Prepare pkg/
68-
mkdir -v "${content_dir}/pkg"
69-
for dpk in $(find "${release_dir}" -name '*.dpk')
87+
mkdir -pv "${content_dir}/pkg"
88+
for dpk in $(find "${release_dir}" ! -path "${work_dir}/*" -name '*.dpk')
7089
do
7190
dest="${content_dir}/pkg/$(basename "${dpk}")"
7291
cp -v "${dpk}" "${dest}"
7392
extractSymbols "${dest}"
7493
done
94+
7595
(
7696
cd "${content_dir}/pkg"
77-
if ls * >/dev/null
97+
if ls *.dpk >/dev/null 2>&1
7898
then
79-
md5sum --binary -- * > md5sums
99+
md5sum --binary -- *.dpk > md5sums
80100
else
81101
touch md5sums
82102
fi
83103
)
84104

85105
# Prepare <os>-<arch>.zip
86-
for os_zip in $(find "${release_dir}" -name '*.zip' | grep -E '/(windows|macos|linux)-[^/]*$')
106+
for os_zip in $(find "${release_dir}" ! -path "${work_dir}/*" -name '*.zip' | grep -E '/(windows|macos|linux)-[^/]*$')
87107
do
88108
dest="${content_dir}/$(basename "${os_zip}")"
89109
cp -v "${os_zip}" "${dest}"
@@ -92,8 +112,8 @@ done
92112

93113
# Compress symbols
94114
(
95-
cd "${work_dir}"
96-
7z a -tzip -mx=9 "unvanquished_${version}/symbols_${version}.zip" symbols
115+
cd "${work_dir}/symbols"
116+
7z a -tzip -mx=9 "../${release_basename}/symbols_${version}.zip" .
97117
)
98118

99119
# Create (partial) universal zip
@@ -104,7 +124,7 @@ done
104124
rm -v "../unvanquished_${version}.zip"
105125
fi
106126
# Even though almost all the contents are compressed already, it still saves some...
107-
7z a -tzip -mx=9 "../unvanquished_${version}.zip" "unvanquished_${version}"
127+
7z a -tzip -mx=9 "../${release_zip}" "${release_basename}"
108128
)
109129

110130
rm -rv "${work_dir}"

0 commit comments

Comments
 (0)