Przeglądaj źródła

install: make install and PREFIX more flexible

This patch has `make install` calling out an install script, located in
a newly created `utils` direcctory. By delegating intallation to a
script, we become more flexible to check for error conditions.

Additionally, we also get rid of `DEST` in the makefile, and make
`PREFIX` a bit more flexible, by allowing us to specify alternative
locations where to install our files.

Signed-off-by: Joao Eduardo Luis <joao@suse.com>
pull/235/head
Joao Eduardo Luis 6 lat temu
rodzic
commit
e521507a5e
3 zmienionych plików z 114 dodań i 18 usunięć
  1. +3
    -17
      Makefile
  2. +9
    -1
      share/mutt-wizard.muttrc
  3. +102
    -0
      utils/install.sh

+ 3
- 17
Makefile Wyświetl plik

@@ -2,28 +2,14 @@

OS = $(shell uname -s)
ifeq ($(OS), Darwin)
PREFIX = /usr/local
PREFIX ?= /usr/local
else
PREFIX = /usr
PREFIX ?= /usr
endif
MANPREFIX = $(PREFIX)/share/man

install:
mkdir -p $(DESTDIR)$(PREFIX)/bin
for script in bin/*; do \
cp -f $$script $(DESTDIR)$(PREFIX)/bin/; \
chmod 755 $(DESTDIR)$(PREFIX)/$$script; \
done
mkdir -p $(DESTDIR)$(PREFIX)/share/mutt-wizard
for shared in share/*; do \
cp -f $$shared $(DESTDIR)$(PREFIX)/share/mutt-wizard; \
done
if [ "$(OS)" = "Darwin" ]; then \
sed -iba 's/\/usr\//\/usr\/local\//' $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc; \
rm $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrcba; \
fi
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1
utils/install.sh -p "$(PREFIX)"

uninstall:
for script in bin/*; do \


+ 9
- 1
share/mutt-wizard.muttrc Wyświetl plik

@@ -3,7 +3,15 @@
# mutt-wizard will have this file sourced from your muttrc.
# In the interest of seamless updating, do not edit this file.
# If you want to override any settings, set those in your muttrc.
set mailcap_path = /usr/share/mutt-wizard/mailcap

# mailcap_path
# PREFIX will be substituted during install. However, if you prefer to
# use this configuration file as a standalone, consider substituting it
# (along with the %'s surrounding it) for the path to your mutt-wizard's
# mailcap file
#
set mailcap_path = %PREFIX%/share/mutt-wizard/mailcap

set certificate_file = ~/.cache/mutt-wizard/certificates
set date_format="%y/%m/%d %I:%M%p"
set index_format="%2C %zs %?X?A& ? %D %-15.15F %s (%-4.4c)"


+ 102
- 0
utils/install.sh Wyświetl plik

@@ -0,0 +1,102 @@
#!/bin/bash


has_color=false

if which tput >&/dev/null; then
num_colors=$(tput colors)
[[ -n "${num_colors}" ]] && [[ num_colors -ge 8 ]] && has_color=true
fi

color_reset='\e[0m'
color_info='\e[1;96m'
color_err='\e[1;91m'
color_bold='\e[0;1m'

if ! $has_color ; then
color_reset=
color_info=
color_err=
color_bold=
fi

info() {
echo -e "${color_info}info: ${color_bold}$*${color_reset}"
}

err() {
>&2 echo -e "${color_err}error: ${color_bold}$*${color_reset}"
}

prefix=/usr
[[ "$(uname -s)" == "Darwin" ]] && prefix=/usr/local

usage() {
cat <<EOF
usage: $0 [-p <prefix>] [-v]

-p <prefix> instalation prefix
(default: ${default_prefix})
-v verbose
-h | --help this message

EOF
}

while [[ $# -gt 0 ]]; do
case $1 in
-h|--help) usage ; exit 0 ;;
-v) set -x ;;
-p)
[[ -z "$2" ]] && \
err "'-p' requires a prefix to be provided" && exit 1
prefix=$(realpath -m ${2})
shift 1
;;
*)
err "unrecognized option '${1}'"
exit 1
;;
esac
shift 1
done

if [[ ! -d "${prefix}" ]] && ! mkdir -p ${prefix} ; then
err "error creating '${prefix}'"
exit 1
fi

bindir=${prefix}/bin
sharedir=${prefix}/share
mandir=${sharedir}/man1

mkdir -p ${bindir}
for target in bin/*; do
script=$(basename ${target})
if ! cp -f ${target} ${bindir}; then
err "error: failed copying '${target}' to '${bindir}'" && exit 1
fi
chmod 755 ${bindir}/${script}
done

mkdir -p ${sharedir} || exit 1
for target in share/*; do
shared=$(basename ${target})
dest=${sharedir}/${shared}

if ! cp -f ${target} ${dest}; then
err "error: failed copying '${target}' to '${dest}'" && exit 1
fi

sed -i "s,%PREFIX%,${concat_dest}," ${dest}
if $(grep -q '%PREFIX%' ${dest}); then
err "error: failed performingg substitutions on '${dest}'" && exit 1
fi
done

mkdir -p ${mandir} || exit 1
if ! cp -f mw.1 ${mandir}/mw.1; then
err "error: failed copying 'mw.1' to '${mandir}'" && exit 1
fi

info "install success"

Ładowanie…
Anuluj
Zapisz