Browse Source

fix Makefile, allow PREFIX, test/dotests without system install

pull/276/head
Roland Puntaier 5 years ago
parent
commit
26acf1e367
4 changed files with 24 additions and 19 deletions
  1. +4
    -6
      Makefile
  2. +11
    -9
      bin/mw
  3. +9
    -3
      test/dotests
  4. +0
    -1
      test/test_mw.bats

+ 4
- 6
Makefile View File

@@ -2,9 +2,9 @@

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

@@ -18,10 +18,7 @@ install:
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
sed -i 's,/usr,$(PREFIX),' $(DESTDIR)$(PREFIX)/share/mutt-wizard/mutt-wizard.muttrc;
mkdir -p $(DESTDIR)$(MANPREFIX)/man1
cp -f mw.1 $(DESTDIR)$(MANPREFIX)/man1/mw.1

@@ -30,5 +27,6 @@ uninstall:
rm -f $(DESTDIR)$(PREFIX)/$$script; \
done
rm -rf $(DESTDIR)$(PREFIX)/share/mutt-wizard
rm -rf $(DESTDIR)$(MANPREFIX)/man1/mw.1

.PHONY: install uninstall

+ 11
- 9
bin/mw View File

@@ -1,14 +1,16 @@
#!/bin/sh

if [ -z "$prefix" ]; then
case "$(uname)" in
Linux) prefix="/usr" ;;
*) prefix="/usr/local" ;;
esac
fi

VERSION="2.0"

if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
prefix=${0}
else
prefix="$BASH_SOURCE"
fi
[ ! ${prefix::1} = "/" ] && prefix="$PWD/$prefix"
prefix="${prefix%/bin/*}"
mwbin="$prefix/bin/mw"

_MW_="mutt-wizard"
_MW_generated="mutt-wizard-generated"

@@ -428,7 +430,7 @@ _mwcron() {
read -r mwcronminutes
printf "\033[0m"
done
(crontab -l; echo "*/$mwcronminutes * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus; export DISPLAY=:0; $(type mw | cut -d' ' -f3) sync") \
(crontab -l; echo "*/$mwcronminutes * * * * export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/$(id -u)/bus; export DISPLAY=:0; $mwbin sync") \
| crontab - && echo "mw cronjob added. Mail will sync every $mwcronminutes minutes. Be sure you have your cron manager running."
}

@@ -645,7 +647,7 @@ _mwsyncandnotify() {
else
$mwmbsyncbin $mwaddr
fi
[ -z "$mwnono" ] && return
[ -n "$mwnono" ] && return
mwlastrun="$mwaccmaildir/.mw.lastrun"
mwnew=$(find "$mwaccmaildir/INBOX/new/" "$mwaccmaildir/Inbox/new/" "$mwaccmaildir/inbox/new/" -type f -newer "$mwlastrun" 2> /dev/null)
newcount=$(echo "$mwnew" | sed '/^\s*$/d' | wc -l)


+ 9
- 3
test/dotests View File

@@ -7,9 +7,7 @@ bats --tap test_mw.bats

echo
echo "Integration tests need working email $mwaddr"
echo "CTRL-C to skip"

#modify
if [ -z "$MAILDIR" ] || [ -z "$mwaddr" ]; then
echo "First do:"
[ -z "$MAILDIR" ] && echo "export MAILDIR=..."
@@ -17,11 +15,15 @@ if [ -z "$MAILDIR" ] || [ -z "$mwaddr" ]; then
exit
fi

cd .. && sudo make install && OK="OK"
export PREFIX=$PWD/mwtesttmp
export PATH=$PATH:$PREFIX/bin

cd .. && make install && OK="OK"

if [ "$OK" = "OK" ]; then

echo "Warning: Out with CTRL-C if your mail (config) files are important here."
read

export mwmaildir=$MAILDIR
export mwname='r n'
@@ -34,6 +36,7 @@ if [ "$OK" = "OK" ]; then
[ -f "${PASSWORD_STORE_DIR:-~/.password-store}/$mwpass.gpg" ] || pass insert $mwpass

echo "= Test 1 ="
echo $PATH
mwtype=online mw add
echo "=> In another prompt, start mutt and verify that mails are shown"
echo "=> Then answer with N"
@@ -53,3 +56,6 @@ if [ "$OK" = "OK" ]; then
fi

cd $CD

rm -rf $PREFIX


+ 0
- 1
test/test_mw.bats View File

@@ -20,7 +20,6 @@ setup()
XDG_CONFIG_HOME=mwtesttmp/config \
MAILDIR=mwtesttmp/share/mail \
XDG_CACHE_HOME=mwtesttmp/cache \
prefix="$PWD" \
source ../bin/mw
export NOTMUCH_CONFIG=mwtesttmp/config/notmuch-config
export mwname="real name"


Loading…
Cancel
Save