Compare commits

..
13 Commits
Author SHA1 Message Date
sisungo d8007af248 feat: add package ninja
Signed-off-by: sisungo <[email protected]>
2026-06-10 05:10:54 +08:00
sisungo e8c3ebafc7 Merge pull request 'feat: add package gnu-make' (#7) from sisungo/semios-packages:gnu-make into master
Reviewed-on: semios/semios-packages#7
2026-06-10 18:30:08 +08:00
sisungo d159cd0b5b Merge pull request 'feat: add hooks/autopatch' (#6) from sisungo/semios-packages:patches into master
Reviewed-on: semios/semios-packages#6
2026-06-10 18:29:41 +08:00
sisungo 5b4036abd2 Merge pull request 'feat: add package mksh' (#5) from sisungo/semios-packages:mksh into master
Reviewed-on: semios/semios-packages#5
2026-06-10 16:13:40 +08:00
sisungo daa4312ece Merge pull request 'feat (lib): add source_git' (#4) from sisungo/semios-packages:source_git into master
Reviewed-on: semios/semios-packages#4
2026-06-10 16:13:26 +08:00
sisungo aaae8fc7af Merge pull request 'feat: add package coreutils' (#3) from sisungo/semios-packages:coreutils into master
Reviewed-on: semios/semios-packages#3
2026-06-10 12:37:48 +08:00
sisungo ec67faee81 Merge pull request 'feat: add rust packing methods' (#2) from sisungo/semios-packages:rust into master
Reviewed-on: semios/semios-packages#2
2026-06-10 12:37:33 +08:00
sisungo ff75acbb20 feat: add package gnu-make
Signed-off-by: sisungo <[email protected]>
2026-06-10 04:54:22 +08:00
sisungo bf52025629 feat: add hooks/autopatch
Signed-off-by: sisungo <[email protected]>
2026-06-10 04:53:01 +08:00
sisungo 1a2fa464c6 feat: add package mksh
Signed-off-by: sisungo <[email protected]>
2026-06-10 03:08:11 +08:00
sisungo 797459750f feat (lib): add source_git
Signed-off-by: sisungo <[email protected]>
2026-06-10 03:06:21 +08:00
sisungo b94159b492 feat: add rust packing methods
Signed-off-by: sisungo <[email protected]>
2026-06-10 00:29:19 +08:00
sisungo 4c6c0a2ecc Merge pull request 'fix (lib/cpp): auto-pack included absolute symlinks' (#1) from sisungo/semios-packages:master into master
Reviewed-on: semios/semios-packages#1
2026-06-09 21:48:59 +08:00
11 changed files with 230 additions and 2 deletions
+6 -1
View File
@@ -1,9 +1,14 @@
from typing import Callable, TypeAlias
from . import autostrip
from . import autopatch, autostrip
PreBuild: TypeAlias = Callable[[], None]
PostBuild: TypeAlias = Callable[[], None]
pre_build: dict[str, PreBuild] = {
"autopatch": autopatch.autopatch,
}
post_build: dict[str, PostBuild] = {
"autostrip": autostrip.autostrip,
}
+29
View File
@@ -0,0 +1,29 @@
import os
import subprocess
import lib.sources as sources
def autopatch():
if not os.path.exists("patches"):
return
target_dir = os.getcwd() + "/target"
source_dir = sources.sources_dir_name()
patches_tag_file = f"{target_dir}/patches.tag"
patches_dir = os.getcwd() + "/patches"
patches = os.listdir(patches_dir)
patches.sort()
os.chdir(source_dir)
if not os.path.exists(patches_tag_file):
open(patches_tag_file, "+w").close()
for i in patches:
with open(patches_tag_file, "r") as file:
if i + "\n" in file.readlines():
continue
with open(f"{patches_dir}/{i}", "r") as file:
subprocess.run(["patch", "-p1"], stdin=file)
with open(patches_tag_file, "+a") as file:
file.write(i + "\n")
+6 -1
View File
@@ -21,7 +21,12 @@ 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)
if not os.path.exists(srcdir):
return
try:
pc.makedir(dstdir)
except Exception:
pass
with os.scandir(srcdir) as entries:
for ent in entries:
if filter(ent):
+4
View File
@@ -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
View File
@@ -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))
+18
View File
@@ -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)
@@ -0,0 +1,36 @@
--- a/lib/fnmatch.c
+++ b/lib/fnmatch.c
@@ -120,9 +120,6 @@
/* Avoid depending on library functions or files
whose names are inconsistent. */
-# if !defined _LIBC && !defined getenv
-extern char *getenv ();
-# endif
# ifndef errno
extern int errno;
--- a/src/getopt.c
+++ b/src/getopt.c
@@ -202,7 +202,7 @@ static char *posixly_correct;
whose names are inconsistent. */
#ifndef getenv
-extern char *getenv ();
+extern char *getenv (const char *);
#endif
static char *
--- a/src/getopt.h
+++ b/src/getopt.h
@@ -102,7 +102,7 @@ struct option
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
+extern int getopt (int, char * const*, const char *);
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
const struct option *longopts, int *longind);
+17
View File
@@ -0,0 +1,17 @@
import lib.cpp as cpp
from lib.make import *
version("4.4.1")
source_url("https://ftp.gnu.org/gnu/make/make-4.4.1.tar.gz")
def build():
cpp.configure(["--prefix=/"])
cpp.make()
cpp.make_install()
on_build(build)
package("gnu-make")
cpp.use_auto_pack(["bin"])
+22
View File
@@ -0,0 +1,22 @@
import os
from lib.make import *
version("1.59.2")
source_git("https://github.com/mirabilos/mksh-cvs2git.git", "mksh-R59c")
def build():
os.system("sh ./Build.sh")
on_build(build)
def pack_mksh(composer):
composer.makedir("bin")
composer.addfile("mksh", "bin/mksh")
package("mksh")
on_pack(pack_mksh)
+23
View File
@@ -0,0 +1,23 @@
import os
import lib.cpp as cpp
from lib.make import *
version("1.13.2")
source_url("https://github.com/ninja-build/ninja/archive/refs/tags/v1.13.2.tar.gz")
def build():
os.system("./configure.py --bootstrap")
on_build(build)
def pack_ninja(composer):
composer.makedir("bin")
composer.addfile("ninja", "bin/ninja")
package("ninja")
on_pack(pack_ninja)
+9
View File
@@ -46,6 +46,13 @@ def run_build_package(package: str):
print(f"Architecture {lib.arch.get_target()} is not supported for this package")
exit(1)
# Run `pre_build` hooks
for n in hooks.pre_build.keys():
if n in lib.make._blocked_hooks:
continue
hooks.pre_build[n]()
os.chdir(package_dir)
# Build the package
if lib.make._on_build:
os.chdir(lib.sources.sources_dir_name())
@@ -54,10 +61,12 @@ def run_build_package(package: str):
print("on_build(): Not defined")
# Run `post_build` hooks
post_build_dir = os.getcwd()
for n in hooks.post_build.keys():
if n in lib.make._blocked_hooks:
continue
hooks.post_build[n]()
os.chdir(post_build_dir)
# Pack packages
for pkgname in lib.make._pkginfo.keys():