Skip to content
This repository has been archived by the owner on Dec 18, 2019. It is now read-only.

Commit

Permalink
paperwork windows installer generator: make it possible to specify th…
Browse files Browse the repository at this point in the history
…e exact download URI

Signed-off-by: Jerome Flesch <[email protected]>
  • Loading branch information
jflesch committed Aug 24, 2017
1 parent 0722a4b commit 63a36ed
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions nsis/gen_installer_nsi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
Expand All @@ -7,6 +7,8 @@
from paperwork_backend.util import find_language


DOWNLOAD_URI = "https://github.com/openpaperwork/paperwork/releases/download/${PRODUCT_SHORT_VERSION}/paperwork_${PRODUCT_VERSION}_win64.zip"

ALL_LANGUAGES = [
"eng", # English (always first)

Expand Down Expand Up @@ -189,6 +191,7 @@
!define PRODUCT_WEB_SITE "https://openpaper.work"
!define PRODUCT_UNINST_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\${PRODUCT_NAME}"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define PRODUCT_DOWNLOAD_URI "{download_uri}"
!addplugindir ".\dll"
Expand Down Expand Up @@ -246,7 +249,7 @@
SetOutPath "$INSTDIR"
SetOverwrite on
inetc::get "https://github.com/openpaperwork/paperwork/releases/download/${PRODUCT_SHORT_VERSION}/paperwork_${PRODUCT_VERSION}_win64.zip" "$PLUGINSDIR\\paperwork.zip" /END
inetc::get "${PRODUCT_DOWNLOAD_URI}" "$PLUGINSDIR\\paperwork.zip" /END
Pop $0
StrCmp $0 "OK" +3
MessageBox MB_OK "Download failed"
Expand Down Expand Up @@ -410,16 +413,22 @@ def get_lang_infos(lang_name):

def main(args):
if (len(args) < 2):
print ("ARGS: {} <version>".format(args[0]))
print ("ARGS: {} <version> [<download URI>]".format(args[0]))
return

version = args[1]
download_uri = DOWNLOAD_URI

m = re.match("([\d\.]+)", version) # match everything but the suffix
short_version = m.string[m.start():m.end()]
if len(args) == 3:
version = short_version = args[1]
download_uri = args[2]
else:
version = args[1]
m = re.match("([\d\.]+)", version) # match everything but the suffix
short_version = m.string[m.start():m.end()]
download_uri = DOWNLOAD_URI

with open("out.nsi", "w") as out_fd:
out_fd.write(VERSION.format(version=version, short_version=short_version))
out_fd.write(VERSION.format(version=version, short_version=short_version, download_uri=download_uri))
out_fd.write(HEADER)


Expand Down Expand Up @@ -466,6 +475,7 @@ def main(args):
""")

out_fd.write(FOOTER)
print ("out.nsi written")

if __name__ == "__main__":
main(sys.argv)

0 comments on commit 63a36ed

Please sign in to comment.