forked from semios/semios-packages
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ea675e4c5e |
+4
-37
@@ -1,8 +1,6 @@
|
|||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import subprocess
|
import subprocess
|
||||||
import tempfile
|
|
||||||
import shutil
|
|
||||||
|
|
||||||
from lib import common
|
from lib import common
|
||||||
|
|
||||||
@@ -15,8 +13,6 @@ def _is_elf(filepath):
|
|||||||
|
|
||||||
|
|
||||||
def autostrip(composer):
|
def autostrip(composer):
|
||||||
processed_inodes = {}
|
|
||||||
|
|
||||||
for ent in common.treedir(composer.workdir):
|
for ent in common.treedir(composer.workdir):
|
||||||
if not ent.is_file(follow_symlinks=False):
|
if not ent.is_file(follow_symlinks=False):
|
||||||
continue
|
continue
|
||||||
@@ -24,36 +20,7 @@ def autostrip(composer):
|
|||||||
continue
|
continue
|
||||||
if not _is_elf(ent.path):
|
if not _is_elf(ent.path):
|
||||||
continue
|
continue
|
||||||
|
oldperm = stat.S_IMODE(os.stat(ent.path).st_mode)
|
||||||
stat_info = os.stat(ent.path)
|
os.chmod(ent.path, 0o777)
|
||||||
inode_key = (stat_info.st_dev, stat_info.st_ino)
|
subprocess.run([strip, ent.path], check=True)
|
||||||
if inode_key in processed_inodes:
|
os.chmod(ent.path, oldperm)
|
||||||
continue
|
|
||||||
processed_inodes[inode_key] = True
|
|
||||||
|
|
||||||
oldperm = stat.S_IMODE(stat_info.st_mode)
|
|
||||||
|
|
||||||
try:
|
|
||||||
with tempfile.NamedTemporaryFile(mode='wb', delete=False) as tmp_file:
|
|
||||||
tmp_path = tmp_file.name
|
|
||||||
shutil.copy2(ent.path, tmp_path)
|
|
||||||
os.chmod(tmp_path, 0o777)
|
|
||||||
|
|
||||||
subprocess.run([strip, tmp_path], check=True)
|
|
||||||
|
|
||||||
with open(tmp_path, 'rb') as tmp_file:
|
|
||||||
stripped_data = tmp_file.read()
|
|
||||||
|
|
||||||
with open(ent.path, 'r+b') as original_file:
|
|
||||||
original_file.truncate(0)
|
|
||||||
original_file.write(stripped_data)
|
|
||||||
original_file.flush()
|
|
||||||
os.fsync(original_file.fileno())
|
|
||||||
|
|
||||||
os.chmod(ent.path, oldperm)
|
|
||||||
os.unlink(tmp_path)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
if 'tmp_path' in locals() and os.path.exists(tmp_path):
|
|
||||||
os.unlink(tmp_path)
|
|
||||||
raise RuntimeError(f"Failed to strip {ent.path}: {e}") from e
|
|
||||||
|
|||||||
+6
-6
@@ -4,16 +4,16 @@ from . import packie
|
|||||||
|
|
||||||
all: dict[str, dict[str, str]] = {
|
all: dict[str, dict[str, str]] = {
|
||||||
"aarch64-semios-linux": {
|
"aarch64-semios-linux": {
|
||||||
"CC": "clang -target aarch64-unknown-linux-musl",
|
"CC": "clang -target aarch64-semios-linux-musl",
|
||||||
"CXX": "clang++ -target aarch64-unknown-linux-musl",
|
"CXX": "clang++ -target aarch64-semios-linux-musl",
|
||||||
},
|
},
|
||||||
"x86_64-semios-linux": {
|
"x86_64-semios-linux": {
|
||||||
"CC": "clang -target x86_64-unknown-linux-musl",
|
"CC": "clang -target x86_64-semios-linux-musl",
|
||||||
"CXX": "clang++ -target x86_64-unknown-linux-musl",
|
"CXX": "clang++ -target x86_64-semios-linux-musl",
|
||||||
},
|
},
|
||||||
"riscv64-semios-linux": {
|
"riscv64-semios-linux": {
|
||||||
"CC": "clang -target riscv64-unknown-linux-musl",
|
"CC": "clang -target riscv64-semios-linux-musl",
|
||||||
"CXX": "clang++ -target riscv64-unknown-linux-musl",
|
"CXX": "clang++ -target riscv64-semios-linux-musl",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
_target: str = packie.host_arch()
|
_target: str = packie.host_arch()
|
||||||
|
|||||||
+24
-15
@@ -13,11 +13,8 @@ BASE_REQUIREMENTS = [
|
|||||||
# Packages for running `semios-packages` scripts
|
# Packages for running `semios-packages` scripts
|
||||||
"python",
|
"python",
|
||||||
"packie",
|
"packie",
|
||||||
"zstd",
|
|
||||||
"libarchive-tools",
|
|
||||||
# Packages for building packages that require patching
|
|
||||||
"patch",
|
"patch",
|
||||||
# Packages for downloading various formats of tarballs
|
"zstd",
|
||||||
"libz-ng",
|
"libz-ng",
|
||||||
"liblzma",
|
"liblzma",
|
||||||
"libbzip2",
|
"libbzip2",
|
||||||
@@ -95,20 +92,32 @@ def enter_build_env(root: str, cmd: list[str], chdir: str = "/"):
|
|||||||
subprocess.run(
|
subprocess.run(
|
||||||
[
|
[
|
||||||
"bwrap",
|
"bwrap",
|
||||||
"--bind", root, "/",
|
"--bind",
|
||||||
|
root,
|
||||||
|
"/",
|
||||||
"--unshare-pid",
|
"--unshare-pid",
|
||||||
"--unshare-user",
|
"--unshare-user",
|
||||||
"--uid", "0",
|
"--uid",
|
||||||
"--gid", "0",
|
"0",
|
||||||
"--dev", "/dev",
|
"--gid",
|
||||||
"--bind", "/sys", "/sys",
|
"0",
|
||||||
"--proc", "/proc",
|
"--dev",
|
||||||
|
"/dev",
|
||||||
|
"--bind",
|
||||||
|
"/sys",
|
||||||
|
"/sys",
|
||||||
|
"--proc",
|
||||||
|
"/proc",
|
||||||
"--clearenv",
|
"--clearenv",
|
||||||
"--setenv", "HOME", "/home/root",
|
"--setenv",
|
||||||
"--setenv", "PATH", "/bin",
|
"HOME",
|
||||||
"--setenv", "SEMIOS_PKGBUILD_IN_ATOMIC", "1",
|
"/home/root",
|
||||||
"--setenv", "USER", "root",
|
"--setenv",
|
||||||
"--setenv", "LOGNAME", "root",
|
"PATH",
|
||||||
|
"/bin",
|
||||||
|
"--setenv",
|
||||||
|
"SEMIOS_PKGBUILD_IN_ATOMIC",
|
||||||
|
"1",
|
||||||
"--chdir",
|
"--chdir",
|
||||||
chdir,
|
chdir,
|
||||||
]
|
]
|
||||||
|
|||||||
+10
-11
@@ -4,10 +4,17 @@ import shutil
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
if sys.version_info >= (3, 14):
|
||||||
|
_archive_format = "zstdtar"
|
||||||
|
_archive_suffix = ".tar.zst"
|
||||||
|
else:
|
||||||
|
_archive_format = "gztar"
|
||||||
|
_archive_suffix = ".tar.gz"
|
||||||
|
|
||||||
|
|
||||||
class PkgComposer:
|
class PkgComposer:
|
||||||
def __init__(self, pkgfile: str):
|
def __init__(self, pkgfile: str):
|
||||||
self.pkgfile = os.path.abspath(pkgfile)
|
self.pkgfile = pkgfile
|
||||||
|
|
||||||
def setworkdir(self, workdir: str):
|
def setworkdir(self, workdir: str):
|
||||||
self.workdir = workdir
|
self.workdir = workdir
|
||||||
@@ -26,16 +33,8 @@ class PkgComposer:
|
|||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
def compose(self):
|
def compose(self):
|
||||||
subprocess.run(
|
shutil.make_archive(self.pkgfile, _archive_format, self.workdir)
|
||||||
[
|
shutil.move(self.pkgfile + _archive_suffix, self.pkgfile)
|
||||||
"tar", "cpf", f"{self.pkgfile}.tar",
|
|
||||||
"-C", self.workdir,
|
|
||||||
"--numeric-owner",
|
|
||||||
".",
|
|
||||||
],
|
|
||||||
check=True,
|
|
||||||
)
|
|
||||||
subprocess.run(["zstd", "--rm", "-f", f"{self.pkgfile}.tar", "-o", self.pkgfile], check=True)
|
|
||||||
|
|
||||||
def makedir(self, name: str):
|
def makedir(self, name: str):
|
||||||
os.mkdir(f"{self.workdir}/bundle/{name}")
|
os.mkdir(f"{self.workdir}/bundle/{name}")
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
import os
|
|
||||||
import shutil
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from . import make, arch
|
|
||||||
|
|
||||||
|
|
||||||
PY3_VERSION = "3.14"
|
|
||||||
|
|
||||||
|
|
||||||
def build():
|
|
||||||
subprocess.run(["python3", "-m", "build", "."], check=True)
|
|
||||||
|
|
||||||
def install():
|
|
||||||
if os.path.exists("../pyinstall"):
|
|
||||||
shutil.rmtree("../pyinstall")
|
|
||||||
for i in os.listdir("dist"):
|
|
||||||
if not i.endswith(".whl"):
|
|
||||||
continue
|
|
||||||
subprocess.run(["python3", "-m", "installer", f"--destdir=../pyinstall", f"dist/{i}"], check=True)
|
|
||||||
os.chdir("../pyinstall")
|
|
||||||
while len(os.listdir(".")) == 1:
|
|
||||||
os.chdir(os.listdir(".")[0])
|
|
||||||
|
|
||||||
def version(s: str):
|
|
||||||
make.version(f"{s}+python{PY3_VERSION}")
|
|
||||||
|
|
||||||
def _depcommon(s: str):
|
|
||||||
if s == "python":
|
|
||||||
return f"python (~{PY3_VERSION}.0) @{arch.get_target()}"
|
|
||||||
elif ".py" in s:
|
|
||||||
if ")" in s:
|
|
||||||
return s.replace(")", f", +python{PY3_VERSION})")
|
|
||||||
else:
|
|
||||||
return s.replace(".py", f" (+python{PY3_VERSION})")
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def builddep(s: str):
|
|
||||||
if s == "$shortcut":
|
|
||||||
builddep("python")
|
|
||||||
builddep("build.py")
|
|
||||||
builddep("installer.py")
|
|
||||||
elif _depcommon(s):
|
|
||||||
make.builddep(_depcommon(s))
|
|
||||||
else:
|
|
||||||
raise RuntimeError("unrecognized python dep")
|
|
||||||
|
|
||||||
def dep(s: str):
|
|
||||||
if _depcommon(s):
|
|
||||||
make.dep(_depcommon(s))
|
|
||||||
else:
|
|
||||||
raise RuntimeError("unrecognized python dep")
|
|
||||||
|
|
||||||
def _auto_pack(composer):
|
|
||||||
base = f"lib/python{PY3_VERSION}/site-packages"
|
|
||||||
composer.makedirs(base)
|
|
||||||
for i in os.listdir("."):
|
|
||||||
composer.add_dir(i, f"{base}/{i}")
|
|
||||||
|
|
||||||
def use_auto_pack():
|
|
||||||
make.on_pack(_auto_pack)
|
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
from lib.make import *
|
||||||
|
from lib import cpp
|
||||||
|
|
||||||
|
|
||||||
|
version("1.7.0")
|
||||||
|
description("The GL Vendor-Neutral Dispatch library")
|
||||||
|
maintainer("sisungo <[email protected]>")
|
||||||
|
source_git("https://gitlab.freedesktop.org/glvnd/libglvnd.git", "v1.7.0")
|
||||||
|
|
||||||
|
builddep("shortcut/meson")
|
||||||
|
builddep("shortcut/c")
|
||||||
|
builddep("libexpat")
|
||||||
|
|
||||||
|
|
||||||
|
def build():
|
||||||
|
cpp.meson_setup([
|
||||||
|
"-Degl=true",
|
||||||
|
"-Dentrypoint-patching=disabled",
|
||||||
|
|
||||||
|
# X11 Stuff
|
||||||
|
# We don't have X11 yet, so leave them disabled
|
||||||
|
"-Dx11=disabled",
|
||||||
|
"-Dglx=disabled",
|
||||||
|
])
|
||||||
|
cpp.meson_compile()
|
||||||
|
cpp.meson_install()
|
||||||
|
|
||||||
|
on_build(build)
|
||||||
|
|
||||||
|
|
||||||
|
def fix_pc(path, name):
|
||||||
|
with open(path, 'r') as file:
|
||||||
|
content = file.read()
|
||||||
|
devpkgname = f"{name}-dev"
|
||||||
|
content = content.replace("prefix=/usr/local", f"prefix=/")
|
||||||
|
content = content.replace("includedir=${prefix}/include", f"includedir={get_prefix(devpkgname)}/include")
|
||||||
|
content = content.replace("libdir=${prefix}/lib", f"libdir={get_prefix(name)}/lib")
|
||||||
|
with open(path, 'wt+') as file:
|
||||||
|
file.write(content)
|
||||||
|
|
||||||
|
def pack_librun(composer, libname):
|
||||||
|
composer.makedir("lib")
|
||||||
|
for i in os.listdir("lib"):
|
||||||
|
if ".so" in i and i.startswith(libname):
|
||||||
|
composer.addfile(f"lib/{i}", f"lib/{i}")
|
||||||
|
|
||||||
|
def pack_libdev(composer, pkgname, pkgconfname, includenames):
|
||||||
|
composer.makedirs("lib/pkgconfig")
|
||||||
|
for i in os.listdir("lib/pkgconfig"):
|
||||||
|
if pkgconfname == i:
|
||||||
|
composer.addfile(f"lib/pkgconfig/{i}", f"lib/pkgconfig/{i}")
|
||||||
|
fix_pc(f"{composer.workdir}/bundle/lib/pkgconfig/{i}", pkgname)
|
||||||
|
composer.makedir("include")
|
||||||
|
for i in includenames:
|
||||||
|
composer.add_dir(f"include/{i}", f"include/{i}")
|
||||||
|
|
||||||
|
|
||||||
|
package("libgldispatch")
|
||||||
|
dep("semi-libc @same-arch")
|
||||||
|
on_pack(lambda composer: pack_librun(composer, "libGLdispatch"))
|
||||||
|
|
||||||
|
package("libgldispatch-dev")
|
||||||
|
dep("semi-libc @same-arch")
|
||||||
|
on_pack(lambda composer: pack_libdev(composer, "libgldispatch", "libglvnd.pc", ["glvnd", "KHR"]))
|
||||||
|
|
||||||
|
package("libegl")
|
||||||
|
dep("libgldispatch (same)")
|
||||||
|
on_pack(lambda composer: pack_librun(composer, "libEGL"))
|
||||||
|
|
||||||
|
package("libegl-dev")
|
||||||
|
dep("libegl (same)")
|
||||||
|
on_pack(lambda composer: pack_libdev(composer, "libegl", "egl.pc", ["EGL"]))
|
||||||
|
|
||||||
|
package("libglesv1-cm")
|
||||||
|
dep("libgldispatch (same)")
|
||||||
|
on_pack(lambda composer: pack_librun(composer, "libGLESv1_CM"))
|
||||||
|
|
||||||
|
package("libglesv1-cm-dev")
|
||||||
|
dep("libglesv1-cm (same)")
|
||||||
|
on_pack(lambda composer: pack_libdev(composer, "libglesv1-cm", "glesv1_cm.pc", ["GLES"]))
|
||||||
|
|
||||||
|
package("libglesv2")
|
||||||
|
dep("libgldispatch (same)")
|
||||||
|
on_pack(lambda composer: pack_librun(composer, "libGLESv2"))
|
||||||
|
|
||||||
|
package("libglesv2-dev")
|
||||||
|
dep("libglesv2 (same)")
|
||||||
|
on_pack(lambda composer: pack_libdev(composer, "libglesv2", "glesv2.pc", ["GLES2", "GLES3"]))
|
||||||
|
|
||||||
|
package("libopengl")
|
||||||
|
dep("libgldispatch (same)")
|
||||||
|
on_pack(lambda composer: pack_librun(composer, "libOpenGL"))
|
||||||
|
|
||||||
|
package("libopengl-dev")
|
||||||
|
dep("libopengl (same)")
|
||||||
|
on_pack(lambda composer: pack_libdev(composer, "libopengl", "opengl.pc", ["GL"]))
|
||||||
@@ -28,7 +28,7 @@ srcdir = None
|
|||||||
packname = None
|
packname = None
|
||||||
|
|
||||||
def llvm_host_triple():
|
def llvm_host_triple():
|
||||||
return arch.get_target().replace("-semios-linux", "-unknown-linux-musl")
|
return arch.get_target().replace("-semios-linux", "-semios-linux-musl")
|
||||||
|
|
||||||
def cmake(sourcedir, args):
|
def cmake(sourcedir, args):
|
||||||
builddir = os.getcwd() + f"/../_build_{sourcedir}"
|
builddir = os.getcwd() + f"/../_build_{sourcedir}"
|
||||||
@@ -76,7 +76,7 @@ def auto_pack_dev(composer, name, devbins=[], extdirs=["lib/cmake"]):
|
|||||||
composer.makedir("lib")
|
composer.makedir("lib")
|
||||||
for i in os.listdir("lib"):
|
for i in os.listdir("lib"):
|
||||||
prefix = None
|
prefix = None
|
||||||
if os.path.isdir(f"lib/{i}") and f"lib/{i}" in extdirs:
|
if os.path.isdir(i) and f"lib/{i}" in extdirs:
|
||||||
composer.add_dir(f"lib/{i}", f"lib/{i}")
|
composer.add_dir(f"lib/{i}", f"lib/{i}")
|
||||||
elif ".so" in i:
|
elif ".so" in i:
|
||||||
prefix = get_prefix(f"lib{name}")
|
prefix = get_prefix(f"lib{name}")
|
||||||
@@ -132,7 +132,7 @@ def build_clang():
|
|||||||
"-DCLANG_DEFAULT_CXX_STDLIB=libc++",
|
"-DCLANG_DEFAULT_CXX_STDLIB=libc++",
|
||||||
"-DCLANG_DEFAULT_RTLIB=compiler-rt",
|
"-DCLANG_DEFAULT_RTLIB=compiler-rt",
|
||||||
"-DLLVM_INCLUDE_TESTS=OFF",
|
"-DLLVM_INCLUDE_TESTS=OFF",
|
||||||
f"-DC_INCLUDE_DIRS=/lib/{arch.get_target()}/include:{get_prefix('clang')}/lib/clang/{pkgver_major}/include",
|
f"-DC_INCLUDE_DIRS=/lib/{arch.get_target()}/include",
|
||||||
]
|
]
|
||||||
cmake("clang", import_llvm() + options)
|
cmake("clang", import_llvm() + options)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user