mu-wizard

shell script to easily configure mu4e accounts on Emacs
git clone git://git.ckyln.com/~cem/mu-wizard
Log | Files | Refs | LICENSE

commit 3e447c869dafe9ac17ae3bbadc73d27d71ce4b1a
parent 04b174fa77a93b26634d7886fa157da01a03fa53
Author: Cem Keylan <cem@ckyln.com>
Date:   Tue, 13 Apr 2021 11:27:30 +0300

Makefile: use install.sh, install manual pages

Diffstat:
MMakefile | 17++++++++---------
Atools/install.sh | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile @@ -1,23 +1,22 @@ PREFIX = /usr/local BINDIR = ${PREFIX}/bin SHAREDIR = ${PREFIX}/share +MANDIR = ${SHAREDIR}/man +MAN1 = ${MANDIR}/man1 MUSHAREDIR = ${SHAREDIR}/mu-wizard +INSTALLSH = ./tools/install.sh all: @echo "Run 'make install' to install mu-wizard." install: - mkdir -p ${DESTDIR}${BINDIR} ${DESTDIR}${MUSHAREDIR} - sed 's|/usr/share/mu-wizard|${MUSHAREDIR}|g' < bin/muw > ${DESTDIR}${BINDIR}/muw - chmod 755 ${DESTDIR}${BINDIR}/muw - cp mu4e-config.el ${DESTDIR}${MUSHAREDIR} - chmod 644 ${DESTDIR}${MUSHAREDIR}/mu4e-config.el - mkdir -p ${DESTDIR}${MUSHAREDIR}/overrides - for override in overrides/*; do\ - cp $${override} ${DESTDIR}${MUSHAREDIR}/overrides/$${override##*/}; \ - chmod 644 ${DESTDIR}${MUSHAREDIR}/overrides/$${override##*/}; done + ${INSTALLSH} -Dm755 -s 's|/usr/share/mu-wizard|${MUSHAREDIR}|g' bin/muw ${DESTDIR}${BINDIR}/muw + ${INSTALLSH} -Dm644 mu4e-config.el ${DESTDIR}${MUSHAREDIR}/mu4e-config.el + ${INSTALLSH} -Dm644 -t ${DESTDIR}${MUSHAREDIR}/overrides overrides/* + ${INSTALLSH} -Dm644 -t ${DESTDIR}${MAN1} man/*.1 uninstall: rm -rf ${DESTDIR}${BINDIR}/muw ${DESTDIR}${MUSHAREDIR} + for man in man/*; do rm -f ${DESTDIR}${MANDIR}/man$${man##*.}/$${man##*/}; done .PHONY: all install uninstall diff --git a/tools/install.sh b/tools/install.sh @@ -0,0 +1,55 @@ +#!/bin/sh -e +# Portable install version that supports -D -m and -t +# We have our own extension flag -s for running sed on the given files while +# installing. +usage() { + printf '%s\n' "usage: $0 [-D] [-m mode] [-s sedcmd] source dest" \ + " or: $0 [-D] [-m mode] [-s sedcmd] [-t dir] [source...]" >&2 + exit 0 +} + +die() { printf '%s\n' "$@" >&2; exit 1;} + +sed='' +mkdirp='' +target='' +mode='' +REST='' + +while getopts 'Dm:s:t:h' opt; do + case $opt in + D) mkdirp=1 ;; + s) sed=$OPTARG ;; + t) target=$OPTARG ;; + m) mode=$OPTARG ;; + h) usage + exit 0 + ;; + '?') exit 1 + esac +done + +shift "$((OPTIND - 1))" + +if [ "$target" ]; then + [ "$mkdirp" ] || [ -d "$target" ] || die "$target doesn't exist" + mkdir -p "$target" + for arg; do + [ -d "$target/${arg##*/}" ] && die "$target/${arg##*/} is a directory" + if [ "$sed" ]; then + sed "$sed" < "$arg" > "$target/${arg##*/}" + else + cp "$arg" "$target" + fi + + # Most implementations set the mode to 0755 by default when -t is set. + chmod "${mode:=0755}" "$target/${arg##*/}" + done +else + case "$2" in */*) [ "$mkdirp" ] || [ -d "${2%/*}" ] || die "${2%/*} doesn't exist" + mkdir -p "${2%/*}" + esac + [ -d "$2" ] && die "$2 is a directory" + if [ "$sed" ]; then sed "$sed" < "$1" > "$2"; else cp "$1" "$2"; fi + chmod "${mode:=0755}" "$2" +fi