From 00504dd80af90fddfd731ce687f5ab28406f89b1 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 16 Sep 2013 13:27:48 +0100 Subject: [PATCH] Closes issue #47. Creates zip, not 7zip archives because I can't get pylzma working (I think I broke my python install...). Not a big problem though. --- README.md | 4 +++ src/archive.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100755 src/archive.py diff --git a/README.md b/README.md index fbe6ed9b..26ffedc9 100644 --- a/README.md +++ b/README.md @@ -154,3 +154,7 @@ make The `masterlist-converter.exe` expects a v2 masterlist named `masterlist.txt` to be present in the same directory as it, and produces a v3 masterlist named `masterlist.txt.yaml`. The converter is a command line utility and will print any errors in encounters to the console. It also won't create a v3 masterlist file if errors are encountered. + +## Packaging Releases + +Installer and zip archive releases for the main BOSS application can be handled by running the scripts `installer.nsi` and `archive.py` in the `src` folder respectively. The installer script requires [NSIS Unicode](http://www.scratchpaper.com/) to be installed, while the archive script requires [Python](http://www.python.org/) to be installed. diff --git a/src/archive.py b/src/archive.py new file mode 100755 index 00000000..177f6500 --- /dev/null +++ b/src/archive.py @@ -0,0 +1,66 @@ +#! /usr/bin/env python +# -*- coding: utf-8 -*- + +# Creates an archive of a BOSS release, putting it in the 'build' folder. + +# Files and folders that need to go in (relative to repository root): +# +# build/BOSS.exe +# resources/graphvis +# resources/svgweb +# resources/svn +# resources/icon.ico +# resources/polyfill.js +# resources/script.js +# resources/style.css +# docs/images +# docs/licenses +# docs/BOSS Metadata Syntax.html +# docs/BOSS Readme.html + +import sys +import os +import shutil +import zipfile + +temp_path = os.path.join('..', 'build', 'archive.tmp') +archive_name = 'archive.zip' + +# Set archive name if alternative is given. +if (len(sys.argv) > 1): + archive_name = sys.argv[1] + +# First make sure that the temporary folder for the archive exists. +if not os.path.exists(temp_path): + os.makedirs(temp_path) + + +# Now copy everything into the temporary folder. +shutil.copy( os.path.join('..', 'build', 'BOSS.exe'), temp_path ) + +shutil.copytree( os.path.join('..', 'resources', 'graphvis'), os.path.join(temp_path, 'resources', 'graphvis') ) +shutil.copytree( os.path.join('..', 'resources', 'svgweb'), os.path.join(temp_path, 'resources', 'svgweb') ) +shutil.copytree( os.path.join('..', 'resources', 'svn'), os.path.join(temp_path, 'resources', 'svn') ) +shutil.copy( os.path.join('..', 'resources', 'icon.ico'), os.path.join(temp_path, 'resources') ) +shutil.copy( os.path.join('..', 'resources', 'polyfill.js'), os.path.join(temp_path, 'resources') ) +shutil.copy( os.path.join('..', 'resources', 'script.js'), os.path.join(temp_path, 'resources') ) +shutil.copy( os.path.join('..', 'resources', 'style.css'), os.path.join(temp_path, 'resources') ) + +shutil.copytree( os.path.join('..', 'docs', 'images'), os.path.join(temp_path, 'docs', 'images') ) +shutil.copytree( os.path.join('..', 'docs', 'licenses'), os.path.join(temp_path, 'docs', 'licenses') ) +shutil.copy( os.path.join('..', 'docs', 'BOSS Metadata Syntax.html'), os.path.join(temp_path, 'docs') ) +shutil.copy( os.path.join('..', 'docs', 'BOSS Readme.html'), os.path.join(temp_path, 'docs') ) + + +# Now compress the temporary folder. (Creating a zip because I can't get pylzma to work...) +os.chdir(temp_path) +zip = zipfile.ZipFile( os.path.join('..', archive_name), 'w', zipfile.ZIP_DEFLATED ) +for root, dirs, files in os.walk('.'): + for file in files: + zip.write(os.path.join(root, file)) +zip.close() +os.chdir('..') + + +# And finally, delete the temporary folder. +shutil.rmtree('archive.tmp')