Exemple #1
0
def source_deb_from_spec(spec, tree):
    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)
Exemple #2
0
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)
def srpmNameFromSpec( spec ):
    h = spec.sourceHeader
    if buildType() == "rpm":
        rpm.addMacro( 'NAME', h['name'] )
    else:
        rpm.addMacro( 'NAME', mappkgname.map_package(h['name'])[0] )
    rpm.addMacro( 'VERSION', h['version'] )
    rpm.addMacro( 'RELEASE', h['release'] )
    rpm.addMacro( 'ARCH', 'src' )

    # There doesn't seem to be a macro for the name of the source
    # rpm, but the name appears to be the same as the rpm name format.
    # Unfortunately expanding that macro gives us a leading 'src' that we
    # don't want, so we strip that off

    if buildType() == "rpm":
        srpmname = os.path.basename( rpm.expandMacro( rpmfilenamepat ) )  
    else:
        srpmname = os.path.basename( rpm.expandMacro( "%{NAME}_%{VERSION}-%{RELEASE}.dsc" ) )  

    rpm.delMacro( 'NAME' )
    rpm.delMacro( 'VERSION' )
    rpm.delMacro( 'RELEASE' )
    rpm.delMacro( 'ARCH' )

    # HACK: rewrite %dist if it appears in the filename 
    return srpmname.replace( chroot_dist, host_dist )
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"]:
        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 #5
0
def main():
    args = parse_cmdline()
    specs = {}
   
    pkgs_to_ignore = args.ignore
    for ignore_from in args.ignore_from:
        with open(ignore_from) as f:
            for name in f.readlines():
                pkgs_to_ignore.append(name.strip())
    for i in pkgs_to_ignore:
      print "# Will ignore: %s" % i

    for spec_path in args.specs:
        try:
            if build_type() == "deb":
                os_type = platform.linux_distribution(full_distribution_name=False)[1].lower()
                map_name_fn=lambda name: mappkgname.map_package(name, os_type)
                spec = pkg.Spec(spec_path, target="deb", map_name=map_name_fn)
            else:
                spec = pkg.Spec(spec_path, target="rpm", dist=args.dist)
            pkg_name = spec.name()
            if pkg_name in pkgs_to_ignore:
                continue

            specs[os.path.basename(spec_path)] = spec

        except pkg.SpecNameMismatch as exn:
            sys.stderr.write("error: %s\n" % exn.message)
            sys.exit(1)

    provides_to_rpm = package_to_rpm_map(specs.values())

    for spec in specs.itervalues():
        build_srpm_from_spec(spec)
        download_rpm_sources(spec)
        build_rpm_from_srpm(spec)
        buildrequires_for_rpm(spec, provides_to_rpm)
        print ""

    # Generate targets to build all srpms and all rpms
    all_rpms = []
    all_srpms = []
    for spec in specs.itervalues():
        rpm_path = spec.binary_package_paths()[0]
        all_rpms.append(rpm_path)
        all_srpms.append(spec.source_package_path())
        print "%s: %s" % (spec.name(), rpm_path)
    print ""

    print "rpms: " + " \\\n\t".join(all_rpms)
    print ""
    print "srpms: " + " \\\n\t".join(all_srpms)
    print ""
    print "install: all"
    print "\t. scripts/%s/install.sh" % build_type()
def rename_source(spec, pkgname, pkgversion):
    # Debian source package name should probably match the tarball name
    origfilename = principal_source_file(spec)
    if origfilename.endswith(".tbz"):
        filename = origfilename[: -len(".tbz")] + ".tar.bz2"
    else:
        filename = origfilename
    match = re.match("^(.+)(\.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))
def source_deb_from_spec(spec, tree):
    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)
Exemple #8
0
def rename_source(spec, pkgname, pkgversion):
    # Debian source package name should probably match the tarball name
    origfilename = principal_source_file(spec)
    if origfilename.endswith(".tbz"):
        filename = origfilename[:-len(".tbz")] + ".tar.bz2"
    else:
        filename = origfilename
    match = re.match("^(.+)(\.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 #9
0
def changelog_from_spec(spec, isnative):
    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 changelos only have "First Last <*****@*****.**>".   
        # For these, we use the version from the spec. 
        match = re.match( "^(.+) - (\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 #10
0
def changelog_from_spec(spec, isnative):
    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 changelos only have "First Last <*****@*****.**>".
        # For these, we use the version from the spec.
        match = re.match("^(.+) - (\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
def map_package_name(name):
    if buildType() == "rpm":
        return [name]
    else:
        return mappkgname.map_package(name)
Exemple #12
0
def map_package_name(name):
    if build_type() == "rpm":
        return [name]
    else:
        return mappkgname.map_package(name)