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 272a25248f14d836f61857891f61e5257ae026ed
parent 8705eb375a3e312270b02d6e9b1247b3aa1297f4
Author: torter <koubbamohamedrayan@gmail.com>
Date:   Sat, 14 Nov 2026 15:47:10 +0000

libtool: keep arguments whole when compiling; :ts and :Q modifiers; GNU configure gets mandir, sysconfdir, localstatedir

Diffstat:
Mmag.c | 13++++++++++++-
Mrepo/dev-build/libtool/libtool | 35++++++++++++++++-------------------
2 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/mag.c b/mag.c @@ -438,6 +438,16 @@ static char *apply_mod(const struct vars *vs, char *val, const char *mod, size_t *o = 0; } } + } else if (!strncmp(m, "ts", 2)) { + char sep = m[2] == '\\' && m[3] == 'n' ? '\n' : m[2] ? m[2] : (m[2] = 0, ' '); + int first = 1; + if (!m[2] && !strcmp(m, "ts")) sep = ' '; + for (w = strtok_r(copy, " \t", &save); w; w = strtok_r(NULL, " \t", &save)) { if (!first) *o++ = sep; o += sprintf(o, "%s", w); first = 0; } + *o = 0; + } else if (!strcmp(m, "Q")) { + const char *p; + for (p = copy; *p; p++) { if (strchr(" \t\n'\"\\$`&|;<>()*?[]#~!", *p)) *o++ = '\\'; *o++ = *p; } + *o = 0; } else if (!strcmp(m, "tl") || !strcmp(m, "tu")) { int up = m[1] == 'u'; char *p; @@ -472,6 +482,7 @@ static char *expand(const struct vars *vs, const char *s, int depth) const char *me = name_end + 1; int dd = 0; while (me < p - 1 && (*me != ':' || dd)) { if (*me == '{') dd++; else if (*me == '}') dd--; me++; } + if (me - (name_end + 1) == 2 && !strncmp(name_end + 1, "ts", 2) && me < p - 1 && *me == ':') me++; tmp = apply_mod(vs, val, name_end + 1, me - (name_end + 1), depth); free(val); val = tmp; name_end = me; @@ -937,7 +948,7 @@ static struct recipe *parse_pkgsrc(const char *id, const char *dir, const char * cmd += sprintf(cmd, "for p in \"$RECIPE_DIR\"/%s/patch-*; do [ -f \"$p\" ] || continue; patch -p0 < \"$p\"; done\n", pd); if (hook[2]) cmd += sprintf(cmd, "%s\n", hook[2]); if (hook[3]) cmd += sprintf(cmd, "%s\n", hook[3]); - else if (hasconfig && !cmake) cmd += sprintf(cmd, "%s ./configure --prefix=$PREFIX %s\n", cenv, cfg); + else if (hasconfig && !cmake) cmd += sprintf(cmd, "%s ./configure --prefix=$PREFIX --mandir=$PREFIX/man --sysconfdir=/etc --localstatedir=/var %s\n", cenv, cfg); if (hook[4]) cmd += sprintf(cmd, "%s\n", hook[4]); if (cmake && !hook[3]) cmd += sprintf(cmd, "mkdir -p mag-build && cd mag-build && %s cmake -G Ninja -DCMAKE_INSTALL_PREFIX=$PREFIX %s ..\nsamu\n", cenv, cfg); else { diff --git a/repo/dev-build/libtool/libtool b/repo/dev-build/libtool/libtool @@ -21,41 +21,39 @@ run() { [ -n "$LIBTOOL_VERBOSE" ] && echo "$*" >&2; "$@"; } compile() { out= src= static=no - args= - while [ $# -gt 0 ]; do - case $1 in - -o) out=$2; shift;; + n=$# + while [ $n -gt 0 ]; do + a=$1; shift; n=$((n - 1)) + case $a in + -o) out=$1; shift; n=$((n - 1));; -static) static=yes;; - -shared|-prefer-pic|-prefer-non-pic|-no-suppress) ;; - -Wc,*) args="$args ${1#-Wc,}";; - -c) ;; - *.c|*.cc|*.cpp|*.cxx|*.S|*.s|*.m) src=$1; args="$args $1";; - *) args="$args $1";; + -shared|-prefer-pic|-prefer-non-pic|-no-suppress|-c) ;; + -Wc,*) set -- "$@" "${a#-Wc,}";; + *.c|*.cc|*.cpp|*.cxx|*.S|*.s|*.m) src=$a; set -- "$@" "$a";; + *) set -- "$@" "$a";; esac - shift done [ -n "$out" ] || { b=${src##*/}; out=${b%.*}.lo; } base=${out%.lo} d=${base%/*}; [ "$d" = "$base" ] && d=. n=${base##*/} + set -f case $out in *.lo) mkdir -p "$d/.libs" - set -f - # shellcheck disable=SC2086 - run $cc_cmd -c $args -o "$d/$n.o" || exit $? + run $cc_cmd -c "$@" -o "$d/$n.o" || exit $? cat > "$out" <<LO # libtool object pic_object='.libs/$n.o' non_pic_object='$n.o' LO if [ $static = no ]; then - run $cc_cmd -c -fPIC -DPIC $args -o "$d/.libs/$n.o" || exit $? + run $cc_cmd -c -fPIC -DPIC "$@" -o "$d/.libs/$n.o" || exit $? else echo "pic_object=none" >> "$out" fi ;; - *) set -f; run $cc_cmd -c $args -o "$out" || exit $? ;; + *) run $cc_cmd -c "$@" -o "$out" || exit $? ;; esac } @@ -169,16 +167,15 @@ install_la() { } install_cmd() { - cmd= + cmd=$1; shift while [ $# -gt 0 ]; do case $1 in - -o|-g|-m) cmd="$cmd $1 $2"; shift;; - -*|install|cp|ginstall|"") cmd="$cmd $1";; + -o|-g|-m|-S|-f) cmd="$cmd $1 $2"; shift;; + -*) cmd="$cmd $1";; *) break;; esac shift done - [ -n "${cmd# }" ] || cmd=install [ $# -ge 2 ] || { echo "libtool: install: need a source and a destination" >&2; exit 1; } eval last=\${$#} for a in "$@"; do