def files_from_pkg(basename, pkg, specpath):
    # should be able to build this from the files sections - can't find how
    # to get at them from the spec object
    res = ""
    files = rpmextra.files_from_spec(basename, specpath)
    for filename in files.get(pkg.header['name'], []):
        # Debian packages must not contain compiled Python files.
        # Instead, the python2 helper arranges to compile these 
        # files when they are installed.
	if os.path.splitext(filename)[1] in [".pyc", ".pyo"]:
            continue

        rpm.addMacro("_libdir", "usr/lib")
        rpm.addMacro("_bindir", "usr/bin")

        # deb just wants relative paths
        src = rpm.expandMacro(filename).lstrip("/")  
        rpm.delMacro("_bindir")
        rpm.delMacro("_libdir")
        rpm.addMacro("_libdir", "/usr/lib")
        rpm.addMacro("_bindir", "/usr/bin")
        dst = rpm.expandMacro(filename)

        # destination paths should be directories, not files.
        # if the file is foo and the path is /usr/bin/foo, the
        # package will end up install /usr/bin/foo/foo 
        if not dst.endswith("/"):
            dst = os.path.dirname(dst)
        rpm.delMacro("_bindir")
        rpm.delMacro("_libdir")
        res += "%s %s\n" % (src, dst)
    return res
def conffiles_from_spec(spec, specpath):
    # Configuration files, not to be overwritten on upgrade.
    # Files in /etc are automatically marked as config files,
    # so we only need to list files here if they are in a 
    # different place.
    res = Tree()
    pkgname = mappkgname.map_package_name(spec.sourceHeader)
    files = rpmextra.files_from_spec(pkgname, specpath)
    if files.has_key( pkgname + "-%config" ):
        for filename in files[pkgname + "-%config"]:
            res.append('debian/conffiles', "%s\n" % filename)
    return res
def rules_dh_install_from_spec(spec, tree, specpath):
    rule = ".PHONY: override_dh_install\n"
    rule += "override_dh_install:\n"
    rule += "\tdh_install\n"

    pkgname = mappkgname.map_package_name(spec.sourceHeader)
    files = rpmextra.files_from_spec(pkgname, specpath)
    if files.has_key(pkgname + "-%exclude"):
        for pat in files[pkgname + "-%exclude"]:
            path = "\trm -f debian/%s/%s\n" % (pkgname, rpm.expandMacro(pat))
            rule += os.path.normpath(path)
    rule += "\n"

    tree.append('debian/rules', rule)
Exemple #4
0
def rules_dh_install_from_spec(spec, tree, specpath):
    rule  =  ".PHONY: override_dh_install\n"
    rule += "override_dh_install:\n"
    rule += "\tdh_install\n"

    pkgname = mappkgname.map_package_name(spec.sourceHeader)
    files = rpmextra.files_from_spec(pkgname, specpath)
    if files.has_key( pkgname + "-%exclude" ):
        for pat in files[pkgname + "-%exclude"]:
            path = "\trm -f debian/%s/%s\n" % (pkgname, rpm.expandMacro(pat))
            rule += os.path.normpath(path)
    rule += "\n"

    tree.append('debian/rules', rule)