From 0722a4b558027c040d8f554e8bfb7ac8265994cd Mon Sep 17 00:00:00 2001 From: Jerome Flesch Date: Thu, 24 Aug 2017 20:24:01 +0200 Subject: [PATCH 1/2] paperwork installer generator : take into account that on a same GitHub release, there can be many win32 releases Signed-off-by: Jerome Flesch --- nsis/gen_installer_nsi.py | 40 ++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/nsis/gen_installer_nsi.py b/nsis/gen_installer_nsi.py index 74a622b8..7233125a 100755 --- a/nsis/gen_installer_nsi.py +++ b/nsis/gen_installer_nsi.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- +import re import sys from paperwork_backend.util import find_language @@ -8,6 +9,7 @@ ALL_LANGUAGES = [ "eng", # English (always first) + "afr", "sqi", # Albanian "amh", @@ -105,8 +107,8 @@ "vie", "cym", # Welsh "yid", -] - + ] + UNKNOWN_LANGUAGE = { 'download_section': """ Section /o "{long}" SEC_{upper} @@ -178,7 +180,8 @@ }, } -VERSION = """!define PRODUCT_VERSION "{version}\"""" +VERSION = """!define PRODUCT_VERSION "{version}\" +!define PRODUCT_SHORT_VERSION "{short_version}\"""" HEADER = """ !define PRODUCT_NAME "Paperwork" @@ -243,7 +246,7 @@ SetOutPath "$INSTDIR" SetOverwrite on - inetc::get "https://github.com/openpaperwork/paperwork/releases/download/${PRODUCT_VERSION}/paperwork_${PRODUCT_VERSION}_win64.zip" "$PLUGINSDIR\\paperwork.zip" /END + inetc::get "https://github.com/openpaperwork/paperwork/releases/download/${PRODUCT_SHORT_VERSION}/paperwork_${PRODUCT_VERSION}_win64.zip" "$PLUGINSDIR\\paperwork.zip" /END Pop $0 StrCmp $0 "OK" +3 MessageBox MB_OK "Download failed" @@ -266,7 +269,7 @@ ; CreateShortCut "$DESKTOP.lnk" "$INSTDIR\\paperwork.exe" ; CreateShortCut "$STARTMENU.lnk" "$INSTDIR\\paperwork.exe" - + SetOutPath "$INSTDIR\\Tesseract" CreateDirectory "$INSTDIR\\Tesseract" nsisunz::UnzipToLog "$PLUGINSDIR\\tesseract.zip" "$INSTDIR" @@ -392,7 +395,7 @@ def get_lang_infos(lang_name): suffix = "" if len(lang) <= 1 else lang[1] lang = find_language(lang_name) - + if not suffix: long_name = lang.name else: @@ -406,16 +409,17 @@ def get_lang_infos(lang_name): def main(args): - if (len(args) < 3): - print ("Syntax:") - print ("\t{} ".format(args[0])) + if (len(args) < 2): + print ("ARGS: {} ".format(args[0])) return version = args[1] - output_file = args[2] + + m = re.match("([\d\.]+)", version) # match everything but the suffix + short_version = m.string[m.start():m.end()] - with open(output_file, "w") as out_fd: - out_fd.write(VERSION.format(version=version)) + with open("out.nsi", "w") as out_fd: + out_fd.write(VERSION.format(version=version, short_version=short_version)) out_fd.write(HEADER) @@ -431,12 +435,12 @@ def main(args): txt = txt.format(**get_lang_infos(lang_name)) out_fd.write(txt) out_fd.write(""" -SectionGroupEnd +SectionGroupEnd """) - + out_fd.write(MIDDLE) - + for lang_name in ALL_LANGUAGES: print ("Adding strings section {}".format(lang_name)) lang = UNKNOWN_LANGUAGE @@ -445,7 +449,7 @@ def main(args): txt = lang['lang_strings'] txt = txt.format(**get_lang_infos(lang_name)) out_fd.write(txt) - + out_fd.write(""" !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${SEC_PAPERWORK} $(DESC_SEC_PAPERWORK) @@ -463,7 +467,5 @@ def main(args): out_fd.write(FOOTER) - print ("{} generated".format(output_file)) - if __name__ == "__main__": - main(sys.argv) + main(sys.argv) \ No newline at end of file From 63a36ed2719693baa8c7287e3c28b76b0d32c85a Mon Sep 17 00:00:00 2001 From: Jerome Flesch Date: Thu, 24 Aug 2017 20:34:35 +0200 Subject: [PATCH 2/2] paperwork windows installer generator: make it possible to specify the exact download URI Signed-off-by: Jerome Flesch --- nsis/gen_installer_nsi.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/nsis/gen_installer_nsi.py b/nsis/gen_installer_nsi.py index 7233125a..09691984 100755 --- a/nsis/gen_installer_nsi.py +++ b/nsis/gen_installer_nsi.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # -*- coding: utf-8 -*- import re @@ -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) @@ -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" @@ -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" @@ -410,16 +413,22 @@ def get_lang_infos(lang_name): def main(args): if (len(args) < 2): - print ("ARGS: {} ".format(args[0])) + print ("ARGS: {} []".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) @@ -466,6 +475,7 @@ def main(args): """) out_fd.write(FOOTER) + print ("out.nsi written") if __name__ == "__main__": main(sys.argv) \ No newline at end of file