3 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" -o -z "$5" ] ; then
5 echo "Usage: ./make-rpm.sh tarball spec_target rpm_args build_dir results_dir"
7 echo "<build_dir>/rpmbuild is the RPM tree where the build will"
8 echo "take place. If rpmbuild does not exist, but SPECS does, then"
9 echo "it is assumed build_dir == the rpmbuild dir. This is useful"
10 echo "in the (hopefully) rare occasions where you need to build in"
13 echo "tarball is the full pathname of the tarball to extract."
14 echo "It is allowed to be relative to the current directory."
15 echo "It will be copied to rpmbuild/SOURCES, and the entire tar tree"
16 echo "will be extracted into <builddir>/binarybuild,"
17 echo "in order to fetch the spec file."
19 echo "spec_target is the filename of the tarball spec file to use"
20 echo "when building. For example, in most cases it will be"
21 echo "rpm/barry.spec. This file will be copied into rpmbuild/SPECS"
22 echo "as 'barry.spec' and will be used to build the binary packages."
24 echo "rpm_args is the full command line to build the package."
26 echo "<results_dir>/results/ is where the resulting RPM and SRC RPM"
27 echo "packages will be copied."
34 SPACBASE
=`basename "$SPECPATH"`
37 if [ -d "$RPMPATH/rpmbuild/SPECS" ] ; then
40 BUILDPATH
="$RPMPATH/binarybuild"
46 # Note that all commands below are done from the current directory.
47 # Where the directory must change, it is done within brackets so that
48 # we return to the current directory immediately afterward.
50 # This is so that all paths and directories given on the command line
51 # may be relative, and everything still works.
59 rm -f "$RPMPATH"/RPMS
/i386
/* "$RPMPATH"/SRPMS
/*
62 tar -C "$BUILDPATH" -xjvf "$TARBALL"
64 # setup RPM build tree
65 cp "$TARBALL" "$RPMPATH/SOURCES"
66 cp "$BUILDPATH"/barry-
*/"$SPECPATH" "$RPMPATH/SPECS/barry.spec"
68 # build binary packages
69 (cd "$RPMPATH"/SPECS
&& $RPMTARGETS)
71 # move results to destination directory
72 mv $
(find "$RPMPATH" -type f
-name "*barry*.rpm" -print) "$DESTPATH"