-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupsource.in
More file actions
executable file
·75 lines (68 loc) · 1.88 KB
/
upsource.in
File metadata and controls
executable file
·75 lines (68 loc) · 1.88 KB
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
#!/bin/sh
PREFIX=@PREFIX@
UPSOURCE_SHELL=@SHELL@
UPSOURCE_LIB=@LIBDIR@
UPSOURCE_RUN=@RUNDIR@
UPSOURCE_LOG=@LOGDIR@
AWK=@AWK@
sourcetab_command()
{
grep -v "^\s*$" | grep -v "^[ ]*[#;]" | ${AWK} -f @LIBDIR@/sourcetab.awk;
}
generate_upsource_commands()
{
ARG=$1
echo "export OWNER GROUP BRANCH FILEMODE";
echo "export PREFIX=@PREFIX@;";
echo "export UPSOURCE_LIB=@LIBDIR@;";
echo "export UPSOURCE_RUN=@RUNDIR@;";
echo "export UPSOURCE_LOG=@LOGDIR@;";
echo "export ETC=@ETC@;";
echo "export SSH_USER SSH_KEY;";
echo "export GIT_SSH_USER GIT_SSH_KEY GIT_HTTP_LOGIN;";
if test -d ${ARG}; then
if test -f ${ARG}/config; then
cat ${ARG}/config; fi;
for tab in ${ARG}/*.srctab; do
if test -f ${tab}; then
cat ${tab} | sourcetab_command;
fi;
done;
elif test -f ${ARG}; then
DIRNAME=`dirname ${ARG}`
if test -f ${DIRNAME}/config; then
cat ${DIRNAME}/config;
fi
if test -f ~/.upsource; then
cat ~/.upsource;
fi
cat ${ARG} | sourcetab_command;
else
echo "usage: upsource [sourcetab file or directory]";
exit;
fi
}
for pre in @LIBDIR@/handlers/*.pre; do
if test -x ${pre}; then ${pre}; fi; done
idu=`id -u`
# With no arguments, process the system upsource.d directory
if test $# -eq 0; then
if test "${idu}" -eq 0; then
generate_upsource_commands @ETC@/upsource.d | sh;
elif test -d ~/.upsource.d/; then
generate_upsource_commands ~/.upsource.d | sh;
else
echo "# (upsource) No ~/.upsource.d/, trying @ETC@/upsource.d/";
generate_upsource_commands @ETC@/upsource.d | sh;
fi;
else
for tab in $*; do \
generate_upsource_commands ${tab} | sh;
done;
fi
# Run any .post files placed in the run dir
for run in @RUNDIR@/*.post; do
if test -f ${run}; then ${run}; fi; done
# Run any .post files in the handlers dir
for post in @LIBDIR@/handlers/*.post; do
if test -x ${post}; then ${post}; fi; done