Skip to content

Commit

Permalink
Build script improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
decoyjoe committed Nov 30, 2024
1 parent 0b04181 commit 6ab266a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ jobs:
run: ./init.sh
- name: Build sanoid-portable binary
run: |
# Build on Ubuntu
# Add a new binfmt entry that matches APE's (Actually Portable Executable)'s
# magic number to avoid execution by Ubuntu's built-in "MZ" binfmt
# interpreter which "helpfully" tries to run the binary with WINE.
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/build/
/output/
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Build the executable:

This script will download and configure APPerl, download necessary Perl modules, and build the portable Sanoid binary.

The executable gets built to `build/sanoid-portable`.
The executable gets built to `output/sanoid-portable`.

## License

Expand Down
12 changes: 6 additions & 6 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

Expand All @@ -12,13 +12,13 @@ echo "Building sanoid-portable version ${SANOID_PORTABLE_VERSION}, based on Sano
repo_root="$(realpath "$(dirname "$0")")"

# Cleanup previous artifacts if they exist
if [ -d build ]; then
echo 'Cleaning up previous build...'
rm -rf build
if [ -d output ]; then
echo 'Cleaning up previous build output...'
rm -rf output
fi

mkdir build
pushd build > /dev/null
mkdir output
pushd output > /dev/null

echo 'Downloading necessary modules...'

Expand Down
9 changes: 5 additions & 4 deletions init.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#!/bin/bash
#!/usr/bin/env bash

set -euo pipefail

# Identify the operating system from /etc/os-release
OS=$(grep ^ID= /etc/os-release | cut -d '=' -f 2 | tr -d '"')
source /etc/os-release
OS=$ID

# Check if the OS is Debian or a Debian derivative (like Ubuntu)
# The only build OS's we've tested.
if [[ "$OS" != 'debian' && "$OS" != 'ubuntu' ]]; then
echo 'Error: This script is intended only for Debian-based systems.'
echo "Error: Unsupported operating system. This script only supports Debian and Ubuntu."
exit 1
fi

Expand Down

0 comments on commit 6ab266a

Please sign in to comment.