base-system: parted construye — GNU parted 3.7 estático (GPT/MBR)
b3:3d7bb8a7. --disable-device-mapper (sin lvm2) --enable-static; make LDFLAGS=-all-static (libtool ignora el -static del lab → binario musl-dinámico que segfaultea fuera del sandbox). parted EXIGE libuuid (uuid_generate p/ GUIDs GPT) y util-linux está roto → horneé una libuuid mínima (UUID v4 desde /dev/urandom) en la fase configure. Probado: mklabel gpt + mkpart reales. TODO: reapuntar a la libuuid real de util-linux cuando ésta compile.
This commit is contained in:
@@ -18,28 +18,122 @@ link = "static"
|
||||
flags = []
|
||||
|
||||
[build.phases]
|
||||
# de build() de Alpine (traducido; el lab provee $CBUILD/$CHOST — Etapa G Fase 3; revisá --shared para estático):
|
||||
compile = '''
|
||||
_abuild_phase() {
|
||||
./configure \
|
||||
--build=$CBUILD \
|
||||
--host=$CHOST \
|
||||
--prefix=/usr \
|
||||
--enable-debug \
|
||||
--disable-nls \
|
||||
--disable-static \
|
||||
--enable-shared
|
||||
make
|
||||
# fase configure EXPLÍCITA (gotcha rsync): sin ella hammer autogenera su propio ./configure
|
||||
# e ignora estos flags.
|
||||
#
|
||||
# libuuid: parted la EXIGE (uuid_generate para los GUID de particiones GPT). En el catálogo
|
||||
# la proveería util-linux, pero esa receta está rota (configure "nonexistent directory") y
|
||||
# e2fsprogs la trae deshabilitada — y aquí sólo se puede tocar parted.toml. Solución
|
||||
# autocontenida: horneamos una libuuid mínima pero FUNCIONAL (uuid v4 desde /dev/urandom) en
|
||||
# /src (persiste entre fases; /tmp es tmpfs fresco por fase) y la apuntamos por CPPFLAGS/
|
||||
# LDFLAGS, que autotools graba en el Makefile para la fase compile. Cubre el API que parted
|
||||
# usa: uuid_generate / uuid_is_null / uuid_parse / uuid_unparse_lower.
|
||||
configure = '''
|
||||
set -e
|
||||
UD=/src/.hammer-uuid
|
||||
mkdir -p "$UD/include/uuid" "$UD/lib"
|
||||
cat > "$UD/include/uuid/uuid.h" <<'HEOF'
|
||||
#ifndef _HAMMER_UUID_UUID_H
|
||||
#define _HAMMER_UUID_UUID_H
|
||||
#define UUID_STR_LEN 37
|
||||
typedef unsigned char uuid_t[16];
|
||||
void uuid_generate(uuid_t out);
|
||||
void uuid_generate_random(uuid_t out);
|
||||
void uuid_generate_time(uuid_t out);
|
||||
int uuid_is_null(const uuid_t uu);
|
||||
int uuid_parse(const char *in, uuid_t uu);
|
||||
void uuid_unparse(const uuid_t uu, char *out);
|
||||
void uuid_unparse_lower(const uuid_t uu, char *out);
|
||||
void uuid_unparse_upper(const uuid_t uu, char *out);
|
||||
void uuid_clear(uuid_t uu);
|
||||
void uuid_copy(uuid_t dst, const uuid_t src);
|
||||
int uuid_compare(const uuid_t a, const uuid_t b);
|
||||
#endif
|
||||
HEOF
|
||||
cat > "$UD/uuid.c" <<'CEOF'
|
||||
#include <uuid/uuid.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
void uuid_generate_random(uuid_t out) {
|
||||
unsigned long n = 0;
|
||||
int fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd >= 0) {
|
||||
while (n < 16) {
|
||||
long r = read(fd, out + n, 16 - n);
|
||||
if (r <= 0) break;
|
||||
n += (unsigned long)r;
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
for (; n < 16; n++) out[n] = (unsigned char)(n * 37 + 11);
|
||||
out[6] = (out[6] & 0x0F) | 0x40; /* version 4 */
|
||||
out[8] = (out[8] & 0x3F) | 0x80; /* variant */
|
||||
}
|
||||
_abuild_phase
|
||||
void uuid_generate(uuid_t out) { uuid_generate_random(out); }
|
||||
void uuid_generate_time(uuid_t out) { uuid_generate_random(out); }
|
||||
int uuid_is_null(const uuid_t uu) { for (int i=0;i<16;i++) if (uu[i]) return 0; return 1; }
|
||||
void uuid_clear(uuid_t uu) { memset(uu, 0, 16); }
|
||||
void uuid_copy(uuid_t d, const uuid_t s) { memcpy(d, s, 16); }
|
||||
int uuid_compare(const uuid_t a, const uuid_t b) { return memcmp(a, b, 16); }
|
||||
|
||||
static int hv(char c) {
|
||||
if (c>='0'&&c<='9') return c-'0';
|
||||
if (c>='a'&&c<='f') return c-'a'+10;
|
||||
if (c>='A'&&c<='F') return c-'A'+10;
|
||||
return -1;
|
||||
}
|
||||
int uuid_parse(const char *in, uuid_t uu) {
|
||||
int i=0,o=0;
|
||||
while (in[i] && o<16) {
|
||||
if (in[i]=='-') { i++; continue; }
|
||||
int hi=hv(in[i]), lo=hv(in[i+1]);
|
||||
if (hi<0||lo<0) return -1;
|
||||
uu[o++]=(unsigned char)((hi<<4)|lo);
|
||||
i+=2;
|
||||
}
|
||||
return o==16 ? 0 : -1;
|
||||
}
|
||||
static void up(const uuid_t uu, char *out, const char *hex) {
|
||||
char *p=out;
|
||||
for (int i=0;i<16;i++) {
|
||||
if (i==4||i==6||i==8||i==10) *p++='-';
|
||||
*p++=hex[(uu[i]>>4)&0xF];
|
||||
*p++=hex[uu[i]&0xF];
|
||||
}
|
||||
*p='\0';
|
||||
}
|
||||
void uuid_unparse_lower(const uuid_t uu, char *out) { up(uu,out,"0123456789abcdef"); }
|
||||
void uuid_unparse_upper(const uuid_t uu, char *out) { up(uu,out,"0123456789ABCDEF"); }
|
||||
void uuid_unparse(const uuid_t uu, char *out) { uuid_unparse_lower(uu,out); }
|
||||
CEOF
|
||||
$CC -O2 -I"$UD/include" -c "$UD/uuid.c" -o "$UD/uuid.o"
|
||||
$AR rcs "$UD/lib/libuuid.a" "$UD/uuid.o"
|
||||
export CPPFLAGS="-I$UD/include $CPPFLAGS"
|
||||
export LDFLAGS="-L$UD/lib $LDFLAGS"
|
||||
./configure \
|
||||
--build=$CBUILD \
|
||||
--host=$CHOST \
|
||||
--prefix=/usr \
|
||||
--disable-device-mapper \
|
||||
--disable-nls \
|
||||
--disable-shared \
|
||||
--enable-static \
|
||||
--without-readline
|
||||
'''
|
||||
# -all-static: libtool ignora el -static del lab para el ejecutable final (queda musl-dinámico
|
||||
# y no corre fuera del sandbox). Se inyecta SÓLO acá (en configure rompería los link-tests, que
|
||||
# no pasan por libtool). Reponemos el -L de la libuuid horneada porque este override pisa LDFLAGS.
|
||||
compile = '''
|
||||
make LDFLAGS="-all-static -L/src/.hammer-uuid/lib"
|
||||
'''
|
||||
# de package() de Alpine (traducido $pkgdir→/out):
|
||||
install = '''
|
||||
_abuild_phase() {
|
||||
make DESTDIR="/out" install
|
||||
}
|
||||
_abuild_phase
|
||||
'''
|
||||
|
||||
# lvm2 (device-mapper) ausente y opcional → --disable-device-mapper. bash/ncurses/readline
|
||||
# innecesarios al binario estático. libuuid horneada en la fase configure (ver arriba).
|
||||
[deps]
|
||||
build = ["bash", "lvm2", "ncurses", "readline", "util-linux"]
|
||||
build = ["linux-headers"]
|
||||
|
||||
Reference in New Issue
Block a user