1#! /bin/sh
2# script to build curl RPM from src RPM (SSL and non-SSL versions)
3
4# initialize
5top_dir=/usr/src/redhat
6sources_dir=$top_dir/SOURCES
7specs_dir=$top_dir/SPECS
8rpms_dir=$top_dir/RPMS
9arch=`rpm --showrc | awk 'NF == 3 && $2 == "_arch" { print $3 }'`
10
11# fill in your own name and email here
12packager_name="Mr Joe Packager Person"
13packager_email='<Joe@packager.person>'
14
15# make sure we're running as root
16if test `id -u` -ne `id -u root`
17then
18   echo "you must build the RPM as root"
19   exit 1
20fi
21
22# get version and release number
23if test $# -lt 1
24then
25   echo "version number?"
26   read version
27else
28   version=$1
29fi
30
31if test $# -lt 2
32then
33   echo "release number?"
34   read release
35else
36   release=$2
37fi
38
39# build all the files
40targets="curl curl-ssl"
41for target in $targets
42do
43   # make sure src RPM exist
44   src_rpm="$target-$version-$release.src.rpm"
45   if test -f $src_rpm
46   then
47      rpm -ivh $src_rpm
48
49      # replace packager in spec file
50      sed -e 's/^Packager: .*/Packager: $packager_name $packager_email/' $specs_dir/$target.spec > $specs_dir/$target-$version-$arch.spec
51
52      # build it
53      if ! rpm -ba $specs_dir/$target-$version-$arch.spec
54      then
55         echo "error building $target for $arch -- check output above"
56      fi
57
58      echo "$target rpm is now in $rpms_dir/$arch"
59   else
60      echo $src_rpm does not exist
61   fi
62done
63