|
@@ -114,6 +114,43 @@ choose_relpfx() {
|
114
|
114
|
return 0
|
115
|
115
|
}
|
116
|
116
|
|
|
117
|
+do_action() {
|
|
118
|
+ local url
|
|
119
|
+ case $Action in
|
|
120
|
+ build)
|
|
121
|
+ copr build "$CoprProject" "$Tmp/slop.spec"
|
|
122
|
+ ;;
|
|
123
|
+ demo)
|
|
124
|
+ warn "demo mode active, we would build:"
|
|
125
|
+ warn " at $CoprProject"
|
|
126
|
+ test -n "$Branch" && warn " using branch $Branch"
|
|
127
|
+ test -n "$Branch" || warn " using last tag"
|
|
128
|
+ warn " from $UrlBase"
|
|
129
|
+ warn " yielding slop-$Version-$Release.*.rpm"
|
|
130
|
+ warn ""
|
|
131
|
+ warn "===== BEGIN slop.spec ====="
|
|
132
|
+ cat "$Tmp/slop.spec"
|
|
133
|
+ warn "===== END slop.spec ====="
|
|
134
|
+ return 1
|
|
135
|
+ ;;
|
|
136
|
+ mkspec)
|
|
137
|
+ cat "$Tmp/slop.spec"
|
|
138
|
+ ;;
|
|
139
|
+ rpmstuff)
|
|
140
|
+ url=$(
|
|
141
|
+ grep -o 'Source.*:.*http.*' "$Tmp/slop.spec" \
|
|
142
|
+ | sed "
|
|
143
|
+ s/.*http/http/
|
|
144
|
+ s/ *$//
|
|
145
|
+ s/%{version}/$Version/
|
|
146
|
+ "
|
|
147
|
+ )
|
|
148
|
+ wget --quiet "$url"
|
|
149
|
+ cat "$Tmp/slop.spec" > slop.spec
|
|
150
|
+ ;;
|
|
151
|
+ esac
|
|
152
|
+}
|
|
153
|
+
|
117
|
154
|
main() {
|
118
|
155
|
local Version # Version in SPEC file
|
119
|
156
|
local Release # Release in SPEC file
|
|
@@ -121,22 +158,28 @@ main() {
|
121
|
158
|
local UrlBase # GitHub URL base
|
122
|
159
|
local Tmp # our temp
|
123
|
160
|
local Branch # branch to use, if empty, tags are considered
|
124
|
|
- local DryRun=false # do not do anything
|
125
|
161
|
local Mode=scratch # implies COPR project and release prefix
|
|
162
|
+ local Action=build # what to do
|
|
163
|
+ local es=0 # exit status
|
126
|
164
|
which copr >/dev/null \
|
127
|
165
|
|| die "copr not found, try 'sudo install copr-cli'"
|
128
|
166
|
Tmp=$(mktemp -d)
|
129
|
167
|
while true; do case $1 in
|
|
168
|
+ -a) Action=$2; shift 2 || usage ;;
|
130
|
169
|
-b) Branch=$2; shift 2 || usage ;;
|
131
|
170
|
-c) CoprProject=$2; shift 2 || usage ;;
|
132
|
171
|
-u) UrlBase=$2; shift 2 || usage ;;
|
133
|
172
|
-r) Release=$2; shift 2 || usage ;;
|
134
|
173
|
-v) Version=${2#v}; shift 2 || usage ;;
|
135
|
|
- -n) DryRun=true; shift ;;
|
|
174
|
+ -n) Action=demo; shift ;;
|
136
|
175
|
-*) usage ;;
|
137
|
176
|
*) break ;;
|
138
|
177
|
esac done
|
139
|
178
|
Mode=${1:-$Mode}
|
|
179
|
+ case $Action in
|
|
180
|
+ build|demo|mkspec|rpmstuff) : ;;
|
|
181
|
+ *) usage ;;
|
|
182
|
+ esac
|
140
|
183
|
case $Mode in
|
141
|
184
|
main|scratch) : ;;
|
142
|
185
|
*) usage ;;
|
|
@@ -153,21 +196,9 @@ main() {
|
153
|
196
|
fi
|
154
|
197
|
Release=$(choose_relpfx)$Release
|
155
|
198
|
mkspec >"$Tmp/slop.spec"
|
156
|
|
- $DryRun && {
|
157
|
|
- warn "dry mode active, we would build:"
|
158
|
|
- warn " at $CoprProject"
|
159
|
|
- test -n "$Branch" && warn " using branch $Branch"
|
160
|
|
- test -n "$Branch" || warn " using last tag"
|
161
|
|
- warn " from $UrlBase"
|
162
|
|
- warn " yielding slop-$Version-$Release.*.rpm"
|
163
|
|
- warn ""
|
164
|
|
- warn "===== BEGIN slop.spec ====="
|
165
|
|
- cat "$Tmp/slop.spec"
|
166
|
|
- warn "===== END slop.spec ====="
|
167
|
|
- exit 1
|
168
|
|
- }
|
169
|
|
- copr build "$CoprProject" "$Tmp/slop.spec"
|
|
199
|
+ do_action
|
170
|
200
|
rm -rf "$Tmp"
|
|
201
|
+ return $es
|
171
|
202
|
}
|
172
|
203
|
|
173
|
204
|
main "$@"
|