diff --git a/.env b/.env index 30b3ab2..87529b7 100644 --- a/.env +++ b/.env @@ -1,5 +1,2 @@ -JAVA_VERSION=17.0.6+10 -JRUBY_VERSION=9.3.9.0 -HUGO_VERSION=0.110.0 SCHEMATRON_VERSION=2020-10-01 SCHUNIT_VERSION=0.4.0 \ No newline at end of file diff --git a/Makefile b/Makefile index 8aae415..51091b5 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,13 @@ PATH=$(shell pwd)/src/bin:$(shell echo $$PATH) include .env -export +export -default: clean linux macos win +default: clean build clean: - @rm -rf target + @rm -rf target tmp -linux: linux-amd64 linux-arm64 - -linux-amd64: - @fetch linux-amd64 linux nix - @package-tar linux-amd64 - -linux-arm64: - @fetch linux-arm64 linux nix - @package-tar linux-arm64 - -macos: macos-amd64 - -macos-amd64: - @fetch macos-amd64 macos nix - @package-tar macos-amd64 - -win: win-amd64 - -win-amd64: - @fetch win-amd64 win - @package-zip win-amd64 +build: + @$(CURDIR)/src/bin/fetch + @$(CURDIR)/src/bin/package-tar + @$(CURDIR)/src/bin/package-zip diff --git a/README.md b/README.md index 0053df3..83defac 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,33 @@ # PDK Environment +[![Version](https://img.shields.io/github/v/release/OpenPeppol/pdk-environment)](https://github.com/OpenPEPPOL/pdk-environment/releases) + + This project prepares a bundle of software as an environment for running Peppol Development Kit (PDK). The bundle consists of: -* [AdoptOpenJDK](https://adoptopenjdk.net/) -* [JRuby](https://www.jruby.org/) * [Schematron](https://schematron.com/) (skeleton implementation) * [SchUnit](https://schunit.com/) * [Saxon](https://www.saxonica.com/) (home edition) -* [Hugo](https://gohugo.io/) (standard edition) \ No newline at end of file + + +## Changelog + +### V1.4.0 +* Removed java, hugo and jruby, as they are +now part of the docker build. +* The releases are now platform independent. +* Made the scripts platform independent so that they can be also run locally on macOS + + +### V1.3.0 + +* updated schunit to 0.4.0 + +### V1.2.0 + +* updated windows hugo script +* updated environments +* Hugo version 0.110.0 + diff --git a/src/bin/_project b/src/bin/_project index d3fae93..0060020 100755 --- a/src/bin/_project +++ b/src/bin/_project @@ -1,3 +1,14 @@ -#!/bin/sh +#!/bin/bash -echo -n $(dirname $(dirname $(dirname "$0"))) \ No newline at end of file +# Resolve the path to this script (even if invoked via PATH). +SCRIPT="$0" +case "$SCRIPT" in + /*) : ;; # absolute + *) SCRIPT="$(command -v -- "$SCRIPT")" ;;# found via PATH +esac + +# Go up three levels from src/bin/_project → repo root +ROOT_DIR=$(cd "$(dirname "$SCRIPT")/../.." && pwd) + +# Print it with a newline (portable) +printf '%s\n' "$ROOT_DIR" diff --git a/src/bin/fetch b/src/bin/fetch index 02a63dd..125d15e 100755 --- a/src/bin/fetch +++ b/src/bin/fetch @@ -1,13 +1,12 @@ -#!/bin/sh +#!/usr/bin/env bash +set -euo pipefail -# Variables to be used by fetchers -PROJECT=$(_project) -TARGET=$PROJECT/target -TMP=$PROJECT/tmp -DIST=$TARGET/dist/$1 +PROJECT="$(_project)" +TARGET="$PROJECT/target" +TMP="$PROJECT/tmp" +DIST="$TARGET/dist/${1:-}" -# Create inital folders -mkdir -p $TARGET $TMP +mkdir -p "$TARGET" "$TMP" # Function: download [filename] [url] download() { @@ -19,13 +18,8 @@ download() { } # Run fetchers -for arch in $@ common; do - if [ -e $PROJECT/src/fetcher/$arch ] && [ $(find $PROJECT/src/fetcher/$arch -name *.sh | wc -l) != "0" ]; then - for fetcher in $(ls $PROJECT/src/fetcher/$arch/*.sh); do - name=$(echo $fetcher | sed 's:\.sh$::') - - echo "* Running $name" - . $fetcher - done - fi +for script in "$PROJECT/src/fetcher"/*.sh; do + [ -e "$script" ] || continue # nullglob guard (POSIX-compatible) + echo "* Running $script" + . "$script" # use `sh "$script"` if you don't need to source done diff --git a/src/bin/package-tar b/src/bin/package-tar index f3bbe77..515e214 100755 --- a/src/bin/package-tar +++ b/src/bin/package-tar @@ -5,7 +5,7 @@ set -u PROJECT=$(_project) TARGET=$PROJECT/target -DIST=$1 +DIST="pdk-environment" echo "* Package $DIST" @@ -14,7 +14,7 @@ mkdir -p $TARGET/pkg test -e $TARGET/pkg/$DIST.tar.gz && rm -rf $TARGET/pkg/$DIST.tar.gz # Create tar -cd $PROJECT/target/dist/$DIST +cd $PROJECT/target/dist/ tar rf $TARGET/pkg/$DIST.tar * # Compress tar diff --git a/src/bin/package-zip b/src/bin/package-zip index ee2f4bf..fe6b323 100755 --- a/src/bin/package-zip +++ b/src/bin/package-zip @@ -5,7 +5,7 @@ set -u PROJECT=$(_project) TARGET=$PROJECT/target -DIST=$1 +DIST="pdk-environment" echo "* Package $DIST" @@ -14,5 +14,5 @@ mkdir -p $TARGET/pkg test -e $TARGET/pkg/$DIST.zip && rm -rf $TARGET/pkg/$DIST.zip # Create zip -cd $PROJECT/target/dist/$DIST +cd $PROJECT/target/dist/ zip -q9r $TARGET/pkg/$DIST.zip * diff --git a/src/fetcher/common/310-schematron.sh b/src/fetcher/310-schematron.sh similarity index 96% rename from src/fetcher/common/310-schematron.sh rename to src/fetcher/310-schematron.sh index de50e17..b277625 100644 --- a/src/fetcher/common/310-schematron.sh +++ b/src/fetcher/310-schematron.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash set -e set -u diff --git a/src/fetcher/common/320-schunit.sh b/src/fetcher/320-schunit.sh similarity index 100% rename from src/fetcher/common/320-schunit.sh rename to src/fetcher/320-schunit.sh diff --git a/src/fetcher/common/330-saxon.sh b/src/fetcher/330-saxon.sh similarity index 82% rename from src/fetcher/common/330-saxon.sh rename to src/fetcher/330-saxon.sh index d064bc0..b5d24aa 100644 --- a/src/fetcher/common/330-saxon.sh +++ b/src/fetcher/330-saxon.sh @@ -13,4 +13,4 @@ download saxon-$VERSION.zip \ https://deac-ams.dl.sourceforge.net/project/saxon/Saxon-HE/9.9/SaxonHE${VERSION}J.zip # Unzip content -unzip -qo $TMP/saxon-$VERSION.zip -d $DIST/lib/saxon \ No newline at end of file +unzip -qo $TMP/saxon-$VERSION.zip -d $DIST/lib/saxon diff --git a/src/fetcher/common/200-jruby.sh b/src/fetcher/common/200-jruby.sh deleted file mode 100644 index 11fef94..0000000 --- a/src/fetcher/common/200-jruby.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${JRUBY_VERSION} - -# Download -download jruby-dist-${VERSION}-bin.zip \ - https://repo1.maven.org/maven2/org/jruby/jruby-dist/${VERSION}/jruby-dist-${VERSION}-bin.zip - -# Make sure there are no existing jruby folders -test ! -e $DIST/lib/jruby || rm -rf $DIST/lib/jruby - -# Unzip jruby -mkdir -p $DIST/lib -unzip -qo $TMP/jruby-dist-${VERSION}-bin.zip -d $DIST/lib -mv $DIST/lib/jruby-${VERSION} $DIST/lib/jruby diff --git a/src/fetcher/linux-amd64/100-java.sh b/src/fetcher/linux-amd64/100-java.sh deleted file mode 100644 index 863ca9c..0000000 --- a/src/fetcher/linux-amd64/100-java.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${JAVA_VERSION} - -# Download -download adoptopenjdk-x64-linux-jre-${VERSION}.tar.gz \ - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$(echo $VERSION | sed "s:+:%2B:g")/OpenJDK17U-jre_x64_linux_hotspot_$(echo $VERSION | sed "s:+:_:g").tar.gz - -# Prepare folder -mkdir -p $DIST/lib/adoptopenjdk - -# Unzip content -tar -zxf $TMP/adoptopenjdk-x64-linux-jre-${VERSION}.tar.gz --strip 1 -C $DIST/lib/adoptopenjdk diff --git a/src/fetcher/linux-amd64/600-hugo.sh b/src/fetcher/linux-amd64/600-hugo.sh deleted file mode 100644 index b82ed31..0000000 --- a/src/fetcher/linux-amd64/600-hugo.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${HUGO_VERSION} - -# Download -download hugo_${VERSION}_Linux-64bit.tar.gz \ - https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_Linux-64bit.tar.gz - -# Prepare folder -mkdir -p $DIST/lib/hugo - -# Unzip content -tar xzf $TMP/hugo_${VERSION}_Linux-64bit.tar.gz -C $DIST/lib/hugo \ No newline at end of file diff --git a/src/fetcher/linux-arm64/100-java.sh b/src/fetcher/linux-arm64/100-java.sh deleted file mode 100644 index 3385889..0000000 --- a/src/fetcher/linux-arm64/100-java.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${JAVA_VERSION} - -# Download -download adoptopenjdk-aarch64-linux-jre-${VERSION}.tar.gz \ - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$(echo $VERSION | sed "s:+:%2B:g")/OpenJDK17U-jre_aarch64_linux_hotspot_$(echo $VERSION | sed "s:+:_:g").tar.gz - -# Prepare folder -mkdir -p $DIST/lib/adoptopenjdk - -# Unzip content -tar -zxf $TMP/adoptopenjdk-aarch64-linux-jre-${VERSION}.tar.gz --strip 1 -C $DIST/lib/adoptopenjdk diff --git a/src/fetcher/linux-arm64/600-hugo.sh b/src/fetcher/linux-arm64/600-hugo.sh deleted file mode 100644 index 67bd4ad..0000000 --- a/src/fetcher/linux-arm64/600-hugo.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${HUGO_VERSION} - -# Download -download hugo_${VERSION}_Linux-ARM64.tar.gz \ - https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_Linux-ARM64.tar.gz - -# Prepare folder -mkdir -p $DIST/lib/hugo - -# Unzip content -tar xzf $TMP/hugo_${VERSION}_Linux-ARM64.tar.gz -C $DIST/lib/hugo \ No newline at end of file diff --git a/src/fetcher/macos-amd64/100-java.sh b/src/fetcher/macos-amd64/100-java.sh deleted file mode 100644 index 54b9add..0000000 --- a/src/fetcher/macos-amd64/100-java.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${JAVA_VERSION} - -# Download -download adoptopenjdk-x64-mac-jre-${VERSION}.tar.gz \ - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$(echo $VERSION | sed "s:+:%2B:g")/OpenJDK17U-jre_x64_mac_hotspot_$(echo $VERSION | sed "s:+:_:g").tar.gz - -# Prepare folder -mkdir -p $DIST/lib/adoptopenjdk - -# Unzip content -tar -zxf $TMP/adoptopenjdk-x64-mac-jre-${VERSION}.tar.gz --strip 3 -C $DIST/lib/adoptopenjdk -rm -f $DIST/lib/adoptopenjdk/libjli.dylib \ No newline at end of file diff --git a/src/fetcher/macos-amd64/600-hugo.sh b/src/fetcher/macos-amd64/600-hugo.sh deleted file mode 100644 index 411114c..0000000 --- a/src/fetcher/macos-amd64/600-hugo.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${HUGO_VERSION} - -# MacOS -mkdir -p $DIST/lib/hugo - -download hugo_${VERSION}_macOS-64bit.tar.gz \ - https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_darwin-universal.tar.gz - -tar xzf $TMP/hugo_${VERSION}_macOS-64bit.tar.gz -C $DIST/lib/hugo diff --git a/src/fetcher/win-amd64/100-java.sh b/src/fetcher/win-amd64/100-java.sh deleted file mode 100644 index 9caf670..0000000 --- a/src/fetcher/win-amd64/100-java.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${JAVA_VERSION} - -# Download -download adoptopenjdk-x64-windows-jre-${VERSION}.zip \ - https://github.com/adoptium/temurin17-binaries/releases/download/jdk-$(echo $VERSION | sed "s:+:%2B:g")/OpenJDK17U-jre_x64_windows_hotspot_$(echo $VERSION | sed "s:+:_:g").zip - -# Prepare folder -mkdir -p $DIST/lib -test ! -e $DIST/lib/adoptopenjdk || rm -rf $DIST/lib/adoptopenjdk - -# Unzip content -unzip -qo $TMP/adoptopenjdk-x64-windows-jre-${VERSION}.zip -d $DIST/lib -mv $DIST/lib/jdk-${VERSION}-jre $DIST/lib/adoptopenjdk \ No newline at end of file diff --git a/src/fetcher/win-amd64/600-hugo.sh b/src/fetcher/win-amd64/600-hugo.sh deleted file mode 100644 index 61ae529..0000000 --- a/src/fetcher/win-amd64/600-hugo.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/sh - -set -e -set -u - - -VERSION=${HUGO_VERSION} - -# Win64 -mkdir -p $DIST/lib/hugo - -download hugo_${VERSION}_Windows-64bit.zip \ - https://github.com/gohugoio/hugo/releases/download/v${VERSION}/hugo_${VERSION}_windows-amd64.zip - -unzip -qo $TMP/hugo_${VERSION}_Windows-64bit.zip -d $DIST/lib/hugo \ No newline at end of file