aboutsummaryrefslogtreecommitdiff
path: root/desktop/package
diff options
context:
space:
mode:
authorMicah Lee <micah@micahflee.com>2022-03-30 08:29:16 -0700
committerMicah Lee <micah@micahflee.com>2022-03-30 08:29:16 -0700
commitc5e73076a4e73a3b254818fa413969c7dd457c32 (patch)
tree661c636c7b50140b78e4f76c9eaab81f7cd5fc76 /desktop/package
parent724e48053cdded29c18fc55ef85b4ffdb992a5cf (diff)
downloadonionshare-c5e73076a4e73a3b254818fa413969c7dd457c32.tar.gz
onionshare-c5e73076a4e73a3b254818fa413969c7dd457c32.zip
Add --ci-build to Windows build script, and do more to make the build in CircleCI
Diffstat (limited to 'desktop/package')
-rw-r--r--desktop/package/build-windows.py303
1 files changed, 163 insertions, 140 deletions
diff --git a/desktop/package/build-windows.py b/desktop/package/build-windows.py
index 9984dd4f..5ae36e19 100644
--- a/desktop/package/build-windows.py
+++ b/desktop/package/build-windows.py
@@ -4,6 +4,7 @@ import inspect
import subprocess
import shutil
import uuid
+import argparse
import xml.etree.ElementTree as ET
@@ -160,6 +161,18 @@ def wix_build_components_xml(root, data):
def main():
+ parser = argparse.ArgumentParser(
+ formatter_class=lambda prog: argparse.HelpFormatter(prog, max_help_position=48)
+ )
+ parser.add_argument(
+ "--ci-build",
+ action="store_true",
+ dest="ci_build",
+ help="Build in CI, don't code sign",
+ )
+ args = parser.parse_args()
+ ci_build = bool(args.ci_build)
+
desktop_dir = os.path.join(root, "desktop")
print("○ Clean up from last build")
@@ -426,161 +439,171 @@ def main():
freed_mb = int(freed_bytes / 1024 / 1024)
print(f"○ Freed {freed_mb} mb")
- print(f"○ Signing onionshare.exe")
- sign(os.path.join("build", "exe.win32-3.9", "onionshare.exe"), desktop_dir)
+ if ci_build:
+ print("Doing a CI build, skipping code signing and msi packaging")
- print(f"○ Signing onionshare-cli.exe")
- sign(os.path.join("build", "exe.win32-3.9", "onionshare-cli.exe"), desktop_dir)
+ else:
+ print(f"○ Signing onionshare.exe")
+ sign(os.path.join("build", "exe.win32-3.9", "onionshare.exe"), desktop_dir)
- print(f"○ Build the WiX file")
- version_filename = os.path.join(
- root, "cli", "onionshare_cli", "resources", "version.txt"
- )
- with open(version_filename) as f:
- version = f.read().strip()
-
- dist_dir = os.path.join(
- root,
- "desktop",
- "build",
- "exe.win32-3.9",
- )
+ print(f"○ Signing onionshare-cli.exe")
+ sign(os.path.join("build", "exe.win32-3.9", "onionshare-cli.exe"), desktop_dir)
- data = {
- "id": "TARGETDIR",
- "name": "SourceDir",
- "dirs": [
- {
- "id": "ProgramFilesFolder",
- "dirs": [],
- },
- {
- "id": "ProgramMenuFolder",
- "dirs": [],
- },
- ],
- }
+ print(f"○ Build the WiX file")
+ version_filename = os.path.join(
+ root, "cli", "onionshare_cli", "resources", "version.txt"
+ )
+ with open(version_filename) as f:
+ version = f.read().strip()
- data["dirs"][0]["dirs"].append(
- wix_build_data(
- dist_dir,
+ dist_dir = os.path.join(
+ root,
+ "desktop",
+ "build",
"exe.win32-3.9",
- "INSTALLDIR",
- "OnionShare",
)
- )
- root_el = ET.Element("Wix", xmlns="http://schemas.microsoft.com/wix/2006/wi")
- product_el = ET.SubElement(
- root_el,
- "Product",
- Name="OnionShare",
- Manufacturer="Micah Lee, et al.",
- Id="*",
- UpgradeCode="$(var.ProductUpgradeCode)",
- Language="1033",
- Codepage="1252",
- Version="$(var.ProductVersion)",
- )
- ET.SubElement(
- product_el,
- "Package",
- Id="*",
- Keywords="Installer",
- Description="OnionShare $(var.ProductVersion) Installer",
- Manufacturer="Micah Lee, et al.",
- InstallerVersion="100",
- Languages="1033",
- Compressed="yes",
- SummaryCodepage="1252",
- )
- ET.SubElement(product_el, "Media", Id="1", Cabinet="product.cab", EmbedCab="yes")
- ET.SubElement(
- product_el,
- "Icon",
- Id="ProductIcon",
- SourceFile="..\\onionshare\\resources\\onionshare.ico",
- )
- ET.SubElement(product_el, "Property", Id="ARPPRODUCTICON", Value="ProductIcon")
- ET.SubElement(
- product_el,
- "Property",
- Id="ARPHELPLINK",
- Value="https://docs.onionshare.org",
- )
- ET.SubElement(
- product_el,
- "Property",
- Id="ARPURLINFOABOUT",
- Value="https://onionshare.org",
- )
- ET.SubElement(product_el, "UIRef", Id="WixUI_Minimal")
- ET.SubElement(product_el, "UIRef", Id="WixUI_ErrorProgressText")
- ET.SubElement(
- product_el,
- "WixVariable",
- Id="WixUILicenseRtf",
- Value="..\\package\\license.rtf",
- )
- ET.SubElement(
- product_el,
- "WixVariable",
- Id="WixUIDialogBmp",
- Value="..\\package\\dialog.bmp",
- )
- ET.SubElement(
- product_el,
- "MajorUpgrade",
- AllowSameVersionUpgrades="yes",
- DowngradeErrorMessage="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.",
- )
+ data = {
+ "id": "TARGETDIR",
+ "name": "SourceDir",
+ "dirs": [
+ {
+ "id": "ProgramFilesFolder",
+ "dirs": [],
+ },
+ {
+ "id": "ProgramMenuFolder",
+ "dirs": [],
+ },
+ ],
+ }
+
+ data["dirs"][0]["dirs"].append(
+ wix_build_data(
+ dist_dir,
+ "exe.win32-3.9",
+ "INSTALLDIR",
+ "OnionShare",
+ )
+ )
- wix_build_dir_xml(product_el, data)
- component_ids = wix_build_components_xml(product_el, data)
+ root_el = ET.Element("Wix", xmlns="http://schemas.microsoft.com/wix/2006/wi")
+ product_el = ET.SubElement(
+ root_el,
+ "Product",
+ Name="OnionShare",
+ Manufacturer="Micah Lee, et al.",
+ Id="*",
+ UpgradeCode="$(var.ProductUpgradeCode)",
+ Language="1033",
+ Codepage="1252",
+ Version="$(var.ProductVersion)",
+ )
+ ET.SubElement(
+ product_el,
+ "Package",
+ Id="*",
+ Keywords="Installer",
+ Description="OnionShare $(var.ProductVersion) Installer",
+ Manufacturer="Micah Lee, et al.",
+ InstallerVersion="100",
+ Languages="1033",
+ Compressed="yes",
+ SummaryCodepage="1252",
+ )
+ ET.SubElement(
+ product_el, "Media", Id="1", Cabinet="product.cab", EmbedCab="yes"
+ )
+ ET.SubElement(
+ product_el,
+ "Icon",
+ Id="ProductIcon",
+ SourceFile="..\\onionshare\\resources\\onionshare.ico",
+ )
+ ET.SubElement(product_el, "Property", Id="ARPPRODUCTICON", Value="ProductIcon")
+ ET.SubElement(
+ product_el,
+ "Property",
+ Id="ARPHELPLINK",
+ Value="https://docs.onionshare.org",
+ )
+ ET.SubElement(
+ product_el,
+ "Property",
+ Id="ARPURLINFOABOUT",
+ Value="https://onionshare.org",
+ )
+ ET.SubElement(product_el, "UIRef", Id="WixUI_Minimal")
+ ET.SubElement(product_el, "UIRef", Id="WixUI_ErrorProgressText")
+ ET.SubElement(
+ product_el,
+ "WixVariable",
+ Id="WixUILicenseRtf",
+ Value="..\\package\\license.rtf",
+ )
+ ET.SubElement(
+ product_el,
+ "WixVariable",
+ Id="WixUIDialogBmp",
+ Value="..\\package\\dialog.bmp",
+ )
+ ET.SubElement(
+ product_el,
+ "MajorUpgrade",
+ AllowSameVersionUpgrades="yes",
+ DowngradeErrorMessage="A newer version of [ProductName] is already installed. If you are sure you want to downgrade, remove the existing installation via Programs and Features.",
+ )
- feature_el = ET.SubElement(product_el, "Feature", Id="DefaultFeature", Level="1")
- for component_id in component_ids:
- ET.SubElement(feature_el, "ComponentRef", Id=component_id)
- ET.SubElement(feature_el, "ComponentRef", Id="ApplicationShortcuts")
+ wix_build_dir_xml(product_el, data)
+ component_ids = wix_build_components_xml(product_el, data)
- with open(os.path.join(root, "desktop", "build", "OnionShare.wxs"), "w") as f:
- f.write('<?xml version="1.0" encoding="windows-1252"?>\n')
- f.write(f'<?define ProductVersion = "{version}"?>\n')
- f.write(
- '<?define ProductUpgradeCode = "12b9695c-965b-4be0-bc33-21274e809576"?>\n'
+ feature_el = ET.SubElement(
+ product_el, "Feature", Id="DefaultFeature", Level="1"
)
+ for component_id in component_ids:
+ ET.SubElement(feature_el, "ComponentRef", Id=component_id)
+ ET.SubElement(feature_el, "ComponentRef", Id="ApplicationShortcuts")
+
+ with open(os.path.join(root, "desktop", "build", "OnionShare.wxs"), "w") as f:
+ f.write('<?xml version="1.0" encoding="windows-1252"?>\n')
+ f.write(f'<?define ProductVersion = "{version}"?>\n')
+ f.write(
+ '<?define ProductUpgradeCode = "12b9695c-965b-4be0-bc33-21274e809576"?>\n'
+ )
- ET.indent(root_el)
- f.write(ET.tostring(root_el).decode())
+ ET.indent(root_el)
+ f.write(ET.tostring(root_el).decode())
- print(f"○ Build the MSI")
- run(
- [shutil.which("candle.exe"), "OnionShare.wxs"],
- os.path.join(desktop_dir, "build"),
- )
- run(
- [shutil.which("light.exe"), "-ext", "WixUIExtension", "OnionShare.wixobj"],
- os.path.join(desktop_dir, "build"),
- )
+ print(f"○ Build the MSI")
+ run(
+ [shutil.which("candle.exe"), "OnionShare.wxs"],
+ os.path.join(desktop_dir, "build"),
+ )
+ run(
+ [shutil.which("light.exe"), "-ext", "WixUIExtension", "OnionShare.wixobj"],
+ os.path.join(desktop_dir, "build"),
+ )
- print(f"○ Prepare OnionShare.msi for signing")
- run(
- [
- shutil.which("insignia.exe"),
- "-im",
+ print(f"○ Prepare OnionShare.msi for signing")
+ run(
+ [
+ shutil.which("insignia.exe"),
+ "-im",
+ os.path.join(desktop_dir, "build", "OnionShare.msi"),
+ ],
+ error_ok=True,
+ )
+ sign(os.path.join(desktop_dir, "build", "OnionShare.msi"))
+
+ final_msi_filename = os.path.join(
+ desktop_dir, "dist", f"OnionShare-{version}.msi"
+ )
+ print(f"○ Final MSI: {final_msi_filename}")
+ os.makedirs(os.path.join(desktop_dir, "dist"), exist_ok=True)
+ os.rename(
os.path.join(desktop_dir, "build", "OnionShare.msi"),
- ],
- error_ok=True,
- )
- sign(os.path.join(desktop_dir, "build", "OnionShare.msi"))
-
- final_msi_filename = os.path.join(desktop_dir, "dist", f"OnionShare-{version}.msi")
- print(f"○ Final MSI: {final_msi_filename}")
- os.makedirs(os.path.join(desktop_dir, "dist"), exist_ok=True)
- os.rename(
- os.path.join(desktop_dir, "build", "OnionShare.msi"),
- final_msi_filename,
- )
+ final_msi_filename,
+ )
if __name__ == "__main__":