Exemplo n.º 1
0
    def list_module_packages(self, module):
        debiandir = self.get_debian_dir(module)

        control = PackageControlParser()

        if os.path.exists(os.path.join(debiandir, "control")):
            control.read(os.path.join(debiandir, "control"))
        else:
            env = self.get_jinja_env()
            data = env.get_template(os.path.join(debiandir, "control.j2")).render(**self.args.vars)
            control.readfp(data.splitlines())

        version = self.get_version(module)

        # Imported package sometimes don't have the same "local tag" as ours.
        # FIXME: this code is mostly duplicated from changelog.py
        if changelog_is_up_to_date(os.path.join(debiandir, "changelog"), version):
            line = file(os.path.join(debiandir, "changelog"), "r").readline()
            version = re.match("^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)", line, re.I).group(2)

        if ":" in version:
            version = version.split(":", 1)[1]
        if self.args.build_tag:
            version += self.args.build_tag

        packages = []
        for package in control.sections:
            name = package["Package"]
            arch = package["Architecture"]
            if arch == "any":
                arch = self.args.arch

            packages.append("%s_%s_%s.deb" % (name, version, arch))

        return packages
Exemplo n.º 2
0
def install_packages(packages_to_install, build_dir, module):
    if not packages_to_install:
        return

    control = PackageControlParser()
    control.read(os.path.join(build_dir, 'debian/control'))

    # Make a list of packages
    packages = [x['Package'] for x in control]

    # Make a list of dependencies we didn't build ourselves
    # FIXME: we skip the ${} for now.
    dependencies = []
    for package_info in control:
        if package_info['Package'] in packages:
            for dep in package_info.get('Depends', '').split(','):
                dep = dep.strip().split(None, 1)[0]
                if dep and not dep.startswith('$') and dep not in packages:
                    dependencies.append(dep)

    # Install said dependencies if there are any
    if dependencies:
        print blue("Installing dependencies for packages '%s'" % "', '".join(packages_to_install))
        code = system('apt-get install %s' % ' '.join(dependencies), root=True)
        check_code(code, module)

    # Install built packages
    print blue("Installing packages '%s'" % "', '".join(packages_to_install))
    dpkg_args = []
    for filename in glob.glob(os.path.join(os.path.dirname(build_dir), '*.deb')):
        if os.path.basename(filename).split('_', 1)[0] in packages_to_install:
            dpkg_args.append(filename)
    code = system("dpkg -i %s" % ' '.join(dpkg_args), root=True)
    check_code(code, module)
Exemplo n.º 3
0
    def list_module_packages(self, module):
        debiandir = self.get_debian_dir(module)

        control = PackageControlParser()

        if os.path.exists(os.path.join(debiandir, 'control')):
            control.read(os.path.join(debiandir, 'control'))
        else:
            env = self.get_jinja_env()
            data = env.get_template(os.path.join(debiandir, 'control.j2')).render(**self.args.vars)
            control.readfp(data.splitlines())

        version = self.get_version(module)

        # Imported package sometimes don't have the same "local tag" as ours.
        # FIXME: this code is mostly duplicated from changelog.py
        if changelog_is_up_to_date(os.path.join(debiandir, 'changelog'), version):
            line = file(os.path.join(debiandir, 'changelog'), 'r').readline()
            version = re.match('^(\w[-+0-9a-z.]*) \(([^\(\) \t]+)\)', line, re.I).group(2)

        if ':' in version:
            version = version.split(':',1)[1]
        if self.args.build_tag:
            version += self.args.build_tag

        packages = []
        for package in control.sections:
            name = package['Package']
            arch = package['Architecture']
            if arch == 'any':
                arch = self.args.arch

            packages.append('%s_%s_%s.deb' % (name, version, arch))

        return packages
Exemplo n.º 4
0
def install_packages(packages_to_install, build_dir, module):
    if not packages_to_install:
        return

    control = PackageControlParser()
    control.read(os.path.join(build_dir, 'debian/control'))

    # Make a list of packages
    packages = [x['Package'] for x in control]

    # Make a list of dependencies we didn't build ourselves
    # FIXME: we skip the ${} for now.
    dependencies = []
    for package_info in control:
        if package_info['Package'] in packages:
            for dep in package_info.get('Depends', '').split(','):
                dep = dep.strip().split(None, 1)[0]
                if dep and not dep.startswith('$') and dep not in packages:
                    dependencies.append(dep)

    # Install said dependencies if there are any
    if dependencies:
        print blue("Installing dependencies for packages '%s'" %
                   "', '".join(packages_to_install))
        code = system('apt-get install %s' % ' '.join(dependencies), root=True)
        check_code(code, module)

    # Install built packages
    print blue("Installing packages '%s'" % "', '".join(packages_to_install))
    dpkg_args = []
    for filename in glob.glob(os.path.join(os.path.dirname(build_dir),
                                           '*.deb')):
        if os.path.basename(filename).split('_', 1)[0] in packages_to_install:
            dpkg_args.append(filename)
    code = system("dpkg -i %s" % ' '.join(dpkg_args), root=True)
    check_code(code, module)
Exemplo n.º 5
0
 def get_dependencies(self, build_dir):
     control = PackageControlParser()
     control.read(os.path.join(build_dir, "debian/control"))
     dependencies = control.source.get("Build-Depends", "")
     return [i.strip().split(None, 1)[0] for i in dependencies.split(",") if i]
Exemplo n.º 6
0
 def get_dependencies(self, build_dir):
     control = PackageControlParser()
     control.read(os.path.join(build_dir, 'debian/control'))
     dependencies = control.source.get('Build-Depends', '')
     return [i.strip().split(None, 1)[0] for i in dependencies.split(',') if i]