source: rpmbuild-bot/rpmbuild-bot.sh@ 748

Last change on this file since 748 was 748, checked in by dmik, 9 years ago

rpmbuild-bot: Copy auxiliary source files for .spec to SOURCES.

Auxiliary source files found in a directory named SPEC located
in the same directory where the SPEC.spec fie resides, will be
automatically copied to the SOURCES directory of the rpmbuild
tree (for further use in .spec via SourceN:).

File size: 21.3 KB
Line 
1#!/bin/sh
2
3#
4# rpmbuild-bot.sh: RPM Build Bot version 1.0.1.
5#
6# Author: Dmitriy Kuminov <coding@dmik.org>
7#
8# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
9# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
10#
11# History
12# -------
13#
14# 1.0.1 [01.04.2016]
15# - Fix bad variable name error.
16# - Understand .CMD extension in REXX wrapper.
17# 1.0 [01.04.2016]
18# - Initial version.
19#
20# Synopsis
21# --------
22#
23# This script performs a build of RPM packages from a given .spec file in
24# controlled environment to guarantee consistent results when building RPMs
25# different machines. It uses a separate file rpmbuild-bot-env.sh located
26# in the same directory to set up the environment and control the build
27# process. The main purpose of this script is to build RPM packages for a
28# specific distribution channel maintaining distribution-siecific rules.
29#
30# Usage
31# -----
32#
33# > rpmbuild-bot.sh SPEC[=VERSION]
34# > [ upload[=REPO] | test[=MODE] | clean[=test] | remove[=REPO] ]
35# > [-f]
36#
37# SPEC is the name of the RPM package spec file (extension is optional,
38# .spec is assumed). The spec file is searched in the SPECS directory of the
39# rpmbuild tree (usually $USER/rpmbuild/SPECS, rpmbuild --eval='%_specdir'
40# will show the exact location). This may be overriden by giving a spec file
41# with a path specification.
42#
43# The second argument defines the command to perform. The default command is
44# "build". The following sections will describe each command.
45#
46# Building packages
47# -----------------
48#
49# The "build" is the main command which is used to generate packages for
50# distribution. This command does the following:
51#
52# 1. Build all RPM packages for all architectures specified in
53# $RPMBUILD_BOT_ARCH_LIST. The packages are stored in the RPMS
54# directory of the rpmbuild tree.
55# 2. Build the source RPM. Stored in the SRPMS directory.
56# 3. Create a ZIP package from the RPMs for the architecture specified
57# last in $RPMBUILD_BOT_ARCH_LIST.
58#
59# The build process for each architecture is stored in a log file in the logs
60# directory of the rpmbuild tree (`rpmbuild --eval='%_topdir'/logs`). Creation
61# of the source RPM and ZIP files is also logged, into separate log files.
62#
63# The "build" command will fail if the log directory contains files from a
64# successfull run of another "build" command for this package. This is to
65# prevent overwriting successfully built packages that are not yet uploaded to
66# the distribution repository (see the "upload" command). You should either
67# run the "upload" command or use the -f option to force removal of these
68# log files and the corresponding package files if you are absolutely sure they
69# should be discarded.
70#
71# The "build" command will also check if there is a directory named SPEC in the
72# same directory where the given .spec file resides. If such a directory
73# exists, all files in it are assumed to be auxiliary source files used by the
74# .spec file via SourceN: directives. These files will be automatically copied
75# to the SOURCES directory in the rpmbuild tree befure starting the build
76# process.
77#
78# Doing test builds
79# -----------------
80#
81# The "test" command is used to build packages for one architecture for testing
82# purposes. In this more, neither the source RPM nor the ZIP file is created.
83# Also, a special option is automatically passed to rpmbuild to clear the %dist
84# variable to indicate that this is a local, non-distribution build. Such
85# packages will always be "older" than the corresponding builds with %dist
86# so that they will be automatically updated on the next yum update to the
87# %dist ones. The packages built in "test" mode are NOT intended for
88# distribution, they are meant only for local testing before performing the
89# full build of everything.
90#
91# It is possible to configure which steps of the build to perform using the MODE
92# argument to the "test" command which may take one of the following values:
93#
94# prep Execute the %prep section of the spec file only.
95# build Execute the %build section only (requres %prep to be executed
96# before). May be run multiple times.
97# install Execute the %install sectuion only (requires "prep" and "build"
98# to be executed before). May be run multiple times.
99# pack Create the RPM packages (requires "prep", "build" and "install"
100# to be executed before). Note that this step will also execute
101# the %clean section so that a new "install" execution is
102# necessary for "pack" to succeed.
103#
104# When no MODE argument is given, all steps are executed in a proper order.
105#
106# The results of the "test" command are stored in a log file in the logs/test
107# directory of the rpmbuild tree. The previous log file, if any, is given a .bak
108# extension (the previous .bak file will be deleted).
109#
110# The "test" command will copy auxiliary source files for the .spec file, if any,
111# to the proper location before rpmbuild execution -- the same way the "build"
112# command does it.
113#
114# Uploading packages
115# ------------------
116#
117# The "upload" command will upload the packages built with the "build"
118# command to the official distribution channel configured in
119# rpmbuild-bot-env.sh. The REPO argument specifies one of the configured
120# repositories. When REPO is not given, the default repository is used
121# (usually experimental or similar).
122#
123# Note that the "upload" command needs log files from the "build" command
124# and will fail otherwise.
125#
126# Upon successful completion, the "upload" command will remove all uploaded
127# RPM and ZIP packages and will move all "build" log files to logs/archive.
128#
129# Cleaning packages
130# -----------------
131#
132# The "clean" command will delete packages built with the "build" command
133# and their log files without uploading them to a repository. This is useful
134# when the successful build needs to be canceled for some reason (wrong source
135# tree state, wrong patches etc.). Note that normally you don't need to use
136# this command; it's an emergency-only tool.
137#
138# The "clean" command needs log files from the "build" command and will fail
139# otherwise.
140#
141# If the "clean" command is given a "test" argument, it will clean up the
142# results of the "test" command instead of "build". The log file from the
143# "test" command needs to be present or the command will fail.
144#
145# Removing packages
146# -----------------
147#
148# The "remove" command allows to remove a particular version of the packages
149# built with the "build" command and uploaded with the "upload" command from a
150# repository. This is useful when the successful build needs to be canceled for
151# some reason (wrong source tree state, wrong patches etc.). Note that normally
152# you don't need to use this command; it's an emergency-only tool.
153#
154# The "remove" command needs log files from the "build" and "upload" commands
155# and will fail otherwise. It also requires the VERSION argument for the SPEC
156# parameter to be given (to specify the version of the packages to remove) and
157# accepts the REPO argument just like the "upload" command does (to specify a
158# repository to remove the packages from).
159#
160# Note that the log files from the "build" and "upload" commands are also removed
161# by this command upon sucessful package removal.
162#
163# Return value
164# ------------
165#
166# The rpmbuild-bot.sh script will return a zero exit code upon successful
167# completion and non-zero otherwise. The log files should be inspected to
168# check for a reason of the failure.
169#
170
171#
172# Helpers.
173#
174
175run()
176{
177 "$@"
178 local rc=$?
179 if test $rc != 0 ; then
180 echo "ERROR: The following command failed with error code $rc:"
181 echo $@
182 exit $rc
183 fi
184}
185
186log_run()
187{
188 log="$1"
189 shift
190 "$@" >"$log" 2>&1
191 local rc=$?
192 if test $rc != 0 ; then
193 echo "ERROR: The following command failed with error code $rc:"
194 echo $@
195 echo "You will find more information in file '$log'."
196 echo "Here are the last 10 lines of output:"
197 echo ""
198 tail "$log" -n 10
199 exit $rc
200 fi
201}
202
203warn()
204{
205 echo "WARNING: $1"
206}
207
208die()
209{
210 echo "ERROR: $1"
211 exit 1
212}
213
214check_dir_var()
215{
216 eval local val="\$$1"
217 [ -n "$val" ] || die "$1 is empty."
218 [ -d "$val" ] || die "$1 is '$val', not a valid directory."
219}
220
221read_file_list()
222{
223 # $1 = file list list filename
224 # $2 = var name where to save read file names (optional)
225 # $3 = function name to call for each file (optional)
226
227 local list="$1"
228 local _read_file_list_ret=
229
230 # Check timestamps.
231 while read l; do
232 local file="${l#*|}"
233 local ts="${l%%|*}"
234 [ "$file" = "$ts" ] && die "Line '$l' in '$list' does not contain timestamps."
235 [ -n "$3" ] && eval $3
236 [ -f "$file" ] || die "File '$file' is not found."
237 echo "Checking tmestamp of $file..."
238 local act_ts=`stat -c '%Y' "$file"`
239 if [ "$ts" != "$act_ts" ] ; then
240 die "Recorded timestamp $ts doesn't match actual timestamp $act_ts for '$file'."
241 fi
242 _read_file_list_ret="$_read_file_list_ret${_read_file_list_ret:+ }$file"
243 done < "$list"
244 # Return the files (if requested).
245 [ -n "$2" ] && eval "$2=\$_read_file_list_ret"
246}
247
248usage()
249{
250 echo "Usage:"
251 sed -n -e "s/rpmbuild-bot.sh/${0##*/}/g" -e 's/^# > / /p' < "$0"
252 exit 255
253}
254
255sync_aux_src()
256{
257 [ -n "$src_dir" ] || die "src_dir is empty."
258 [ -n "$spec_full" ] || die "spec_full is empty."
259
260 # Aux source dir is expected along the .spec file.
261 local aux_src_dir="${spec_full%.spec}"
262
263 # Return early if there is no aux source dir.
264 [ -d "$aux_src_dir" ] || return
265
266 echo "Copying auxiliary sources for '$spec' to $src_dir..."
267
268 for f in "$aux_src_dir"/* ; do
269 local ts=`stat -c '%Y' "$f"`
270 local trg_ts=
271 local trg_f="$src_dir/${f##*/}"
272 [ -f "$trg_f" ] && trg_ts=`stat -c '%Y' "$trg_f"`
273 if [ "$ts" != "$trg_ts" ] ; then
274 echo "Copying $f..."
275 run cp -p "$f" "$trg_f"
276 fi
277 done
278}
279
280build_cmd()
281{
282 local base_arch="${RPMBUILD_BOT_ARCH_LIST##* }"
283
284 echo "Spec file: $spec_full"
285 echo "Targets: $RPMBUILD_BOT_ARCH_LIST + SRPM + ZIP ($base_arch)"
286
287 sync_aux_src
288
289 if [ -f "$spec_list" ] ; then
290 if [ -z "$force" ] ; then
291 die "File '$spec_list' already exists.
292This file indicates a successful build that was not yet uploaded.
293Either run the '"'upload'"' command to upload the generated RPM and ZIP
294packages to the distribution repository or use the -f option to
295force their removal if you are sure they should be discarded."
296 fi
297
298 echo "Detected successful build in $spec_list, cleaning up due to -f option..."
299 local files=
300 read_file_list "$spec_list" files
301 for f in $files; do
302 echo "Removing $f..."
303 run rm -f "$f"
304 done
305 unset files
306
307 echo "Removing $log_base.*.log and .list files..."
308 rm -f "$log_base".*.log "$log_base".*.list "$log_base".list
309 fi
310
311 # Generate RPMs.
312 for arch in $RPMBUILD_BOT_ARCH_LIST ; do
313 echo "Creating RPMs for '$arch' target (logging to $log_base.$arch.log)..."
314 log_run "$log_base.$arch.log" rpmbuild.exe --target=$arch -bb "$spec_full"
315 done
316
317 # Generate SRPM.
318 echo "Creating SRPM (logging to $log_base.srpm.log)..."
319 log_run "$log_base.srpm.log" rpmbuild -bs "$spec_full"
320
321 # Find SRPM file name in the log.
322 local src_rpm=`grep "^Wrote: \+.*\.src\.rpm$" "$log_base.srpm.log" | sed -e "s#^Wrote: \+##g"`
323 [ -n "$src_rpm" ] || die "Cannot find .src.rpm file name in '$log_base.srpm.log'."
324
325 # Find package version.
326 local ver_full="${src_rpm%.src.rpm}"
327 ver_full="${ver_full##*/}"
328 [ "${ver_full%%-[0-9]*}" = "$spec_name" ] || die \
329"SRPM name '${src_rpm##*/}' does not match .spec name ('$spec_name').
330Either rename '$spec_name.spec' to '${ver_full%%-[0-9]*}.spec' or set 'Name:' tag to '$spec_name'."
331 ver_full="${ver_full#${spec_name}-}"
332 [ -n "$ver_full" ] || die "Cannot deduce package version from '$src_rpm'."
333
334 # Find all RPM packages for the base arch (note the quotes around `` - it's to preserve multi-line result).
335 local rpms="`grep "^Wrote: \+.*\.\($base_arch\.rpm\|noarch\.rpm\)$" "$log_base.$base_arch.log" | sed -e "s#^Wrote: \+##g"`"
336 [ -n "$rpms" ] || die "Cannot find .$base_arch.rpm/.noarch.rpm file names in '$log_base.base_arch.log'."
337
338 local ver_full_zip=`echo $ver_full | tr . _`
339 local zip="$zip_dir/$spec_name-$ver_full_zip.zip"
340
341 # Generate ZIP.
342 echo "Creating ZIP (logging to $log_base.zip.log)..."
343 create_zip()
344 {(
345 run cd "$zip_dir"
346 rm -r "@unixroot" 2> /dev/null
347 # Note no quoters around $rpms - it's to split at EOL.
348 for f in $rpms ; do
349 echo "Unpacking $f..."
350 run rpm2cpio "$f" | cpio -idm
351 done
352 rm -f "$zip" 2> /dev/null
353 echo "Creating '$zip'..."
354 run zip -mry9 "$zip" "@unixroot"
355 )}
356 log_run "$log_base.zip.log" create_zip
357
358 local ver_list="$log_base.$ver_full.list"
359
360 # Generate list of all generated packages for further reference.
361 echo "Creating list file ($ver_list)..."
362 echo `stat -c '%Y' "$src_rpm"`"|$src_rpm" > "$ver_list"
363 echo `stat -c '%Y' "$zip"`"|$zip" >> "$ver_list"
364 # Save base arch RPMs.
365 for f in $rpms ; do
366 echo `stat -c '%Y' "$f"`"|$f" >> "$ver_list"
367 done
368 # Save other arch RPMs.
369 for arch in ${RPMBUILD_BOT_ARCH_LIST%${base_arch}} ; do
370 rpms="`grep "^Wrote: \+.*\.$arch\.rpm$" "$log_base.$arch.log" | sed -e "s#^Wrote: \+##g"`"
371 [ -n "$rpms" ] || die "Cannot find .$arch.rpm file names in '$log_base.arch.log'."
372 for f in $rpms ; do
373 echo `stat -c '%Y' "$f"`"|$f" >> "$ver_list"
374 done
375 done
376
377 # Everything succeeded. Symlink the list file so that "upload" can find it.
378 run ln -s "${ver_list##*/}" "$log_base.list"
379}
380
381test_cmd()
382{
383 echo "Spec file: $spec_full"
384
385 sync_aux_src
386
387 local base_arch="${RPMBUILD_BOT_ARCH_LIST##* }"
388 local cmds=
389
390 [ -z "$command_arg" ] && command_arg="all"
391
392 case "$command_arg" in
393 all)
394 cmds="$cmds -bb"
395 ;;
396 prep)
397 cmds="$cmds -bp --short-circuit"
398 ;;
399 build)
400 cmds="$cmds -bc --short-circuit"
401 ;;
402 install)
403 cmds="$cmds -bi --short-circuit"
404 ;;
405 pack)
406 cmds="$cmds -bb --short-circuit"
407 ;;
408 *)
409 die "Invalid test build sub-command '$command_arg'."
410 ;;
411 esac
412
413 local log_file="$log_dir/test/$spec_name.log"
414
415 if [ -f "$log_file" ] ; then
416 rm -f "$log_file.bak"
417 run mv "$log_file" "$log_file.bak"
418 fi
419
420 echo "Doing test RPM build for '$base_arch' target (logging to $log_file)..."
421 log_run "$log_file" rpmbuild.exe "--define=dist %nil" --target=$base_arch $cmds $spec_full
422
423 # Show the generated RPMs when appropriate.
424 if [ "$command_arg" = "all" -o "$command_arg" = "pack" ] ; then
425 # Find all RPM packages for the base arch (note the quotes around `` - it's to preserve multi-line result).
426 local rpms="`grep "^Wrote: \+.*\.\($base_arch\.rpm\|noarch\.rpm\)$" "$log_file" | sed -e "s#^Wrote: \+##g"`"
427 if [ -n "$rpms" ] ; then
428 echo "Successfully generated the following RPMs:"
429 for f in $rpms; do
430 echo "$f"
431 done
432 else
433 warn "Cannot find .$base_arch.rpm/.noarch.rpm file names in '$log_file'."
434 fi
435 fi
436}
437
438repo_dir_for_file()
439{
440 # $1 = input file name
441 # $2 = var name to save dir to
442
443 [ -n "$1" -a -n "$2" ] || die "Invalid arguments."
444
445 local _repo_dir_for_file_ret=
446 case "$1" in
447 *.src.rpm)
448 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_srpm"
449 ;;
450 *.*.rpm)
451 local arch="${1%.rpm}"
452 arch="${arch##*.}"
453 [ -n "$arch" ] || die "No arch spec in file name '$1'."
454 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_rpm"
455 ;;
456 *.zip)
457 eval _repo_dir_for_file_ret="$RPMBUILD_BOT_UPLOAD_REPO_LAYOUT_zip"
458 ;;
459 esac
460
461 eval "$2=\$_repo_dir_for_file_ret"
462}
463
464upload_cmd()
465{
466 # Check settings.
467 test -n "$RPMBUILD_BOT_UPLOAD_REPO_LIST" || die "RPMBUILD_BOT_UPLOAD_REPO_LIST is empty."
468
469 local repo="$command_arg"
470 [ -z "$repo" ] && repo="${RPMBUILD_BOT_UPLOAD_REPO_LIST%% *}"
471
472 check_dir_var "RPMBUILD_BOT_UPLOAD_${repo}_DIR"
473
474 eval local base="\$RPMBUILD_BOT_UPLOAD_${repo}_DIR"
475
476 [ -f "$spec_list" ] || die \
477"File '$spec_list' is not found.
478You may need to build the packages using the 'build' command."
479
480 local files=
481 read_file_list "$spec_list" files
482 for f in $files; do
483 local d=
484 repo_dir_for_file "$f" d
485 [ -n "$d" ] || die "Unsupported file name '$f' in '$spec_list'."
486 [ -d "$d" ] || die "'$d' is not a directory."
487 [ -f "$d/${f##*/}" -a -z "$force" ] && die \
488"File '$d/${f##*/}' already exists.
489Use the -f option to force uploading if you are sure the existing
490packages in the repository should be discarded."
491 echo "Copying $f to $d..."
492 run cp -p "$f" "$d"
493 done
494
495 # On success, delete the uploaded packages and archive log files.
496 for f in $files; do
497 echo "Removing $f..."
498 run rm -f "$f"
499 done
500
501 # Note: versioned .list file will remain in archive forever (for further reference).
502 echo "Removing old '$spec_name' logs from $log_dir/archive..."
503 rm -f "$log_dir/archive/$spec_name".*.log "$log_dir/archive/$spec_name".list
504 echo "Moving '$spec_name' logs to $log_dir/archive..."
505 run mv "$log_base".*.log "$log_base".*.list "$log_base".list "$log_dir/archive/"
506}
507
508clean_cmd()
509{
510 if [ "$command_arg" = "test" ] ; then
511 # Cleanup after "test" command.
512 local base_arch="${RPMBUILD_BOT_ARCH_LIST##* }"
513 local log_file="$log_dir/test/$spec_name.log"
514
515 [ -f "$log_file" ] || die "File '$test_log' is not found."
516
517 # Find all RPM packages for the base arch (note the quotes around `` - it's to preserve multi-line result).
518 local rpms="`grep "^Wrote: \+.*\.\($base_arch\.rpm\|noarch\.rpm\)$" "$log_file" | sed -e "s#^Wrote: \+##g"`"
519 if [ -n "$rpms" ] ; then
520 for f in $rpms; do
521 echo "Removing $f..."
522 run rm -f "$f"
523 done
524 echo "Removing $log_file[.bak]..."
525 run rm -f "$log_file" "$log_file".bak
526 else
527 die "Cannot find .$base_arch.rpm/.noarch.rpm file names in '$log_file'."
528 fi
529
530 return
531 fi
532
533 # Cleanup after "build command".
534 [ -f "$spec_list" ] || die \
535"File '$spec_list' is not found.
536You man need to build the packages using the 'build' command."
537
538 local files=
539 read_file_list "$spec_list" files
540
541 for f in $files; do
542 echo "Removing $f..."
543 run rm -f "$f"
544 done
545
546 echo "Removing '$spec_name' logs from $log_dir..."
547 rm -f "$log_base".*.log "$log_base".*.list "$log_base".list
548}
549
550remove_cmd()
551{
552 # Check settings.
553 [ -n "$spec_ver" ] || die "SPEC parameter lacks version specification."
554
555 test -n "$RPMBUILD_BOT_UPLOAD_REPO_LIST" || die "RPMBUILD_BOT_UPLOAD_REPO_LIST is empty."
556
557 local repo="$command_arg"
558 [ -z "$repo" ] && repo="${RPMBUILD_BOT_UPLOAD_REPO_LIST%% *}"
559
560 check_dir_var "RPMBUILD_BOT_UPLOAD_${repo}_DIR"
561
562 eval local base="\$RPMBUILD_BOT_UPLOAD_${repo}_DIR"
563
564 local ver_list="$log_dir/archive/$spec_name.$spec_ver.list"
565 [ -f "$ver_list" ] || die "File '$ver_list' is not found."
566
567 local files=
568 read_file_list "$ver_list" files 'local dir=; repo_dir_for_file $file dir; file="${dir}/${file##*/}"'
569
570 for f in $files; do
571 echo "Removing $f..."
572 run rm -f "$f"
573 done
574
575 echo "Removing $ver_list..."
576 run rm -f "$ver_list"
577
578 # Also remove the logs of last "build" if we are removing the last "build" package.
579 if [ -L "$log_dir/archive/$spec_name.list" -a \
580 `readlink "$log_dir/archive/$spec_name.list"` = "$spec_name.$spec_ver.list" ] ; then
581 echo "Removing '$spec_name' logs from $log_dir/archive..."
582 rm -f "$log_dir/archive/$spec_name".*.log "$log_dir/archive/$spec_name".list
583 fi
584}
585
586#
587# Main.
588#
589
590# Parse command line.
591while [ -n "$1" ] ; do
592 case "$1" in
593 -*)
594 options="$*"
595 while [ -n "$1" ] ; do
596 case "$1" in
597 -f) force="-f"
598 ;;
599 *) usage
600 ;;
601 esac
602 shift
603 done
604 break
605 ;;
606 *)
607 if [ -z "$spec" ] ; then
608 spec="$1"
609 else
610 command="$1"
611 fi
612 ;;
613 esac
614 shift
615done
616
617[ -n "$spec" ] || usage
618[ -z "$command" ] && command="build"
619
620spec_ver="${spec#*=}"
621spec="${spec%=*}"
622[ "$spec" = "$spec_ver" ] && spec_ver=
623
624command_name="${command%=*}"
625command_arg="${command#*=}"
626[ "$command_name" = "$command_arg" ] && command_arg=
627
628need_spec_file=
629
630# Validate commands.
631case "$command_name" in
632 build|test)
633 need_spec_file=1
634 ;;
635 upload|clean|remove)
636 ;;
637 *) usage
638 ;;
639esac
640
641# Query all rpmbuild macros in a single run as it may be slow.
642eval `rpmbuild.exe --eval='rpmbuild_dir="%_topdir" ; spec_dir="%_specdir" ; src_dir="%_sourcedir"' | tr '\\\' /`
643
644[ -n "$rpmbuild_dir" -a -d "$rpmbuild_dir" ] || die "Falied to get %_topdir from rpmbuild or not directory ($rpmbuild_dir)."
645[ -n "$spec_dir" -a -d "$spec_dir" ] || die "Falied to get %_specdir from rpmbuild or not directory ($spec_dir)."
646[ -n "$src_dir" -a -d "$src_dir" ] || die "Falied to get %_sourcedir from rpmbuild or not directory ($src_dir)."
647
648log_dir="$rpmbuild_dir/logs"
649zip_dir="$rpmbuild_dir/zip"
650
651spec=`echo $spec | tr '\\\' /`
652
653spec_name="${spec##*/}"
654
655if [ "$spec_name" = "$spec" ] ; then
656 # No path information, use SPECS
657 spec_full="$spec_dir/${spec_name%.spec}.spec"
658else
659 # Has some path, use it.
660 spec_full="${spec%.spec}.spec"
661fi
662
663spec_name="${spec_name%.spec}"
664
665[ -z "$need_spec_file" -o -f "$spec_full" ] || die "Spec file '$spec_full' is not found."
666
667# Prepare some (non-rpmbuild-standard) directories.
668run mkdir -p "$log_dir"
669run mkdir -p "$log_dir/archive"
670run mkdir -p "$log_dir/test"
671run mkdir -p "$zip_dir"
672
673[ -z "$command" ] && command="build"
674
675command_name="${command%=*}"
676comand_arg="${command#*=}"
677[ "$command_name" = "$command_arg" ] && command_arg=
678
679log_base="$log_dir/$spec_name"
680spec_list="$log_base.list"
681
682echo "Package: $spec_name"
683echo "Command: $command $options"
684
685# Set up the rpmbuild-bot environment.
686. "${0%%.sh}-env.sh"
687
688# Check common settings.
689test -n "$RPMBUILD_BOT_ARCH_LIST" || die "RPMBUILD_BOT_ARCH_LIST is empty."
690
691run eval "${command_name}_cmd"
692
693echo "All done."
694
695exit 0
Note: See TracBrowser for help on using the repository browser.