|
1 | 1 | ### |
2 | | -#This file is a part of the NVDA project. |
3 | | -#URL: https://www.nvaccess.org/ |
4 | | -#Copyright 2018-2019 NV Access Limited |
5 | | -#This program is free software: you can redistribute it and/or modify |
6 | | -#it under the terms of the GNU General Public License version 2.0, as published by |
7 | | -#the Free Software Foundation. |
8 | | -#This program is distributed in the hope that it will be useful, |
9 | | -#but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | | -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11 | | -#This license can be found at: |
12 | | -#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
| 2 | +# This file is a part of the NVDA project. |
| 3 | +# URL: https://www.nvaccess.org/ |
| 4 | +# Copyright 2018-2019 NV Access Limited |
| 5 | +# This program is free software: you can redistribute it and/or modify |
| 6 | +# it under the terms of the GNU General Public License version 2.0, as published by |
| 7 | +# the Free Software Foundation. |
| 8 | +# This program is distributed in the hope that it will be useful, |
| 9 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 11 | +# This license can be found at: |
| 12 | +# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
13 | 13 | ### |
14 | 14 |
|
15 | 15 | import subprocess |
16 | 16 | import versionInfo |
17 | 17 | import os |
18 | 18 |
|
19 | | -Import([ |
20 | | - 'env', |
21 | | - 'outFilePrefix', |
22 | | - 'isStoreSubmission', |
23 | | -]) |
| 19 | +Import( |
| 20 | + [ |
| 21 | + "env", |
| 22 | + "outFilePrefix", |
| 23 | + "isStoreSubmission", |
| 24 | + ] |
| 25 | +) |
| 26 | + |
24 | 27 |
|
25 | 28 | def getCertPublisher(env): |
26 | 29 | """ |
27 | 30 | If no signing certificate is provided, then the given publisher is used as is. |
28 | 31 | If a signing certificate is given, then the publisher is extracted from the certificate. |
29 | 32 | """ |
30 | | - certFilePath = env.get('certFile') |
| 33 | + certFilePath = env.get("certFile") |
31 | 34 | if not certFilePath: |
32 | | - return env['publisher'] |
33 | | - certPassword=env.get('certPassword','') |
| 35 | + return env["publisher"] |
| 36 | + certPassword = env.get("certPassword", "") |
34 | 37 | if not os.path.isabs(certFilePath): |
35 | 38 | # If path is not absolute it is assumed that it is being given relative to the top dir of the repo |
36 | | - repoTopDir = Dir('#').abspath |
| 39 | + repoTopDir = Dir("#").abspath |
37 | 40 | certFilePath = os.path.abspath(os.path.normpath(os.path.join(repoTopDir, certFilePath))) |
38 | | - cmd=['certutil', '-dump', '-p', certPassword, certFilePath] |
39 | | - lines=subprocess.run(cmd,check=True,capture_output=True,text=True).stdout.splitlines() |
40 | | - linePrefix='Subject: ' |
| 41 | + cmd = ["certutil", "-dump", "-p", certPassword, certFilePath] |
| 42 | + lines = subprocess.run(cmd, check=True, capture_output=True, text=True).stdout.splitlines() |
| 43 | + linePrefix = "Subject: " |
41 | 44 | for line in lines: |
42 | 45 | if line.startswith(linePrefix): |
43 | | - subject=line[len(linePrefix):].rstrip() |
| 46 | + subject = line[len(linePrefix) :].rstrip() |
44 | 47 | return subject |
45 | 48 |
|
46 | | -packageName="NVAccessLimited.NVDANonVisualDesktopAccess" |
47 | | -packageVersion="%s.%s.%s.%s"%(versionInfo.version_year,versionInfo.version_major,env['version_build'],0) |
| 49 | + |
| 50 | +packageName = "NVAccessLimited.NVDANonVisualDesktopAccess" |
| 51 | +packageVersion = "%s.%s.%s.%s" % ( |
| 52 | + versionInfo.version_year, |
| 53 | + versionInfo.version_major, |
| 54 | + env["version_build"], |
| 55 | + 0, |
| 56 | +) |
48 | 57 | if isStoreSubmission: |
49 | | - packageFileName=outFilePrefix+"_storeSubmission.appx" |
| 58 | + packageFileName = outFilePrefix + "_storeSubmission.appx" |
50 | 59 | # NV Access Limited's Windows Store publisher ID |
51 | 60 | # It is okay to be here as the only way to submit, validate and sign the package is via the NV Access store account. |
52 | | - packagePublisher="CN=83B1DA31-9B66-442C-88AB-77B4B815E1DE" |
53 | | - packagePublisherDisplayName="NV Access Limited" |
54 | | - productName="NVDA Screen Reader (Windows Store Edition)" |
55 | | -else: # not for submission, just side-loadable |
56 | | - packageFileName=outFilePrefix+"_sideLoadable.appx" |
57 | | - packagePublisher=getCertPublisher(env) |
58 | | - packagePublisherDisplayName=env['publisher'] |
59 | | - productName="NVDA Screen Reader (Windows Desktop Bridge Edition)" |
| 61 | + packagePublisher = "CN=83B1DA31-9B66-442C-88AB-77B4B815E1DE" |
| 62 | + packagePublisherDisplayName = "NV Access Limited" |
| 63 | + productName = "NVDA Screen Reader (Windows Store Edition)" |
| 64 | +else: # not for submission, just side-loadable |
| 65 | + packageFileName = outFilePrefix + "_sideLoadable.appx" |
| 66 | + packagePublisher = getCertPublisher(env) |
| 67 | + packagePublisherDisplayName = env["publisher"] |
| 68 | + productName = "NVDA Screen Reader (Windows Desktop Bridge Edition)" |
60 | 69 |
|
61 | | -signExec = env['signExec'] if (bool(env['certFile']) ^ bool(env['apiSigningToken'])) else None |
| 70 | +signExec = env["signExec"] if (bool(env["certFile"]) ^ bool(env["apiSigningToken"])) else None |
62 | 71 |
|
63 | 72 |
|
64 | 73 | # Files from NVDA's distribution that cannot be included in the appx due to policy or security restrictions |
65 | 74 | excludedDistFiles = [ |
66 | | - 'nvda_slave.exe', |
67 | | - 'nvda_noUIAccess.exe', |
68 | | - 'lib/IAccessible2Proxy.dll', |
69 | | - 'lib/ISimpleDOM.dll', |
70 | | - 'lib/NVDAHelperRemote.dll', |
71 | | - 'lib64/', |
72 | | - 'libArm64/', |
73 | | - 'uninstall.exe', |
| 75 | + "nvda_slave.exe", |
| 76 | + "nvda_noUIAccess.exe", |
| 77 | + "lib/IAccessible2Proxy.dll", |
| 78 | + "lib/ISimpleDOM.dll", |
| 79 | + "lib/NVDAHelperRemote.dll", |
| 80 | + "lib64/", |
| 81 | + "libArm64/", |
| 82 | + "uninstall.exe", |
74 | 83 | ] |
75 | 84 |
|
76 | | -# Create an appx manifest with version and publisher etc all filled in |
77 | | -manifest=env.Substfile( |
| 85 | +# Create an appx manifest with version and publisher etc all filled in |
| 86 | +manifest = env.Substfile( |
78 | 87 | "AppxManifest.xml", |
79 | | - 'manifest.xml.subst', |
| 88 | + "manifest.xml.subst", |
80 | 89 | SUBST_DICT={ |
81 | | - '%packageName%':packageName, |
82 | | - '%packageVersion%':packageVersion, |
83 | | - '%packagePublisher%':packagePublisher, |
84 | | - '%publisher%':packagePublisherDisplayName, |
85 | | - '%productName%':productName, |
86 | | - '%description%':versionInfo.description, |
| 90 | + "%packageName%": packageName, |
| 91 | + "%packageVersion%": packageVersion, |
| 92 | + "%packagePublisher%": packagePublisher, |
| 93 | + "%publisher%": packagePublisherDisplayName, |
| 94 | + "%productName%": productName, |
| 95 | + "%description%": versionInfo.description, |
87 | 96 | }, |
88 | 97 | ) |
89 | | -# Make a copy of the dist dir produced by py2exe |
| 98 | +# Make a copy of the dist dir produced by py2exe |
90 | 99 | # And also place some extra appx specific images in there |
91 | | -appxContent=env.Command( |
92 | | - target='content', |
93 | | - source=[Dir("#dist"),Dir('#appx/appx_images'),manifest], |
| 100 | +appxContent = env.Command( |
| 101 | + target="content", |
| 102 | + source=[Dir("#dist"), Dir("#appx/appx_images"), manifest], |
94 | 103 | action=[ |
95 | 104 | Delete("$TARGET"), |
96 | | - Copy("$TARGET","${SOURCES[0]}"), |
97 | | - Copy("${TARGET}\\appx_images","${SOURCES[1]}"), |
98 | | - Copy("${TARGET}\\AppxManifest.xml","${SOURCES[2]}"), |
99 | | - ]+[Delete("${TARGET}/%s"%excludeFile) for excludeFile in excludedDistFiles], |
| 105 | + Copy("$TARGET", "${SOURCES[0]}"), |
| 106 | + Copy("${TARGET}\\appx_images", "${SOURCES[1]}"), |
| 107 | + Copy("${TARGET}\\AppxManifest.xml", "${SOURCES[2]}"), |
| 108 | + ] |
| 109 | + + [Delete("${TARGET}/%s" % excludeFile) for excludeFile in excludedDistFiles], |
100 | 110 | ) |
101 | | -# Ensure that it is always copied as we can't tell if dist changed |
| 111 | +# Ensure that it is always copied as we can't tell if dist changed |
102 | 112 | env.AlwaysBuild(appxContent) |
103 | 113 | # Package the appx |
104 | | -appx=env.Command(packageFileName,appxContent,"makeappx pack /p $TARGET /d $SOURCE") |
| 114 | +appx = env.Command(packageFileName, appxContent, "makeappx pack /p $TARGET /d $SOURCE") |
105 | 115 | if signExec and not isStoreSubmission: |
106 | | - env.AddPostAction(appx,signExec) |
| 116 | + env.AddPostAction(appx, signExec) |
107 | 117 |
|
108 | | -Return(['appx']) |
| 118 | +Return(["appx"]) |
0 commit comments