summaryrefslogtreecommitdiff
path: root/scripts/bootstrap-abuild
blob: c35dd2f51514828bc8c3dcd7467fd6bb6df44765 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#!/bin/sh -e

##
# This script is to be called from 'bootstrap.sh', not sourced.
# PATH is fully contained. We install to 'MCMTOOLS/sys', which
# will add (and may overwrite) in some cases. This process is
# destructive. We do this so that we may easily 'chroot' later.
#
HERE="$(dirname $(readlink -f ${0}))";
DEST=/usr/local;

git config --global http.sslCAInfo "${CURL_CA_BUNDLE}";

mkdir -p "${DEST}";
cd "${DEST}"; # this directory will already exist if correct

##
# musl
#
# This provides the dynamic loader for the foreign (target) arch
# so that we do not have to force building static musl binaries.
#
nmus=musl;
vmus=1.2.3;
test ! -f ._${nmus}-${vmus} &&                                 \
(
    test ! -d ${nmus}-${vmus}                                  \
        && curl -s https://musl.libc.org/releases/${nmus}-${vmus}.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${nmus}-${vmus};
    rm -fr x; mkdir x; cd x;
    ../configure                                               \
        --prefix=/usr                                          \
        --enable-static                                        \
        --enable-shared                                        \
        ;
    make -j$(nproc);
    make install;
)
touch ._${nmus}-${vmus};
rm -fr  ${nmus}-${vmus};


##
# OpenSSL
#
nssl=openssl;
vssl=1.1.1s;
test ! -f ._${nssl}-${vssl} &&                                 \
(
    test ! -d ${nssl}-${vssl}                                  \
        && curl -s https://www.openssl.org/source/${nssl}-${vssl}.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${nssl}-${vssl};
    rm -fr x; mkdir x; cd x;
    ../Configure cc                                            \
        --prefix="${DEST}"                                     \
        --openssldir="${DEST}"                                 \
        no-shared                                              \
        ;
    make -j$(nproc);
    make install_sw install_ssldirs;
)
touch ._${nssl}-${vssl};
rm -fr  ${nssl}-${vssl};


##
# zlib
#
nzlb=zlib;
vzlb=1.2.13;
test ! -f ._${nzlb}-${vzlb} &&                                 \
(
    test ! -d ${nzlb}-${vzlb}                                  \
        && curl -s https://www.zlib.net/${nzlb}-${vzlb}.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${nzlb}-${vzlb};
    rm -fr x; mkdir x; cd x;
    ../configure                                               \
        --prefix="${DEST}"                                     \
        --static                                               \
        ;
    make -j$(nproc);
    make install;
)
touch ._${nzlb}-${vzlb};
rm -fr  ${nzlb}-${vzlb};


##
# abuild
#
nbld=abuild;
vbld=ee13f777d56e8f3e8848fec9a422430a66292cc1;
test ! -f ._${nbld}-${vbld} &&                                 \
(
    test ! -d ${nbld}-${vbld}                                  \
        && git clone https://git.alpinelinux.org/${nbld} ${nbld}-${vbld} \
        ;
    cd abuild-${vbld};
    git checkout ${vbld};
#    patch -p1 --forward < "${HERE}/patches/0001-allow-untrusted.diff" || true; # FIXME
#    patch -p1 --forward < "${HERE}/patches/0001-etc-apk-keys.diff" || true; # FIXME
#    patch -p1 --forward < "${HERE}/patches/0001-extra-lib-paths.diff" || true; # FIXME
    rm -fr x; mkdir x; cd x;
    export SSL_CFLAGS="-I${DEST}/include";
    export SSL_LDFLAGS="-L${DEST}/lib";
    export SSL_LIBS="-lssl -lcrypto"; # not in mcmtools
    export ZLIB_LIBS="-lz"; # do not use from mcmtools
    export LDFLAGS="-L${DEST}/lib -lssl -lcrypto";
    export CFLAGS="-DABUILD_GROUP=\\\"$(id -gn)\\\" -static -I${DEST}/include"; # default 'abuild' if undefined
    sed -i "${DEST}/abuild-${vbld}/abuild-sudo.c"              \
        -e "s@/sbin/apk@${DEST}/bin/apk@"                      \
        ; # hardcoded
    make -j$(nproc) -C .. install                              \
        prefix="${DEST}"                                       \
        sysconfdir="${DEST}"                                   \
        SCDOC=true                                             \
        ;
    sed -i "${DEST}/bin/abuild"                                \
        -e 's@/bin/ash -e@/usr/bin/env bash@'                  \
        ; # hardcoded
)
touch ._${nbld}-${vbld};
rm -fr  ${nbld}-${vbld};


