diff --git a/.gitignore b/.gitignore index f058830..a48972e 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ _data/ __pycache__ *.egg-info bin -dist \ No newline at end of file +dist +build +releases \ No newline at end of file diff --git a/README.md b/README.md index 52d06d7..0879dff 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ The restore operation works in reverse: reads the QR codes from a single or a se - Backing up seed files from crypto wallets +## Installation + +Download and extract one of the releases or download the python source code and execute. + + ## Basic Usage Using `--sha256` prints the hash of the input (on backup) or output (on restore) file. diff --git a/pyinstaller-hooks/hook-zbarlight.py b/pyinstaller-hooks/hook-zbarlight.py new file mode 100644 index 0000000..3dc32cb --- /dev/null +++ b/pyinstaller-hooks/hook-zbarlight.py @@ -0,0 +1,3 @@ +from PyInstaller.utils.hooks import copy_metadata, collect_data_files + +datas = copy_metadata('zbarlight') diff --git a/pypaperbak.spec b/pypaperbak.spec new file mode 100644 index 0000000..738db3e --- /dev/null +++ b/pypaperbak.spec @@ -0,0 +1,33 @@ +# -*- mode: python -*- + +block_cipher = None + + +a = Analysis(['pypaperbak/__main__.py'], + pathex=['/home/user/projetos/pypaperbak'], + binaries=[], + datas=[('README.md', '.'), ('LICENSE.md', '.'), ('samples', 'samples')], + hiddenimports=['png'], + hookspath=['pyinstaller-hooks'], + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher) +pyz = PYZ(a.pure, a.zipped_data, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + exclude_binaries=True, + name='pypaperbak', + debug=False, + strip=False, + upx=True, + console=True ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + strip=False, + upx=True, + name='pypaperbak') diff --git a/pypaperbak/app.py b/pypaperbak/app.py index cc5f2f9..f008fe1 100644 --- a/pypaperbak/app.py +++ b/pypaperbak/app.py @@ -109,7 +109,7 @@ def run_backup(self, args): infile_size = os.path.getsize(infile.name) outfile = args.outfile - inputhash = hashlib.sha256() if args.sha256 else None + inputhash = hashlib.sha256() framedata = self.frame_data_func(args) qr_count = infile_size / chunksize + 1 @@ -124,7 +124,7 @@ def run_backup(self, args): bindata = infile.read(chunksize) if not bindata: break frame = framedata(bindata, qr_count, sizesofar) - if inputhash is not None: inputhash.update(bindata) + inputhash.update(bindata) sizesofar += len(bindata) qr_number += 1 @@ -136,7 +136,7 @@ def run_backup(self, args): exporter.finish(inputhash) self.logger.info('Finished exporting') - if inputhash is not None: + if args.sha256: print('SHA-256 of input: %s' % inputhash.hexdigest()) def run_restore(self, args): diff --git a/setup.py b/setup.py index 771100b..f503c40 100644 --- a/setup.py +++ b/setup.py @@ -39,7 +39,8 @@ 'pyqrcode', 'zbarlight', 'fpdf', - 'python-magic' + 'python-magic', + 'pypng' ], classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/util/gen-release.py b/util/gen-release.py new file mode 100755 index 0000000..203c180 --- /dev/null +++ b/util/gen-release.py @@ -0,0 +1,14 @@ +#!/bin/env python + +import os +import shutil + +exec(open('pypaperbak/_version.py').read()) + +shutil.rmtree('build', True) +shutil.rmtree('dist', True) +os.makedirs('releases', exist_ok=True) + + +os.system('pyinstaller pypaperbak.spec') +os.system('tar -C dist -cjf releases/pypaperbak-%s-linux-x64.tar.bz2 pypaperbak' % __version__)