diff options
-rw-r--r-- | .appveyor.yml | 28 | ||||
-rw-r--r-- | release/hooks/hook-cryptography.py | 3 | ||||
-rw-r--r-- | release/hooks/hook-pydivert.py | 2 | ||||
-rw-r--r-- | release/installbuilder/.gitignore | 2 | ||||
-rw-r--r-- | release/installbuilder/license.xml.enc | 1 | ||||
-rw-r--r-- | release/installbuilder/logo-installer-icon.png | bin | 0 -> 4506 bytes | |||
-rw-r--r-- | release/installbuilder/logo-installer.png | bin | 0 -> 39467 bytes | |||
-rw-r--r-- | release/installbuilder/logo.ico | bin | 0 -> 98065 bytes | |||
-rw-r--r-- | release/installbuilder/mitmproxy.xml | 135 | ||||
-rwxr-xr-x | release/rtool.py | 52 | ||||
-rw-r--r-- | release/setup.py | 1 | ||||
-rw-r--r-- | setup.cfg | 2 | ||||
-rw-r--r-- | tox.ini | 4 |
13 files changed, 216 insertions, 14 deletions
diff --git a/.appveyor.yml b/.appveyor.yml index 5cf194a9..b95b23e3 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -16,6 +16,8 @@ environment: secure: 6yBwmO5gv4vAwoFYII8qjQ== SNAPSHOT_PASS: secure: LPjrtFrWxYhOVGXzfPRV1GjtZE/wHoKq9m/PI6hSalfysUK5p2DxTG9uHlb4Q9qV + RTOOL_KEY: + secure: 0a+UUNbA+JjquyAbda4fd0JmiwL06AdG6torRPdCvbPDbKHnaW/BHHp1nRPytOKM install: - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" @@ -30,6 +32,29 @@ test_script: tox -e wheel tox -e rtool -- bdist + - ps: | + if( + ($Env:TOXENV -match "py35") -and + (($Env:APPVEYOR_REPO_BRANCH -In ("master", "pyinstaller")) -or ($Env:APPVEYOR_REPO_TAG -match "true")) + ) { + tox -e rtool -- decrypt release\installbuilder\license.xml.enc release\installbuilder\license.xml + if (!(Test-Path "C:\projects\mitmproxy\release\installbuilder-installer.exe")) { + "Download InstallBuilder..." + (New-Object System.Net.WebClient).DownloadFile( + "https://installbuilder.bitrock.com/installbuilder-enterprise-16.11.1-windows-installer.exe", + "C:\projects\mitmproxy\release\installbuilder-installer.exe" + ) + } + Start-Process "C:\projects\mitmproxy\release\installbuilder-installer.exe" "--mode unattended --unattendedmodeui none" -Wait + & 'C:\Program Files (x86)\BitRock InstallBuilder Enterprise 16.11.1\bin\builder-cli.exe' ` + build ` + .\release\installbuilder\mitmproxy.xml ` + windows ` + --license .\release\installbuilder\license.xml ` + --setvars project.version=$Env:VERSION ` + --verbose + } + deploy_script: # we build binaries on every run, but we only upload them for master snapshots or tags. ps: | @@ -37,10 +62,11 @@ deploy_script: ($Env:TOXENV -match "py35") -and (($Env:APPVEYOR_REPO_BRANCH -In ("master", "pyinstaller")) -or ($Env:APPVEYOR_REPO_TAG -match "true")) ) { - tox -e rtool -- upload-snapshot --bdist --wheel + tox -e rtool -- upload-snapshot --bdist --wheel --installer } cache: + - C:\projects\mitmproxy\release\installbuilder-installer.exe -> .appveyor.yml - C:\Users\appveyor\AppData\Local\pip\cache notifications: diff --git a/release/hooks/hook-cryptography.py b/release/hooks/hook-cryptography.py index d53a438b..5ecbd6cc 100644 --- a/release/hooks/hook-cryptography.py +++ b/release/hooks/hook-cryptography.py @@ -1,4 +1,5 @@ # Taken from the latest pyinstaller master on 2016-11-27 (0729a2b). +# flake8: noqa #----------------------------------------------------------------------------- # Copyright (c) 2005-2016, PyInstaller Development Team. @@ -40,4 +41,4 @@ cryptography_dir = os.path.dirname(get_module_file_attribute('cryptography')) for ext in EXTENSION_SUFFIXES: ffimods = glob.glob(os.path.join(cryptography_dir, '*_cffi_*%s*' % ext)) for f in ffimods: - binaries.append((f, 'cryptography'))
\ No newline at end of file + binaries.append((f, 'cryptography')) diff --git a/release/hooks/hook-pydivert.py b/release/hooks/hook-pydivert.py index 3fe8c552..72b7eb7d 100644 --- a/release/hooks/hook-pydivert.py +++ b/release/hooks/hook-pydivert.py @@ -1,3 +1,3 @@ from PyInstaller.utils.hooks import collect_data_files -datas = collect_data_files('pydivert.windivert_dll')
\ No newline at end of file +datas = collect_data_files('pydivert.windivert_dll') diff --git a/release/installbuilder/.gitignore b/release/installbuilder/.gitignore new file mode 100644 index 00000000..00c10a2d --- /dev/null +++ b/release/installbuilder/.gitignore @@ -0,0 +1,2 @@ +license.xml +*.xml.backup
\ No newline at end of file diff --git a/release/installbuilder/license.xml.enc b/release/installbuilder/license.xml.enc new file mode 100644 index 00000000..3df7210a --- /dev/null +++ b/release/installbuilder/license.xml.enc @@ -0,0 +1 @@ +gAAAAABYSXtgysddnqWL5sAreDTENJZdFkEf9p2nfMZTynY2hEep8vIDwR0P1glL40C04kLUv3piHkqyz0I893b-_YpnZC-W7qwfhChoFxnAQd0NY_d1mLsCHF1nQK0k907IbextZ3XHSCqSkS2nw0S41p9sEbzWLludSRRqJRn-AmxAKdm5s43kheNpP5iArWKtBrtubgytIDanulTfibdAPHaZedyx3JDww3hIUgo2shird7L4q2xQsE0bBDBgGrlndZ6lYGJDKf600LpOPSzSON6uXdPefhPD1bZP0GAFTNMAkm0K39e9J-j9Xz5ao7bEswfR6pcYO1uQC9VmxJYdLkuY9vYiltED6m5dW--NXVx0pudr_e5BXfpT5-RdUHaGM0Od6EZggeD5PNgUtWXxmXd6C0gFBZZEx_KobDXrCD9s8tmRJjb3ACBSCh2NdfFCCfOU3JRHeSgANTDYzY0pcJicoE5UcvP2dEICVvEORwbTumtfWbuDSbXwHqcynVjkJbwxHhRMMeJtjnx4dbb6_wdp2RjOUilTb2ob40OWyU0szgpSe2-5XS_F7ixL7vMf00OHFtTDk0Wg_dv15IR3C-zK8WFWEr4b4POc1P6pRrKOLKIFIKBGGZWF-S-u3gedAL2VLpFoUCG5FMnnJGv2iNfNYkG20zObn9K6FG5uNq6T0ZvfJIjJYNvXV45mx7jhOg2R5HAkZXlx16iIv95qlHIvJR6UZKHqWr_Hp3YvaxatkqbFwpXxQU0xtMJO3dXafATFMW_l
\ No newline at end of file diff --git a/release/installbuilder/logo-installer-icon.png b/release/installbuilder/logo-installer-icon.png Binary files differnew file mode 100644 index 00000000..c39541bb --- /dev/null +++ b/release/installbuilder/logo-installer-icon.png diff --git a/release/installbuilder/logo-installer.png b/release/installbuilder/logo-installer.png Binary files differnew file mode 100644 index 00000000..42de543d --- /dev/null +++ b/release/installbuilder/logo-installer.png diff --git a/release/installbuilder/logo.ico b/release/installbuilder/logo.ico Binary files differnew file mode 100644 index 00000000..8e08e8cc --- /dev/null +++ b/release/installbuilder/logo.ico diff --git a/release/installbuilder/mitmproxy.xml b/release/installbuilder/mitmproxy.xml new file mode 100644 index 00000000..e4ad00a3 --- /dev/null +++ b/release/installbuilder/mitmproxy.xml @@ -0,0 +1,135 @@ +<project>
+ <shortName>mitmproxy</shortName>
+ <fullName>mitmproxy</fullName>
+ <version>1.0</version>
+ <leftImage>logo-installer.png</leftImage>
+ <logoImage>logo-installer-icon.png</logoImage>
+ <componentList>
+ <component>
+ <name>default</name>
+ <description>Default Component</description>
+ <canBeEdited>1</canBeEdited>
+ <selected>1</selected>
+ <show>1</show>
+ <folderList>
+ <folder>
+ <description>Program Files</description>
+ <destination>${installdir}</destination>
+ <name>programfiles</name>
+ <platforms>all</platforms>
+ <distributionFileList>
+ <distributionFile>
+ <origin>logo.ico</origin>
+ </distributionFile>
+ </distributionFileList>
+ </folder>
+ <folder>
+ <description>Program Files/bin</description>
+ <destination>${installdir}/bin</destination>
+ <name>binaries</name>
+ <platforms>all</platforms>
+ <distributionFileList>
+ <distributionFile>
+ <allowWildcards>1</allowWildcards>
+ <excludeFiles>*/patho*</excludeFiles>
+ <origin>../build/binaries/${platform_name}/*</origin>
+ </distributionFile>
+ </distributionFileList>
+ </folder>
+ </folderList>
+ <postInstallationActionList>
+ <addDirectoryToPath>
+ <insertAt>end</insertAt>
+ <path>${installdir}/bin</path>
+ <scope>user</scope>
+ </addDirectoryToPath>
+ </postInstallationActionList>
+ <postUninstallationActionList>
+ <removeDirectoryFromPath>
+ <path>${installdir}/bin</path>
+ <scope>user</scope>
+ </removeDirectoryFromPath>
+ </postUninstallationActionList>
+ <startMenuShortcutList>
+ <startMenuShortcut>
+ <comment></comment>
+ <name>mitmproxy ui</name>
+ <runAsAdmin>0</runAsAdmin>
+ <runInTerminal>0</runInTerminal>
+ <windowsExec>${installdir}\bin\mitmweb.exe</windowsExec>
+ <windowsExecArgs></windowsExecArgs>
+ <windowsIcon>${installdir}/logo.ico</windowsIcon>
+ <windowsPath>${installdir}</windowsPath>
+ </startMenuShortcut>
+ <startMenuShortcut>
+ <comment></comment>
+ <name>mitmdump</name>
+ <runAsAdmin>0</runAsAdmin>
+ <runInTerminal>0</runInTerminal>
+ <windowsExec>${installdir}\bin\mitmdump.exe</windowsExec>
+ <windowsExecArgs></windowsExecArgs>
+ <windowsIcon>${installdir}/logo.ico</windowsIcon>
+ <windowsPath>${installdir}</windowsPath>
+ </startMenuShortcut>
+ </startMenuShortcutList>
+ </component>
+ </componentList>
+ <createOsxBundleDmg>1</createOsxBundleDmg>
+ <disableSplashScreen>1</disableSplashScreen>
+ <enableRollback>1</enableRollback>
+ <enableTimestamp>1</enableTimestamp>
+ <outputDirectory>../dist</outputDirectory>
+ <productDisplayIcon>logo.ico</productDisplayIcon>
+ <saveRelativePaths>1</saveRelativePaths>
+ <vendor>mitmproxy.org</vendor>
+ <windowsExecutableIcon>logo.ico</windowsExecutableIcon>
+ <finalPageActionList>
+ <runProgram>
+ <program>cmd</program>
+ <programArguments>/c start "mitmproxy ui" "${installdir}\bin\mitmweb.exe" &</programArguments>
+ <progressText>Launch mitmproxy ui now</progressText>
+ <ruleList>
+ <platformTest>
+ <type>windows</type>
+ </platformTest>
+ </ruleList>
+ </runProgram>
+ <runProgram>
+ <program>${installdir}/mitmproxy</program>
+ <programArguments>&</programArguments>
+ <progressText>Launch mitmproxy now</progressText>
+ <ruleList>
+ <platformTest>
+ <negate>1</negate>
+ <type>windows</type>
+ </platformTest>
+ </ruleList>
+ </runProgram>
+ </finalPageActionList>
+ <parameterList>
+ <directoryParameter>
+ <name>installdir</name>
+ <description>Installer.Parameter.installdir.description</description>
+ <explanation>Installer.Parameter.installdir.explanation</explanation>
+ <value></value>
+ <default>${platform_install_prefix}/${product_shortname}</default>
+ <allowEmptyValue>0</allowEmptyValue>
+ <ask>yes</ask>
+ <cliOptionName>prefix</cliOptionName>
+ <mustBeWritable>yes</mustBeWritable>
+ <mustExist>0</mustExist>
+ <width>40</width>
+ <postShowPageActionList>
+ <!-- This will skip the readytoinstall page -->
+ <setInstallerVariable name="next_page" value="installation"/>
+ </postShowPageActionList>
+ <preShowPageActionList>
+ <setInstallerVariable>
+ <name>ui.button(next).text</name>
+ <value>${msg(Installer.Button.Install)}</value>
+ </setInstallerVariable>
+ </preShowPageActionList>
+ </directoryParameter>
+ </parameterList>
+</project>
+
diff --git a/release/rtool.py b/release/rtool.py index 4a6d1e16..59899510 100755 --- a/release/rtool.py +++ b/release/rtool.py @@ -13,6 +13,7 @@ import zipfile from os.path import join, abspath, dirname, exists, basename import click +import cryptography.fernet import pysftp # https://virtualenv.pypa.io/en/latest/userguide.html#windows-notes @@ -37,6 +38,12 @@ else: def Archive(name): return tarfile.open(name, "w:gz") +PLATFORM_TAG = { + "Darwin": "osx", + "Windows": "windows", + "Linux": "linux", +}.get(platform.system(), platform.system()) + ROOT_DIR = abspath(join(dirname(__file__), "..")) RELEASE_DIR = join(ROOT_DIR, "release") @@ -47,7 +54,7 @@ PYINSTALLER_SPEC = join(RELEASE_DIR, "specs") # PyInstaller 3.2 does not bundle pydivert's Windivert binaries PYINSTALLER_HOOKS = join(RELEASE_DIR, "hooks") PYINSTALLER_TEMP = join(BUILD_DIR, "pyinstaller") -PYINSTALLER_DIST = join(BUILD_DIR, "binaries") +PYINSTALLER_DIST = join(BUILD_DIR, "binaries", PLATFORM_TAG) VENV_DIR = join(BUILD_DIR, "venv") @@ -91,11 +98,6 @@ def get_snapshot_version() -> str: def archive_name(bdist: str) -> str: - platform_tag = { - "Darwin": "osx", - "Windows": "win32", - "Linux": "linux" - }.get(platform.system(), platform.system()) if platform.system() == "Windows": ext = "zip" else: @@ -103,7 +105,7 @@ def archive_name(bdist: str) -> str: return "{project}-{version}-{platform}.{ext}".format( project=bdist, version=get_version(), - platform=platform_tag, + platform=PLATFORM_TAG, ext=ext ) @@ -114,6 +116,19 @@ def wheel_name() -> str: ) +def installer_name() -> str: + ext = { + "Windows": "exe", + "Darwin": "dmg", + "Linux": "run" + }[platform.system()] + return "mitmproxy-{version}-{platform}-installer.{ext}".format( + version=get_version(), + platform=PLATFORM_TAG, + ext=ext, + ) + + @contextlib.contextmanager def chdir(path: str): old_dir = os.getcwd() @@ -130,6 +145,24 @@ def cli(): pass +@cli.command("encrypt") +@click.argument('infile', type=click.File('rb')) +@click.argument('outfile', type=click.File('wb')) +@click.argument('key', envvar='RTOOL_KEY') +def encrypt(infile, outfile, key): + f = cryptography.fernet.Fernet(key.encode()) + outfile.write(f.encrypt(infile.read())) + + +@cli.command("decrypt") +@click.argument('infile', type=click.File('rb')) +@click.argument('outfile', type=click.File('wb')) +@click.argument('key', envvar='RTOOL_KEY') +def decrypt(infile, outfile, key): + f = cryptography.fernet.Fernet(key.encode()) + outfile.write(f.decrypt(infile.read())) + + @cli.command("contributors") def contributors(): """ @@ -238,7 +271,8 @@ def upload_release(username, password, repository): @click.option("--private-key-password", envvar="SNAPSHOT_PASS", prompt=True, hide_input=True) @click.option("--wheel/--no-wheel", default=False) @click.option("--bdist/--no-bdist", default=False) -def upload_snapshot(host, port, user, private_key, private_key_password, wheel, bdist): +@click.option("--installer/--no-installer", default=False) +def upload_snapshot(host, port, user, private_key, private_key_password, wheel, bdist, installer): """ Upload snapshot to snapshot server """ @@ -256,6 +290,8 @@ def upload_snapshot(host, port, user, private_key, private_key_password, wheel, if bdist: for bdist in sorted(BDISTS.keys()): files.append(archive_name(bdist)) + if installer: + files.append(installer_name()) for f in files: local_path = join(DIST_DIR, f) diff --git a/release/setup.py b/release/setup.py index 1d60e46c..01d0672d 100644 --- a/release/setup.py +++ b/release/setup.py @@ -8,6 +8,7 @@ setup( "click>=6.2, <7.0", "twine>=1.6.5, <1.9", "pysftp==0.2.8", + "cryptography>=1.6, <1.7", ], entry_points={ "console_scripts": [ @@ -2,7 +2,7 @@ max-line-length = 140 max-complexity = 25 ignore = E251,C901,W503 -exclude = mitmproxy/contrib/*,test/mitmproxy/data/* +exclude = mitmproxy/contrib/*,test/mitmproxy/data/*,release/build/* addons = file,open,basestring,xrange,unicode,long,cmp [tool:pytest] @@ -8,7 +8,7 @@ basepython = python3.5 deps = {env:CI_DEPS:} -rrequirements.txt -passenv = CODECOV_TOKEN CI CI_* TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* SNAPSHOT_* OPENSSL_* +passenv = CODECOV_TOKEN CI CI_* TRAVIS TRAVIS_* APPVEYOR APPVEYOR_* SNAPSHOT_* OPENSSL_* RTOOL_* setenv = HOME = {envtmpdir} commands = mitmdump --sysinfo @@ -22,7 +22,7 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html [testenv:lint] commands = mitmdump --sysinfo - flake8 --jobs 8 --count mitmproxy pathod examples test + flake8 --jobs 8 --count mitmproxy pathod examples test release rstcheck README.rst mypy --silent-imports \ mitmproxy/addons \ |