コード例 #1
0
def make_deb(dest_dir):
    '''Make a '.deb' package

    :param dest_dir: path to the directory that contains the 'release'
                     directory with the programme's files and where to
                     put the package at
    '''

    print("Making '.deb' package...")

    dest_dir = pathlib.Path(dest_dir)
    release_dir = dest_dir / 'release'
    if not release_dir.exists():
        raise RuntimeError('Package cannot be made if app is not built yet')

    pkg_name = f'{md.NAME.lower()}_{md.VERSION}-1_{architecture()}'
    pkg_dir = dest_dir / pkg_name
    if pkg_dir.exists():
        shutil.rmtree(pkg_dir)
    pkg_dir.mkdir()

    pkg_exe, installed_exe_dir = _copy_exe(release_dir, pkg_dir)
    _copy_licenses(release_dir, pkg_dir)
    _copy_icon(release_dir, pkg_dir)
    _generate_desktop_file(pkg_dir, installed_exe_dir)
    generate_control(pkg_dir, pkg_exe)

    make_pkg_cmd = f'fakeroot dpkg-deb --build {pkg_name}'
    # If dpkg-deb is fresh enough, use the command below
    #make_pkg_cmd = f'dpkg-deb --build --root-owner-group {pkg_name}'
    utils.run(make_pkg_cmd, cwd=dest_dir)

    shutil.rmtree(pkg_dir)

    print('Done.')
コード例 #2
0
def make_zst(dest_dir):
    '''Make a '.zst' package

    :param dest_dir: path to the directory that contains the 'release'
                     directory with the programme's files and where to
                     put the package at
    '''

    print("Making '.zst' package...")

    dest_dir = pathlib.Path(dest_dir)
    release_dir = dest_dir / 'release'
    if not release_dir.exists():
        raise RuntimeError('Package cannot be made if app is not built yet')

    exe_name = md.NAME.lower()
    version = md.VERSION
    pkg_name = f'{exe_name}-{version}'
    pkg_dir = dest_dir / pkg_name
    if pkg_dir.exists():
        shutil.rmtree(pkg_dir)

    shutil.copytree(release_dir, pkg_dir)
    bundle.generate_desktop(release_dir, '/usr/bin', '', True)
    generate_PKGBUILD(pkg_dir)

    utils.run('makepkg', cwd=pkg_dir)

    zst_file_name = f'{exe_name}-{version}-1-x86_64.pkg.tar.xz'
    shutil.copy(pkg_dir / zst_file_name, dest_dir / zst_file_name)

    shutil.rmtree(pkg_dir)

    print('Done.')
コード例 #3
0
def check_package(pkg_dir):
    '''Run the 'lintian' command to check the package for sanity

    :param pkg_dir: directory containing the built package
    '''

    print('Checking the package...')

    pkg_name = f'{md.NAME.lower()}_{md.VERSION}-1_{architecture()}.deb'
    cmd = f'lintian {pkg_name}'
    utils.run(cmd, cwd=pkg_dir)

    print('Done.')
コード例 #4
0
def check_package(pkg_dir):
    '''Run the 'namcap' command to check the package for sanity

    :param pkg_dir: directory containing the built package
    '''

    print('Checking the package...')

    pkg_name = f'{md.NAME.lower()}-{md.VERSION}-1-x86_64.pkg.tar.xz'
    cmd = f'namcap {pkg_name}'
    utils.run(cmd, cwd=pkg_dir)

    print('Done.')
コード例 #5
0
def source(setup_file):
    '''Make "Source Distribution"

    :param setup_file: path to the 'setup.py' file,
    :raise ImportWarning: 'setuptools' is not installed
    '''

    print('Source Distribution...')

    _check_package_installed('setuptools')

    cmd = f'python {setup_file} sdist'
    utils.run(cmd)
コード例 #6
0
def run(cmd, src_dir, cwd=None):
    '''Run a command in the shell

    :param cmd: command to run,
    :param src_dir: folder with Qt5 source (to set environment variables in
                    Windows),
    :param cwd: set the current working directory (optional, default - None)
    '''

    if not utils.is_linux():
        set_vars_cmd = set_vars_msvc_cmd(src_dir)
        cmd = f'{set_vars_cmd} && {cmd}'

    utils.run(cmd, cwd=cwd)
