mag

a binary package manager in one C file: apk and pacman repos, CRUX, Void and Exherbo ports
git clone https://github.com/tortr-rs/mag
Log | Files | Refs | README | LICENSE

commit d96fd35ea32345d6c74c6c5c77a44613feabce6b
parent 8a630e3c1c63ddb3a8c6cb6afcf8e96b8be0ea60
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Sat, 14 Nov 2026 14:38:11 +0000

mag: PKG_OPTIONS and /etc/mag.conf (JOBS, flags, default options), PROVIDES, includes relative to the including file, .CURDIR, root-aware build env

Diffstat:
Mmag.c | 150++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
Arepo/PROVIDES | 39+++++++++++++++++++++++++++++++++++++++
Mrepo/app-arch/bzip2 | 2+-
Mrepo/app-arch/lz4 | 2+-
Mrepo/app-arch/xz | 2+-
Mrepo/app-arch/zstd | 2+-
Mrepo/app-shells/dash | 2+-
Mrepo/app-shells/oksh | 2+-
Mrepo/dev-build/bc | 2+-
Mrepo/dev-build/byacc | 2+-
Mrepo/dev-build/gmake | 2+-
Mrepo/dev-build/m4 | 2+-
Mrepo/dev-build/pkgconf | 2+-
Mrepo/dev-build/samurai | 2+-
Mrepo/dev-lang/perl | 2+-
Mrepo/dev-libs/expat | 2+-
Mrepo/dev-libs/libffi | 2+-
Mrepo/dev-libs/libressl | 2+-
Mrepo/dev-libs/netbsd-curses | 6+++++-
Mrepo/dev-libs/pcre2 | 2+-
Mrepo/net-libs/libnl | 2+-
Mrepo/net-misc/dhcpcd | 2+-
Mrepo/sys-apps/dinit | 2+-
Mrepo/sys-apps/util-linux | 2+-
Mrepo/sys-boot/limine | 2+-
Mrepo/sys-fs/dosfstools | 2+-
Mtests/run.sh | 28++++++++++++++++++++++++++++
27 files changed, 233 insertions(+), 36 deletions(-)

