3 # ******************************************************************
6 # Description: Create an MPC rpm based on the current version number.
7 # ******************************************************************
9 ## First find out where this script is located
10 if [ "$0" != "`basename $0`" ]; then
11 if [ "`echo $0 | cut -c1`" = "/" ]; then
14 loc
="`pwd`/`dirname $0`"
17 ## Do my own 'which' here
19 for i
in `echo $PATH | tr ':' '\012'`; do
20 if [ -x "$i/$0" -a ! -d "$i/$0" ]; then
27 ## Now, get back to where the main MPC script is located
28 while [ ! -x $loc/mpc.pl
]; do
32 ## Build up the packager name and email address
33 if [ -z "$REPLYTO" ]; then
34 DOMAIN
=`hostname | sed 's/[^\.][^\.]*\.//'`
35 FULLDOMAIN
=`echo $DOMAIN | grep '\.'`
36 if [ -z "$DOMAIN" -o -z "$FULLDOMAIN" ]; then
37 RESOLVDOMAIN
=`grep '^search' /etc/resolv.conf | sed 's/.*\s//'`
38 FULLDOMAIN
=`echo $RESOLVDOMAIN | grep '\.'`
39 if [ -z "$DOMAIN" -o -n "$FULLDOMAIN" ]; then
43 REPLYTO
="$LOGNAME@$DOMAIN"
45 PACKAGER
=`getent passwd $LOGNAME | cut -d: -f5`
46 if [ -z "$PACKAGER" ]; then
49 if [ -z "$PACKAGER" ]; then
52 PACKAGER
="$PACKAGER <$REPLYTO>"
55 ## Save the MPC version
56 VERSION
=`$loc/mpc.pl --version | sed 's/.*v//'`
58 ## This is where we'll create the spec file and do the work
61 ## This is the directory name that RPM expects
64 ## This corresponds to BuildRoot in MPC.spec
67 ## This is the final install directory and corresponds to the %files section
71 ##Check if build and work directory already exist
72 if [ -d "$BDIR" -o -f "$BDIR" ]; then
73 echo "Necessary directory $BDIR already exists."
78 if [ -d "$WDIR" -o -f "$WDIR" ]; then
79 echo "Necessary directory $WDIR already exists."
84 ## Create our working directory
87 ## The directory where RPM will place the resulting file
88 if [ -x /usr
/src
/redhat
-a -w /usr
/src
/redhat
]; then
89 RPMLOC
=/usr
/src
/redhat
90 elif [ -x /usr
/src
/packages
-a -w /usr
/src
/packages
]; then
91 RPMLOC
=/usr
/src
/packages
95 mkdir
-p $RPMLOC/BUILD
97 mkdir
-p $RPMLOC/SOURCES
100 ## Make the spec file
102 sed "s/VERSION/$VERSION/; s/PACKAGER/$PACKAGER/; s!FINALDIR!$FDIR!" $loc/rpm
/MPC.templ
> MPC.spec
104 ## Make a copy of the original MPC source to the new directory
107 tar --exclude=.git\
* -cf - . |
(cd $WDIR/$MDIR/$FDIR; tar -xf -)
109 ## Create the build source tar.bz2
111 tar --owner root
--group root
-cf $RPMLOC/SOURCES
/$MDIR.
tar $MDIR
112 bzip2 -9f $RPMLOC/SOURCES
/$MDIR.
tar
114 ## Perform the RPM creation step
117 rpmbuild
--define "_topdir $RPMLOC" --define "_buildrootdir $BDIR" --define "buildroot $BDIR" --define "__arch_install_post %{nil}" -bb MPC.spec
119 if [ "$RPMLOC" = "$WDIR/rpmbuild" ]; then
120 echo "Copying rpm to $loc/rpm"
121 cp $RPMLOC/RPMS
/*/*.rpm
$loc/rpm
124 ## Clean everything up