コード例 #7
0
def wheel(setup_file):
    '''Make "Pure Python Wheel"

    :param setup_file: path to the 'setup.py' file,
    :raise ImportWarning: 'setuptools' or/and 'wheel' are not installed
    '''

    print('Pure Python Wheel...')

    _check_package_installed('setuptools')
    _check_package_installed('wheel')

    cmd = f'python {setup_file} bdist_wheel'
    utils.run(cmd)
コード例 #8
0
ファイル: msi.py プロジェクト: oratosquilla-oratoria/myfyrio
def make_msi(dest_dir, wix_dir):
    '''Make a '.msi' package (installer)

    :param dest_dir: path to the directory that contains the 'release'
                     directory with the programme's files and where to
                     put the package at,
    :param wix_dir: path to the 'Wix#' directory
    '''

    print("Making '.msi' package...")

    dest_dir = pathlib.Path(dest_dir)
    release_dir = dist_dir / 'release'
    if not release_dir.exists():
        raise RuntimeError('Package cannot be made if app is not built yet')

    exe_name = md.NAME.lower()
    version = md.VERSION
    pkg_dir = dest_dir / f'{exe_name}-{md.VERSION}'
    if pkg_dir.exists():
        shutil.rmtree(pkg_dir)
    pkg_dir.mkdir()

    files_dir = pkg_dir / 'Files'
    files_dir.mkdir()

    _copy_exe(release_dir, files_dir)
    _copy_licenses(release_dir, files_dir)
    _copy_wix(wix_dir, pkg_dir)
    _copy_setup(pkg_dir)

    cmd = f'{set_env_vars(wix_dir)} && cscs.exe setup.cs'
    utils.run(cmd, cwd=pkg_dir)

    shutil.copyfile(pkg_dir / f'{md.NAME}.msi',
                    dist_dir / f'{exe_name}-{version}-x64.msi')

    shutil.rmtree(pkg_dir)

    print('Done.')
コード例 #9
0
ファイル: rpm.py プロジェクト: oratosquilla-oratoria/myfyrio
def make_rpm(dest_dir):
    '''Make a '.rpm' package

    :param dist_dir: path to the directory that contains the 'release'
                     directory with the programme's files and where to
                     put the package at
    '''

    print("Making '.rpm' package...")

    dest_dir = pathlib.Path(dest_dir)
    release_dir = dest_dir / 'release'
    if not release_dir.exists():
        raise RuntimeError('Package cannot be made if app is not built yet')

    pkg_name = f'{md.NAME.lower()}-{md.VERSION}'
    pkg_dir = dest_dir / pkg_name
    if pkg_dir.exists():
        shutil.rmtree(pkg_dir)
    pkg_dir.mkdir()

    pkg_BUILD_dir = pkg_dir / 'BUILD'
    _, installed_exe_dir = _copy_exe(release_dir, pkg_BUILD_dir)
    _copy_licenses(release_dir, pkg_BUILD_dir)
    _copy_icon(release_dir, pkg_BUILD_dir)
    _generate_desktop_file(pkg_BUILD_dir, installed_exe_dir)
    spec_file = generate_spec(pkg_dir)

    make_pkg_cmd = (f'rpmbuild {spec_file} -bb '
                    f'--define "_topdir {pkg_dir}" '
                    f'--define "_rpmdir {dest_dir}"')
    utils.run(make_pkg_cmd, cwd=dest_dir)

    shutil.rmtree(pkg_dir)

    print('Done.')
コード例 #10
0
def dependencies(executable):
    '''Return the external dependencies of the executable (in dpkg's terms)

    :param executable: path to the executable file
    '''

    cwd = project_dir / 'dist'

    # The command need 'debian/control' to work, for some reason
    debian_dir = cwd / 'debian'
    debian_dir.mkdir()
    with open(debian_dir / 'control', 'x'):
        pass  # pylint:disable=multiple-statements

    cmd = f'dpkg-shlibdeps -O {executable}'
    output = utils.run(cmd, cwd=cwd, stdout=False)

    shutil.rmtree(debian_dir)

    return output.split('Depends=')[-1].rstrip()
コード例 #11
0
def architecture():
    '''Return the system architecture (in dpkg's terms)'''

    cmd = 'dpkg --print-architecture'
    output = utils.run(cmd, stdout=False)
    return output.rstrip()