From 6fa7a643e6ebdafb719ae0734bb7f8fdcae0e59e Mon Sep 17 00:00:00 2001 From: Jason Walton Date: Wed, 14 Dec 2022 22:40:11 -0500 Subject: [PATCH 1/7] feat: add x64-glibc-217 recipe --- .gitignore | 1 + README.md | 3 ++- bin/build.sh | 3 ++- recipes/x64-glibc-217/Dockerfile | 32 +++++++++++++++++++++++ recipes/x64-glibc-217/cloudlinux.repo | 9 +++++++ recipes/x64-glibc-217/run.sh | 37 +++++++++++++++++++++++++++ recipes/x64-glibc-217/should-build.sh | 10 ++++++++ 7 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 recipes/x64-glibc-217/Dockerfile create mode 100644 recipes/x64-glibc-217/cloudlinux.repo create mode 100755 recipes/x64-glibc-217/run.sh create mode 100755 recipes/x64-glibc-217/should-build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2fa65f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/workdir diff --git a/README.md b/README.md index 31b2a86..67691da 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ This list of officially supported platforms is available in the Node.js [BUILDIN ## Builds * **linux-x64-musl**: Linux x64 binaries compiled against [musl libc](https://www.musl-libc.org/) version 1.1.20. Primarily useful for users of Alpine Linux 3.9 and later. Linux x64 with musl is considered "Experimental" by Node.js but the Node.js test infrastructure includes some Alpine test servers so support is generally good. These Node.js builds require the `libstdc++` package to be installed on Alpine Linux, which is not installed by default. You can add this by running `apk add libstdc++`. +* **linux-x64-glibc-217**: Linux x64, compiled with glibc 2.17 to support [older Linux distros](https://en.wikipedia.org/wiki/Glibc#Version_history), QNAP QTS 4.x and 5.x, and Synology DSM 7, and other environments where a newer glibc is unavailable. * **linux-x86**: Linux x86 (32-bit) binaries compiled against libc 2.17, similar to the way the official [linux-x64 binaries are produced](https://github.com/nodejs/node/blob/master/BUILDING.md#official-binary-platforms-and-toolchains). 32-bit Linux binaries were dropped for Node.js 10 and 32-bit support is now considered "Experimental". * **linux-armv6l**: Linux ARMv6 binaries, cross-compiled on Ubuntu 16.04 with a [custom GCC 6 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js versions earlier than 16) or Ubuntu 18.04 with a [custom GCC 8 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js 16 and later) in a similar manner to the official linux-armv7l binaries. Binaries are optimized for `armv6zk` which is suitable for Raspberry Pi devices (1, 1+ and Zero in particular). ARMv6 binaries were dropped from Node.js 12 and ARMv6 support is now considered "Experimental". * **riscv64**: Linux riscv64 (RISC-V), cross compiled on Ubuntu 20.04 with the toolchain which the Adoptium project uses (for now...). Built with --openssl-no-asm (Should be with --with-intl=none but that gets overriden) @@ -41,7 +42,7 @@ The build process can be described as: 1. This repository is cloned onto the unofficial-builds server whenever it is updated (triggered via [github-webhook](https://github.com/rvagg/github-webhook)) and Docker images contained within the [`/recipes`](/recipes) directory are built by means of the [`/bin/deploy.sh`](/bin/deploy.sh) script which in turn calls the [`/bin/prepare-images.sh`](/bin/prepare-images.sh) script. 2. A periodic service runs every 5 minutes via systemd on the server which calls [`/bin/periodic.sh`](/bin/periodic.sh) script. -3. `periodic.sh` calls [`/bin/check-releases.sh`](/bin/check-releases.sh) for each release line being checked ("release", "rc", etc.). Any new versions that check-releases.sh finds are added to the build queue via [`/bin/queue-push.sh`](/bin/queue-push.sh) (the build queue uses a locking mechanism to prevent concurrent changes). +3. `periodic.sh` calls [`/bin/check-releases.sh`](/bin/check-releases.sh) for each release line being checked ("release", "rc", etc.). Any new versions that check-releases.sh finds are added to the build queue via [`/bin/queue-push.sh`](/bin/queue-push.sh) (the build queue uses a locking mechanism to prevent concurrent changes). 4. `periodic.sh` calls [`/bin/build-if-queued.sh`](/bin/build-if-queued.sh) which will execute a build if there is at least one build in the queue and no builds are currently running. [`/bin/queue-pop.sh`](/bin/queue-pop.sh) is used to atomically remove the next build from the queue. Note that only zero or one build per periodic run is executed. If the queue has more than one build, these will be deferred until later periodic runs. 5. When `build-if-queued.sh` encounters a build in the queue that it can execute, it calls [`/bin/build.sh`](/bin/build.sh) to perform the build. This script iterates through the images that have been pre-built from the [`/recipes`](/recipes) directory, starting with the [`/recipes/fetch-source`](/recipes/fetch-source) recipe that fetches the source file for the given version and validates official releases using GPG keys. Optionally, a recipe might have a `should-build` file which is used to determine if the recipe should run for a specific Node.js version. Each recipe is passed this source and is given a staging directory to place its binaries in. After all recipes are finished, builds are promoted to the directory along with a SHASUMS256.txt file and the index.tab and index.json files for that release type are updated. diff --git a/bin/build.sh b/bin/build.sh index 2328dac..6dd666a 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -14,6 +14,7 @@ recipes=" \ musl \ armv6l \ armv6l-pre16 \ + x64-glibc-217 \ x64-pointer-compression \ x64-usdt \ riscv64 \ @@ -67,7 +68,7 @@ docker run --rm \ # Build all other recipes for recipe in $recipes; do # each recipe has 3 variable components: - # - individiaul ~/.ccache directory + # - individual ~/.ccache directory # - a ~/node.tar.xz file that fetch-source has downloaded # - an output /out directory that puts generated assets into a staging directory ccachemount="-v ${ccachedir}/${recipe}/:/home/node/.ccache/" diff --git a/recipes/x64-glibc-217/Dockerfile b/recipes/x64-glibc-217/Dockerfile new file mode 100644 index 0000000..43f4ae7 --- /dev/null +++ b/recipes/x64-glibc-217/Dockerfile @@ -0,0 +1,32 @@ +FROM centos:7 + +ARG GID=1000 +ARG UID=1000 + +RUN groupadd --gid $GID node \ + && adduser --gid $GID --uid $UID node + +COPY cloudlinux.repo /etc/yum.repos.d/cloudlinux.repo + +RUN yum install -y epel-release \ + && yum upgrade -y \ + && yum install -y \ + git \ + curl \ + make \ + python2 \ + python3 \ + ccache \ + xz-utils \ + devtoolset-9 \ + glibc-devel + +COPY --chown=node:node run.sh /home/node/run.sh + +VOLUME /home/node/.ccache +VOLUME /out +VOLUME /home/node/node.tar.xz + +USER node + +ENTRYPOINT [ "/home/node/run.sh" ] diff --git a/recipes/x64-glibc-217/cloudlinux.repo b/recipes/x64-glibc-217/cloudlinux.repo new file mode 100644 index 0000000..2ca8962 --- /dev/null +++ b/recipes/x64-glibc-217/cloudlinux.repo @@ -0,0 +1,9 @@ +[cloudlinux-sclo-devtoolset-8] +name=Cloudlinux devtoolset-8 +baseurl=https://repo.cloudlinux.com/cloudlinux/7/sclo/devtoolset-8/x86_64/ +gpgcheck=0 + +[cloudlinux-sclo-devtoolset-9] +name=Cloudlinux devtoolset-9 +baseurl=https://repo.cloudlinux.com/cloudlinux/7/sclo/devtoolset-9/x86_64/ +gpgcheck=0 diff --git a/recipes/x64-glibc-217/run.sh b/recipes/x64-glibc-217/run.sh new file mode 100755 index 0000000..bf4002e --- /dev/null +++ b/recipes/x64-glibc-217/run.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +set -e +set -x + +release_urlbase="$1" +disttype="$2" +customtag="$3" +datestring="$4" +commit="$5" +fullversion="$6" +source_url="$7" +config_flags="" + +cd /home/node + +tar -xf node.tar.xz +cd "node-${fullversion}" + +export CC="ccache gcc" +export CXX="ccache g++" +export MAJOR_VERSION=$(echo ${fullversion} | cut -d . -f 1 | tr --delete v) + +. /opt/rh/devtoolset-9/enable + +make -j$(getconf _NPROCESSORS_ONLN) binary V= \ + DESTCPU="x64" \ + ARCH="x64" \ + VARIATION="glibc-217" \ + DISTTYPE="$disttype" \ + CUSTOMTAG="$customtag" \ + DATESTRING="$datestring" \ + COMMIT="$commit" \ + RELEASE_URLBASE="$release_urlbase" \ + CONFIG_FLAGS="$config_flags" + +mv node-*.tar.?z /out/ diff --git a/recipes/x64-glibc-217/should-build.sh b/recipes/x64-glibc-217/should-build.sh new file mode 100755 index 0000000..2453d49 --- /dev/null +++ b/recipes/x64-glibc-217/should-build.sh @@ -0,0 +1,10 @@ +#!/bin/bash -xe + +__dirname=$1 +fullversion=$2 + +. ${__dirname}/_decode_version.sh + +decode "$fullversion" + +test "$major" -ge "18" From f848e8d10b05c9258bf66282ab33f972e2f69131 Mon Sep 17 00:00:00 2001 From: Stewart X Addison Date: Tue, 16 May 2023 12:26:25 +0100 Subject: [PATCH 2/7] update link to riscv64 toolchain Signed-off-by: Stewart X Addison --- recipes/riscv64/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/riscv64/Dockerfile b/recipes/riscv64/Dockerfile index aff3453..2ba19fe 100644 --- a/recipes/riscv64/Dockerfile +++ b/recipes/riscv64/Dockerfile @@ -21,7 +21,7 @@ RUN apt-get update \ ccache \ xz-utils -RUN curl https://ci.adoptopenjdk.net/userContent/riscv/riscv_toolchain_linux64.tar.xz | tar xJf - -C /opt +RUN curl https://ci.adoptium.net/userContent/riscv/riscv_toolchain_linux64.tar.xz | tar xJf - -C /opt COPY --chown=node:node run.sh /home/node/run.sh From c25b43a63c11e38a4ed03b03d97b4fb3bf95bf25 Mon Sep 17 00:00:00 2001 From: Marcelo Politzer Date: Wed, 26 Apr 2023 20:21:26 -0300 Subject: [PATCH 3/7] update riscv64 ubuntu to 22.04, the next lts version --- README.md | 2 +- recipes/riscv64/Dockerfile | 11 +++++------ recipes/riscv64/run.sh | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 67691da..b2df6c2 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This list of officially supported platforms is available in the Node.js [BUILDIN * **linux-x64-glibc-217**: Linux x64, compiled with glibc 2.17 to support [older Linux distros](https://en.wikipedia.org/wiki/Glibc#Version_history), QNAP QTS 4.x and 5.x, and Synology DSM 7, and other environments where a newer glibc is unavailable. * **linux-x86**: Linux x86 (32-bit) binaries compiled against libc 2.17, similar to the way the official [linux-x64 binaries are produced](https://github.com/nodejs/node/blob/master/BUILDING.md#official-binary-platforms-and-toolchains). 32-bit Linux binaries were dropped for Node.js 10 and 32-bit support is now considered "Experimental". * **linux-armv6l**: Linux ARMv6 binaries, cross-compiled on Ubuntu 16.04 with a [custom GCC 6 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js versions earlier than 16) or Ubuntu 18.04 with a [custom GCC 8 toolchain](https://github.com/rvagg/rpi-newer-crosstools) (for Node.js 16 and later) in a similar manner to the official linux-armv7l binaries. Binaries are optimized for `armv6zk` which is suitable for Raspberry Pi devices (1, 1+ and Zero in particular). ARMv6 binaries were dropped from Node.js 12 and ARMv6 support is now considered "Experimental". - * **riscv64**: Linux riscv64 (RISC-V), cross compiled on Ubuntu 20.04 with the toolchain which the Adoptium project uses (for now...). Built with --openssl-no-asm (Should be with --with-intl=none but that gets overriden) + * **riscv64**: Linux riscv64 (RISC-V), cross compiled on Ubuntu 22.04 with the ubuntu toolchain. Built with --openssl-no-asm (Should be with --with-intl=none but that gets overriden) "Experimental" status for Node.js is defined as: > Experimental: May not compile or test suite may not pass. The core team does not create releases for these platforms. Test failures on experimental platforms do not block releases. Contributions to improve support for these platforms are welcome. diff --git a/recipes/riscv64/Dockerfile b/recipes/riscv64/Dockerfile index 2ba19fe..f4b8be4 100644 --- a/recipes/riscv64/Dockerfile +++ b/recipes/riscv64/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:20.04 +FROM ubuntu:22.04 ARG GID=1000 ARG UID=1000 @@ -13,15 +13,14 @@ RUN apt-get update \ && apt-get update \ && apt-get install -y \ git \ - g++-9 \ + g++-9 \ curl \ make \ python3 \ - python3-distutils \ + python3-distutils \ ccache \ - xz-utils - -RUN curl https://ci.adoptium.net/userContent/riscv/riscv_toolchain_linux64.tar.xz | tar xJf - -C /opt + g++-riscv64-linux-gnu \ + gcc-riscv64-linux-gnu COPY --chown=node:node run.sh /home/node/run.sh diff --git a/recipes/riscv64/run.sh b/recipes/riscv64/run.sh index 97bc464..9b651b6 100755 --- a/recipes/riscv64/run.sh +++ b/recipes/riscv64/run.sh @@ -19,8 +19,8 @@ cd "node-${fullversion}" export CC_host="ccache gcc-9" export CXX_host="ccache g++-9" -export CC="ccache /opt/riscv_toolchain_linux/bin/riscv64-unknown-linux-gnu-gcc" -export CXX="ccache /opt/riscv_toolchain_linux/bin/riscv64-unknown-linux-gnu-g++" +export CC="ccache riscv64-linux-gnu-gcc" +export CXX="ccache riscv64-linux-gnu-g++" make -j$(getconf _NPROCESSORS_ONLN) binary V= \ DESTCPU="riscv64" \ From 9be03b447504de82ce88857a8d91a70ab48ea89b Mon Sep 17 00:00:00 2001 From: Marcelo Politzer Date: Wed, 26 Apr 2023 20:23:22 -0300 Subject: [PATCH 4/7] add support to build only one of the recipies --- bin/build.sh | 3 ++- bin/prepare-images.sh | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/build.sh b/bin/build.sh index 6dd666a..069ace6 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -30,6 +30,7 @@ if [[ "X${1}" = "X" ]]; then fi fullversion="$1" +shift . ${__dirname}/_decode_version.sh decode "$fullversion" # see _decode_version for all of the magic variables now set and available for use @@ -66,7 +67,7 @@ docker run --rm \ > ${thislogdir}/fetch-source.log 2>&1 # Build all other recipes -for recipe in $recipes; do +for recipe in ${1:-$recipes}; do # each recipe has 3 variable components: # - individual ~/.ccache directory # - a ~/node.tar.xz file that fetch-source has downloaded diff --git a/bin/prepare-images.sh b/bin/prepare-images.sh index b38d68f..12b4eca 100755 --- a/bin/prepare-images.sh +++ b/bin/prepare-images.sh @@ -5,7 +5,8 @@ __dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" image_tag_pfx=unofficial-build-recipe- -for recipe in $(ls ${__dirname}/../recipes/); do +recipes=${1:-$(ls ${__dirname}/../recipes/)} +for recipe in $recipes; do docker build ${__dirname}/../recipes/${recipe}/ -t ${image_tag_pfx}${recipe} --build-arg UID=1000 --build-arg GID=1000 done From 4bca355e7de159e2cdfcfba8139147a7d9f1f57a Mon Sep 17 00:00:00 2001 From: Marcelo Politzer Date: Wed, 26 Apr 2023 21:40:10 -0300 Subject: [PATCH 5/7] Add single target example to README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index b2df6c2..aa5a0d4 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,19 @@ This list of officially supported platforms is available in the Node.js [BUILDIN **unofficial-builds** attempts to provide basic Node.js binaries for some platforms that either not supported or only partially supported by Node.js. This project **does not provide any guarantees** and its results are not rigorously tested. Builds made available at nodejs.org have very high quality standards for code quality, support on the relevant platforms and for timing and methods of delivery. Builds made available by unofficial-builds have minimal or no testing; the platforms may have no inclusion in the official Node.js test infrastructure. These builds are made available for the convenience of their user community but those communities are expected to assist in their maintenance. +## Run + +Execute the following commands to cross compile riscv64 node binaries. Select the node version on the `bin/build.sh` call. + +```sh +./bin/prepare-images.sh "fetch-source riscv64" +mkdir -p build/download +mkdir -p build/logs +mkdir -p build/staging +mkdir -p build/.ccache +workdir=$PWD/build/ bin/build.sh v18.16.0 riscv64 +``` + ## Builds * **linux-x64-musl**: Linux x64 binaries compiled against [musl libc](https://www.musl-libc.org/) version 1.1.20. Primarily useful for users of Alpine Linux 3.9 and later. Linux x64 with musl is considered "Experimental" by Node.js but the Node.js test infrastructure includes some Alpine test servers so support is generally good. These Node.js builds require the `libstdc++` package to be installed on Alpine Linux, which is not installed by default. You can add this by running `apk add libstdc++`. From 4ce4214e998dcf0e161026f858fd47d547340bb7 Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Wed, 26 Apr 2023 21:56:34 -0300 Subject: [PATCH 6/7] manual build workflow --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ bin/build.sh | 6 ++++++ 2 files changed, 43 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..56510e0 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: build +on: + workflow_dispatch: + inputs: + version: + type: string + description: Node.js version to build + required: true + arch: + type: string + description: Architecture to build + default: riscv64 +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: prepare + run: bin/prepare-images.sh "fetch-source ${{ github.event.inputs.arch }}" + - name: create build directories + run: mkdir -p build/download build/logs build/staging build/.ccache + - name: build + run: bin/build.sh ${{ github.event.inputs.version }} ${{ github.event.inputs.arch }} + env: + workdir: build + - name: save logs + uses: actions/upload-artifact@v3 + if: always() + with: + name: logs + path: build/logs + - name: save download + uses: actions/upload-artifact@v3 + if: always() + with: + name: download + path: build/download diff --git a/bin/build.sh b/bin/build.sh index 069ace6..5aa1e07 100755 --- a/bin/build.sh +++ b/bin/build.sh @@ -59,6 +59,9 @@ distdir_promote="${distdir}/${disttype_promote}" distoutdir="${distdir_promote}/${fullversion}" mkdir -p $distoutdir +# give write permission to all, to avoid docker permission issues +chmod 777 -R ${workdir} + # Build fetch-source, needs to be the first and must succeed docker run --rm \ -v ${sourcedir}:/out \ @@ -77,6 +80,9 @@ for recipe in ${1:-$recipes}; do sourcemount="-v ${sourcefile}:/home/node/node.tar.xz" stagingmount="-v ${stagingoutdir}:/out" + # give write permission to all (again), to avoid docker permission issues + chmod 777 -R ${ccachedir}/${recipe} + shouldbuild="${__dirname}/../recipes/$recipe/should-build.sh" if [ -f "$shouldbuild" ]; then From 76fc078fa64a42749cdf34e70c7364a284ae0b5a Mon Sep 17 00:00:00 2001 From: Danilo Tuler Date: Thu, 27 Apr 2023 22:52:31 -0300 Subject: [PATCH 7/7] create release on manual build workflow --- .github/workflows/build.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 56510e0..cdc0c0d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,11 @@ jobs: path: build/logs - name: save download uses: actions/upload-artifact@v3 - if: always() with: name: download path: build/download + - name: Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ github.event.inputs.version }} + files: build/download/release/${{ github.event.inputs.version }}/*