gioser

sergio/takana

> Una distribución Linux construida con un laboratorio funcional y hermético en el > sótano, y una terminal mutable, clásica y anárquica en el piso de arriba — diseñada > desde el suelo para que una IA programadora entienda, modifique y co…

TOML 815Rust 56Shell 37Markdown 291229 Sutichaykuna

⎇ fb6cb05aab989f7813ae3becba7a3a4754d5ecee recipes/parted.toml TOML · 139 siq'ikuna · 5.3 KB Ñawpa willay ch'uya

base-system: promover 17 esenciales a canónicas + repo firmado (713→730) fb6cb05aa · sergio ·

1# Importada de Alpine aports por `hammer import-alpine` (Etapa G). PUNTO DE PARTIDA — pero
2# YA trae los parches de musl de Alpine (lo que un import de nix pierde). Pendiente: el
3# sha256 del tarball (el wrapper lo calcula), y adaptar build/install del shell de abuild.
4name    = "parted"
5version = "3.7"
6
7[source]
8tarball = "https://ftp.gnu.org/gnu/parted/parted-3.7.tar.xz"
9# FIXME sha256: el wrapper lo calcula (Alpine publica sha512). sha512 de Alpine:
10# sha512 = "941afeb68edb45c33fb797f4c320ed1aa1de2e8b35defa5d742aa6894618e6729a1440e3ee0824e8710bc58eb42b85d77f28ba083d92d4ea3f3f65f37c8307b0"
11sha256  = "008de57561a4f3c25a0648e66ed11e7b30be493889b64334a6d70f2c1951ef7b"
12patches = ["fix-includes.patch", "fix-libintl-header-s390x.patch", "parted-include-sysmacros.patch", "fix-truncate-tests.patch", "make-tests.patch", "skip-duplicate-bsd-test-on-s390x.patch"]
13
14[build]
15compiler = "zig-cc"
16target   = "x86_64-linux-musl"
17link     = "static"
18flags    = []
19
20[build.phases]
21# fase configure EXPLÍCITA (gotcha rsync): sin ella hammer autogenera su propio ./configure
22# e ignora estos flags.
23#
24# libuuid: parted la EXIGE (uuid_generate para los GUID de particiones GPT). En el catálogo
25# la proveería util-linux, pero esa receta está rota (configure "nonexistent directory") y
26# e2fsprogs la trae deshabilitada — y aquí sólo se puede tocar parted.toml. Solución
27# autocontenida: horneamos una libuuid mínima pero FUNCIONAL (uuid v4 desde /dev/urandom) en
28# /src (persiste entre fases; /tmp es tmpfs fresco por fase) y la apuntamos por CPPFLAGS/
29# LDFLAGS, que autotools graba en el Makefile para la fase compile. Cubre el API que parted
30# usa: uuid_generate / uuid_is_null / uuid_parse / uuid_unparse_lower.
31configure = '''
32set -e
33UD=/src/.hammer-uuid
34mkdir -p "$UD/include/uuid" "$UD/lib"
35cat > "$UD/include/uuid/uuid.h" <<'HEOF'
36#ifndef _HAMMER_UUID_UUID_H
37#define _HAMMER_UUID_UUID_H
38#define UUID_STR_LEN 37
39typedef unsigned char uuid_t[16];
40void uuid_generate(uuid_t out);
41void uuid_generate_random(uuid_t out);
42void uuid_generate_time(uuid_t out);
43int  uuid_is_null(const uuid_t uu);
44int  uuid_parse(const char *in, uuid_t uu);
45void uuid_unparse(const uuid_t uu, char *out);
46void uuid_unparse_lower(const uuid_t uu, char *out);
47void uuid_unparse_upper(const uuid_t uu, char *out);
48void uuid_clear(uuid_t uu);
49void uuid_copy(uuid_t dst, const uuid_t src);
50int  uuid_compare(const uuid_t a, const uuid_t b);
51#endif
52HEOF
53cat > "$UD/uuid.c" <<'CEOF'
54#include <uuid/uuid.h>
55#include <fcntl.h>
56#include <unistd.h>
57#include <string.h>
58
59void uuid_generate_random(uuid_t out) {
60    unsigned long n = 0;
61    int fd = open("/dev/urandom", O_RDONLY);
62    if (fd >= 0) {
63        while (n < 16) {
64            long r = read(fd, out + n, 16 - n);
65            if (r <= 0) break;
66            n += (unsigned long)r;
67        }
68        close(fd);
69    }
70    for (; n < 16; n++) out[n] = (unsigned char)(n * 37 + 11);
71    out[6] = (out[6] & 0x0F) | 0x40; /* version 4 */
72    out[8] = (out[8] & 0x3F) | 0x80; /* variant   */
73}
74void uuid_generate(uuid_t out)      { uuid_generate_random(out); }
75void uuid_generate_time(uuid_t out) { uuid_generate_random(out); }
76int  uuid_is_null(const uuid_t uu)  { for (int i=0;i<16;i++) if (uu[i]) return 0; return 1; }
77void uuid_clear(uuid_t uu)          { memset(uu, 0, 16); }
78void uuid_copy(uuid_t d, const uuid_t s) { memcpy(d, s, 16); }
79int  uuid_compare(const uuid_t a, const uuid_t b) { return memcmp(a, b, 16); }
80
81static int hv(char c) {
82    if (c>='0'&&c<='9') return c-'0';
83    if (c>='a'&&c<='f') return c-'a'+10;
84    if (c>='A'&&c<='F') return c-'A'+10;
85    return -1;
86}
87int uuid_parse(const char *in, uuid_t uu) {
88    int i=0,o=0;
89    while (in[i] && o<16) {
90        if (in[i]=='-') { i++; continue; }
91        int hi=hv(in[i]), lo=hv(in[i+1]);
92        if (hi<0||lo<0) return -1;
93        uu[o++]=(unsigned char)((hi<<4)|lo);
94        i+=2;
95    }
96    return o==16 ? 0 : -1;
97}
98static void up(const uuid_t uu, char *out, const char *hex) {
99    char *p=out;
100    for (int i=0;i<16;i++) {
101        if (i==4||i==6||i==8||i==10) *p++='-';
102        *p++=hex[(uu[i]>>4)&0xF];
103        *p++=hex[uu[i]&0xF];
104    }
105    *p='\0';
106}
107void uuid_unparse_lower(const uuid_t uu, char *out) { up(uu,out,"0123456789abcdef"); }
108void uuid_unparse_upper(const uuid_t uu, char *out) { up(uu,out,"0123456789ABCDEF"); }
109void uuid_unparse(const uuid_t uu, char *out)       { uuid_unparse_lower(uu,out); }
110CEOF
111$CC -O2 -I"$UD/include" -c "$UD/uuid.c" -o "$UD/uuid.o"
112$AR rcs "$UD/lib/libuuid.a" "$UD/uuid.o"
113export CPPFLAGS="-I$UD/include $CPPFLAGS"
114export LDFLAGS="-L$UD/lib $LDFLAGS"
115./configure \
116	--build=$CBUILD \
117	--host=$CHOST \
118	--prefix=/usr \
119	--disable-device-mapper \
120	--disable-nls \
121	--disable-shared \
122	--enable-static \
123	--without-readline
124'''
125# -all-static: libtool ignora el -static del lab para el ejecutable final (queda musl-dinámico
126# y no corre fuera del sandbox). Se inyecta SÓLO acá (en configure rompería los link-tests, que
127# no pasan por libtool). Reponemos el -L de la libuuid horneada porque este override pisa LDFLAGS.
128compile = '''
129make LDFLAGS="-all-static -L/src/.hammer-uuid/lib"
130'''
131# de package() de Alpine (traducido $pkgdir→/out):
132install = '''
133make DESTDIR="/out" install
134'''
135
136# lvm2 (device-mapper) ausente y opcional → --disable-device-mapper. bash/ncurses/readline
137# innecesarios al binario estático. libuuid horneada en la fase configure (ver arriba).
138[deps]
139build = ["linux-headers"]