def _parse_deb_project(changelog='debian/changelog'):
    clog = Changelog()
    try:
        clog.parse_changelog(open(changelog), max_blocks=1)
        return clog.package
    except ChangelogParseError:
        raise LGPException("Malformed Debian changelog '%s'" % changelog)
Exemple #2
0
def find_changelog(t, merge, max_blocks=1):
    """Find the changelog in the given tree.

    First looks for 'debian/changelog'. If "merge" is true will also
    look for 'changelog'.

    The returned changelog is created with 'allow_empty_author=True'
    as some people do this but still want to build.
    'max_blocks' defaults to 1 to try and prevent old broken
    changelog entries from causing the command to fail, 

    "top_level" is a subset of "merge" mode. It indicates that the
    '.bzr' dir is at the same level as 'changelog' etc., rather
    than being at the same level as 'debian/'.

    :param t: the Tree to look in.
    :param merge: whether this is a "merge" package.
    :param max_blocks: Number of max_blocks to parse (defaults to 1). Use None
        to parse the entire changelog.
    :return: (changelog, top_level) where changelog is the Changelog,
        and top_level is a boolean indicating whether the file is
        located at 'changelog' (rather than 'debian/changelog') if
        merge was given, False otherwise.
    """
    top_level = False
    with t.lock_read():
        changelog_file = 'debian/changelog'
        if not t.has_filename(changelog_file):
            checked_files = ['debian/changelog']
            if merge:
                # Assume LarstiQ's layout (.bzr in debian/)
                changelog_file = 'changelog'
                top_level = True
                if not t.has_filename(changelog_file):
                    checked_files.append(changelog_file)
                    changelog_file = None
            else:
                changelog_file = None
            if changelog_file is None:
                if getattr(t, "abspath", None):
                    checked_files = [t.abspath(f) for f in checked_files]
                raise MissingChangelogError(" or ".join(checked_files))
        elif merge and t.has_filename('changelog'):
            # If it is a "top_level" package and debian is a symlink to
            # "." then it will have found debian/changelog. Try and detect
            # this.
            if (t.is_versioned('debian') and
                t.kind('debian') == 'symlink' and
                t.get_symlink_target('debian') == '.'):
                changelog_file = 'changelog'
                top_level = True
        mutter("Using '%s' to get package information", changelog_file)
        if not t.is_versioned(changelog_file):
            raise AddChangelogError(changelog_file)
        contents = t.get_file_text(changelog_file)
    changelog = Changelog()
    try:
        changelog.parse_changelog(contents, max_blocks=max_blocks, allow_empty_author=True)
    except ChangelogParseError, e:
        raise UnparseableChangelog(str(e))
Exemple #3
0
def link_upstream_tarball(releaseType):
    #Find out the tarball link name
    upstream_name = os.path.basename( os.getcwd() )
    #paragraphs = deb822.Packages.iter_paragraphs(open('./debian/copyright', 'r'));
    #upstream_name = next(paragraphs)['Upstream-Name']
    
    changelog = Changelog()
    changelog.parse_changelog(open('./debian/changelog', 'r'))
    src_package_name = changelog.get_package()
    upstream_version = changelog.get_version().upstream_version
    #Handle packages with updated tarballs
    #e.g. 5.0.0a version instead of 5.0.0
    last_char = upstream_version[-1]
    if last_char.isalpha():
        real_upstream_version = upstream_version.rstrip(last_char)
    else:
        real_upstream_version = upstream_version
    
    link_name = '../' + src_package_name + '_' + upstream_version + '.orig.tar.xz'
    #Find out the tarball link target path
    cwd = os.path.dirname(os.path.realpath(__file__))
    config_tarball_loc = json.load(open(cwd + "/../conf/tarball-locations.json"))
    config_versions = json.load(open(cwd + "/../conf/versions.json"))
    link_target = os.path.expanduser(config_tarball_loc[releaseType]) 
    link_target += '/' + config_versions[releaseType] + '/'
    link_target += upstream_name + '-' + real_upstream_version + ".tar.xz"
    #Create the link
    try:
        os.symlink(link_target,link_name)
    except:
        pass
def _parse_deb_version(changelog='debian/changelog'):
    try:
        clog = Changelog()
        clog.parse_changelog(open(changelog), max_blocks=1)
        return clog.full_version
    except IOError:
        raise LGPException("Debian changelog '%s' cannot be found" % changelog)
    except ChangelogParseError:
        raise LGPException("Malformed Debian changelog '%s'" % changelog)
Exemple #5
0
def parse_changelog(path):
    changelog = Changelog()
    with open(path, 'r') as file_changelog:
        changelog.parse_changelog(file_changelog.read())
    set_ids = set()
    for block in changelog:
        for change in block.changes():
            set_ids = set_ids.union(WorkfrontNoteInfo.getIds(change))
    return (set_ids, changelog)
def _parse_deb_distrib(changelog='debian/changelog'):
    clog = Changelog()
    try:
        clog.parse_changelog(open(changelog), max_blocks=1)
        return clog.distributions
    except IOError:
        raise DistributionException("Debian changelog '%s' cannot be found" %
                                    changelog)
    except ChangelogParseError:
        raise DistributionException("Malformed Debian changelog '%s'" %
                                    changelog)
Exemple #7
0
 def parse_changelog(self):
     c = Changelog()
     with open(self.changelog_file, 'r') as f:
         c.parse_changelog(f)
     return c
Exemple #8
0
                    type=str,
                    help="github branch to set (default: [dist])")
parser.add_argument("-o", "--outdir", type=str, help="output directory")
parser.add_argument("-j", "--no_jenkinsfile", action='store_true')

args = parser.parse_args()

outdir = args.outdir
if not args.outdir:
    outdir = args.bzr.split("/")[-1]

subprocess.call(["./do_convert.sh", args.bzr, outdir])
changelog_file = outdir + "/debian/changelog"

changelog = Changelog()
changelog.parse_changelog(open(changelog_file))

l_version_ = changelog.get_version()
l_version = l_version_.__str__()

r_version = l_version.split("+")[0]

# Bump version number to make sure we are one version above
if not "." in r_version:
    if r_version.isdigit():
        n_version = str(int(r_version) + 1)
    else:
        n_version = r_version + "1"
else:
    dot_split = r_version.split(".")
    print(dot_split[-1].isdigit())