/
checkInstalled
executable file
·122 lines (107 loc) · 3.76 KB
/
checkInstalled
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
#
# Filename: checkInstalled
# Purpose: Rough check of installed files from r-makefile-definitions
#
# To make file executable in terminal use: chmod +x checkInstalled
# Created at: Frid 2017-09-29 at 13:04:11
# Author: Peter Baker
# Hostname: clearwell2.fritz.box
# Directory: ~/dev/r-makefile-definitions
# should be placed in PATH eg ~/bin
# Licence: GPLv3 see <http://www.gnu.org/licenses/>
#
# Platform: Not specified - linux at least but any bash shell should work
#
# Based on pp 7-8 of Randal K Michael (2008) Mastering UNIX Shell Scripting
#
# set -n # Uncomment to check script syntax, without extension
# # NOTE: Do not forget to put the comment back in or
# # the shell script wil not execute
# set -x # Uncomment to debug this shell script
#
# Change Log: First version
#
#
######################################################################
# Define files and variables here #
######################################################################
## Pattern rule .mk files to be compared
SRC_DIR=.
LIB_DIR=${HOME}/lib
MK_FILES='r-rules-functions.mk r-rules.mk'
## Makefile template files for comparison
BIN_DIR=${HOME}/bin
BASH_SCRIPTS=cpMakeTemplate
SRC_TEMPLATES=makeTemplates
DEST_TEMPLATES=${LIB_DIR}/${SRC_TEMPLATES}
TEMPLATES='install.txt Makefile Makefile.rsync Makefile.rsync2 Makefile.runR'
## Beamer template files for comparison
SRC_BEAMER=beamerPreamble
DEST_BEAMER=${LIB_DIR}/${SRC_BEAMER}
BEAMER_TEMPLATES='b1.Rnw Makefile preambleHandout.Rnw preamblePresent.Rnw b2.rnw preambleArticle.Rnw preambleNotes.Rnw preambleSlides.Rnw'
######################################################################
# Define functions here #
######################################################################
usage() { echo "Usage: $0 [-s source dir] [-l libDirectory] [-p] [-m] [-b]";\
echo "Defaults: source dir is '.', libDirectory ~/lib"; \
echo " -p, -m, -b: turn off comparing pattern rules, makefiles, beamers" 1>&2; exit 1; }
######################################################################
# Beginning of MAIN #
######################################################################
## process command line args - see pp 33-34 Michael (2008)
if [[ $1 == "" ]]; then
echo Comparing Files:
else
#parse options with getopts code block here;
while getopts :sl:hpmb PARS 2>/dev/null
do
case $PARS in
s) SRC_DIR=$OPTARG
;;
l) LIB_DIR=$OPTARG
;;
p) PATOFF=1
;;
m) MAKOFF=1
;;
b) BMROFF=1
;;
h|\?)
usage
exit 1
;;
*)
usage
exit 1
;;
esac
done
fi
echo ""
if [[ $PATOFF == "1" ]]; then
echo "Pattern rule files not compared."
else
echo Comparing pattern rule files in ${LIB_DIR}:
for F in ${MK_FILES}; do echo +++ File: $F; diff ${SRC_DIR}/$F ${LIB_DIR}/$F; done
fi
echo ""
if [[ $MAKOFF == "1" ]]; then
echo "Makefile templates not compared."
else
echo Comparing bash script for copying pattern rule files in ${BIN_DIR}:
for F in ${BASH_SCRIPTS}; do echo +++ File: $F; diff ${SRC_DIR}/$F ${BIN_DIR}/$F; done
echo ""
echo Comparing Makefile templates in ${DEST_TEMPLATES}:
for F in ${TEMPLATES}; do echo +++ File: $F; diff ${SRC_TEMPLATES}/$F ${DEST_TEMPLATES}/$F; done
fi
echo ""
if [[ $BMROFF == "1" ]]; then
echo "Beamer templates, stubs and examples not compared."
else
echo Comparing Beamer templatesin ${DEST_BEAMER}:
for F in ${BEAMER_TEMPLATES}; do echo +++ File: $F; diff ${SRC_BEAMER}/$F ${DEST_BEAMER}/$F; done
fi
echo ""
echo If necessary, use cp, meld or rsync etc to bring library versions up to date
echo "NB: Be careful not to modify any fles you have customised"