From b0838beb6ff184c6afc44f7a3d70fab5405ccb05 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Mon, 26 Jul 2021 16:20:44 -0400 Subject: [PATCH] Create install and uninstall targets in the Makefile And create helper scripts under tools/ Signed-off-by: Anna Schumaker --- Makefile | 17 +++++++++++++++ data/emmental | 3 +++ data/emmental.desktop | 10 +++++++++ tools/install.sh | 44 ++++++++++++++++++++++++++++++++++++++ tools/list_install_dirs.py | 8 +++++++ 5 files changed, 82 insertions(+) create mode 100644 data/emmental create mode 100644 data/emmental.desktop create mode 100755 tools/install.sh create mode 100755 tools/list_install_dirs.py diff --git a/Makefile b/Makefile index de117a2..0699f8b 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,27 @@ # Copyright 2019 (c) Anna Schumaker. +export PREFIX = /usr/local + +export EMMENTAL_LIB = ${PREFIX}/lib/emmental +export EMMENTAL_BIN = ${PREFIX}/bin +export EMMENTAL_SHARE = ${PREFIX}/share + clean: find . -type d -name __pycache__ -exec rm -r {} \+ find data/ -type d -name "Test Album" -exec rm -r {} \+ find data/ -type d -name "Test Library" -exec rm -r {} \+ +.PHONY: install +install: + exec tools/install.sh + +.PHONY: uninstall +uninstall: + rm -fv ${EMMENTAL_BIN}/emmental + rm -rfv ${EMMENTAL_LIB} + rm -fv ${EMMENTAL_SHARE}/icons/hicolor/scalable/apps/emmental*.svg + rm -fv ${EMMENTAL_SHARE}/applications/emmental.desktop + .PHONY: tests tests: python tools/generate_tracks.py diff --git a/data/emmental b/data/emmental new file mode 100644 index 0000000..dd8d154 --- /dev/null +++ b/data/emmental @@ -0,0 +1,3 @@ +#!/bin/bash + +python {EMMENTAL_LIB}/emmental.py $* diff --git a/data/emmental.desktop b/data/emmental.desktop new file mode 100644 index 0000000..ca33e99 --- /dev/null +++ b/data/emmental.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Type=Application +Version=1.5 +Name=Emmental +GenericName=Music Player +Comment=Listen to your music +Exec={EMMENTAL_BIN}/emmental +Icon=emmental +Terminal=false +Categories=AudioVideo;Audio; diff --git a/tools/install.sh b/tools/install.sh new file mode 100755 index 0000000..d71d83b --- /dev/null +++ b/tools/install.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +function install_file() +{ + install -p -v $* | grep -v "^removed" +} + + +# +# Install source files +# +install -d -v -m 755 $EMMENTAL_LIB +install_file -m 644 emmental.py $EMMENTAL_LIB/emmental.py + +for dir in `tools/list_install_dirs.py`; do + install -d -v -m 755 $EMMENTAL_LIB/$dir + + files=`find $dir -not -name "test_*.py" -name "*.py"` + install_file -m 644 $files $EMMENTAL_LIB/$dir/ +done + + +# +# Install icons +# +EMMENTAL_ICONS=$EMMENTAL_SHARE/icons/hicolor/scalable/apps +install -d -v -m 755 $EMMENTAL_ICONS +install_file -m 644 data/hicolor/scalable/apps/*.svg $EMMENTAL_ICONS/ + + +# +# Install and adjust executable +# +install -d -v -m 755 $EMMENTAL_BIN +install_file -m 655 data/emmental $EMMENTAL_BIN/emmental +sed -i "s|{EMMENTAL_LIB}|$EMMENTAL_LIB|" $EMMENTAL_BIN/emmental + + +# +# Install and adjust .desktop file +# +install -d -v -m 755 $EMMENTAL_SHARE/applications +install_file -m 644 data/emmental.desktop $EMMENTAL_SHARE/applications +sed -i "s|{EMMENTAL_BIN}|$EMMENTAL_BIN|" $EMMENTAL_SHARE/applications/emmental.desktop diff --git a/tools/list_install_dirs.py b/tools/list_install_dirs.py new file mode 100755 index 0000000..f9dcec7 --- /dev/null +++ b/tools/list_install_dirs.py @@ -0,0 +1,8 @@ +#!/usr/bin/python +import pathlib + +exclude = [ ".git", "data", "tools" ] + +for p in pathlib.Path(".").iterdir(): + if p.is_dir() and not str(p) in exclude: + print(p)