diff --git a/.github/workflows/buildNative.yml b/.github/workflows/buildNative.yml index 2eb8b9481..f704bdf5d 100644 --- a/.github/workflows/buildNative.yml +++ b/.github/workflows/buildNative.yml @@ -53,9 +53,9 @@ jobs: cache: 'maven' github-token: ${{ secrets.GITHUB_TOKEN }} - - name: "Install all with Maven" + - name: "Install all with Maven" - run: mvn --batch-mode clean install -DskipTests -T 1C + run: mvn --batch-mode clean install -pl !org.nzbhydra:linux-release,!org.nzbhydra:windows-release,!org.nzbhydra:generic-release -DskipTests -T 1C - name: "Run unit tests" run: mvn --batch-mode test -T 1C -pl !org.nzbhydra:tests,!org.nzbhydra.tests:system --fail-at-end diff --git a/.idea/misc.xml b/.idea/misc.xml index b85a2a86f..fedcf572c 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -70,7 +70,7 @@ - + \ No newline at end of file diff --git a/core/src/main/resources/changelog.yaml b/core/src/main/resources/changelog.yaml index 1f9760053..fd58f0f1c 100644 --- a/core/src/main/resources/changelog.yaml +++ b/core/src/main/resources/changelog.yaml @@ -3,6 +3,8 @@ changes: - type: "feature" text: "Include service scripts for windows and linux in generic release" + - type: "feature" + text: "The previously compiled binaries did not start on all linux distros. I switched to an older distro to compile the binary so it hopefully is also runnable on older distros." final: true - version: "v5.0.4" date: "2023-01-22" diff --git a/misc/build-and-release.ps1 b/misc/build-and-release.ps1 index 9f8c28105..673cd3d0c 100644 --- a/misc/build-and-release.ps1 +++ b/misc/build-and-release.ps1 @@ -91,8 +91,6 @@ if (-not $?) { exit 1 } -Read-Host -Prompt "nzbhydra.exe didn't work before. Have you made sure it works?" - Write-Host "Generating changelog" exec { mvn -q -B org.nzbhydra:github-release-plugin:3.0.0:generate-changelog } if (-not $?) { @@ -166,6 +164,12 @@ if (-not $?) { exit 1 } +$genericVersion = java -jar releases/generic-release/include/core-$version-exec.jar -version +if ($genericVersion -ne $version) { + Write-Error "Generic version $version expected but is $genericVersion" + exit 1 +} + Write-Host "Building windows executable" try { .\buildCore.cmd @@ -181,13 +185,8 @@ if ($windowsVersion -ne $version) { exit 1 } -$genericVersion = java -jar releases/generic-release/include/core-$version-exec.jar -version -if ($genericVersion -ne $version) { - Write-Error "Generic version $version expected but is $genericVersion" - exit 1 -} - -Read-Host -Prompt "Wait for build to finish on pipeline. Copy linux executable to include folder. Press enter to continue" +Write-Host "Building linux executable" +wsl -d Ubuntu -- sh -c ./misc/buildLinuxCore/buildLinuxCore.sh $linuxVersion = wsl -d Ubuntu releases/linux-release/include/core -version if ($linuxVersion -ne $version) { diff --git a/misc/buildLinuxCore/buildDockerImage.sh b/misc/buildLinuxCore/buildDockerImage.sh new file mode 100644 index 000000000..c3b4eff10 --- /dev/null +++ b/misc/buildLinuxCore/buildDockerImage.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# Builds the docker image which is used to build the linux core executable + +docker build -t hydrabuild . diff --git a/misc/buildLinuxCore/buildInContainer.sh b/misc/buildLinuxCore/buildInContainer.sh new file mode 100644 index 000000000..11bfde12c --- /dev/null +++ b/misc/buildLinuxCore/buildInContainer.sh @@ -0,0 +1,7 @@ +#!/bin/bash +#Is run in the docker image to actually build the linux executable + +cd /nzbhydra2 || exit +mvn --batch-mode clean install -pl \!org.nzbhydra:linux-release,\!org.nzbhydra:windows-release,\!org.nzbhydra:generic-release -DskipTests -T 1C +mvn -pl org.nzbhydra:core -Pnative clean native:compile -DskipTests +/upx-4.0.1-amd64_linux/upx -3 core/target/core diff --git a/misc/buildLinuxCore/buildLinuxCore.sh b/misc/buildLinuxCore/buildLinuxCore.sh new file mode 100644 index 000000000..0a8769034 --- /dev/null +++ b/misc/buildLinuxCore/buildLinuxCore.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Prepares and runs the docker container to build the core executable + +if [[ ! -d "${PWD}/core" ]] ; then + echo "${PWD}/core not found " + return +fi + +echo rsync -rvu --exclude "target" --exclude "bower_components" --exclude "node_modules" --exclude ".git" --exclude ".idea" --exclude "results" --exclude "*.db" --exclude "venv*" ${PWD}/ ~/nzbhydra2/ + +docker run -v ~/nzbhydra2/:/nzbhydra2:rw -v ~/.m2/repository:/root/.m2/repository:rw --rm hydrabuild:latest +if [[ ! -f ~/nzbhydra2/core/target/core ]] ; then + echo "core executable does not exist" +else + cp ~/nzbhydra2/core/target/core ${PWD}/core/target/ + cp ~/nzbhydra2/core/target/core ${PWD}/releases/linux-release/include/ +fi diff --git a/misc/buildLinuxCore/dockerfile b/misc/buildLinuxCore/dockerfile new file mode 100644 index 000000000..025b8ddf9 --- /dev/null +++ b/misc/buildLinuxCore/dockerfile @@ -0,0 +1,31 @@ +# alpine doesn't work because we need libgc for the native image +FROM ubuntu:16.04 +# See https://octopus.com/blog/using-ubuntu-docker-image +RUN echo 'APT::Install-Suggests "0";' >> /etc/apt/apt.conf.d/00-docker +RUN echo 'APT::Install-Recommends "0";' >> /etc/apt/apt.conf.d/00-docker +RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y zip unzip wget curl libfreetype6 libfreetype6-dev build-essential ca-certificates +RUN wget -nv --no-check-certificate https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz -P /tmp + +RUN tar xf /tmp/apache-maven-*.tar.gz -C /opt +RUN ln -s /opt/apache-maven-3.8.7 /opt/maven +ENV M2_HOME=/opt/maven +ENV MAVEN_HOME=/opt/maven +ENV PATH=${M2_HOME}/bin:${PATH} + +RUN wget -nv --no-check-certificate https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-22.3.0/graalvm-ce-java17-linux-amd64-22.3.0.tar.gz +RUN tar xzf graalvm-ce-java17-linux-amd64-22.3.0.tar.gz -C / +ENV PATH=/graalvm-ce-java17-22.3.0/bin/:$PATH +ENV JAVA_HOME=/graalvm-ce-java17-22.3.0 + +RUN wget -nv --no-check-certificate https://github.com/upx/upx/releases/download/v4.0.1/upx-4.0.1-amd64_linux.tar.xz +RUN tar -xf upx-4.0.1-amd64_linux.tar.xz +ENV PATH=/tmp/upx-4.0.1-amd64_linux/:$PATH + +ENV HYDRA_NATIVE_BUILD=true + +COPY buildInContainer.sh / + +ENTRYPOINT /buildInContainer.sh + +# To debug docker run --rm -it --entrypoint bash hydrabuild +# or for a running container docker exec -it bash diff --git a/misc/rsyncAndStartGraalvmDocker.sh b/misc/rsyncAndStartGraalvmDocker.sh new file mode 100644 index 000000000..0bd47f1af --- /dev/null +++ b/misc/rsyncAndStartGraalvmDocker.sh @@ -0,0 +1,12 @@ +SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) + +if [[ -f core ]] ; then + cd .. +fi +if [[ -f core ]] ; then + echo "core folder not found" + exit 1 +fi + +rsync -rvu --exclude "target" --exclude "bower_components" --exclude "node_modules" --exclude ".git" --exclude ".idea" --exclude "results" --exclude "*.db" --exclude "venv*" . ~/nzbhydra2/ +docker run -v ~/.m2/repository:/root/.m2/repository:rw -v ~/nzbhydra2:/nzbhydra2 -it --rm vegardit/graalvm-maven:22.3.0-java17 bash diff --git a/misc/rsyncToHome.sh b/misc/rsyncToHome.sh deleted file mode 100644 index f710f57a5..000000000 --- a/misc/rsyncToHome.sh +++ /dev/null @@ -1 +0,0 @@ -rsync -rvu --exclude "target" --exclude "bower_components" --exclude "node_modules" --exclude ".git" --exclude ".idea" --exclude "results" --exclude "*.db" --exclude "venv*" . ~/nzbhydra2/ diff --git a/nativeNotes.md b/nativeNotes.md index 4c44474b9..399fc709e 100644 --- a/nativeNotes.md +++ b/nativeNotes.md @@ -125,3 +125,17 @@ If anything fails you can always switch back to the old folder or docker image u +apt update +apt install -y zip unzip wget curl libfreetype6 libfreetype6-dev apt-get install build-essential +wget https://dlcdn.apache.org/maven/maven-3/3.8.7/binaries/apache-maven-3.8.7-bin.tar.gz -P /tmp +tar xf /tmp/apache-maven-*.tar.gz -C /opt +ln -s /opt/apache-maven-3.8.7 /opt/maven +export M2_HOME=/opt/maven +export MAVEN_HOME=/opt/maven +export PATH=${M2_HOME}/bin:${PATH} +curl -s "https://get.sdkman.io" | bash +source "/root/.sdkman/bin/sdkman-init.sh" +sdk install java 22.3.r17-grl +mvn --batch-mode clean install -DskipTests -T 1C +export HYDRA_NATIVE_BUILD=true +mvn -pl org.nzbhydra:core -Pnative clean native:compile -DskipTests