##
# util-linux (for 'getopt' used by 'abuild-keygen')
#
nutl=util-linux;
vutl=08431acdf5b3accd0887ab550bfa4efabed751d6;
test ! -f ._${nutl}-${vutl} &&                                 \
(
    test ! -d ${nutl}-${vutl}                                  \
        && mkdir ${nutl}-${vutl}                               \
        && git clone https://github.com/karelzak/${nutl}.git ${nutl}-${vutl} \
        ;
    cd ${nutl}-${vutl};
    git checkout ${vutl};
    test -f configure || ./autogen.sh;
    rm -fr x; mkdir x; cd x;
    ../configure                                               \
        --prefix="${DEST}"                                     \
        --host="$(${CC} -dumpmachine)"                         \
        --enable-static                                        \
        --disable-shared                                       \
        ;
    sed -i Makefile                                            \
        -e 's/chgrp/-chgrp/g'                                  \
        -e 's/chmod/-chmod/g'                                  \
        -e 's/chown/-chown/g'                                  \
        ; # allow non-root installation
    make -j$(nproc) install;
)
touch ._${nutl}-${vutl};
rm -fr  ${nutl}-${vutl};


##
# pkgconf (pkg-config replacement)
#
npkg=pkgconf;
vpkg=623b8f7851648a5c476de904a8ffed7b7b679aab; # until autoconf 2.71
test ! -f ._${npkg}-${vpkg} &&
(
    test ! -d ${npkg}-${vpkg}                                  \
        && git clone https://github.com/${npkg}/${npkg}.git ${npkg}-${vpkg} \
        ;
    cd ${npkg}-${vpkg};
    git checkout ${vpkg};
    ./autogen.sh;
    ./configure                                                \
        --prefix="${DEST}"                                     \
        --host="$(${CC} -dumpmachine)"                         \
        --enable-static                                        \
        --disable-shared                                       \
        --with-system-libdir=/lib:/usr/lib                     \
        --with-system-includedir=/usr/include                  \
        ;
    make -j$(nproc) install;
)
touch ._${npkg}-${vpkg};
rm -fr  ${npkg}-${vpkg};


##
# samurai (ninja replacement)
#
nsam=samurai;
vsam=4cc8f4a3654b72c977e0e62367d1ab6d5b873def;
test ! -f ._${nsam}-${vsam} &&
(
    test ! -d ${nsam}-${vsam}                                  \
        && git clone https://github.com/michaelforney/${nsam}.git ${nsam}-${vsam} \
        ;
    cd ${nsam}-${vsam};
    make -j$(nproc) install                                    \
        PREFIX=""                                              \
        DESTDIR="${DEST}"                                      \
        ;

)
touch ._${nsam}-${vsam};
rm -fr  ${nsam}-${vsam};


##
# muon (meson replacement)
#
nmun=muon;
vmun=62ce4561b4444e5020dc39aad0381655afeda0d6;
test ! -f ._${nmun}-${vmun} &&
(
    test ! -d ${nmun}-${vmun}                                  \
        && git clone https://git.sr.ht/~lattis/${nmun} ${nmun}-${vmun} \
        ;
    cd ${nmun}-${vmun};
    sed -i bootstrap.sh                                        \
        -e 's/if.*then/if false; then/g'                       \
        ;
    ./bootstrap.sh                                             \
        bootstrap                                              \
        ;
	bootstrap/muon setup \
		-Dstatic=true \
		build \
        ;
    sed -i build/build.ninja                                   \
        -e "s@\bar\b@${AR}@g"                                  \
        ;
	samu -C build;
    cp build/muon "${DEST}/bin";
)
touch ._${nmun}-${vmun};
rm -fr  ${nmun}-${vmun};


