Make scripts compatible with macOS/BSD

All the scripts used by this repo were more focused on Linux based systems.
They did not work on macOS or other BSD based systems because of flags
or commands which are not available.

This PR resolves those items by adjusting the failed commands so they
work on both Linux and macOS/BSD systems.

Fixes #112
This commit is contained in:
BlackDex 2023-02-15 21:50:55 +01:00
parent cffdfb06f9
commit 34c0540ec9
No known key found for this signature in database
GPG key ID: 58C80A2AA6C765E1
8 changed files with 18 additions and 12 deletions

View file

@ -53,7 +53,7 @@ WORKDIR /vault/apps/web
RUN npm run dist:oss:selfhost RUN npm run dist:oss:selfhost
RUN printf '{"version":"%s"}' \ RUN printf '{"version":"%s"}' \
$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/dani-garcia/bw_web_builds.git 'v*' | tail -n1 | sed -E 's#.*?refs/tags/v##') \ $(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/dani-garcia/bw_web_builds.git 'v*' | tail -n1 | grep -Eo '[^\/]*$') \
> build/vw-version.json > build/vw-version.json
# Delete debugging map files, optional # Delete debugging map files, optional

View file

@ -10,7 +10,7 @@ if [[ -z ${PATCH_NAME} ]]; then
else else
echo "Patch file not found, using latest" echo "Patch file not found, using latest"
# If not, use the latest one # If not, use the latest one
PATCH_NAME="$(find ../patches -printf "%f\\n" | sort -V | tail -n1)" PATCH_NAME="$(find ../patches -type f -print0 | xargs -0 basename -a | sort -V | tail -n1)"
fi fi
fi fi

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
# Error handling # Error handling
handle_error() { handle_error() {
@ -30,7 +30,7 @@ npm run dist:oss:selfhost
# Create vw-version.json with the latest tag from the remote repo. # Create vw-version.json with the latest tag from the remote repo.
printf '{"version":"%s"}' \ printf '{"version":"%s"}' \
"$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/dani-garcia/bw_web_builds.git 'v*' | tail -n1 | sed -E 's#.*?refs/tags/v##')" \ "$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/dani-garcia/bw_web_builds.git 'v*' | tail -n1 | grep -Eo '[^\/]*$')" \
> build/vw-version.json > build/vw-version.json
popd popd

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
# Error handling # Error handling
handle_error() { handle_error() {

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
# Error handling # Error handling
handle_error() { handle_error() {

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
handle_error() { handle_error() {
read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." _ read -n1 -r -p "FAILED: line $1, exit code $2. Press any key to exit..." _

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
# Error handling # Error handling
handle_error() { handle_error() {

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -o pipefail -o errexit set -o pipefail -o errexit
BASEDIR=$(dirname "$(readlink -f "$0")") BASEDIR=$(RL=$(readlink -n "$0"); SP="${RL:-$0}"; dirname "$(cd "$(dirname "${SP}")"; pwd)/$(basename "${SP}")")
# Error handling # Error handling
handle_error() { handle_error() {
@ -24,7 +24,7 @@ DATE_FORMAT="${DATE_FORMAT:-%Y-%m-%dT%H:%M:%S%z}"
# Preserve previous output # Preserve previous output
if [[ -f "${OUTPUT_NAME}.tar.gz" ]]; if [[ -f "${OUTPUT_NAME}.tar.gz" ]];
then then
DATE_SUFFIX=$(date +"${DATE_FORMAT}" -r "${OUTPUT_NAME}.tar.gz") DATE_SUFFIX=$(date -r "${OUTPUT_NAME}.tar.gz" +"${DATE_FORMAT}")
mv "${OUTPUT_NAME}.tar.gz" "${OUTPUT_NAME}_${DATE_SUFFIX}.tar.gz" mv "${OUTPUT_NAME}.tar.gz" "${OUTPUT_NAME}_${DATE_SUFFIX}.tar.gz"
fi fi
@ -36,10 +36,16 @@ fi
mv build web-vault mv build web-vault
# Tar the web-vault # Tar the web-vault
tar -czvf "${OUTPUT_NAME}.tar.gz" web-vault --owner=0 --group=0 # Check if we are using bsdtar or gnu-tar, bsdtar does not support --owner/--group
if [[ "$(tar --version)" =~ .*bsdtar.* ]];
then
tar -czvf "${OUTPUT_NAME}.tar.gz" web-vault
else
tar -czvf "${OUTPUT_NAME}.tar.gz" web-vault --owner=0 --group=0
fi
# Copy the web-vault # Copy the web-vault
cp -dpr web-vault "${OUTPUT_NAME}" cp -pR web-vault "${OUTPUT_NAME}"
mv web-vault build mv web-vault build
popd popd