Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
language: generic
sudo: required
dist: trusty

Expand Down Expand Up @@ -28,5 +29,12 @@ script:
- lintian --profile debian -i --fail-on-warnings -EvIL +pedantic ../vimpager*.changes
- make all
- make test
- |
set -e
sudo make install
[[ "$(which vimpager)" == /usr/local/bin/vimpager ]]
[[ "$(which vimcat)" == /usr/local/bin/vimcat ]]
vimpager -v
vimcat -v

# vim: sw=4
62 changes: 48 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,27 @@ all: ${PROGRAMS:=-vertag-stamp} standalone/vimpager standalone/vimcat docs
@git describe >$<-version.txt 2>/dev/null \
|| sed -n '/^[0-9][0-9.]* [0-9-]*:$$/{s/ .*//;p;q;}' ChangeLog_$<.yml >$<-version.txt

standalone/vimpager: vimpager vimpager-version.txt ${SRC:=.uu} inc/* Makefile
standalone/vimpager: vimpager vimpager-version.txt ${SRC:=.uu} inc/bundled_scripts.sh inc/do_uudecode.sh inc/prologue.sh inc/vimpager_functions.sh Makefile
@echo building $@
@${MKPATH} ${@D}
@sed \
-e '/^ *\. .*inc\/prologue.sh"$$/{' \
-e '/^\. .*inc\/prologue.sh"$$/{' \
-e 'r inc/prologue.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/vimpager_functions.sh"$$/{' \
-e 'r inc/vimpager_functions.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/common_functions.sh"$$/{' \
-e 'r inc/common_functions.sh' \
-e d \
-e '}' \
-e 's/^\( *\)# EXTRACT BUNDLED SCRIPTS HERE$$/\1extract_bundled_scripts/' \
-e 's|^version=.*|version="'"`cat vimpager-version.txt`"' (standalone, shell=\$$(command -v \$$POSIX_SHELL))"|' \
-e 's!^\( *\)runtime=.*$$!\1runtime='\''\$$tmp/runtime'\''!' \
-e 's!^\( *\)vimcat=.*$$!\1vimcat='\''\$$runtime/bin/vimcat'\''!' \
-e 's!^\( *\)system_vimpagerrc=.*$$!\1system_vimpagerrc='\'\''!' \
-e 's!^version=.*!version="'"`cat vimpager-version.txt`"' (standalone, shell=\$$(command -v \$$POSIX_SHELL))"!' \
-e 's!^runtime=.*$$!runtime='\''\$$tmp/runtime'\''!' \
-e 's!^vimcat=.*$$!vimcat='\''\$$runtime/bin/vimcat'\''!' \
-e 's!^system_vimpagerrc=.*$$!system_vimpagerrc='\'\''!' \
-e '/^# INCLUDE BUNDLED SCRIPTS HERE$$/{ q; }' \
vimpager > $@
@cat inc/do_uudecode.sh >> $@
Expand All @@ -63,7 +71,7 @@ standalone/vimpager: vimpager vimpager-version.txt ${SRC:=.uu} inc/* Makefile
@sed -n '/^# END OF BUNDLED SCRIPTS$$/,$$p' vimpager >> $@
@chmod +x $@

standalone/vimcat: vimcat autoload/vimcat.vim vimcat-version.txt inc/prologue.sh Makefile
standalone/vimcat: vimcat autoload/vimcat.vim inc/prologue.sh inc/vimcat_functions.sh inc/common_functions.sh Makefile vimcat-version.txt
@echo building $@
@${MKPATH} ${@D}
@nlinit=`echo 'nl="'; echo '"'`; eval "$$nlinit"; \
Expand All @@ -79,6 +87,14 @@ standalone/vimcat: vimcat autoload/vimcat.vim vimcat-version.txt inc/prologue.sh
-e 'r inc/prologue.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/vimcat_functions.sh"$$/{' \
-e 'r inc/vimcat_functions.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/common_functions.sh"$$/{' \
-e 'r inc/common_functions.sh' \
-e d \
-e '}' \
vimcat > $@
@cp $@ $@.work
@awk '/^[ ]*(if|for|while)/ { print $$1 }' $@ \
Expand All @@ -89,16 +105,24 @@ standalone/vimcat: vimcat autoload/vimcat.vim vimcat-version.txt inc/prologue.sh
@sed -e 's/vimcat#\([^ ]*\)(/\1(/g' autoload/vimcat.vim >> $@
@chmod +x $@

vimcat.uu: vimcat vimcat-version.txt
vimcat.uu: vimcat vimcat-version.txt inc/vimcat_functions.sh inc/common_functions.sh inc/prologue.sh Makefile
@echo uuencoding vimcat
@echo 'vimcat_script() {' > $@
@printf "\t(cat <<'EOF') | do_uudecode > bin/vimcat\n" >> $@
@sed \
-e 's|^version=.*|version="'"`cat vimcat-version.txt`"' (bundled, shell=\$$(command -v \$$POSIX_SHELL))"|' \
-e '/^ *\. .*inc\/prologue.sh"$$/{' \
-e '/^\. .*inc\/prologue.sh"$$/{' \
-e 'r inc/prologue.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/vimcat_functions.sh"$$/{' \
-e 'r inc/vimcat_functions.sh' \
-e d \
-e '}' \
-e '/^\. .*inc\/common_functions.sh"$$/{' \
-e 'r inc/common_functions.sh' \
-e d \
-e '}' \
vimcat > $@.work
@uuencode $@.work vimcat >> $@
@echo EOF >> $@
Expand Down Expand Up @@ -173,9 +197,11 @@ install: docs vimpager.configured vimcat.configured
echo ${INSTALLCONF} vimpagerrc "$${SYSCONFDIR}/vimpagerrc"; \
${INSTALLCONF} vimpagerrc "$${SYSCONFDIR}/vimpagerrc"

%.configured: % %-version.txt
%.configured: % %-version.txt inc/%_functions.sh inc/common_functions.sh
@echo configuring $<
@POSIX_SHELL="`scripts/find_shell`"; \
BASE='${@F}'; \
BASE=$${BASE%.configured}; \
if [ '${PREFIX}' = /usr ]; then \
vimpagerrc=/etc/vimpagerrc; \
else \
Expand All @@ -184,11 +210,19 @@ install: docs vimpager.configured vimcat.configured
sed -e '1{ s|.*|#!'"$$POSIX_SHELL"'|; }' \
-e 's|\$$POSIX_SHELL|'"$$POSIX_SHELL|" \
-e '/^ *\. .*inc\/prologue.sh"$$/d' \
-e 's|^version=.*|version="'"`cat $<-version.txt`"' (configured, shell='"$$POSIX_SHELL"')"|' \
-e 's|^version=.*|version="'"`cat $$BASE-version.txt`"' (configured, shell='"$$POSIX_SHELL"')"|' \
-e '/^# FIND REAL PARENT DIRECTORY$$/,/^# END OF FIND REAL PARENT DIRECTORY$$/d' \
-e 's!^\( *\)runtime=.*!\1runtime='\''${PREFIX}/share/vimpager'\''!' \
-e 's!^\( *\)vimcat=.*!\1vimcat='\''${PREFIX}/bin/vimcat'\''!' \
-e 's!^\( *\)system_vimpagerrc=.*!\1system_vimpagerrc='\'"$$vimpagerrc"\''!' \
-e 's!^runtime=.*!runtime='\''${PREFIX}/share/vimpager'\''!' \
-e 's!^vimcat=.*!vimcat='\''${PREFIX}/bin/vimcat'\''!' \
-e 's!^system_vimpagerrc=.*!system_vimpagerrc='\'"$$vimpagerrc"\''!' \
-e '/^\. .*inc\/'"$$BASE"'_functions.sh"$$/{' \
-e "r inc/$${BASE}_functions.sh" \
-e d \
-e '}' \
-e '/^\. .*inc\/common_functions.sh"$$/{' \
-e 'r inc/common_functions.sh' \
-e d \
-e '}' \
$< > $@
@chmod +x $@

Expand Down
75 changes: 75 additions & 0 deletions inc/common_functions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Function definitions common for vimpager and vimcat.

squeeze_blank_lines() {
sed '/^[ ]*$/{
N
/^[ ]*\n[ ]*$/D
}'
}

create_tmp_directory() {
if ! mkdir $mkdir_options "$tmp"; then
echo "ERROR: Could not create temporary directory $tmp" >&2
rm -rf "$tmp" 2>/dev/null # rm -rf "" shows error on OpenBSD
exit 1
fi
}

set_system_vars() {
case "$(uname -s)" in
Linux) linux=1;;
SunOS) solaris=1;;
Darwin) osx=1 bsd=1;;
CYGWIN*) cygwin=1 win32=1;;
MINGW*) msys=1 win32=1;;
MSYS*) msys=1 win32=1;;
OpenBSD) openbsd=1 bsd=1;;
FreeBSD) freebsd=1 bsd=1;;
NetBSD) netbsd=1 bsd=1;;
*) bsd=1;;
esac
}

install_trap() {
trap 'quit 1' PIPE HUP INT QUIT ILL TRAP KILL BUS TERM
}

check_for_cygpath() {
# special handling to rewrite cygwin/msys paths to windows POSIX paths
if [ -n "$win32" ] && command -v cygpath >/dev/null; then
_have_cygpath=1
fi
}

resolve_path() {
if [ -n "$_have_cygpath" ]; then
cygpath --unix "$1"
else
echo "$1"
fi
}

find_tmp_directory() {
# Find and create the temporary directory used by vimpager. Set the $tmp and $mkdir_options variable.
mkdir_options='-m 700'
# Default to /tmp
tmp=/tmp

if [ -n "$win32" ]; then
# Use the real TEMP directory on windows in case we are
# using a native vim/gvim
# TEMP can be /tmp sometimes too
tmp=$(resolve_path "$TEMP")
if [ -n "$msys" -a -n "$temp" ]; then
# MSYS2 is a little tricky, we're gonna stick to the user's private temp
tmp=$(resolve_path "$temp")
fi
# chmod doesn't work here, even in /tmp sometimes
mkdir_options=
fi

# Add a final component to the path, all other temp files should be placed in this directory.
tmp=$tmp/${prog}_$$
}

# vim: sw=4 et tw=0:
Loading