diff --git a/mag.c b/mag.c @@ -254,7 +254,7 @@ static char *sha512_file(const char *path) /* ---- recipes ---- */ struct recipe { - char *id, *file, *dir, *desc, *version, *url, *sha, *sha512, *steps, *cache; + char *id, *file, *dir, *desc, *version, *url, *sha, *sha512, *steps, *cache, *options; struct list deps, alts; }; @@ -342,6 +342,43 @@ static struct recipe *parse_recipe(const char *id, const char *file, const char * Makefile.common and of buildlink3.mk files (those are the dependencies). what is not understood is skipped, * and a package that needs the mk/ framework for more than that says so when it fails to build */ +/* PROVIDES in a repo: "pkgsrc/id our/id" per line, "-" drops the dependency, "needs pkgsrc/id our/id" adds one the Makefile leaves out. it is how a pkgsrc package gets our zlib and not a second one */ +static struct list prov_from, prov_to, need_for, need_dep; + +static void load_provides(const char *repo) +{ + char *f = fmt("%s/PROVIDES", repo), *text = slurp(f, NULL), *line, *next; + free(f); + if (!text) return; + for (line = text; line; line = next) { + char *sp; + next = strchr(line, '\n'); + if (next) *next++ = 0; + line = trim(line); + if (!*line || *line == '#') continue; + if (!strncmp(line, "needs ", 6)) { + char *a = trim(line + 6), *b = strpbrk(a, " \t"); + if (!b) continue; + *b = 0; + push(&need_for, xstrdup(a)); push(&need_dep, xstrdup(trim(b + 1))); + continue; + } + sp = strpbrk(line, " \t"); + if (!sp) continue; + *sp = 0; + push(&prov_from, xstrdup(line)); push(&prov_to, xstrdup(trim(sp + 1))); + } + free(text); +} + +static void dep_add(struct recipe *r, const char *id) +{ + int i; + for (i = 0; i < prov_from.n; i++) if (!strcmp(prov_from.v[i], id)) { id = prov_to.v[i]; break; } + if (!strcmp(id, "-") || !strncmp(id, "mk/", 3) || has(&r->deps, id)) return; + push(&r->deps, xstrdup(id)); +} + struct vars { char **k, **v; int n, cap; }; static const char *var_get(const struct vars *vs, const char *k) @@ -519,6 +556,67 @@ static int cond_eval(const struct vars *vs, const char *c) } } +/* PKG_OPTIONS, what bsd.options.mk works out in pkgsrc: the suggested options, then PKG_DEFAULT_OPTIONS, then the package's own variable, each word adding an option or, with a minus, taking it off */ +static void words_into(struct list *l, const char *text) +{ + char *c = xstrdup(text), *save, *w; + for (w = strtok_r(c, " \t", &save); w; w = strtok_r(NULL, " \t", &save)) push(l, xstrdup(w)); + free(c); +} +static void opts_apply(struct list *sel, const struct list *sup, const char *text) +{ + struct list ws = { 0 }; + int i, j; + words_into(&ws, text); + for (i = 0; i < ws.n; i++) { + const char *name = ws.v[i] + (ws.v[i][0] == '-'); + if (!has(sup, name)) continue; + if (ws.v[i][0] == '-') { for (j = 0; j < sel->n; j++) if (!strcmp(sel->v[j], name)) { memmove(sel->v + j, sel->v + j + 1, (sel->n - j - 1) * sizeof *sel->v); sel->n--; break; } } + else if (!has(sel, name)) push(sel, xstrdup(name)); + } +} +static void compute_options(struct vars *vs) +{ + struct list sup = { 0 }, sel = { 0 }, groups = { 0 }; + const char *g; + char *e, *vname, *out; + int i, j, len = 0; + static const char *const gvars[] = { "PKG_OPTIONS_OPTIONAL_GROUPS", "PKG_OPTIONS_REQUIRED_GROUPS", "PKG_OPTIONS_NONEMPTY_SETS", "PKG_OPTIONS_ONEOF_SETS", NULL }; + if ((g = var_get(vs, "PKG_SUPPORTED_OPTIONS"))) { e = expand(vs, g, 0); words_into(&sup, e); free(e); } + for (i = 0; gvars[i]; i++) if ((g = var_get(vs, gvars[i]))) { e = expand(vs, g, 0); words_into(&groups, e); free(e); } + for (i = 0; i < groups.n; i++) { + char *k = fmt("PKG_OPTIONS_GROUP.%s", groups.v[i]), *k2 = fmt("PKG_OPTIONS_SET.%s", groups.v[i]); + if ((g = var_get(vs, k))) { e = expand(vs, g, 0); words_into(&sup, e); free(e); } + if ((g = var_get(vs, k2))) { e = expand(vs, g, 0); words_into(&sup, e); free(e); } + free(k); free(k2); + } + if ((g = var_get(vs, "PKG_SUGGESTED_OPTIONS"))) { e = expand(vs, g, 0); opts_apply(&sel, &sup, e); free(e); } + if ((g = var_get(vs, "PKG_DEFAULT_OPTIONS"))) { e = expand(vs, g, 0); opts_apply(&sel, &sup, e); free(e); } + if ((g = var_get(vs, "PKG_OPTIONS_VAR"))) { + vname = expand(vs, g, 0); + if ((g = var_get(vs, vname))) { e = expand(vs, g, 0); opts_apply(&sel, &sup, e); free(e); } + free(vname); + } + for (j = 0; j < sel.n; j++) len += strlen(sel.v[j]) + 1; + out = xmalloc(len + 1); + out[0] = 0; + for (j = 0; j < sel.n; j++) { if (j) strcat(out, " "); strcat(out, sel.v[j]); } + var_set(vs, "PKG_OPTIONS", out); + free(out); +} + +/* /etc/mag.conf in the root: pkgsrc's mk.conf, plain VAR=value lines. JOBS, CFLAGS and the like for every build, PKG_DEFAULT_OPTIONS and PKG_OPTIONS.name for the pkgsrc packages */ +static struct vars conf; +static void read_makefile(struct vars *vs, const char *file, const char *pkgdir, const char *repo, struct list *bl, int depth); +static void load_conf(void) +{ + char *f = fmt("%s/etc/mag.conf", root); + struct list bl = { 0 }; + if (exists(f)) read_makefile(&conf, f, ".", ".", &bl, 0); + free(f); +} +static const char *conf_get(const char *k) { return var_get(&conf, k); } + static void read_makefile(struct vars *vs, const char *file, const char *pkgdir, const char *repo, struct list *bl, int depth) { char *text = slurp(file, NULL), *line, *next; @@ -573,12 +671,16 @@ static void read_makefile(struct vars *vs, const char *file, const char *pkgdir, char *sl = strstr(d, "/buildlink3.mk"); *sl = 0; if (!has(bl, d)) push(bl, d); else free(d); + } else if (strstr(inc, "mk/bsd.options.mk")) { + compute_options(vs); } else if (!strncmp(inc, "../../mk/", 9) || !strncmp(inc, "../mk/", 6)) { - /* the framework: not read */ - } else if (!strncmp(inc, "../../", 6) && strstr(inc, ".mk")) { - /* another package's .mk file: not read */ + /* the framework is not read, but what it stands for can be a dependency: PROVIDES says which */ + if (strstr(inc, ".buildlink3.mk")) { char *d = xstrdup(inc + 6); if (!has(bl, d)) push(bl, d); else free(d); } } else if (inc[0] != '/') { - char *p = fmt("%s/%s", pkgdir, inc); + char *here = xstrdup(file), *sl = strrchr(here, '/'), *p; + if (sl) *sl = 0; else strcpy(here, "."); + p = fmt("%s/%s", here, inc); + free(here); read_makefile(vs, p, pkgdir, repo, bl, depth + 1); free(p); } @@ -651,6 +753,8 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * int i; var_set(&vs, "OPSYS", "Linux"); var_set(&vs, "MACHINE_ARCH", "x86_64"); var_set(&vs, "LOWER_OPSYS", "linux"); var_set(&vs, "MACHINE_PLATFORM", "Linux-x86_64"); var_set(&vs, "PKGSRC_COMPILER", "clang"); var_set(&vs, "OPSYS_VERSION", "0"); + { int ci; for (ci = 0; ci < conf.n; ci++) var_set(&vs, conf.k[ci], conf.v[ci]); } + var_set(&vs, ".CURDIR", dir); var_set(&vs, "PKGSRCDIR", repo); load_sites(&vs, repo); read_makefile(&vs, mf, dir, repo, &bl, 0); free(mf); @@ -668,6 +772,7 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * var_set(&vs, "PKGBASE", dash ? (x = strndup(pkgname, dash - pkgname), x) : pkgname); var_set(&vs, "PKGVERSION", r->version); if (rev && *rev && strcmp(rev, "0")) { char *v2 = fmt("%snb%s", r->version, rev); free(r->version); r->version = v2; var_set(&vs, "PKGVERSION", v2); } } + if (var_get(&vs, "PKG_OPTIONS") && *var_get(&vs, "PKG_OPTIONS")) r->options = xstrdup(var_get(&vs, "PKG_OPTIONS")); r->desc = var_get(&vs, "COMMENT") ? expand(&vs, var_get(&vs, "COMMENT"), 0) : xstrdup(""); sufx = expand(&vs, var_get(&vs, "EXTRACT_SUFX") ? var_get(&vs, "EXTRACT_SUFX") : ".tar.gz", 0); distfiles = var_get(&vs, "DISTFILES") ? expand(&vs, var_get(&vs, "DISTFILES"), 0) : fmt("%s%s", distname, sufx); @@ -675,6 +780,7 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * dfile = xstrdup(distfiles); dfile[strcspn(dfile, " \t")] = 0; { char *c = strchr(dfile, ':'); if (c) *c = 0; } + if (var_get(&vs, "DISTINFO_FILE")) { char *e = expand(&vs, var_get(&vs, "DISTINFO_FILE"), 0); free(di); di = e[0] == '/' ? e : fmt("%s/%s", dir, e); if (di != e) free(e); } dtext = slurp(di, NULL); free(di); r->sha512 = distinfo_hash(dtext, "SHA512", dfile); @@ -730,19 +836,20 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * char *c = strstr(w, ":../../"); if (!c) continue; x = xstrdup(c + 7); - if (has(&r->deps, x)) free(x); else push(&r->deps, x); + dep_add(r, x); free(x); } free(s); } } - for (i = 0; i < bl.n; i++) if (!has(&r->deps, bl.v[i])) push(&r->deps, bl.v[i]); + for (i = 0; i < bl.n; i++) dep_add(r, bl.v[i]); + for (i = 0; i < need_for.n; i++) if (!strcmp(need_for.v[i], id)) dep_add(r, need_dep.v[i]); if ((g = var_get(&vs, "USE_TOOLS"))) { int j; s = expand(&vs, g, 0); for (w = strtok_r(s, " \t", &save); w; w = strtok_r(NULL, " \t", &save)) { char *c = strchr(w, ':'); if (c) *c = 0; - for (j = 0; tool_pkgs[j][0]; j++) if (!strcmp(w, tool_pkgs[j][0]) && !has(&r->deps, (char *)tool_pkgs[j][1])) push(&r->deps, xstrdup(tool_pkgs[j][1])); + for (j = 0; tool_pkgs[j][0]; j++) if (!strcmp(w, tool_pkgs[j][0])) dep_add(r, tool_pkgs[j][1]); } free(s); } @@ -758,6 +865,7 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * char *wrksrc = var_get(&vs, "WRKSRC") ? expand(&vs, var_get(&vs, "WRKSRC"), 0) : NULL; int gnu = var_get(&vs, "GNU_CONFIGURE") != NULL, cmake = var_get(&vs, "USE_CMAKE") != NULL, hasconfig = gnu || var_get(&vs, "HAS_CONFIGURE") != NULL; const char *make = "make"; + char *pd = var_get(&vs, "PATCHDIR") ? expand(&vs, var_get(&vs, "PATCHDIR"), 0) : xstrdup("patches"); size_t cap = 4096; (void)prefix_args; if ((g = var_get(&vs, "USE_TOOLS")) && strstr(g, "gmake")) make = "gmake"; @@ -768,15 +876,15 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * char *rel = strstr(wrksrc, distname); if (rel && rel[strlen(distname)] == '/') cmd += sprintf(cmd, "cd %s\n", rel + strlen(distname) + 1); } - cmd += sprintf(cmd, "for p in \"$RECIPE_DIR\"/patches/patch-*; do [ -f \"$p\" ] || continue; patch -p0 < \"$p\"; done\n"); + cmd += sprintf(cmd, "for p in \"$RECIPE_DIR\"/%s/patch-*; do [ -f \"$p\" ] || continue; patch -p0 < \"$p\"; done\n", pd); if (cmake) cmd += sprintf(cmd, "mkdir -p mag-build && cd mag-build && %s cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$PREFIX %s ..\nsamu\nDESTDIR=$DESTDIR samu install\n", cenv, cfg); else { if (hasconfig) cmd += sprintf(cmd, "%s ./configure --prefix=$PREFIX %s\n", cenv, cfg); cmd += sprintf(cmd, "%s %s -j$JOBS %s %s\n", menv, make, mflags, btarget); cmd += sprintf(cmd, "%s %s DESTDIR=$DESTDIR %s %s\n", menv, make, mflags, itarget); } - r->steps = steps; - free(cfg); free(mflags); free(menv); free(cenv); free(btarget); free(itarget); free(wrksrc); + r->steps = r->url ? steps : xstrdup("true\n"); + free(cfg); free(mflags); free(menv); free(cenv); free(btarget); free(itarget); free(wrksrc); free(pd); } free(dtext); free(distname); free(pkgname); free(sufx); free(distfiles); free(dfile); free(sites); (void)repo; @@ -1020,7 +1128,23 @@ static char *build(const struct recipe *r) setenv("VERSION", r->version, 1); setenv("RECIPE_DIR", r->dir, 1); setenv("PREFIX", prefix ? prefix : "/usr", 1); + if (*root) { + /* a root that is not / holds the dependencies: the compiler, the linker and the shell have to look there too */ + const char *pa = getenv("PATH"), *cp = getenv("CPPFLAGS"), *lf = getenv("LDFLAGS"); + char *v; + v = fmt("%s/usr/bin:%s/bin:%s", root, root, pa ? pa : "/usr/bin:/bin"); setenv("PATH", v, 1); free(v); + v = fmt("-I%s/usr/include %s", root, cp ? cp : ""); setenv("CPPFLAGS", v, 1); free(v); + v = fmt("-L%s/usr/lib %s", root, lf ? lf : ""); setenv("LDFLAGS", v, 1); free(v); + v = fmt("-I%s/usr/include %s", root, getenv("CFLAGS") ? getenv("CFLAGS") : "-O2"); setenv("CFLAGS", v, 1); free(v); + v = fmt("%s/usr/lib/pkgconfig:%s/usr/share/pkgconfig", root, root); setenv("PKG_CONFIG_PATH", v, 1); free(v); + } + if (!jobs) jobs = conf_get("JOBS") ? conf_get("JOBS") : conf_get("MAKE_JOBS"); setenv("JOBS", jobs ? jobs : "4", 1); + { + static const char *const fl[] = { "CFLAGS", "CXXFLAGS", "CPPFLAGS", "LDFLAGS", NULL }; + int fi; + for (fi = 0; fl[fi]; fi++) if (conf_get(fl[fi]) && !getenv(fl[fi])) setenv(fl[fi], conf_get(fl[fi]), 1); + } printf("==> building %s %s\n", r->id, r->version); av[0] = (char *)(sh ? sh : "/bin/sh"); av[1] = "-ec"; av[2] = r->steps; av[3] = NULL; if (run(av, src)) die("%s: the steps failed, left in %s", r->id, work); @@ -1337,6 +1461,7 @@ static int cmd_info(const char *name) printf("%s %s\n", r->id, r->version); if (*r->desc) printf(" %s\n", r->desc); if (r->url) printf(" source: %s\n", r->url); + if (r->options) printf(" options: %s\n", r->options); if (r->deps.n) { printf(" deps:"); for (i = 0; i < r->deps.n; i++) printf(" %s", r->deps.v[i]); putchar('\n'); } printf(" recipe: %s\n", r->file); if (v) printf(" installed: %s\n", v); else puts(" not installed"); @@ -1491,9 +1616,10 @@ int main(int argc, char **argv) for (s = rr; s; ) { char *e = strchr(s, ':'); if (e) *e++ = 0; - if (*s) { repos = xrealloc(repos, (nrepos + 1) * sizeof *repos); repos[nrepos++] = s; } + if (*s) { repos = xrealloc(repos, (nrepos + 1) * sizeof *repos); repos[nrepos++] = s; load_provides(s); } s = e; } + load_conf(); for (; i < argc && argv[i][0] == '-' && argv[i][1]; i++) { const char *o; if (!strcmp(argv[i], "--")) { i++; break; } diff --git a/repo/PROVIDES b/repo/PROVIDES @@ -0,0 +1,39 @@ +# pkgsrc package -> the one of this repo that stands for it. a "-" means nothing is needed +devel/zlib sys-libs/zlib +devel/gmake dev-build/gmake +devel/pkgconf dev-build/pkgconf +devel/pcre2 dev-libs/pcre2 +security/openssl dev-libs/libressl +security/libressl dev-libs/libressl +www/curl net-misc/curl +lang/perl5 dev-lang/perl +textproc/expat dev-libs/expat +devel/libffi dev-libs/libffi +devel/libevent dev-libs/libevent +archivers/xz app-arch/xz +archivers/zstd app-arch/zstd +archivers/lz4 app-arch/lz4 +archivers/bzip2 app-arch/bzip2 +archivers/libarchive app-arch/libarchive +devel/bison dev-build/bison +devel/m4 dev-build/m4 +devel/flex dev-build/flex +devel/byacc dev-build/byacc +devel/cmake dev-build/cmake +devel/samurai dev-build/samurai +math/bc dev-build/bc +shells/dash app-shells/dash +shells/oksh app-shells/oksh +sysutils/file sys-apps/file +net/dhcpcd net-misc/dhcpcd +converters/libiconv - +devel/gettext-lib - +devel/gettext-tools - +pkgtools/bootstrap-mk-files - +pkgtools/digest - +mk/curses.buildlink3.mk dev-libs/netbsd-curses +mk/termcap.buildlink3.mk dev-libs/netbsd-curses +mk/readline.buildlink3.mk - +mk/editline.buildlink3.mk - +needs shells/oksh dev-libs/netbsd-curses +needs editors/vim dev-libs/netbsd-curses diff --git a/repo/app-arch/bzip2 b/repo/app-arch/bzip2 @@ -2,7 +2,7 @@ desc: block-sorting compression version: 1.0.8 url: https://sourceware.org/pub/bzip2/bzip2-${version}.tar.gz sha256: ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269 -deps: sys-libs/musl +deps: steps: make -j$JOBS libbz2.a bzip2 bzip2recover make PREFIX=$DESTDIR$PREFIX install diff --git a/repo/app-arch/lz4 b/repo/app-arch/lz4 @@ -2,7 +2,7 @@ desc: extremely fast compression version: 1.11.1 url: https://github.com/lz4/lz4/releases/download/v${version}/lz4-${version}.tar.gz sha256: 683fed08a844ad012196381e40badf80c0bbe4962959761416d41c9e67d77ec7 -deps: sys-libs/musl +deps: steps: make -j$JOBS BUILD_SHARED=no prefix=$PREFIX make BUILD_SHARED=no prefix=$PREFIX DESTDIR=$DESTDIR install diff --git a/repo/app-arch/xz b/repo/app-arch/xz @@ -2,7 +2,7 @@ desc: LZMA compression, the xz tools and liblzma version: 5.8.4 url: https://github.com/tukaani-project/xz/releases/download/v${version}/xz-${version}.tar.xz sha256: 4ce24038fd4221e0d13bc1a2de7a4db56e90b92b3bf75321f6c14be73f65de4b -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared --disable-nls --disable-doc make -j$JOBS diff --git a/repo/app-arch/zstd b/repo/app-arch/zstd @@ -2,7 +2,7 @@ desc: fast compression from Facebook version: 1.5.7 url: https://github.com/facebook/zstd/releases/download/v${version}/zstd-${version}.tar.gz sha256: eb33e51f49a15e023950cd7825ca74a4a2b43db8354825ac24fc1b7ee09e6fa3 -deps: sys-libs/musl +deps: steps: make -j$JOBS prefix=$PREFIX HAVE_THREAD=0 HAVE_ZLIB=0 HAVE_LZMA=0 HAVE_LZ4=0 make prefix=$PREFIX DESTDIR=$DESTDIR install diff --git a/repo/app-shells/dash b/repo/app-shells/dash @@ -2,7 +2,7 @@ desc: the small POSIX shell, /bin/sh version: 0.5.13.6 url: http://gondor.apana.org.au/~herbert/dash/files/dash-${version}.tar.gz sha256: 26aac476f476cef391c600cb064417d82a5465d8fc7c4fd56158c276e86538c1 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared make -j$JOBS diff --git a/repo/app-shells/oksh b/repo/app-shells/oksh @@ -2,7 +2,7 @@ desc: the portable OpenBSD ksh, for interactive use version: 7.9 url: https://github.com/ibara/oksh/releases/download/oksh-${version}/oksh-${version}.tar.gz sha256: 51b2d92515950c959dbf24f6fc33336db8c0526c2a50fee4ca598a18a6114a49 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --no-thanks make -j$JOBS diff --git a/repo/dev-build/bc b/repo/dev-build/bc @@ -2,7 +2,7 @@ desc: Gavin Howard's bc and dc version: 7.0.3 url: https://github.com/gavinhoward/bc/releases/download/${version}/bc-${version}.tar.xz sha256: 91eb74caed0ee6655b669711a4f350c25579778694df248e28363318e03c7fc4 -deps: sys-libs/musl +deps: steps: ./configure.sh -G -O3 --prefix=$PREFIX --disable-nls make -j$JOBS diff --git a/repo/dev-build/byacc b/repo/dev-build/byacc @@ -2,7 +2,7 @@ desc: Berkeley yacc, the parser generator that isn't bison version: 20260126 url: https://invisible-mirror.net/archives/byacc/byacc-${version}.tgz sha256: b618c5fb44c2f5f048843db90f7d1b24f78f47b07913c8c7ba8c942d3eb24b00 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --program-prefix= make -j$JOBS diff --git a/repo/dev-build/gmake b/repo/dev-build/gmake @@ -2,7 +2,7 @@ desc: GNU make. only here to build the kernel and musl, nothing else may depend version: 4.4.1 url: https://ftp.gnu.org/gnu/make/make-${version}.tar.gz sha256: dd16fb1d67bfab79a72f5e8390735c49e3e8e70b4945a15ab1f81ddb78658fb3 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --program-prefix=g --disable-nls make -j$JOBS diff --git a/repo/dev-build/m4 b/repo/dev-build/m4 @@ -2,7 +2,7 @@ desc: GNU m4. only a build tool of the kernel (through bison and flex), nothing version: 1.4.20 url: https://ftp.gnu.org/gnu/m4/m4-${version}.tar.xz sha256: e236ea3a1ccf5f6c270b1c4bb60726f371fa49459a8eaaebc90b216b328daf2b -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-nls make -j$JOBS diff --git a/repo/dev-build/pkgconf b/repo/dev-build/pkgconf @@ -2,7 +2,7 @@ desc: pkg-config without the GNU version: 3.0.10 url: https://distfiles.ariadne.space/pkgconf/pkgconf-${version}.tar.xz sha256: 9371b2f6372da574d4c6dc96fe9b1463037bcf6afcb6671c1555afde7b17e2de -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared make -j$JOBS diff --git a/repo/dev-build/samurai b/repo/dev-build/samurai @@ -2,7 +2,7 @@ desc: ninja in C99, no make needed version: 1.3 url: https://github.com/michaelforney/samurai/releases/download/${version}/samurai-${version}.tar.gz sha256: 1bc020a9e133432df51911ac71cc34322f828934d9a2282ba2916d88c15976af -deps: sys-libs/musl +deps: steps: make -j$JOBS make PREFIX=$PREFIX DESTDIR=$DESTDIR install diff --git a/repo/dev-lang/perl b/repo/dev-lang/perl @@ -2,7 +2,7 @@ desc: perl. a build tool of the kernel and of a lot of ports version: 5.44.0 url: https://www.cpan.org/src/5.0/perl-${version}.tar.xz sha256: 505cf43912e9480495c344c70260452e32aa2a73c546a026b3f100053b23ce91 -deps: sys-libs/musl +deps: steps: sh Configure -des -Dprefix=$PREFIX -Dcc=clang -Uusedl -Dman1dir=none -Dman3dir=none make -j$JOBS diff --git a/repo/dev-libs/expat b/repo/dev-libs/expat @@ -2,7 +2,7 @@ desc: stream-oriented XML parser version: 2.10.0 url: https://github.com/libexpat/libexpat/releases/download/R_2_10_0/expat-${version}.tar.xz sha256: c624ba2998fc65df1163a49641ff3f9ab73138b11641d92c86bee0fb01b1bc7f -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared --without-docbook make -j$JOBS diff --git a/repo/dev-libs/libffi b/repo/dev-libs/libffi @@ -2,7 +2,7 @@ desc: foreign function interface version: 3.8.1 url: https://github.com/libffi/libffi/releases/download/v${version}/libffi-${version}.tar.gz sha256: 81e879c094cc5ec3186c48510c6385ac6b3e866192e8bc71a35245703757ee40 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared --disable-docs make -j$JOBS diff --git a/repo/dev-libs/libressl b/repo/dev-libs/libressl @@ -2,7 +2,7 @@ desc: the OpenBSD fork of OpenSSL: TLS and crypto version: 4.4.1 url: https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-${version}.tar.gz sha256: 290cdf1b53c086255dc302f118b98602a444e9ae6d11e9bfdd8c9b1b60aa3a22 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --sysconfdir=/etc --disable-shared make -j$JOBS diff --git a/repo/dev-libs/netbsd-curses b/repo/dev-libs/netbsd-curses @@ -2,7 +2,11 @@ desc: curses from NetBSD, the ncurses that is not GNU version: 0.3.2 url: http://ftp.barfooze.de/pub/sabotage/tarballs/netbsd-curses-${version}.tar.xz sha256: d28358b833e6cabcf229fecef98c649e2e90c29858aa34220476faf0e5ce10a1 -deps: sys-libs/musl +deps: steps: make -j$JOBS PREFIX=$PREFIX make PREFIX=$PREFIX DESTDIR=$DESTDIR install + # static only like everything else here. programs written for ncurses link -lcurses and nothing else, but setupterm lives in libterminfo + rm -f $DESTDIR$PREFIX/lib/*.so + mv $DESTDIR$PREFIX/lib/libcurses.a $DESTDIR$PREFIX/lib/libcurses_real.a + echo "INPUT(libcurses_real.a libterminfo.a)" > $DESTDIR$PREFIX/lib/libcurses.a diff --git a/repo/dev-libs/pcre2 b/repo/dev-libs/pcre2 @@ -2,7 +2,7 @@ desc: Perl compatible regular expressions version: 10.49 url: https://github.com/PCRE2Project/pcre2/releases/download/pcre2-${version}/pcre2-${version}.tar.bz2 sha256: 53c156e1ba416a20da8e65395daa132da0d80e76910424caca3fcdae7831d384 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared --enable-jit make -j$JOBS diff --git a/repo/net-libs/libnl b/repo/net-libs/libnl @@ -2,7 +2,7 @@ desc: netlink library, for iw and wpa_supplicant version: 3.12.0 url: https://github.com/thom311/libnl/releases/download/libnl3_12_0/libnl-${version}.tar.gz sha256: fc51ca7196f1a3f5fdf6ffd3864b50f4f9c02333be28be4eeca057e103c0dd18 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --sysconfdir=/etc --disable-shared --disable-cli make -j$JOBS diff --git a/repo/net-misc/dhcpcd b/repo/net-misc/dhcpcd @@ -2,7 +2,7 @@ desc: DHCP and IPv6 router solicitation client version: 10.5.2 url: https://github.com/NetworkConfiguration/dhcpcd/releases/download/v${version}/dhcpcd-${version}.tar.xz sha256: 3e476657fdb6eeb38b277da3a48d0ac0113ecce5858ebdcddff2b629faed52b4 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --sysconfdir=/etc --dbdir=/var/lib/dhcpcd --runstatedir=/run --libexecdir=$PREFIX/lib/dhcpcd make -j$JOBS diff --git a/repo/sys-apps/dinit b/repo/sys-apps/dinit @@ -2,7 +2,7 @@ desc: service manager and init version: 0.23.0 url: https://github.com/davmac314/dinit/releases/download/v${version}/dinit-${version}.tar.xz sha256: b99067eb85f6e69c7e1411b6e0956ea1ae0831598bae5a4361ebef87317c326e -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --sbindir=$PREFIX/bin --sysconfdir=/etc --disable-shutdown --unit-dir=/etc/dinit.d make -j$JOBS diff --git a/repo/sys-apps/util-linux b/repo/sys-apps/util-linux @@ -2,7 +2,7 @@ desc: mount, fdisk, lsblk, losetup and the other basics from the kernel people version: 2.42 url: https://cdn.kernel.org/pub/linux/utils/util-linux/v2.42/util-linux-${version}.tar.xz sha256: 3452b260bbaa775d6e749ac3bb22111785003fc1f444970025c8da26dfa758e9 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --disable-shared --disable-nls --disable-liblastlog2 --without-python --without-systemd --without-udev --disable-makeinstall-chown --disable-makeinstall-setuid make -j$JOBS diff --git a/repo/sys-boot/limine b/repo/sys-boot/limine @@ -2,7 +2,7 @@ desc: the bootloader, BIOS and UEFI version: 12.10.0 url: https://github.com/limine-bootloader/limine/releases/download/v${version}/limine-${version}.tar.xz sha256: 58ccb2bf39bdbda60cbbb2a2678c42e27a4424d6190a5f370e4e060bba20116b -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --enable-uefi-x86-64 --enable-bios --enable-bios-cd make -j$JOBS diff --git a/repo/sys-fs/dosfstools b/repo/sys-fs/dosfstools @@ -2,7 +2,7 @@ desc: mkfs.fat and fsck.fat, for the EFI partition version: 4.2 url: https://github.com/dosfstools/dosfstools/releases/download/v${version}/dosfstools-${version}.tar.gz sha256: 64926eebf90092dca21b14259a5301b7b98e7b1943e8a201c7d726084809b527 -deps: sys-libs/musl +deps: steps: ./configure --prefix=$PREFIX --without-udev make -j$JOBS diff --git a/tests/run.sh b/tests/run.sh @@ -154,5 +154,33 @@ printf 'SHA512 (hello-2.1.tar) = %s\n' "0000" >"$T/repo/devel/hello/distinfo" rm -f "$T/root/var/cache/mag/hello-2.1.tar" $MAG remove hello >/dev/null 2>&1; $MAG install devel/hello >"$T/out" 2>&1; check 'pkgsrc wrong checksum' 1 $? +# options and mag.conf +mkdir -p "$T/repo/devel/opt" "$T/root/etc" +cat >"$T/repo/devel/opt/Makefile" <<'R' +DISTNAME= opt-1.0 +MASTER_SITES= file:///nonexistent/ +COMMENT= a package with options +.include "options.mk" +.include "../../mk/bsd.pkg.mk" +R +cat >"$T/repo/devel/opt/options.mk" <<'R' +PKG_OPTIONS_VAR= PKG_OPTIONS.opt +PKG_SUPPORTED_OPTIONS= alpha beta gamma +PKG_SUGGESTED_OPTIONS= alpha beta +.include "../../mk/bsd.options.mk" +.if !empty(PKG_OPTIONS:Mbeta) +DEPENDS+= base>=1:../../devel/base +.endif +R +echo 'SHA512 (opt-1.0.tar.gz) = 00' >"$T/repo/devel/opt/distinfo" +check 'options suggested' " options: alpha beta" "$($MAG info devel/opt | grep '^ options:')" +check 'options give a dep' "devel/base" "$($MAG deps devel/opt)" +printf 'PKG_DEFAULT_OPTIONS=-beta gamma\n' >"$T/root/etc/mag.conf" +check 'mag.conf default options' " options: alpha gamma" "$($MAG info devel/opt | grep '^ options:')" +check 'options off, dep gone' "" "$($MAG deps devel/opt)" +printf 'PKG_DEFAULT_OPTIONS=-beta\nPKG_OPTIONS.opt=gamma -alpha\n' >"$T/root/etc/mag.conf" +check 'package option variable' " options: gamma" "$($MAG info devel/opt | grep '^ options:')" +rm "$T/root/etc/mag.conf" + echo "$pass passed, $fail failed" [ $fail = 0 ]