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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
|
#!/bin/bash
if [ ! -f "$1" ]
then
echo "Please supply the path to an existing zip binary as the first argument"
exit 1
fi
while true
do
DOCKER_RESULT=$(docker ps)
if [ "$?" != "0" ]
then
echo "It appears the Docker daemon is not running, make sure you started it"
read -p "Press [Enter] key to AFTER you started Docker"
continue
fi
break
done
GITHUB_TOKEN_FILE="${HOME}/.config/github-api-token"
GPG_KEYFILE="${HOME}/.config/signkeys/Duplicati/updater-gpgkey.key"
AUTHENTICODE_PFXFILE="${HOME}/.config/signkeys/Duplicati/authenticode.pfx"
AUTHENTICODE_PASSWORD="${HOME}/.config/signkeys/Duplicati/authenticode.key"
MONO=/Library/Frameworks/Mono.framework/Commands/mono
GPG=/usr/local/bin/gpg2
# Newer GPG needs this to allow input from a non-terminal
export GPG_TTY=$(tty)
ZIPFILE=$(basename "$1")
VERSION=$(echo "${ZIPFILE}" | cut -d "-" -f 2 | cut -d "_" -f 1)
BUILDTYPE=$(echo "${ZIPFILE}" | cut -d "-" -f 2 | cut -d "_" -f 2)
BUILDTAG_RAW=$(echo "${ZIPFILE}" | cut -d "." -f 1-4 | cut -d "-" -f 2-4)
BUILDTAG="${BUILDTAG_RAW//-}"
RPMNAME="duplicati-${VERSION}-${BUILDTAG}.noarch.rpm"
DEBNAME="duplicati_${VERSION}-1_all.deb"
MSI64NAME="duplicati-${BUILDTAG_RAW}-x64.msi"
MSI32NAME="duplicati-${BUILDTAG_RAW}-x86.msi"
DMGNAME="duplicati-${BUILDTAG_RAW}.dmg"
PKGNAME="duplicati-${BUILDTAG_RAW}.pkg"
SPKNAME="duplicati-${BUILDTAG_RAW}.spk"
SIGNAME="duplicati-${BUILDTAG_RAW}-signatures.zip"
UPDATE_TARGET="Updates/build/${BUILDTYPE}_target-${VERSION}"
echo "Filename: ${ZIPFILE}"
echo "Version: ${VERSION}"
echo "Buildtype: ${BUILDTYPE}"
echo "Buildtag: ${BUILDTAG}"
echo "RPMName: ${RPMNAME}"
echo "DEBName: ${DEBNAME}"
echo "SPKName: ${SPKNAME}"
build_file_signatures() {
if [ -f "${GPG_KEYFILE}" ]; then
"${MONO}" "BuildTools/GnupgSigningTool/bin/Debug/GnupgSigningTool.exe" \
--inputfile=\"$1\" \
--signaturefile=\"$2.sig\" \
--armor=false --gpgkeyfile="${GPG_KEYFILE}" --gpgpath="${GPG}" \
--keyfile-password="${KEYFILE_PASSWORD}"
"${MONO}" "BuildTools/GnupgSigningTool/bin/Debug/GnupgSigningTool.exe" \
--inputfile=\"$1\" \
--signaturefile=\"$2.sig.asc\" \
--armor=true --gpgkeyfile="${GPG_KEYFILE}" --gpgpath="${GPG}" \
--keyfile-password="${KEYFILE_PASSWORD}"
fi
md5 "$1" | awk -F ' ' '{print $NF}' > "$2.md5"
shasum -a 1 "$1" | awk -F ' ' '{print $1}' > "$2.sha1"
shasum -a 256 "$1" | awk -F ' ' '{print $1}' > "$2.sha256"
}
if [ -f "${GPG_KEYFILE}" ]; then
if [ "z${KEYFILE_PASSWORD}" == "z" ]; then
echo -n "Enter keyfile password: "
read -s KEYFILE_PASSWORD
echo
fi
GPGDATA=$("${MONO}" "BuildTools/AutoUpdateBuilder/bin/Debug/SharpAESCrypt.exe" d "${KEYFILE_PASSWORD}" "${GPG_KEYFILE}")
if [ ! $? -eq 0 ]; then
echo "Decrypting GPG keyfile failed"
exit 1
fi
GPGID=$(echo "${GPGDATA}" | head -n 1)
GPGKEY=$(echo "${GPGDATA}" | head -n 2 | tail -n 1)
else
echo "No GPG keyfile found, skipping gpg signatures"
fi
# Pre-boot virtual machine
echo "Booting Win10 build instance"
VBoxHeadless --startvm Duplicati-Win10-Build &
# Then do the local build to mask the waiting a little more
echo ""
echo ""
echo "Building OSX package locally ..."
echo ""
echo "Enter local sudo password..."
cd "Installer/OSX"
bash "make-dmg.sh" "../../$1"
mv "Duplicati.dmg" "../../${UPDATE_TARGET}/${DMGNAME}"
mv "Duplicati.pkg" "../../${UPDATE_TARGET}/${PKGNAME}"
cd "../.."
echo ""
echo ""
echo "Building Synology package locally ..."
cd Installer/Synology
bash "make-binary-package.sh" "../../$1"
mv "${SPKNAME}" "../../${UPDATE_TARGET}/"
cd ../..
echo ""
echo ""
echo "Building Debian deb with Docker ..."
cd "Installer/debian"
bash "docker-build-binary.sh" "../../$1"
cd "../.."
mv "Installer/debian/${DEBNAME}" "${UPDATE_TARGET}"
echo "Done building deb package"
echo ""
echo ""
echo "Building Fedora RPM with Docker ..."
cd "Installer/fedora"
bash "docker-build-binary.sh" "../../$1"
cd "../.."
mv "Installer/fedora/${RPMNAME}" "${UPDATE_TARGET}"
echo "Done building rpm package"
echo ""
echo ""
echo "Building Docker images ..."
cd Installer/Docker
bash build-images.sh ../../$1
cd ../..
echo "Done building Docker images"
echo ""
echo ""
echo "Building Windows instance in virtual machine"
while true
do
ssh -o ConnectTimeout=5 IEUser@192.168.56.101 "dir"
if [ $? -eq 255 ]; then
echo "Windows Build machine is not responding, try restarting it"
read -p "Press [Enter] key to try again"
continue
fi
break
done
cat > "tmp-windows-commands.bat" <<EOF
SET VS120COMNTOOLS=%VS140COMNTOOLS%
cd \\Duplicati\\Installer\\Windows
build-msi.bat "../../$1"
EOF
ssh IEUser@192.168.56.101 "\\Duplicati\\tmp-windows-commands.bat"
ssh IEUser@192.168.56.101 "shutdown /s /t 0"
rm "tmp-windows-commands.bat"
mv "./Installer/Windows/Duplicati.msi" "${UPDATE_TARGET}/${MSI64NAME}"
mv "./Installer/Windows/Duplicati-32bit.msi" "${UPDATE_TARGET}/${MSI32NAME}"
if [ -f "${AUTHENTICODE_PFXFILE}" ] && [ -f "${AUTHENTICODE_PASSWORD}" ]; then
echo "Performing authenticode signing of installers"
if [ "z${KEYFILE_PASSWORD}" == "z" ]; then
echo -n "Enter keyfile password: "
read -s KEYFILE_PASSWORD
echo
fi
authenticode_sign() {
NEST=""
for hashalg in sha1 sha256; do
SIGN_MSG=$(osslsigncode sign -pkcs12 "${AUTHENTICODE_PFXFILE}" -pass "${PFX_PASS}" -n "Duplicati" -i "http://www.duplicati.com" -h "${hashalg}" ${NEST} -t "http://timestamp.verisign.com/scripts/timstamp.dll" -in "$1" -out tmpfile)
if [ "${SIGN_MSG}" != "Succeeded" ]; then echo "${SIGN_MSG}"; fi
mv tmpfile "$1"
NEST="-nest"
done
}
PFX_PASS=$("${MONO}" "BuildTools/AutoUpdateBuilder/bin/Debug/SharpAESCrypt.exe" d "${KEYFILE_PASSWORD}" "${AUTHENTICODE_PASSWORD}")
DECRYPT_STATUS=$?
if [ "${DECRYPT_STATUS}" -ne 0 ]; then
echo "Failed to decrypt, SharpAESCrypt gave status ${DECRYPT_STATUS}, exiting"
exit 4
fi
if [ "x${PFX_PASS}" == "x" ]; then
echo "Failed to decrypt, SharpAESCrypt gave empty password, exiting"
exit 4
fi
authenticode_sign "${UPDATE_TARGET}/${MSI64NAME}"
authenticode_sign "${UPDATE_TARGET}/${MSI32NAME}"
else
echo "Skipped authenticode signing as files are missing"
fi
echo ""
echo ""
echo "Performing macOS notarization ..."
# Notarize and staple, cannot run in parallel but takes a while
bash Installer/OSX/notarize-and-staple.sh "${UPDATE_TARGET}/${DMGNAME}"
bash Installer/OSX/notarize-and-staple.sh "${UPDATE_TARGET}/${PKGNAME}"
echo ""
echo ""
echo "Done building, uploading installers ..."
if [ -d "./tmp" ]; then
rm -rf "./tmp"
fi
mkdir "./tmp"
echo "{" > "./tmp/latest-installers.json"
process_installer() {
if [ "$2" != "zip" ]; then
aws --profile=duplicati-upload s3 cp "${UPDATE_TARGET}/$1" "s3://updates.duplicati.com/${BUILDTYPE}/$1"
fi
local MD5=$(md5 ${UPDATE_TARGET}/$1 | awk -F ' ' '{print $NF}')
local SHA1=$(shasum -a 1 ${UPDATE_TARGET}/$1 | awk -F ' ' '{print $1}')
local SHA256=$(shasum -a 256 ${UPDATE_TARGET}/$1 | awk -F ' ' '{print $1}')
cat >> "./tmp/latest-installers.json" <<EOF
"$2": {
"name": "$1",
"url": "https://updates.duplicati.com/${BUILDTYPE}/$1",
"md5": "${MD5}",
"sha1": "${SHA1}",
"sha256": "${SHA256}"
},
EOF
}
process_installer "${ZIPFILE}" "zip"
process_installer "${SPKNAME}" "spk"
process_installer "${RPMNAME}" "rpm"
process_installer "${DEBNAME}" "deb"
process_installer "${DMGNAME}" "dmg"
process_installer "${PKGNAME}" "pkg"
process_installer "${MSI32NAME}" "msi86"
process_installer "${MSI64NAME}" "msi64"
cat >> "./tmp/latest-installers.json" <<EOF
"version": "${VERSION}"
}
EOF
echo "duplicati_installers =" > "./tmp/latest-installers.js"
cat "./tmp/latest-installers.json" >> "./tmp/latest-installers.js"
echo ";" >> "./tmp/latest-installers.js"
aws --profile=duplicati-upload s3 cp "./tmp/latest-installers.json" "s3://updates.duplicati.com/${BUILDTYPE}/latest-installers.json"
aws --profile=duplicati-upload s3 cp "./tmp/latest-installers.js" "s3://updates.duplicati.com/${BUILDTYPE}/latest-installers.js"
if [ -d "./tmp" ]; then
rm -rf "./tmp"
fi
SIG_FOLDER="duplicati-${BUILDTAG_RAW}-signatures"
mkdir tmp
mkdir "./tmp/${SIG_FOLDER}"
for FILE in "${SPKNAME}" "${RPMNAME}" "${DEBNAME}" "${DMGNAME}" "${PKGNAME}" "${MSI32NAME}" "${MSI64NAME}" "${ZIPFILE}"; do
build_file_signatures "${UPDATE_TARGET}/${FILE}" "./tmp/${SIG_FOLDER}/${FILE}"
done
if [ "z${GPGID}" != "z" ]; then
echo "${GPGID}" > "./tmp/${SIG_FOLDER}/sign-key.txt"
echo "https://pgp.mit.edu/pks/lookup?op=get&search=${GPGID}" >> "./tmp/${SIG_FOLDER}/sign-key.txt"
fi
if [ -f "${UPDATE_TARGET}/${SIGNAME}" ]; then
rm "${UPDATE_TARGET}/${SIGNAME}"
fi
cd tmp
zip -r9 "./${SIGNAME}" "./${SIG_FOLDER}/"
cd ..
mv "./tmp/${SIGNAME}" "${UPDATE_TARGET}/${SIGNAME}"
rm -rf "./tmp/${SIG_FOLDER}"
aws --profile=duplicati-upload s3 cp "${UPDATE_TARGET}/${SIGNAME}" "s3://updates.duplicati.com/${BUILDTYPE}/${SIGNAME}"
GITHUB_TOKEN=$(cat "${GITHUB_TOKEN_FILE}")
if [ "x${GITHUB_TOKEN}" == "x" ]; then
echo "No GITHUB_TOKEN found in environment, you can manually upload the binaries"
else
for FILE in "${SPKNAME}" "${RPMNAME}" "${DEBNAME}" "${DMGNAME}" "${PKGNAME}" "${MSI32NAME}" "${MSI64NAME}" "${SIGNAME}"; do
github-release upload \
--tag "v${VERSION}-${BUILDTAG_RAW}" \
--name "${FILE}" \
--repo "duplicati" \
--user "duplicati" \
--security-token "${GITHUB_TOKEN}" \
--file "${UPDATE_TARGET}/${FILE}"
done
fi
rm -rf "./tmp"
if [ -f ~/.config/duplicati-mirror-sync.sh ]; then
bash ~/.config/duplicati-mirror-sync.sh
else
echo "Skipping CDN update"
fi
VBoxManage controlvm "Duplicati-Win10-Build" poweroff
|