Exemple #1
0
def source_deb_from_spec(spec, tree):
    """
    Create the source package stanza of the debian/source file from spec.
    """
    res = ""
    res += "Source: %s\n" % \
        mappkgname.map_package(spec.sourceHeader['name'])[0]
    res += "Priority: %s\n" % "optional"
    res += "Maintainer: %s\n" % "Euan Harris <*****@*****.**>"
    res += "Section: %s\n" % mappkgname.map_section(spec.sourceHeader['group'])
    res += "Standards-Version: %s\n" % STANDARDS_VERSION

    res += "Build-Depends:\n"
    build_depends = ["debhelper (>= 8)", "dh-ocaml (>= 0.9)", "ocaml-nox",
                     "python"]
    for pkg, version in zip(spec.sourceHeader['requires'],
                            spec.sourceHeader['requireVersion']):
        deps = mappkgname.map_package(pkg)
        for dep in deps:
            if version:
                dep += " (>= %s)" % version
            build_depends.append(dep)

    res += ",\n".join(set([" %s" % d for d in build_depends]))
    res += "\n\n"

    tree.append('debian/control', res)
def binary_deb_from_spec(spec, tree):
    res = ""
    res += "Package: %s\n" % mappkgname.map_package_name(spec.header)
    if spec.header['arch'] in ["x86_64", "i686", "armhf", "armv7l"]:
        res += "Architecture: any\n"
    else:
        res += "Architecture: all\n"

    res += "Depends:\n"
    depends = ["${ocaml:Depends}", "${shlibs:Depends}", "${misc:Depends}"]
    for pkg, version in zip(spec.header['requires'],
                            spec.header['requireVersion']):
        deps = mappkgname.map_package(pkg)
        for dep in deps:
            if version:
                dep += " (>= %s)" % version
            depends.append(dep)
    res += ",\n".join([" %s" % d for d in depends])
    res += "\n"

    # XXX These lines should only be added for ocaml packages
    res += "Provides: ${ocaml:Provides}\n"
    res += "Recommends: ocaml-findlib\n"

    res += "Description: %s\n" % spec.header['summary']
    res += format_description(spec.header['description'])
    res += "\n\n"

    tree.append('debian/control', res)
Exemple #3
0
def rename_source(spec, pkgname, pkgversion):
    # Debian source package name should probably match the tarball name
    origfilename = debianmisc.principal_source_file(spec)
    if origfilename.endswith(".tbz"):
        filename = origfilename[:-len(".tbz")] + ".tar.bz2"
    else:
        filename = origfilename
    match = re.match(r"^(.+)(\.tar\.(gz|bz2|lzma|xz))", filename)
    if not match:
        print "error: could not parse filename %s" % filename
    _, ext = match.groups()[:2]
    base_filename = "%s_%s.orig%s" % (mappkgname.map_package(pkgname)[0],
                                      pkgversion, ext)
    shutil.copy(os.path.join(SRC_DIR, origfilename),
                os.path.join(BUILD_DIR, base_filename))
Exemple #4
0
def changelog_from_spec(spec, isnative):
    """Generate a Debian changelog from spec"""

    res = Tree()

    hdr = spec.sourceHeader
    log = ""
    for (name, timestamp, text) in zip(hdr['changelogname'],
                                       hdr['changelogtime'],
                                       hdr['changelogtext']):

        # A Debian package's version is defined by the version of the
        # first entry in the changelog, so we must get this right.
        # Most spec files have changelog entries starting:
        #   "First Last # <*****@*****.**> - version"
        # This seems to be the standard for Red Hat spec files.
        # Some of our changelogs only have "First Last <*****@*****.**>".
        # For these, we use the version from the spec.
        match = re.match(r"^(.+) - (\S+)$", name)
        if match:
            author = match.group(1)
            version = match.group(2)
            if isnative:
                version = re.sub('-', '.', version)
        else:
            author = name
            sep = '.' if isnative else '-'
            version = "%s%s%s" % (spec.sourceHeader['version'],
                                  sep,
                                  spec.sourceHeader['release'])
        print version

        package_name = mappkgname.map_package(hdr['name'])[0]
        log += "%s (%s) UNRELEASED; urgency=low\n" % (package_name, version)
        log += "\n"

        text = re.sub("^-", "*", text, flags=re.MULTILINE)
        text = re.sub("^", "  ", text, flags=re.MULTILINE)
        log += "%s\n" % text
        log += "\n"

        date_string = time.strftime("%a, %d %b %Y %H:%M:%S %z",
                                    time.gmtime(int(timestamp)))
        log += " -- %s  %s\n" % (author, date_string)
        log += "\n"

    res.append('debian/changelog', log)
    return res
Exemple #5
0
 def map_name_fn(name):
     # pylint: disable=C0111
     return mappkgname.map_package(name, os_type)
Exemple #6
0
 def map_name_fn(name):
     return mappkgname.map_package(name, os_type)