summarylogtreecommitdiffstats
path: root/gen-PKGBUILD.py
diff options
context:
space:
mode:
authorJanusz Lewandowski2016-03-29 00:45:39 +0200
committerJanusz Lewandowski2016-03-29 00:50:55 +0200
commit6eed4701b02b819d19f09f5b14227155f5c7cba8 (patch)
tree5668978a299ac259bdbd5e1356ed351e3f70dc6e /gen-PKGBUILD.py
downloadaur-6eed4701b02b819d19f09f5b14227155f5c7cba8.tar.gz
Might work... Cannot test, as AMDGPU does not work on my Athlon 5350.
Diffstat (limited to 'gen-PKGBUILD.py')
-rw-r--r--gen-PKGBUILD.py168
1 files changed, 168 insertions, 0 deletions
diff --git a/gen-PKGBUILD.py b/gen-PKGBUILD.py
new file mode 100644
index 00000000000..03eaba8dbdd
--- /dev/null
+++ b/gen-PKGBUILD.py
@@ -0,0 +1,168 @@
+from debian import deb822
+import re
+import gzip
+
+header_tpl = """# Maintainer: Janusz Lewandowski <lew21@xtreeme.org>
+# Autogenerated from AMD's Packages file
+# with https://github.com/LEW21/archlinux-amdgpu/blob/master/gen-PKGBUILD.py
+
+pkgbase=amdgpu-pro-installer
+pkgname={PACKAGES}
+pkgver=16.15.2
+pkgrel=277429
+arch=('x86_64')
+url="http://www.amd.com"
+
+url_ref="http://support.amd.com/en-us/kb-articles/Pages/AMDGPU-PRO-Beta-Driver-for-Vulkan-Release-Notes.aspx"
+DLAGENTS="https::/usr/bin/curl --referer ${{url_ref}} -o %o %u"
+
+source=(https://www2.ati.com/drivers/beta/amdgpu-pro_${{pkgver}}-277429.tar.xz)
+sha256sums=('e857cc74959706c276328b5876dfeba7d1ec0cbfacf966b607c50a748f7f5233')
+"""
+
+package_header_tpl = """
+package_{NAME} () {{
+ pkgdesc={DESC}
+ depends={DEPENDS}
+ arch=('{ARCH}')
+
+ rm -Rf "${{srcdir}}"/{Package}_{Version}_{Architecture}
+ mkdir "${{srcdir}}"/{Package}_{Version}_{Architecture}
+ cd "${{srcdir}}"/{Package}_{Version}_{Architecture}
+ ar x "${{srcdir}}"/amdgpu-pro-driver/{Filename}
+ tar -C "${{pkgdir}}" -xf data.tar.xz
+"""
+
+package_footer = """}
+"""
+
+special_ops = {
+ "amdgpu-pro-firmware": "mv ${pkgdir}/lib ${pkgdir}/usr/",
+ "amdgpu-pro-core": "mv ${pkgdir}/lib ${pkgdir}/usr/",
+}
+
+replace_deps = {
+ "libc6": None,
+ "libgcc1": None,
+ "libstdc++6": None,
+ "libx11-6": "libx11",
+ "libx11-xcb1": None,
+ "libxcb-dri2-0": "libxcb",
+ "libxcb-dri3-0": "libxcb",
+ "libxcb-present0": "libxcb",
+ "libxcb-sync1": "libxcb",
+ "libxcb-glx0": "libxcb",
+ "libxcb1": "libxcb",
+ "libxext6": "libxext",
+ "libxshmfence1": "libxshmfence",
+ "libxdamage1": "libxdamage",
+ "libxfixes3": "libxfixes",
+ "libxxf86vm1": "libxxf86vm",
+ "libudev1": "libsystemd",
+ "libpciaccess0": "libpciaccess",
+ "libepoxy0": "libepoxy",
+ "libelf1": "libelf",
+ "xserver-xorg-core": "xorg-server",
+ "libcunit1": "cunit",
+ "libdrm-radeon1": "libdrm",
+}
+
+dependency = re.compile(r"([^ ]+)(?: \((.+)\))?")
+
+arch_map = {
+ "amd64": "x86_64",
+ "i386": "i686",
+ "all": "any"
+}
+
+deb_archs={}
+
+def archPackageName(info):
+ lib32 = "lib32-" if info["Architecture"] == "i386" else ""
+ return lib32 + info["Package"]
+
+def quote(string):
+ return "\"" + string.replace("\\", "\\\\").replace("\"", "\\\"") + "\""
+
+def convertName(name):
+ if info["Architecture"] == "i386" and (name not in deb_archs or "any" not in deb_archs[name]):
+ return "lib32-" + name
+ return name
+
+def convertVersionSpecifier(spec):
+ if not spec:
+ return ""
+
+ sign, spec = spec.split(" ", 1)
+
+ spec = spec.strip()
+ if ":" in spec:
+ whatever, spec = spec.rsplit(":", 1)
+ return sign + spec
+
+def convertPackage(info):
+ if info["Architecture"] == "i386":
+ name = "lib32-" + info["Package"]
+ arch = "x86_64"
+ else:
+ name = info["Package"]
+ arch = arch_map[info["Architecture"]]
+
+ try:
+ deps = info["Depends"].split(", ")
+ except:
+ deps = []
+
+ deps = [dependency.match(dep).groups() for dep in deps]
+ deps = [(replace_deps[name] if name in replace_deps else name, version) for name, version in deps]
+ deps = ["'" + convertName(name) + convertVersionSpecifier(version) + "'" for name, version in deps if name]
+ deps2 = []
+ for dep in deps:
+ if not dep in deps2:
+ deps2.append(dep)
+ deps = "(" + " ".join(deps2) + ")"
+
+ special_op = special_ops[info["Package"]] if info["Package"] in special_ops else ""
+
+ desc = info["Description"].split("\n")
+ if len(desc) > 2:
+ desc = desc[0]
+ else:
+ desc = " ".join(x.strip() for x in desc)
+
+ ret = package_header_tpl.format(DEPENDS=deps, NAME=name, ARCH=arch, SPECIAL_OPS=special_op, DESC=quote(desc), **info)
+ if special_op:
+ ret += "\n\t" + special_op + "\n"
+ ret += package_footer
+
+ return ret
+
+with gzip.open("src/amdgpu-pro-driver/Packages.gz", "r") as f:
+ package_list=[]
+
+ for info in deb822.Packages.iter_paragraphs(f):
+ if info["Filename"].startswith("./dkms/dst/amdgpu-pro/"):
+ continue
+
+ if not info["Package"] in deb_archs:
+ deb_archs[info["Package"]] = set()
+
+ deb_archs[info["Package"]].add(info["Architecture"])
+
+ if info["Architecture"] == "i386":
+ name = "lib32-" + info["Package"]
+ else:
+ name = info["Package"]
+
+ package_list.append(name)
+
+ print(header_tpl.format(PACKAGES="(" + " ".join(package_list) + ")"))
+
+ f.seek(0)
+
+ for info in deb822.Packages.iter_paragraphs(f):
+ if info["Filename"].startswith("./dkms/dst/amdgpu-pro/"):
+ continue
+
+ print(convertPackage(info))
+