Skip to content

Commit

Permalink
better install method (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullyj3 committed Jul 26, 2024
1 parent 1fc1595 commit ad330b4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 51 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ jobs:
use-mathlib-cache: "false"
build: "true"
- name: Create package
# todo parameterize version
run: |
./create_release.sh
RELEASE_DIR=sand-release
mkdir -p $RELEASE_DIR
env PREFIX="$RELEASE_DIR" ./install.sh
RELEASE_ARCHIVE=sand-x86_64-linux.tar.zst
tar --zstd -cvf "$RELEASE_ARCHIVE" "$RELEASE_DIR"
echo "release archive created at $RELEASE_ARCHIVE"
- name: Upload artifact
uses: actions/upload-artifact@v4.3.4
with:
name: sand
path: release/sand-x86_64-linux.tar.zst
path: sand-x86_64-linux.tar.zst
35 changes: 0 additions & 35 deletions create_release.sh

This file was deleted.

38 changes: 24 additions & 14 deletions scripts/install.sh → install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@

set -e

BIN_PATH="/usr/bin/sand"
SERVICE_PATH="/usr/lib/systemd/user/sand.service"
SOCKET_PATH="/usr/lib/systemd/user/sand.socket"
SOUND_DIR="/usr/share/sand"
PREFIX="${PREFIX:-/usr/local}"

BIN_PATH="$PREFIX/bin/sand"
SERVICE_PATH="$PREFIX/lib/systemd/user/sand.service"
SOCKET_PATH="$PREFIX/lib/systemd/user/sand.socket"

SOUND_DIR="$PREFIX/share/sand"
SOUND_PATH="$SOUND_DIR/timer_sound.opus"

README_DIR="$PREFIX/share/doc/sand"
README_PATH="$README_DIR/README.md"

LICENSE_DIR="$PREFIX/share/licenses/sand"
LICENSE_PATH="$LICENSE_DIR/LICENSE"

install_sand() {
set -x

install -Dm755 ./sand "$BIN_PATH"
install -Dm755 ./.lake/build/bin/sand "$BIN_PATH"
install -Dm644 resources/systemd/sand.service "$SERVICE_PATH"
install -Dm644 resources/systemd/sand.socket "$SOCKET_PATH"
install -Dm644 resources/timer_sound.opus "$SOUND_PATH"
install -Dm644 README.md "$README_PATH"
install -Dm644 LICENSE "$LICENSE_PATH"

strip "$BIN_PATH"

{ set +x; } 2>/dev/null

Expand All @@ -30,8 +43,12 @@ install_sand() {
uninstall_sand() {
set -x

rm -f "$BIN_PATH" "$SERVICE_PATH" "$SOCKET_PATH" "$SOUND_PATH"
rm -rf "$SOUND_DIR"
rm -f "$BIN_PATH"
rm -f "$SERVICE_PATH"
rm -f "$SOCKET_PATH"
rm -rf "$SOUND_DIR"
rm -rf "$README_DIR"
rm -rf "$LICENSE_DIR"

{ set +x; } 2>/dev/null

Expand All @@ -43,13 +60,6 @@ show_help() {
exit 1
}

# Check if run with sufficient permissions
if [ "$EUID" -ne 0 ]; then
echo "Please run as root or use sudo"
exit 1
fi

# Parse command line arguments
case "$1" in
install|"")
install_sand
Expand Down

0 comments on commit ad330b4

Please sign in to comment.