summaryrefslogtreecommitdiff
path: root/scripts/setup-abuild
blob: cc8e238beee3dc7d4a5ecc4eef8a916e3f6bf32e (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
#!/bin/sh -e

##
# This script is to be called from 'bootstrap.sh', not sourced.
# PATH is fully contained. We install to 'MCMTOOLS/abuild/'.
#
export PATH="${MCMTOOLS}/sys/bin:${MCMTOOLS}/host/bin";

HERE="$(dirname $(readlink -f ${0}))";
DEST="${MCMTOOLS}/abuild";

mkdir -p "${DEST}";
cd "${DEST}";


##
# OpenSSL
#
nssl=openssl;
vssl=1.1.1l;
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};


##
# abuild
#
nbld=abuild;
vbld=ff913b49072352604ce081378f015af1714e1bd2;
test ! -f ._${nbld}-${vbld} &&                                 \
(
    test ! -d ${nbld}-${vbld}                                  \
        && git clone https://git.alpinelinux.org/${nbld} ${nbld}-${vbld} \
        ;
    cd abuild-${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 -I${MCMTOOLS}/sys/include";
    export SSL_LDFLAGS="-L${DEST}/lib -L${MCMTOOLS}/sys/lib";
    export SSL_LIBS="-lssl -lcrypto"; # not in mcmtools
    export ZLIB_LIBS="-lz"; # from mcmtools
    export CFLAGS="-DABUILD_GROUP=\\\"$(id -gn)\\\""; # 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}"                                   \
        ;
    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=2.37.2;
test ! -f ._${nutl}-${vutl} &&                                 \
(
    test ! -d ${nutl}-${vutl}                                  \
        && mkdir ${nutl}-${vutl}                               \
        && curl -sL https://github.com/karelzak/${nutl}/archive/refs/tags/v${vutl}.tar.gz \
        | tar -C ${nutl}-${vutl} --strip-components=1 -xzf -   \
        ;
    cd ${nutl}-${vutl};
    test -f configure || ./autogen.sh;
    rm -fr x; mkdir x; cd x;
    ../configure                                               \
        --prefix="${DEST}"                                     \
        --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};


##
# apk-tools
#
natl=apk-tools;
vatl=9f07a3447ea1e8fb67cdbd5c30b2ea144e826490;
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 src/Makefile                                        \
        -e 's/$(install-libapk_so)//g' -e 's/$(libapk_so)//g'  \
        ; # disable shared libs
    sed -i src/context.c                                       \
        -e "s@var/log@${DEST}/${1}/var/log@"                   \
        ; # hardcoded
    export LUA=no; # documentation requires lua
    make clean;
    make                                                       \
        INSTALLDIR="${DEST}"                                   \
        CFLAGS="-I${DEST}/include -I${MCMTOOLS}/sys/include"   \
        LDFLAGS="-L${DEST}/lib -L${MCMTOOLS}/sys/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=1.3.3;
test ! -f ._${npax}-${vpax} &&                                 \
(
    test ! -d ${npax}-${vpax}                                  \
        && curl -s https://gitweb.gentoo.org/proj/${npax}.git/snapshot/${npax}-${vpax}.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${npax}-${vpax};
    sed -i Makefile                                            \
        -e '/$(MPAGES)/d'                                      \
        ;
    rm -fr x; mkdir x; cd x;
    make -j$(nproc) -C .. install                              \
        PREFIX="${DEST}"                                       \
        MANDIR="${DEST}/man"                                   \
        USE_PYTHON=no                                          \
        ;
)
touch ._${npax}-${vpax};
rm -fr  ${npax}-${vpax};


##
# fakeroot
#
nfrt=fakeroot;
vfrt=20210907T092512Z:1.26; # look on snapshot.d.o for this
test ! -f ._${nfrt}-${vfrt#*:} &&                              \
(
    test ! -d ${nfrt}-${vfrt#*:}                               \
        && curl -s https://snapshot.debian.org/archive/debian/${vfrt%:*}/pool/main/f/${nfrt}/${nfrt}_${vfrt#*:}.orig.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${nfrt}-${vfrt#*:};
    f=$(mktemp);
    echo > ${f} "#include <linux/capability.h>";
    cat libfakeroot.c >> ${f};
    mv ${f} libfakeroot.c;
    rm -fr x; mkdir x; cd x;
    ../configure --prefix="${DEST}";
    make -j$(nproc) install;
)
touch ._${nfrt}-${vfrt#*:};
rm -fr  ${nfrt}-${vfrt#*:};