forked from rpm-software-management/rpm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdevtool
executable file
·152 lines (137 loc) · 4.29 KB
/
devtool
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh
##
## devtool -- Development Tool
## Copyright (c) 2001 Ralf S. Engelschall <rse@engelschall.com>
##
Usage () {
cat <<EOF 1>&2
Usage: ./devtool <target command>
where target command is one of the following:
$(grep '^%[[:alpha:]][[:alpha:]]*' devtool.conf | sed -e 's#^%##')
EOF
}
# determine source tree location
DEVTOOL_SRCDIR=`echo "$0" | sed -e 's;/devtool$;;'`
export DEVTOOL_SRCDIR
# build environment sanity check
if [ ! -f ${DEVTOOL_SRCDIR}/devtool.conf ]; then
echo "devtool:ERROR: no devtool.conf in current directory" 1>&2
exit 1
fi
# usage sanity check
if [ $# -eq 0 ]; then
Usage
exit 1
fi
cmd="$1"
shift
[ "${cmd}" = "--help" -o "${cmd}" = "-h" ] && Usage && exit 0
cmdline=`grep "^%$cmd" ${DEVTOOL_SRCDIR}/devtool.conf`
if [ ".$cmdline" = . ]; then
echo "devtool:ERROR: target command $cmd not found in devtool.conf" 1>&2
Usage
exit 1
fi
# ensure a reasonable temporary directory exists
if [ ".$TMPDIR" != . ]; then
tmpdir="$TMPDIR"
elif [ ".$TEMPDIR" != . ]; then
tmpdir="$TEMPDIR"
else
tmpdir="/tmp"
fi
tmpfile="$tmpdir/devtool.$$.tmp"
# generate run-command script
rm -f $tmpfile
touch $tmpfile
( sed <${DEVTOOL_SRCDIR}/devtool -e '1,/^## devtool.func {/d' -e '/^## } devtool.func/,$d'
sed <${DEVTOOL_SRCDIR}/devtool.conf -e "1,/^%common/d" -e '/^%.*/,$d'
sed <${DEVTOOL_SRCDIR}/devtool.conf -e "1,/^%$cmd/d" -e '/^%.*/,$d' ) |\
sed -e 's;\([ ]\)@\([a-zA-Z_][a-zA-Z0-9_-]*\);\1devtool_\2;' \
-e 's;\([ ]\)%\([a-zA-Z_][a-zA-Z0-9_-]*\);\1devtool_execute \2;' \
>>$tmpfile
# execute run-command script
sh $tmpfile "$@"
rc=$?
# cleanup and graceful exit
rm -f $tmpfile >/dev/null 2>&1 || true
exit $rc
## devtool.func { # is now embedded. This line used as cutting point. Do not remove.
devtool_execute () {
sh ${DEVTOOL_SRCDIR}/devtool "$@"
}
devtool_source () {
_tmpfile="${TMPDIR-/tmp}/devtool.$$.tmp.$2"
rm -f $_tmpfile
sed <${DEVTOOL_SRCDIR}/devtool.conf -e "1,/^%$2/d" -e '/^%.*/,$d' |\
sed -e 's;\([ ]\)@\([a-zA-Z_][a-zA-Z0-9_-]*\);\1devtool_\2;' \
-e 's;\([ ]\)%\([a-zA-Z_][a-zA-Z0-9_-]*\);\1devtool_execute \2;' >$_tmpfile
. $_tmpfile
rm -f $_tmpfile
}
devtool_require () {
t="$1"; o="$2"; p="$3"; e="$4"; a="$5"
v=`($t $o | head -1 | awk "{ print \\\$$p; }") 2>/dev/null`
if [ ".$v" = . ]; then
echo "devtool:ERROR: unable to determine version of $t" 1>&2
exit 1
fi
case "$v" in
$e )
;;
$a )
echo "devtool:WARNING: $t version $v accepted, but expected $e." 1>&2
;;
* )
echo "devtool:ERROR: $t version $v NOT acceptable, requires $e." 1>&2
exit 1
;;
esac
echo "$v"
}
devtool_autogen () {
tool=$1
shift
case $tool in
autoconf )
autoconf_version=`devtool_require autoconf --version 4 "$1" "$2"`
echo "generating (GNU Autoconf $autoconf_version): configure config.h.in"
autoconf
autoheader 2>&1 | grep -v "is unchanged"
rm -rf autom4te.cache >/dev/null 2>&1
;;
libtool )
libtoolize_version=`devtool_require libtoolize --version 4 "$1" "$2"`
echo "generating (GNU Libtool $libtoolize_version): ltmain.sh, libtool.m4, config.guess, config.sub"
libtoolize --force --copy --install >/dev/null 2>&1
cp `libtoolize --force --copy --dry-run --install | grep "add the contents of" |\
sed -e 's;^[^\`]*\`;;' -e "s;'.*;;"` libtool.m4
;;
shtool )
shtoolize_version=`devtool_require shtoolize -v 3 "$1" "$2"`
echo "generating (GNU Shtool $shtoolize_version): shtool"
shift
shift
shtoolize -q "$@"
;;
esac
}
devtool_autoclean () {
tool=$1
shift
case $tool in
autoconf )
echo "removing: configure config.h.in"
rm -f configure config.h.in
;;
libtool )
echo "removing: ltmain.sh libtool.m4 config.guess config.sub"
rm -f ltmain.sh libtool.m4 config.guess config.sub
;;
shtool )
echo "removing: shtool"
rm -f shtool
;;
esac
}
## } devtool.func # is now embedded. This line used as cutting point. Do not remove.