##
# apk-tools
#
# Ariadne says use meson, and 'muon' doesn't work so... kludges!
# Also, '-j' will break the build.
#
natl=apk-tools;
vatl=be4ce40797af9056c79be4dc74ff978f1f4957e4;
test ! -f ._${natl}-${vatl} &&                                 \
(
    test ! -d ${natl}-${vatl}                                  \
        && git clone https://git.alpinelinux.org/${natl} ${natl}-${vatl} \
        ;
    cd ${natl}-${vatl};
    sed -i Make.rules                                          \
        -e '/targets += $(__shlibs) $(shobjs)/d'               \
        ; # disable shared libs
    sed -i Make.rules                                          \
        -e '/CC.*:=/d'                                         \
        -e '/AR.*:=/d'                                         \
        -e '/LD.*:=/d'                                         \
        ; # inherit from environment
    sed -i src/Makefile                                        \
        -e 's/$(install-libapk_so)//g' -e 's/$(libapk_so)//g'  \
        -e 's/ version.o/ version.o strlcpy.o/'                \
        ; # disable shared libs, hack the hack
    sed -i src/context.c                                       \
        -e "s@var/log@${DEST}/${1}/var/log@"                   \
        ; # hardcoded
    ln -sf ../portability/strlcpy.c src/strlcpy.c;
    export LUA=no; # documentation requires lua
    make clean;
    make                                                       \
        INSTALLDIR="${DEST}"                                   \
        CFLAGS="-I${DEST}/include -DNEED_STRLCPY -Wno-error"   \
        LDFLAGS="-L${DEST}/lib -L${DEST}/${natl}-${vatl}/libfetch" \
        LIBS="-lapk -lfetch -lssl -lcrypto -lz"                \
        ;
    cp src/apk "${DEST}/bin";
)
touch ._${natl}-${vatl};
rm -fr  ${natl}-${vatl};


##
# pax-utils
#
npax=pax-utils;
vpax=974b9359c2f89d57e69598572aafcd8f920d79e2;
test ! -f ._${npax}-${vpax} &&                                 \
(
    test ! -d ${npax}-${vpax}                                  \
        && git clone https://anongit.gentoo.org/git/proj/${npax}.git ${npax}-${vpax} \
        ;
    cd ${npax}-${vpax};
    git checkout ${vpax};
    muon setup build;
)
touch ._${npax}-${vpax};
rm -fr  ${npax}-${vpax};


##
# fakeroot
#
nfrt=fakeroot;
vfrt=8c0260009e85264fd1ea282fbb22063fc694c552; # until autoconf 2.71
test ! -f ._${nfrt}-${vfrt#*:} &&                              \
(
    test ! -d ${nfrt}-${vfrt}                                  \
        && git clone https://salsa.debian.org/clint/${nfrt}.git ${nfrt}-${vfrt} \
        ;
    cd ${nfrt}-${vfrt};
    git checkout ${vfrt};
    while read k; do curl -s ${k} | patch -p1 || true; done <<EOF
https://git.alpinelinux.org/aports/plain/main/fakeroot/do-not-redefine-id_t.patch?id=bb497eeb2155d0332284942105692bc05fec25a9
https://git.alpinelinux.org/aports/plain/main/fakeroot/fakeroot-no64.patch?id=bb497eeb2155d0332284942105692bc05fec25a9
https://git.alpinelinux.org/aports/plain/main/fakeroot/fakeroot-stdint.patch?id=bb497eeb2155d0332284942105692bc05fec25a9
https://git.alpinelinux.org/aports/plain/main/fakeroot/fix-format.patch?id=bb497eeb2155d0332284942105692bc05fec25a9
https://git.alpinelinux.org/aports/plain/main/fakeroot/fix-shell-in-fakeroot.patch?id=bb497eeb2155d0332284942105692bc05fec25a9
EOF
    ./bootstrap;
    f=$(mktemp); # needed due to "error: unknown type name 'cap_user_header_t'"
    echo > ${f} "#include <linux/capability.h>";
    cat libfakeroot.c >> ${f};
    mv ${f} libfakeroot.c;
    rm -fr x; mkdir x; cd x;
    CFLAGS="-D_STAT_VER=0 $CFLAGS"                             \
    ../configure                                               \
        --prefix="${DEST}"                                     \
        ;
    sed -i Makefile                                            \
        -e '/^SUBDIRS =/ s/doc//g'                             \
        ;
    make -j$(nproc) install;
)
touch ._${nfrt}-${vfrt#*:};
rm -fr  ${nfrt}-${vfrt#*:};