Ejemplo n.º 1
0
def fetch_changelog(repo, options, tree):
    """Fetch the correct changelog based on the options given"""
    changelog = 'debian/changelog'

    try:
        if tree:
            cp = du.parse_changelog_repo(repo, tree, changelog)
        else:
            cp = ChangeLog(filename=changelog)
    except NoChangeLogError:
        raise GbpError("'%s' does not exist, not a debian package" % changelog)
    except ParseChangeLogError as err:
        raise GbpError("Error parsing Changelog: %s" % err)
    except KeyError:
        raise GbpError("Can't parse version from changelog")
    return cp
Ejemplo n.º 2
0
def detect_name_and_version(repo, source, options):
    # Guess defaults for the package name and version from the
    # original tarball.
    guessed_package, guessed_version = source.guess_version()

    # Try to find the source package name
    try:
        cp = ChangeLog(filename='debian/changelog')
        sourcepackage = cp['Source']
    except NoChangeLogError:
        try:
            # Check the changelog file from the repository, in case
            # we're not on the debian-branch (but upstream, for
            # example).
            cp = parse_changelog_repo(repo, options.debian_branch,
                                      'debian/changelog')
            sourcepackage = cp['Source']
        except NoChangeLogError:
            if options.interactive:
                sourcepackage = ask_package_name(
                    guessed_package, DebianPkgPolicy.is_valid_packagename,
                    DebianPkgPolicy.packagename_msg)
            else:
                if guessed_package:
                    sourcepackage = guessed_package
                else:
                    raise GbpError(
                        "Couldn't determine upstream package name. Use --interactive."
                    )

    # Try to find the version.
    if options.version:
        version = options.version
    else:
        if options.interactive:
            version = ask_package_version(
                guessed_version, DebianPkgPolicy.is_valid_upstreamversion,
                DebianPkgPolicy.upstreamversion_msg)
        else:
            if guessed_version:
                version = guessed_version
            else:
                raise GbpError(
                    "Couldn't determine upstream version. Use '-u<version>' or --interactive."
                )

    return (sourcepackage, version)
Ejemplo n.º 3
0
    def detect_name_version_and_component(self, repo, options):
        # Guess defaults for the package name, version, and component from the
        # original tarball.
        (guessed_package, guessed_version, guessed_component) = self._source.guess_version() or ('', '', '')

        # Try to find the source package name
        try:
            cp = ChangeLog(filename='debian/changelog')
            sourcepackage = cp['Source']
        except NoChangeLogError:
            try:
                # Check the changelog file from the repository, in case
                # we're not on the debian-branch (but upstream, for
                # example).
                cp = parse_changelog_repo(repo, options.debian_branch, 'debian/changelog')
                sourcepackage = cp['Source']
            except NoChangeLogError:
                if options.interactive:
                    sourcepackage = ask_package_name(guessed_package,
                                                     DebianPkgPolicy.is_valid_packagename,
                                                     DebianPkgPolicy.packagename_msg)
                else:
                    if guessed_package:
                        sourcepackage = guessed_package
                    else:
                        raise GbpError("Couldn't determine upstream package name. Use --interactive.")

        # Try to find the version.
        if options.version:
            version = options.version
        else:
            if options.interactive:
                version = ask_package_version(guessed_version,
                                              DebianPkgPolicy.is_valid_upstreamversion,
                                              DebianPkgPolicy.upstreamversion_msg)
            else:
                if guessed_version:
                    version = guessed_version
                else:
                    raise GbpError("Couldn't determine upstream version. Use '-u<version>' or --interactive.")

        self.name = sourcepackage
        self.version = version
        self.component = guessed_component
Ejemplo n.º 4
0
def detect_name_and_version(repo, source, options):
    # Guess defaults for the package name and version from the
    # original tarball.
    guessed_package, guessed_version = source.guess_version()

    # Try to find the source package name
    try:
        cp = ChangeLog(filename="debian/changelog")
        sourcepackage = cp["Source"]
    except NoChangeLogError:
        try:
            # Check the changelog file from the repository, in case
            # we're not on the debian-branch (but upstream, for
            # example).
            cp = parse_changelog_repo(repo, options.debian_branch, "debian/changelog")
            sourcepackage = cp["Source"]
        except NoChangeLogError:
            if options.interactive:
                sourcepackage = ask_package_name(
                    guessed_package, DebianPkgPolicy.is_valid_packagename, DebianPkgPolicy.packagename_msg
                )
            else:
                if guessed_package:
                    sourcepackage = guessed_package
                else:
                    raise GbpError("Couldn't determine upstream package name. Use --interactive.")

    # Try to find the version.
    if options.version:
        version = options.version
    else:
        if options.interactive:
            version = ask_package_version(
                guessed_version, DebianPkgPolicy.is_valid_upstreamversion, DebianPkgPolicy.upstreamversion_msg
            )
        else:
            if guessed_version:
                version = guessed_version
            else:
                raise GbpError("Couldn't determine upstream version. Use '-u<version>' or --interactive.")

    return (sourcepackage, version)