-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgear-remote
executable file
·167 lines (147 loc) · 4.52 KB
/
gear-remote
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#!/bin/sh -efu
#
# Copyright (C) 2007-2018 Alexey Gladkov <legion@altlinux.org>
# Copyright (C) 2007 Alexey I. Froloff <raorn@altlinux.org>
# Copyright (C) 2008 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_command_method='gear'
show_help()
{
cat <<-EOF
Usage: $PROG [options] [$gear_command_method options] [<user>@]<hostname> <workdir>
<hostname> - remote build host;
<workdir> - working directory onto <hostname>.
Options:
--remote-repo make remote repository and do not download results;
--build-only do not download results onto current host;
--cleanup-repo cleanup hasher workdir on remote host;
--commit make temporary commit prior to extract;
--target=ARCH target architecture;
-m, --method=TYPE defines build method on the remote host (default: gear);
-o, --outdir=OUTDIR download results in DIR on local machine;
-r, --rules=FILE override rules file name;
-t, --tree-ish=ID COMMIT[:PATH] specifying the tree to process;
-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) 2007-2018 Alexey Gladkov <legion@altlinux.org>
Copyright (C) 2007 Alexey I. Froloff <raorn@altlinux.org>
Copyright (C) 2008 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
}
[ "$#" -gt 0 ] ||
show_help
case "$PROG" in
*-hsh) gear_command_method='hsh' ;;
*-rpm) gear_command_method='rpm' ;;
esac
GETOPT_ALLOW_UNKNOWN=1
GETOPT_ALLOW_ABBREV=
TEMP=$(getopt -n $PROG -o m:,o:,r:,t:,v,V,h -l build-only,cleanup,commit,method:,remote-repo,rules:,target:,tree-ish:,outdir:,verbose,version,help -- "$@") ||
show_usage
eval set -- "$TEMP"
rules=
do_commit=
main_tree_id=
gear_command_remote_repo=
gear_command_build_only=
while :; do
case "$1" in
--build-only)
gear_command_build_only=1
;;
--cleanup)
gear_command_cleanup=1
;;
--commit)
do_commit=1
;;
--remote-repo)
[ "$gear_command_method" != 'rpm' ] ||
show_usage 'Option --method=rpm with --remote-repo does not make sense.'
gear_command_remote_repo=1
;;
--target) shift
gear_command_target="$1"
;;
-m|--method) shift
[ "$1" != 'rpm' ] || [ -z "$gear_command_remote_repo" ] ||
show_usage 'Option --method=rpm with --remote-repo does not make sense.'
gear_command_method="$1"
;;
-o|--outdir)
gear_command_outdir="$(opt_check_dir "$1" "$2")"
shift
;;
-r|--rules) shift; rules="$1"
;;
-t|--tree-ish) shift; main_tree_id="$1"
[ -z "$do_commit" ] || [ -z "$main_tree_id" ] ||
show_usage 'Options --commit and --tree-ish are mutually exclusive.'
;;
-v|--verbose) verbose=-v
;;
-V|--version) print_version
;;
-h|--help) show_help
;;
--) shift; break
;;
*) fatal "Unrecognized option: $1"
;;
esac
shift
done
[ "$#" -ge 2 ] ||
show_help
args="$verbose"
while [ $# -gt 2 ]; do
case "$1" in
--target=*)
target="${1#--target=}"
gear_command_target="$(string_quote_remove "$target")"
;;
esac
args="$args \"$(quote_shell "$1")\""
shift
done
gear_command_server="$1"; shift
gear_command_workdir="$1"; shift
export gear_command_server gear_command_workdir gear_command_method gear_command_target
export gear_command_outdir gear_command_build_only gear_command_cleanup
export gear_command_remote_repo
eval gear \
$verbose \
${rules:+-r "$rules"} \
${do_commit:+--commit} \
${main_tree_id:+-t "$main_tree_id"} \
--command \
-- gear-command-remote-build "$args"