-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgear-rpm
executable file
·118 lines (104 loc) · 2.79 KB
/
gear-rpm
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
#!/bin/sh -efu
#
# Copyright (C) 2008-2018 Alexey Gladkov <legion@altlinux.org>
# Copyright (C) 2008-2010 Dmitry V. Levin <ldv@altlinux.org>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
. gear-utils-sh-functions
. shell-getopt
gear_cmd=
show_help()
{
cat <<-EOF
Usage: ${PROG?} [options] [$gear_cmd options] [gear options]
Options:
-v, --verbose print a message for each action;
-V, --version print program version and exit;
-h, --help show this text and exit.
Report bugs to https://bugzilla.altlinux.org/
EOF
exit
}
print_version()
{
cat <<-EOF
$PROG version $PROG_VERSION
Written by Alexey Gladkov <legion@altlinux.org>
Copyright (C) 2008-2018 Alexey Gladkov <legion@altlinux.org>
Copyright (C) 2008-2010 Dmitry V. Levin <ldv@altlinux.org>
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
EOF
exit
}
conflicting_option_list=
args='--command -- gear-command'
case "$PROG" in
gear-hsh)
gear_cmd=hasher
prog=hsh
;;
gear-mock)
gear_cmd=mock
prog=mock
conflicting_option_list='-r'
;;
gear-rpm)
gear_cmd=rpmbuild
prog=rpmbuild
conflicting_option_list='-r -t'
;;
gear-buildreq)
gear_cmd=rpmbuild
prog=buildreq
conflicting_option_list='-r -t'
;;
*)
fatal "Unknown command: $PROG"
;;
esac
args="$args-$gear_cmd $prog"
GETOPT_ALLOW_UNKNOWN=1
GETOPT_ALLOW_ABBREV=
TEMP=$(getopt -n $PROG -o "$gear_short_options" -l "$gear_long_options" -- "$@") ||
show_usage
eval set -- "$TEMP"
gear_args=
while :; do
for pattern in $conflicting_option_list; do
[ -n "${1##$pattern}" ] ||
fatal "Option \`$1' is present both in gear and $prog, please use an equivalent long option instead."
done
case "$1" in
-h|--help) show_help
;;
-V|--version) print_version
;;
-v|--verbose) verbose=-v
;;
--) shift; break
;;
esac
gear_args="$gear_args \"$(quote_shell "$1")\""
shift
done
while [ $# -gt 0 ]; do
args="$args \"$(quote_shell "$1")\""
shift
done
[ "$(type -t "$prog")" = file ] ||
fatal "$prog: command not found; maybe an appropriate package is not installed"
eval exec gear $gear_args $args