summaryrefslogblamecommitdiff
path: root/setup-abuild
blob: e59ec41f331396bb021e033f38b584bab6963dd6 (plain) (tree)
1
2
3
4
5
6
7






                                                       













                                                                
                                                                           



















                                                                

             

                                                                

                                                                                               
                                                                
                             



















                                                                
           


                                                                
                                                                 


























                                                                                     
                                                                  
                 
                                                                                              


















                                                                
                                                              













































































                                                                                   
                                                                










                                                                




                                                                
          
                                              


                                                                

                                                                              







                                                                


                                                                
         
                  












                                                                
                                              





















                                                                          














                                                                     
                                               
                                                              

























                                                                                      


                                                                











                                                                    
                                                             





                                                                                 
                                                                  











                                                                                                                              
                                                                

                                                                
                                                                





                                                                

                        














                                                                                      
                                                                

                                                                
                                                                






                                                                
#!/bin/sh -e

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 -sL 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.1v;
vssl=1.1.1w;
test ! -f ._${nssl}-${vssl} &&                                 \
(
#https://www.openssl.org/source/${nssl}-${vssl}.tar.gz
temp=https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz;
    test ! -d ${nssl}-${vssl}                                  \
        && curl -sL ${temp} \
        | 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.3.1;
test ! -f ._${nzlb}-${vzlb} &&                                 \
(
    test ! -d ${nzlb}-${vzlb}                                  \
        && curl -sL 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=f75ebd1953f6e41416b5037c4049b55b9a21a1ea;
test ! -f ._${nbld}-${vbld} &&                                 \
(
    test ! -d ${nbld}-${vbld}                                  \
        && git clone https://git.adelielinux.org/adelie/${nbld}.git ${nbld}-${vbld} \
        ;
    cd abuild-${vbld};
    git checkout ${vbld};
    while read k; do curl -sL ${k} | patch -p1 || true; done <<EOF
http://ix.io/4ifN
https://git.alpinelinux.org/abuild/patch/abuild.in?id=f263cb9f49f3861f3141c22a74360b06cec7b868
EOF
    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="-static -I${DEST}/include";
    sed -i "${DEST}/abuild-${vbld}/abuild-sudo.c"              \
        -e "s@__DEST__@${DEST}@"                               \
        ; # 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
    chmod +r "${DEST}"/bin/abuild-sudo; # otherwise has s/x/x!
)
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;
    ln -s pkgconf "${DEST}"/bin/pkg-config
)
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=""                                              \
        LDFLAGS="-static"                                      \
        DESTDIR="${DEST}"                                      \
        ;

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


##
# muon (meson replacement)
#
# Temporarily using tarball archive download:
#
#     fatal: unable to access 'https://git.sr.ht/~lattis/muon/':
#     The requested URL returned error: 500
#
nmun=muon;
vmun=834460da03dd4a0c5b4570ca905780ce191c2443;
test ! -f ._${nmun}-${vmun} &&
(
    test ! -d ${nmun}-${vmun}                                  \
        && curl -sL https://git.sr.ht/~lattis/${nmun}/archive/${vmun}.tar.gz \
        | tar -xzf -                                           \
        ;
    cd ${nmun}-${vmun};
    sed -i bootstrap.sh                                        \
        -e 's/if.*then/if false; then/g'                       \
        ;
    ./bootstrap.sh                                             \
        bootstrap                                              \
        ;
    bootstrap/muon setup                                       \
        -Dstatic=true                                          \
        build                                                  \
        ;
    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=3bf28d03a025f7cd7fc174af4102405090dba24c;
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;
    patch -p1 <<"EOF"
diff -ur a/src/apk_defines.h b/src/apk_defines.h
--- a/src/apk_defines.h	2024-08-05 17:15:31.825944384 -0500
+++ b/src/apk_defines.h	2024-08-05 17:16:57.788404910 -0500
@@ -124,6 +124,8 @@
 #define APK_DEFAULT_BASE_ARCH	"aarch64"
 #elif defined(__s390x__)
 #define APK_DEFAULT_BASE_ARCH	"s390x"
+#elif defined(__m68k__)
+#define APK_DEFAULT_BASE_ARCH	"m68k"
 #elif defined(__mips64) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
 #define APK_DEFAULT_BASE_ARCH	"mips64"
 #elif defined(__mips64) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
EOF

    export LUA=no; # documentation requires lua
    export ZSTD=no; # d7fb939a68cb20c0398753379a17fc165b3c892a
    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;
    sed -i build/build.ninja                                   \
        -e "s@ ar @ ${AR} @g"                                  \
        ;
    samu    -C build;
    muon    -C build install;
)
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 -sL ${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="-static -D_STAT_VER=0 $CFLAGS"                     \
    ../configure                                               \
        --prefix="${DEST}"                                     \
        --host="$(${CC} -dumpmachine)"                         \
        ;
    sed -i Makefile                                            \
        -e '/^SUBDIRS =/ s/doc//g'                             \
        ;
    make -j$(nproc) install;
)
touch ._${nfrt}-${vfrt};
rm -fr  ${nfrt}-${vfrt};


##
# attr
#
natt=attr;
vatt=2979615e71fb53b3f2f9085eea516d4e2b3174ea;
test ! -f ._${natt}-${vatt} &&
(
    test ! -d ${natt}-${vatt}                                  \
        && git clone https://git.savannah.nongnu.org/git/${natt}.git ${natt}-${vatt} \
        ;
    cd ${natt}-${vatt};
    git checkout ${vatt};
    ./autogen.sh;
    CFLAGS="-static"                                           \
    ./configure                                                \
        --prefix="${DEST}"                                     \
        --host="$(${CC} -dumpmachine)"                         \
        --enable-static                                        \
        --disable-shared                                       \
        ;
    make -j$(nproc) install;
)
touch ._${natt}-${vatt};
rm -fr  ${natt}-${vatt};