diff options
Diffstat (limited to 'install.sh')
-rwxr-xr-x | install.sh | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..4c16960 --- /dev/null +++ b/install.sh @@ -0,0 +1,78 @@ +#!/bin/bash + +PREFIX=/usr/local +BINDIR=${PREFIX}/bin +DATADIR=${PREFIX}/share +MANDIR=${DATADIR}/man +MAN1DIR=${MANDIR}/man1 +DOCDIR=${DATADIR}/doc/dotwm +EXAMPLEDIR=${DOCDIR}/examples +SYSCONFDIR=/etc +CONFIGDIR=${SYSCONFDIR}/xdg/dotwm +XSESSIONDIR=${DATADIR}/share/xsessions + +fail_dependencies() { + cat <<EOF +You need to install all the dependencies. +Check www.rust-lang.org for installation instructions for rust compiler and cargo. +EOF +} + +_build() { + echo Building... + if ! which rustc 2> /dev/null > /dev/null + then + fail_dependencies + fi + + if ! which cargo 2> /dev/null > /dev/null + then + fail_dependencies + fi + + cargo build --release +} + +_install() { + echo $@ + if [[ x"$1" = "x--prefix" ]] + then + PREFIX=$2 + fi + echo "Base dir for installation: ${PREFIX}" + install -m 755 target/release/dotwm $BINDIR + install -m 644 dotwm.1 ${MAN1DIR} + mkdir -p ${DOCDIR} + mkdir -p ${EXAMPLEDIR} + install -m 755 autostart ${EXAMPLEDIR} + install -m 644 LICENSE ${DOCDIR} + install -m 644 README.md ${DOCDIR} + install -m 644 dotwm.desktop ${XSESSIONDIR} +} + +_uninstall() { + rm $BINDIR/dotwm + rm ${EXAMPLEDIR}/autostart + rm ${MAN1DIR}/dotwm.1 + rm -r ${DOCDIR} + rm ${XSESSIONDIR}/dotwm.desktop +} + +base=$1 +shift +case $base in + build) + _build + ;; + install) + _install $@ + ;; + uninstall) + _uninstall $@ + ;; + *) + _build + _install $@ + ;; +esac + |