def update_maintainer(debian_directory, verbose=False):
    """updates the Maintainer field of an Ubuntu package

    * No modifications are made if the Maintainer field contains an ubuntu.com
      email address. Otherwise, the Maintainer field will be set to
      Ubuntu Developers <*****@*****.**>
    * The old value will be saved in a field named XSBC-Original-Maintainer
      if the Maintainer field is modified.

    Policy: https://wiki.ubuntu.com/DebianMaintainerField
    """
    try:
        changelog_file, control_files = _find_files(debian_directory, verbose)
    except MaintainerUpdateException as e:
        Logger.error(str(e))
        raise

    distribution = _get_distribution(changelog_file)
    for control_file in control_files:
        control = Control(control_file)
        original_maintainer = control.get_maintainer()

        if original_maintainer is None:
            Logger.error("No Maintainer field found in %s.", control_file)
            raise MaintainerUpdateException("No Maintainer field found")

        if original_maintainer.strip().lower() in _PREVIOUS_UBUNTU_MAINTAINER:
            if verbose:
                print("The old maintainer was: %s" % original_maintainer)
                print("Resetting as: %s" % _UBUNTU_MAINTAINER)
            control.set_maintainer(_UBUNTU_MAINTAINER)
            control.save()
            continue

        if original_maintainer.strip().endswith("ubuntu.com>"):
            if verbose:
                print(
                    "The Maintainer email is set to an ubuntu.com address. Doing nothing."
                )
            continue

        if distribution in ("stable", "testing", "unstable", "experimental"):
            if verbose:
                print("The package targets Debian. Doing nothing.")
            return

        if control.get_original_maintainer() is not None:
            Logger.warn("Overwriting original maintainer: %s",
                        control.get_original_maintainer())

        if verbose:
            print("The original maintainer is: %s" % original_maintainer)
            print("Resetting as: %s" % _UBUNTU_MAINTAINER)
        control.set_original_maintainer(original_maintainer)
        control.set_maintainer(_UBUNTU_MAINTAINER)
        control.save()

    return
示例#2
0
def get_debian_srcpkg(name, release):
    debian = Distribution('debian')
    debian_archive = debian.getArchive()

    try:
        release = DebianDistroInfo().codename(release, None, release)
    except DistroDataOutdated as e:
        Logger.warn(e)

    return debian_archive.getSourcePackage(name, release)
示例#3
0
def check_dependencies():
    "Do we have all the commands we need for full functionality?"
    missing = []
    for cmd in ('patch', 'bzr', 'quilt', 'dput', 'lintian'):
        if not is_command_available(cmd):
            missing.append(cmd)
    if not is_command_available('bzr-buildpackage'):
        missing.append('bzr-builddeb')
    if not any(
            is_command_available(cmd, check_sbin=True)
            for cmd in ('pbuilder', 'sbuild', 'cowbuilder')):
        missing.append('pbuilder/cowbuilder/sbuild')

    if missing:
        Logger.warn(
            "sponsor-patch requires %s to be installed for full "
            "functionality", ', '.join(missing))
示例#4
0
def _get_srcpkg(distro, name, release):
    if distro == 'debian':
        # Canonicalise release:
        debian_info = DebianDistroInfo()
        try:
            codename = debian_info.codename(release, default=release)
        except DistroDataOutdated as e:
            Logger.warn(e)

    lines = list(rmadison(distro, name, suite=codename, arch='source'))
    if not lines:
        lines = list(rmadison(distro, name, suite=release, arch='source'))
        if not lines:
            raise PackageNotFoundException(
                "'%s' doesn't appear to exist in %s '%s'" %
                (name, distro.capitalize(), release))
    pkg = max(lines, key=lambda x: Version(x['version']))

    return FakeSPPH(pkg['source'], pkg['version'], pkg['component'], distro)
示例#5
0
 def parse_devscripts_config(self):
     """Read the devscripts configuration files, and return the values as a
     dictionary
     """
     config = {}
     for filename in ('/etc/devscripts.conf', '~/.devscripts'):
         try:
             f = open(os.path.expanduser(filename), 'r')
         except IOError:
             continue
         for line in f:
             parsed = shlex.split(line, comments=True)
             if len(parsed) > 1:
                 Logger.warn('Cannot parse variable assignment in %s: %s',
                             getattr(f, 'name', '<config>'), line)
             if len(parsed) >= 1 and '=' in parsed[0]:
                 key, value = parsed[0].split('=', 1)
                 config[key] = value
         f.close()
     return config
示例#6
0
    def get_value(self, key, default=None, boolean=False, compat_keys=()):
        """Retrieve a value from the environment or configuration files.
        keys are prefixed with the script name, falling back to UBUNTUTOOLS for
        package-wide keys.

        Variable Priority: PREFIX_KEY, UBUNTUTOOLS_KEY, compat_keys
        Store Priority: Environment variables, user conf, system conf

        Historical variable names can be supplied via compat_keys, no prefix is
        applied to them.
        """
        if default is None and key in self.defaults:
            default = self.defaults[key]

        keys = [self.prefix + '_' + key]
        if key in self.defaults:
            keys.append('UBUNTUTOOLS_' + key)
        keys += compat_keys

        for k in keys:
            for store in (os.environ, self.config):
                if k in store:
                    value = store[k]
                    if boolean:
                        if value in ('yes', 'no'):
                            value = value == 'yes'
                        else:
                            continue
                    if k in compat_keys:
                        replacements = self.prefix + '_' + key
                        if key in self.defaults:
                            replacements += 'or UBUNTUTOOLS_' + key
                        Logger.warn(
                            'Using deprecated configuration variable %s. '
                            'You should use %s.', k, replacements)
                    return value
        return default