def main(args): parser = argparse.ArgumentParser( description='Generate a .dmg package for macOS.', prog=args[0]) parser.add_argument( 'output', help='The destination .dmg file', ) parser.add_argument( 'build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) args = parser.parse_args(args[1:]) with temp_install(args.build_dir) as install_path: (install_path / 'Applications').symlink_to('/Applications') command = shlex.split( 'genisoimage -V Taisei -D -R -apple -no-pad -o') + [ args.output, str(install_path), ] subprocess.check_call(command, cwd=str(install_path)) print('\nPackage generated:', args.output)
def main(args): parser = argparse.ArgumentParser( description='Generate an ZIP distribution.', prog=args[0]) parser.add_argument( 'build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) parser.add_argument( 'output', help='The output file path', type=Path, ) add_common_args(parser) args = parser.parse_args(args[1:]) with temp_install(args.build_dir) as install_dir, ZipFile( str(args.output), "w", ZIP_DEFLATED) as zfile: for path in install_dir.glob('**/*'): if not path.is_dir(): rel = str(path.relative_to(install_dir)) print("Adding file {}".format(rel)) zfile.write(str(path), rel) print("Generated package {}".format(str(args.output)))
def main(args): parser = argparse.ArgumentParser(description='Generate a .dmg package for macOS.', prog=args[0]) parser.add_argument('output', help='The destination .dmg file', ) parser.add_argument('build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) args = parser.parse_args(args[1:]) with temp_install(args.build_dir) as install_path: (install_path / 'Applications').symlink_to('/Applications') command = shlex.split('genisoimage -V Taisei -D -R -apple -no-pad -o') + [ args.output, str(install_path), ] subprocess.check_call(command, cwd=str(install_path)) print('\nPackage generated:', args.output)
def main(args): parser = argparse.ArgumentParser( description='Generate a .dmg package for macOS.', prog=args[0]) parser.add_argument( 'output', help='The destination .dmg file', ) parser.add_argument( 'build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) parser.add_argument( 'installation', help= 'Specify a pre-built directory instead of making a new one from the build directory (i.e: in the case of a universal image)', type=Path, nargs='?', ) args = parser.parse_args(args[1:]) if args.installation is None: with temp_install(args.build_dir) as install_path: package_dmg(install_path, args.output) else: package_dmg(args.installation, args.output)
def main(args): parser = argparse.ArgumentParser(description='Generate an NSIS installer for Windows.', prog=args[0]) parser.add_argument('build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) parser.add_argument('script_template', help='The NSIS script template', type=Path, ) add_configure_args(parser) add_common_args(parser) args = parser.parse_args(args[1:]) args.variables = dict(args.variables) with args.script_template.open('r') as infile: template = infile.read() with temp_install(args.build_dir) as install_dir: glob = tuple(install_dir.glob('**/*')) files = sorted((PureWindowsPath(p.relative_to(install_dir)) for p in glob if not p.is_dir()), reverse=True) dirs = sorted((PureWindowsPath(p.relative_to(install_dir)) for p in glob if p.is_dir()), reverse=True) indent = ' ' * 4 instdir = '$INSTDIR' uninstall_files = ('\n'+indent).join('Delete "{}\\{}"'.format(instdir, path) for path in files) uninstall_dirs = ('\n'+indent).join('RMDir "{}\\{}"'.format(instdir, path) for path in dirs) uninstall_commands = indent + ('\n\n'+indent).join((uninstall_files, uninstall_dirs)) print(uninstall_commands) args.variables.update({ 'INSTALL_DIR': str(install_dir), 'UNINSTALL_COMMANDS': uninstall_commands, 'INSTALL_OPTIONS_INI': str(Path(args.rootdir) / 'scripts' / 'NSIS.InstallOptions.ini') }) script = configure(template, args.variables, prefix='@', suffix='@', args=args ) nsis_cmd = shlex.split('makensis -V3 -NOCD -INPUTCHARSET UTF8 -WX -') with subprocess.Popen(nsis_cmd, stdin=subprocess.PIPE, cwd=str(args.build_dir)) as proc: proc.stdin.write(script.encode('utf-8')) if proc.returncode != 0: raise MakeNSISError(proc.returncode)
def main(args): import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger(__name__) parser = argparse.ArgumentParser(description='Generate a distribution archive.', prog=args[0]) parser.add_argument('build_dir', help='the build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) parser.add_argument('output', help='the output file path', type=Path, ) parser.add_argument('--format', help='the archive format', default='zip', choices=sorted(map(lambda x: x[0], shutil.get_archive_formats())), ) parser.add_argument('--prefix', help='add a common prefix to all files and directories in the archive', default=None, ) add_common_args(parser) args = parser.parse_args(args[1:]) if args.prefix is not None: p = PurePosixPath(args.prefix) if p.is_absolute() or p.is_reserved() or '..' in p.parts: raise ValueError('Bad prefix: {}'.format(args.prefix)) args.prefix = str(p) if args.prefix == '.': args.prefix = None with temp_install(args.build_dir) as install_dir: if args.prefix is not None: os.chdir(str(install_dir.parent)) install_dir.rename(install_dir.parent / args.prefix) archive = shutil.make_archive(str(args.output), args.format, '.', str(args.prefix)) else: archive = shutil.make_archive(str(args.output), args.format, str(install_dir)) archive = Path(archive) archive.rename(args.output) print("Generated distribution archive {}".format(str(args.output)))
def main(args): parser = argparse.ArgumentParser( description='Generate an NSIS installer for Windows.', prog=args[0]) parser.add_argument( 'build_dir', help='The build directory (defaults to CWD)', default=Path(os.getcwd()), type=Path, nargs='?', ) parser.add_argument( 'script_template', help='The NSIS script template', type=Path, ) add_configure_args(parser) add_common_args(parser) args = parser.parse_args(args[1:]) args.variables = dict(args.variables) with args.script_template.open('r') as infile: template = infile.read() with temp_install(args.build_dir) as install_dir: glob = tuple(install_dir.glob('**/*')) files = sorted((PureWindowsPath(p.relative_to(install_dir)) for p in glob if not p.is_dir()), reverse=True) dirs = sorted((PureWindowsPath(p.relative_to(install_dir)) for p in glob if p.is_dir()), reverse=True) indent = ' ' * 4 instdir = '$INSTDIR' uninstall_files = ('\n' + indent).join( 'Delete "{}\\{}"'.format(instdir, path) for path in files) uninstall_dirs = ('\n' + indent).join( 'RMDir "{}\\{}"'.format(instdir, path) for path in dirs) uninstall_commands = ('\n\n' + indent).join( (uninstall_files, uninstall_dirs)) print(uninstall_commands) args.variables.update({ 'INSTALL_DIR': str(install_dir), 'UNINSTALL_COMMANDS': uninstall_commands, 'INSTALL_OPTIONS_INI': str(Path(args.rootdir) / 'scripts' / 'NSIS.InstallOptions.ini') }) script = configure(template, args.variables, prefix='@', suffix='@', args=args) nsis_cmd = shlex.split('makensis -V4 -NOCD -INPUTCHARSET UTF8 -WX -') with subprocess.Popen(nsis_cmd, stdin=subprocess.PIPE, cwd=str(args.build_dir)) as proc: proc.stdin.write(script.encode('utf-8')) if proc.returncode != 0: raise MakeNSISError(proc.returncode)