diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2015-12-08 01:10:08 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2015-12-08 01:10:08 -0300 |
commit | ad181f63bc252303d52dc413433890f14d21b915 (patch) | |
tree | fdb4e153b8fdfc010e0fe1ec3fcd91c0f8a2cb75 /install.sh | |
parent | c754763c4370a9eb055e68db3d638fd38382c137 (diff) | |
download | dotwm-ad181f63bc252303d52dc413433890f14d21b915.tar.gz |
Add a simple installation script and xsession file
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 + |