Commit 5dc33c7c authored by jan.koester's avatar jan.koester
Browse files

tetst

parent 42012659
Loading
Loading
Loading
Loading
+17 −290
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ declare -A LIBS=(
    [libpq]="https://github.com/postgres/postgres.git"
    [libressl]="https://github.com/libressl/portable.git"
    [icu]="https://github.com/unicode-org/icu.git"
    [nodejs]="https://github.com/nodejs/node.git"
    # Custom libraries
    [libcmdplus]="$GIT_BASE/jan.koester/libcmdplus.git"
    [uuidplus]="$GIT_BASE/tuxist/uuidplus.git"
@@ -105,7 +104,7 @@ setup_chroot() {
            apt-get install -y --no-install-recommends \
                ca-certificates wget git cmake ninja-build pkg-config autoconf automake libtool \
                xz-utils python3 file dpkg-dev fakeroot debhelper \
                bison flex libreadline-dev zlib1g-dev patchutils
                bison flex libreadline-dev zlib1g-dev patchutils libarchive-dev
        '
    }

@@ -398,23 +397,6 @@ build_libraries() {
            touch .\${name}.done
        }

        ensure_icupkg() {
            local c
            for c in \
                \$PREFIX/icu-host/bin/icupkg \
                \$PREFIX/icu-host/sbin/icupkg \
                /build/libs/icu/icu4c/source/build-host/bin/icupkg \
                /usr/local/bin/icupkg
            do
                if [ -x "\$c" ]; then
                    ICUPKG_BIN="\$c"
                    return 0
                fi
            done
            ICUPKG_BIN=
            return 1
        }

        # ── System/third-party dependencies ──
        build_lib json-c '${LIBS[json-c]}' '-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DDISABLE_WERROR=ON'
        build_lib libyaml '${LIBS[libyaml]}' '-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DINSTALL_CMAKE_DIR=lib/cmake/yaml'
@@ -486,117 +468,6 @@ build_libraries() {
            echo \"  [skip] libressl already built\"
        fi

        # Node.js (built from source with musl wrappers)
        if [ ! -f /build/libs/.icu-tools.done ]; then
            echo \"  [build] icu-tools (icupkg)\"
            cd /build/libs
            if [ ! -d icu ]; then
                git clone --depth 1 --branch release-75-1 '${LIBS[icu]}' icu || git clone --depth 1 '${LIBS[icu]}' icu
            fi
            cd icu/icu4c/source
            mkdir -p build-host && cd build-host
            ../configure --prefix=\$PREFIX/icu-host
            make -j\$(nproc)
            make install
            ICUPKG_BIN=
            for c in \
                \$PREFIX/icu-host/bin/icupkg \
                \$PREFIX/icu-host/sbin/icupkg \
                /build/libs/icu/icu4c/source/build-host/bin/icupkg
            do
                if [ -x "\$c" ]; then
                    ICUPKG_BIN="\$c"
                    break
                fi
            done
            if [ -z "\$ICUPKG_BIN" ]; then
                echo \"FATAL: icupkg was not built by ICU\" >&2
                exit 1
            fi
            ln -sf "\$ICUPKG_BIN" /usr/local/bin/icupkg
            cd /build/libs
            touch .icu-tools.done
        else
            echo \"  [skip] icu-tools already built\"
        fi

        if [ ! -f /build/libs/.nodejs.done ]; then
            echo \"  [build] nodejs\"
            cd /build/libs
            if [ ! -d nodejs ]; then
                git clone --depth 1 --branch v22.x '${LIBS[nodejs]}' nodejs || git clone --depth 1 '${LIBS[nodejs]}' nodejs
            fi
            if ! ensure_icupkg; then
                echo \"FATAL: icupkg is not available for node build\" >&2
                exit 1
            fi
            if [ -z "\$ICUPKG_BIN" ] || [ ! -x "\$ICUPKG_BIN" ]; then
                echo \"FATAL: detected icupkg path is invalid: \$ICUPKG_BIN\" >&2
                exit 1
            fi
            ln -sf "\$ICUPKG_BIN" /usr/local/bin/icupkg
            cd nodejs
            export CC=/usr/local/musl/bin/musl-clang
            export CXX=/usr/local/musl/bin/musl-clang++
            export AR=llvm-ar-${LLVM_VERSION}
            export RANLIB=llvm-ranlib-${LLVM_VERSION}
            export CC_host=clang-${LLVM_VERSION}
            export CXX_host=clang++-${LLVM_VERSION}
            export AR_host=llvm-ar-${LLVM_VERSION}
            export RANLIB_host=llvm-ranlib-${LLVM_VERSION}
            export PATH=\$PREFIX/icu-host/bin:\$PREFIX/icu-host/sbin:\$PATH
            export LD_LIBRARY_PATH=\$PREFIX/icu-host/lib:\$PREFIX/icu-host/lib64:/usr/local/lib:\${LD_LIBRARY_PATH:-}
            export ICU_PKG=/usr/local/bin/icupkg
            export LDFLAGS="-rtlib=compiler-rt"
            # remove -latomic which is not available in musl (and not needed on x86_64)
            sed -i 's/-latomic//g' node.gyp tools/v8_gypfiles/v8.gyp
            # Avoid running node_mksnapshot in this musl-targeted build.
            export GYP_DEFINES=\"\${GYP_DEFINES:-} v8_use_snapshot=false node_use_node_snapshot=false\"
            ./configure --prefix=\$PREFIX --shared --shared-musl --without-node-snapshot
            mkdir -p out/Release
            rm -f out/Release/icupkg
            install -m 0755 "\$ICUPKG_BIN" out/Release/icupkg
            if [ ! -x out/Release/icupkg ]; then
                echo \"FATAL: failed to stage out/Release/icupkg for node build\" >&2
                exit 1
            fi

            # Node's ICU build step expects a host genccode at out/Release/genccode.
            GENCCODE_BIN=
            for c in \
                \$PREFIX/icu-host/bin/genccode \
                \$PREFIX/icu-host/sbin/genccode \
                /build/libs/icu/icu4c/source/build-host/bin/genccode
            do
                if [ -x \"\$c\" ]; then
                    GENCCODE_BIN=\"\$c\"
                    break
                fi
            done
            if [ -z \"\$GENCCODE_BIN\" ]; then
                echo \"FATAL: genccode is not available for node build\" >&2
                exit 1
            fi
            rm -f out/Release/genccode
            install -m 0755 \"\$GENCCODE_BIN\" out/Release/genccode
            if [ ! -x out/Release/genccode ]; then
                echo \"FATAL: failed to stage out/Release/genccode for node build\" >&2
                exit 1
            fi
            make -j1
            make install
            NODE_SO_REAL=\$(find /usr/local/lib -maxdepth 1 -type f -name 'libnode.so.*' | sort -V | tail -n 1 || true)
            if [ -n "\$NODE_SO_REAL" ] && [ ! -e /usr/local/lib/libnode.so ]; then
                NODE_SO_BASENAME=\${NODE_SO_REAL##*/}
                ln -sf "\$NODE_SO_BASENAME" /usr/local/lib/libnode.so
            fi
            ln -sf /usr/local/bin/node /usr/local/bin/nodejs
            cd /build/libs
            touch .nodejs.done
        else
            echo \"  [skip] nodejs already built\"
        fi

        # ── Custom libraries ──
        build_lib libcmdplus '${LIBS[libcmdplus]}'
        build_lib uuidplus '${LIBS[uuidplus]}'
@@ -651,7 +522,6 @@ update_libraries() {
                cd /build/libs
            fi

            # Remove done marker and rebuild
            rm -f .\${name}.done
            rm -rf \$name/build
            mkdir -p \$name/build && cd \$name/build
@@ -667,23 +537,6 @@ update_libraries() {
            touch .\${name}.done
        }

        ensure_icupkg() {
            local c
            for c in \
                \$PREFIX/icu-host/bin/icupkg \
                \$PREFIX/icu-host/sbin/icupkg \
                /build/libs/icu/icu4c/source/build-host/bin/icupkg \
                /usr/local/bin/icupkg
            do
                if [ -x "\$c" ]; then
                    ICUPKG_BIN="\$c"
                    return 0
                fi
            done
            ICUPKG_BIN=
            return 1
        }

        # ── System/third-party dependencies ──
        update_lib json-c '${LIBS[json-c]}' '-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DDISABLE_WERROR=ON'
        update_lib libyaml '${LIBS[libyaml]}' '-DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DINSTALL_CMAKE_DIR=lib/cmake/yaml'
@@ -737,144 +590,6 @@ update_libraries() {
            cd /build/libs
        fi

        # ICU tools (icupkg)
        if [ ! -d icu ]; then
            echo \"  [clone] icu\"
            git clone --depth 1 --branch release-75-1 '${LIBS[icu]}' icu || git clone --depth 1 '${LIBS[icu]}' icu
            rm -f /build/libs/.icu-tools.done
        else
            echo \"  [pull] icu\"
            cd icu
            git fetch --depth 1 origin
            LOCAL=\$(git rev-parse HEAD)
            REMOTE=\$(git rev-parse FETCH_HEAD)
            if [ \"\$LOCAL\" != \"\$REMOTE\" ]; then
                git reset --hard FETCH_HEAD
                rm -f /build/libs/.icu-tools.done
            else
                echo \"  [skip] icu already up-to-date\"
            fi
            cd /build/libs
        fi

        if [ ! -f /build/libs/.icu-tools.done ]; then
            echo \"  [rebuild] icu-tools (icupkg)\"
            cd /build/libs/icu/icu4c/source
            rm -rf build-host
            mkdir -p build-host && cd build-host
            ../configure --prefix=\$PREFIX/icu-host
            make -j\$(nproc)
            make install
            ICUPKG_BIN=
            for c in \
                \$PREFIX/icu-host/bin/icupkg \
                \$PREFIX/icu-host/sbin/icupkg \
                /build/libs/icu/icu4c/source/build-host/bin/icupkg
            do
                if [ -x "\$c" ]; then
                    ICUPKG_BIN="\$c"
                    break
                fi
            done
            if [ -z "\$ICUPKG_BIN" ]; then
                echo \"FATAL: icupkg was not built by ICU\" >&2
                exit 1
            fi
            ln -sf "\$ICUPKG_BIN" /usr/local/bin/icupkg
            touch /build/libs/.icu-tools.done
            cd /build/libs
        fi

        # Node.js (source build)
        if [ ! -d nodejs ]; then
            echo \"  [clone] nodejs\"
            git clone --depth 1 --branch v22.x '${LIBS[nodejs]}' nodejs || git clone --depth 1 '${LIBS[nodejs]}' nodejs
        else
            echo \"  [pull] nodejs\"
            cd nodejs
            git fetch --depth 1 origin
            LOCAL=\$(git rev-parse HEAD)
            REMOTE=\$(git rev-parse FETCH_HEAD)
            if [ \"\$LOCAL\" != \"\$REMOTE\" ]; then
                git reset --hard FETCH_HEAD
                rm -f /build/libs/.nodejs.done
            else
                echo \"  [skip] nodejs already up-to-date\"
            fi
            cd /build/libs
        fi

        if [ ! -f /build/libs/.nodejs.done ]; then
            echo \"  [rebuild] nodejs\"
            cd /build/libs/nodejs
            if ! ensure_icupkg; then
                echo \"FATAL: icupkg is not available for node build\" >&2
                exit 1
            fi
            if [ -z \"\$ICUPKG_BIN\" ] || [ ! -x \"\$ICUPKG_BIN\" ]; then
                echo \"FATAL: detected icupkg path is invalid: \$ICUPKG_BIN\" >&2
                exit 1
            fi

            ln -sf \"\$ICUPKG_BIN\" /usr/local/bin/icupkg
            export CC=/usr/local/musl/bin/musl-clang
            export CXX=/usr/local/musl/bin/musl-clang++
            export AR=llvm-ar-${LLVM_VERSION}
            export RANLIB=llvm-ranlib-${LLVM_VERSION}
            export CC_host=clang-${LLVM_VERSION}
            export CXX_host=clang++-${LLVM_VERSION}
            export AR_host=llvm-ar-${LLVM_VERSION}
            export RANLIB_host=llvm-ranlib-${LLVM_VERSION}
            export PATH=\$PREFIX/icu-host/bin:\$PREFIX/icu-host/sbin:\$PATH
            export LD_LIBRARY_PATH=\$PREFIX/icu-host/lib:\$PREFIX/icu-host/lib64:/usr/local/lib:\${LD_LIBRARY_PATH:-}
            export ICU_PKG=/usr/local/bin/icupkg
            # remove -latomic which is not available in musl (and not needed on x86_64)
            sed -i 's/-latomic//g' node.gyp tools/v8_gypfiles/v8.gyp
            # Avoid running node_mksnapshot in this musl-targeted build.
            export GYP_DEFINES=\"\${GYP_DEFINES:-} v8_use_snapshot=false node_use_node_snapshot=false\"
            ./configure --prefix=\$PREFIX --shared --without-npm --without-node-snapshot
            mkdir -p out/Release
            rm -f out/Release/icupkg
            install -m 0755 \"\$ICUPKG_BIN\" out/Release/icupkg
            if [ ! -x out/Release/icupkg ]; then
                echo \"FATAL: failed to stage out/Release/icupkg for node build\" >&2
                exit 1
            fi

            # Node's ICU build step expects a host genccode at out/Release/genccode.
            GENCCODE_BIN=
            for c in \
                \$PREFIX/icu-host/bin/genccode \
                \$PREFIX/icu-host/sbin/genccode \
                /build/libs/icu/icu4c/source/build-host/bin/genccode
            do
                if [ -x \"\$c\" ]; then
                    GENCCODE_BIN=\"\$c\"
                    break
                fi
            done
            if [ -z \"\$GENCCODE_BIN\" ]; then
                echo \"FATAL: genccode is not available for node build\" >&2
                exit 1
            fi
            rm -f out/Release/genccode
            install -m 0755 \"\$GENCCODE_BIN\" out/Release/genccode
            if [ ! -x out/Release/genccode ]; then
                echo \"FATAL: failed to stage out/Release/genccode for node build\" >&2
                exit 1
            fi
            make -j32
            make install
            NODE_SO_REAL=\$(find /usr/local/lib -maxdepth 1 -type f -name 'libnode.so.*' | sort -V | tail -n 1 || true)
            if [ -n "\$NODE_SO_REAL" ] && [ ! -e /usr/local/lib/libnode.so ]; then
                NODE_SO_BASENAME=\${NODE_SO_REAL##*/}
                ln -sf "\$NODE_SO_BASENAME" /usr/local/lib/libnode.so
            fi
            ln -sf /usr/local/bin/node /usr/local/bin/nodejs
            touch /build/libs/.nodejs.done
            cd /build/libs
        fi

        # ── Custom libraries ──
        update_lib libcmdplus '${LIBS[libcmdplus]}'
        update_lib uuidplus '${LIBS[uuidplus]}'
@@ -941,10 +656,22 @@ run_phase() {
    local phase="$1"
    case "$phase" in
        chroot)      setup_chroot ;;
        toolchain)   setup_toolchain ;;
        libraries)   build_libraries ;;
        update-libs) update_libraries ;;
        blogi)       build_blogi ;;
        toolchain)
            setup_chroot
            setup_toolchain
            ;;
        libraries)
            setup_chroot
            build_libraries
            ;;
        update-libs)
            setup_chroot
            update_libraries
            ;;
        blogi)
            setup_chroot
            build_blogi
            ;;
        all)
            setup_chroot
            setup_toolchain