summaryrefslogtreecommitdiff
path: root/rpm
diff options
context:
space:
mode:
authorfields_t <oth3r1if3@users.noreply.github.com>2011-11-30 23:12:56 +0000
committerfields_t <oth3r1if3@users.noreply.github.com>2011-11-30 23:12:56 +0000
commit483cc9caf2d4c6a974bc53570e4b6dd4952cdf0f (patch)
treebf04156f755189c60a56ba23734b3149de0966a8 /rpm
parent730a1dcee26f5ae441107fdd9a8d00f9e7b3af5d (diff)
downloadMPC-483cc9caf2d4c6a974bc53570e4b6dd4952cdf0f.tar.gz
Wed Nov 30 21:33:46 UTC 2011 Trevor Fields <fields_t@ociweb.com>
* rpm/buildrpm.sh: Fixes to correctly gather packager information. Changes so rpm can be built by non root user.
Diffstat (limited to 'rpm')
-rwxr-xr-xrpm/buildrpm.sh40
1 files changed, 33 insertions, 7 deletions
diff --git a/rpm/buildrpm.sh b/rpm/buildrpm.sh
index 90039ed9..01fe6fca 100755
--- a/rpm/buildrpm.sh
+++ b/rpm/buildrpm.sh
@@ -31,7 +31,7 @@ while [ ! -x $loc/mpc.pl ]; do
done
## Build up the packager name and email address
-if [ -z "REPLYTO" ]; then
+if [ -z "$REPLYTO" ]; then
DOMAIN=`hostname | sed 's/[^\.][^\.]*\.//'`
if [ -z "$DOMAIN" ]; then
DOMAIN=`grep '^search' /etc/resolv.conf | sed 's/.* //'`
@@ -64,15 +64,36 @@ BDIR=/tmp/mpc
## of MPC.spec
FDIR=/usr/lib/MPC
+##Check if build and work diretory already exist
+if [ -d "$BDIR" -o -f "$BDIR" ]; then
+ echo "Necessary directory $BDIR aleady exists."
+ echo "Exiting."
+ exit
+fi
+
+if [ -d "$WDIR" -o -f "$WDIR" ]; then
+ echo "Necessary directory $WDIR aleady exists."
+ echo "Exiting."
+ exit
+fi
+
+## Create our working directory
+mkdir -p $WDIR
+
## The directory where RPM will place the resulting file
-if [ -x /usr/src/redhat ]; then
+if [ -x /usr/src/redhat -a -w /usr/src/redhat ]; then
RPMLOC=/usr/src/redhat
-else
+elif [ -x /usr/src/packages -a -w /usr/src/packages ]; then
RPMLOC=/usr/src/packages
+else
+ RPMLOC=$WDIR/rpmbuild
+ mkdir -p $RPMLOC
+ mkdir -p $RPMLOC/BUILD
+ mkdir -p $RPMLOC/RPMS
+ mkdir -p $RPMLOC/SOURCES
fi
-## Create our working directory and make the spec file
-mkdir -p $WDIR
+## Make the spec file
cd $WDIR
sed "s/VERSION/$VERSION/; s/PACKAGER/$PACKAGER/; s!FINALDIR!$FDIR!" $loc/rpm/MPC.templ > MPC.spec
@@ -83,13 +104,18 @@ tar --exclude=.svn -cf - . | (cd $WDIR/$MDIR/$FDIR; tar -xf -)
## Create the build source tar.bz2
cd $WDIR
-tar cf $RPMLOC/SOURCES/$MDIR.tar $MDIR
+tar --owner root --group root -cf $RPMLOC/SOURCES/$MDIR.tar $MDIR
bzip2 -9f $RPMLOC/SOURCES/$MDIR.tar
## Perform the RPM creation step
rm -rf $BDIR
mkdir -p $BDIR
-rpmbuild -bb MPC.spec
+rpmbuild --define "_topdir $RPMLOC" -bb MPC.spec
+
+if [ "$RPMLOC" = "$WDIR/rpmbuild" ]; then
+ echo "Copying rpm to $loc/rpm"
+ cp $RPMLOC/RPMS/*/*.rpm $loc/rpm
+fi
## Clean everything up
cd ..