Ejemplo n.º 1
0
def prepare_build(dir_path):
    control_file = os.path.join(dir_path, 'debian/control')
    rules_file = os.path.join(dir_path, 'debian/rules')
    install_file = os.path.join(dir_path, 'debian/install')

    make_file = os.path.join(dir_path, 'Makefile')

    if not os.path.exists(control_file) or not os.path.exists(rules_file):
        return

    remove_deps = ['libraspberrypi-dev', 'openbox (>=3.5.2-4~kano.1)', 'chromium']
    remove_installs = ['eglsaver']

    control_file_str = read_file_contents(control_file)
    for dep in remove_deps:
        control_file_str = control_file_str.replace(dep + ',', '').replace(dep, '')
    write_file_contents(control_file, control_file_str)

    # custom build target
    if os.path.exists(make_file):
        make_file_str = read_file_contents(make_file)
        if 'kano-debber:' in make_file_str:
            rules_file_str = read_file_contents(rules_file)

            insert_start = '#!/usr/bin/make -f\n'
            insert_str = 'override_dh_auto_build:\n\tdh_auto_build -- kano-debber\n'

            rules_file_str = rules_file_str.replace(insert_start, insert_start + insert_str)
            write_file_contents(rules_file, rules_file_str)

    install_lines = read_file_contents_as_lines(install_file)
    if install_lines:
        for remove_install in remove_installs:
            install_lines = [l for l in install_lines if remove_install not in l]
        write_file_contents(install_file, '\n'.join(install_lines))
Ejemplo n.º 2
0
def parse_repos():
    lines = read_file_contents_as_lines('repos')
    if not lines:
        sys.exit('error with repos file')

    data = OrderedDict()
    section = ''
    for i, l in enumerate(lines):
        if not l:
            continue

        if l[0] == '[':
            section = l.translate(None, '[]')
        else:
            if l[0] == '#':
                continue

            if not section:
                sys.exit('Error with repos file, needs to start with a section!')

            parts = l.split()
            if len(parts) != 2:
                sys.exit('Bad line in repos file:\n{}'.format(l))
            repo, branch = l.split()

            data.setdefault(section, list()).append((repo, branch))
    return data
Ejemplo n.º 3
0
def parse_repos():
    lines = read_file_contents_as_lines('repos')
    if not lines:
        sys.exit('error with repos file')

    data = OrderedDict()
    section = ''
    for i, l in enumerate(lines):
        if not l:
            continue

        if l[0] == '[':
            section = l.translate(None, '[]')
        else:
            if l[0] == '#':
                continue

            if not section:
                sys.exit(
                    'Error with repos file, needs to start with a section!')

            parts = l.split()
            if len(parts) != 2:
                sys.exit('Bad line in repos file:\n{}'.format(l))
            repo, branch = l.split()

            data.setdefault(section, list()).append((repo, branch))
    return data
Ejemplo n.º 4
0
def prepare_build(dir_path):
    control_file = os.path.join(dir_path, 'debian/control')
    rules_file = os.path.join(dir_path, 'debian/rules')
    install_file = os.path.join(dir_path, 'debian/install')

    make_file = os.path.join(dir_path, 'Makefile')

    if not os.path.exists(control_file) or not os.path.exists(rules_file):
        return

    remove_deps = [
        'libraspberrypi-dev', 'openbox (>=3.5.2-4~kano.1)', 'chromium'
    ]
    remove_installs = ['eglsaver']

    control_file_str = read_file_contents(control_file)
    for dep in remove_deps:
        control_file_str = control_file_str.replace(dep + ',',
                                                    '').replace(dep, '')
    write_file_contents(control_file, control_file_str)

    # custom build target
    if os.path.exists(make_file):
        make_file_str = read_file_contents(make_file)
        if 'kano-debber:' in make_file_str:
            rules_file_str = read_file_contents(rules_file)

            insert_start = '#!/usr/bin/make -f\n'
            insert_str = 'override_dh_auto_build:\n\tdh_auto_build -- kano-debber\n'

            rules_file_str = rules_file_str.replace(insert_start,
                                                    insert_start + insert_str)
            write_file_contents(rules_file, rules_file_str)

    install_lines = read_file_contents_as_lines(install_file)
    if install_lines:
        for remove_install in remove_installs:
            install_lines = [
                l for l in install_lines if remove_install not in l
            ]
        write_file_contents(install_file, '\n'.join(install_lines))