forked from semios/semios-packages
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
797459750f | ||
|
|
aaae8fc7af | ||
|
|
ec67faee81 | ||
|
|
b94159b492 | ||
|
|
4c6c0a2ecc |
+1
-1
@@ -21,7 +21,7 @@ def make_install(rem: list[str] | None = None, chdir: bool = True):
|
||||
|
||||
|
||||
def _do_auto_pack(pc: pkgcomposer.PkgComposer, srcdir: str, dstdir: str, filter):
|
||||
pc.makedir(srcdir)
|
||||
pc.makedir(dstdir)
|
||||
with os.scandir(srcdir) as entries:
|
||||
for ent in entries:
|
||||
if filter(ent):
|
||||
|
||||
@@ -59,3 +59,7 @@ def block_hook(hook: str):
|
||||
|
||||
def source_url(url: str):
|
||||
sources.source_url(url)
|
||||
|
||||
|
||||
def source_git(url: str, branch: str | None = None):
|
||||
sources.source_git(url, branch)
|
||||
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from . import arch, make, pkgcomposer
|
||||
|
||||
|
||||
def _rust_triple(semios: str) -> str:
|
||||
return semios.replace("-semios-linux", "-unknown-linux-musl")
|
||||
|
||||
|
||||
def build(rem: list[str] = []):
|
||||
cmdline = [
|
||||
"cargo",
|
||||
"build",
|
||||
"--release",
|
||||
"--target",
|
||||
_rust_triple(arch.get_target()),
|
||||
] + rem
|
||||
os.environ["RUSTFLAGS"] = (
|
||||
os.environ.get("RUSTFLAGS", "") + " -C target-feature=-crt-static"
|
||||
)
|
||||
subprocess.run(cmdline)
|
||||
|
||||
|
||||
def _do_auto_pack(pc: pkgcomposer.PkgComposer, srcdir: str, dstdir: str, filter):
|
||||
pc.makedir(dstdir)
|
||||
with os.scandir(srcdir) as entries:
|
||||
for ent in entries:
|
||||
if filter(ent):
|
||||
if ent.is_dir(follow_symlinks=False):
|
||||
pc.makedir(f"{dstdir}/{ent.name}")
|
||||
elif ent.is_file(follow_symlinks=False):
|
||||
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
||||
elif ent.is_symlink() and not os.path.isabs(os.readlink(ent.path)):
|
||||
pc.addfile(ent.path, f"{dstdir}/{ent.name}")
|
||||
|
||||
|
||||
def _autopack_filter_lib(ent) -> bool:
|
||||
if ent.is_dir(follow_symlinks=False):
|
||||
return False
|
||||
if ent.name.endswith(".so"):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def _autopack_filter_bin(ent) -> bool:
|
||||
return os.access(ent.path, os.X_OK) and ent.is_file(follow_symlinks=False)
|
||||
|
||||
|
||||
def _auto_pack(profiles: list[str], pc: pkgcomposer.PkgComposer):
|
||||
target_dir = f"target/{_rust_triple(arch.get_target())}/release"
|
||||
if "lib" in profiles:
|
||||
_do_auto_pack(pc, target_dir, "lib", _autopack_filter_lib)
|
||||
if "bin" in profiles:
|
||||
_do_auto_pack(pc, target_dir, "bin", _autopack_filter_bin)
|
||||
|
||||
|
||||
def use_auto_pack(profiles: list[str]):
|
||||
make.on_pack(lambda pc: _auto_pack(profiles, pc))
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import urllib.parse
|
||||
@@ -109,3 +110,20 @@ def source_url(url: str):
|
||||
tar.extractall(extract_dir)
|
||||
with open("./target/sources.tag", "wt+") as file:
|
||||
file.write(sources_dir)
|
||||
|
||||
|
||||
def _git_repo_name(url: str) -> str:
|
||||
return url.split("/")[-1].replace(".git", "")
|
||||
|
||||
|
||||
def source_git(url: str, branch: str | None = None):
|
||||
source_path = os.getcwd() + "/target/" + _git_repo_name(url)
|
||||
if os.path.exists("./target/sources.tag"):
|
||||
return
|
||||
cmdline = ["git", "clone", "--depth=1"]
|
||||
if branch:
|
||||
cmdline += ["-b", branch]
|
||||
cmdline += [url, source_path]
|
||||
subprocess.run(cmdline, check=True)
|
||||
with open("./target/sources.tag", "wt+") as file:
|
||||
file.write(source_path)
|
||||
|
||||
Reference in New Issue
Block a user