BUG#: 5022
[tpot/pegasus/.git] / rpmBuild
1 #!/bin/sh
2 if test 'whoami' != 'root'; then
3   echo "You have to be root to build the pegasus rpm"
4   #exit
5 fi
6 #
7 echo "This script executes <make clean> first"
8 read -n 1 -p "Do you want to continue ? (y/n)" retcode
9
10 if test $retcode != "y"; then
11   echo "Okay, you don\'t want to execute make clean now"
12   exit
13 fi
14 echo;
15
16 export PEGASUS_PLATFORM=LINUX_IX86_GNU
17 if test -z $PEGASUS_HOME; then
18   echo "Please make sure that PEGASUS_ROOT points to the current"
19   echo "location of the Pegasus sources"
20   read -n 1 -p "Is current directory the location of Pegasus? (y/n)" retcode
21   if test $retcode != "y"; then
22     echo "Okay, please set the variable first"
23     exit
24   fi
25   export PEGASUS_HOME=`pwd`
26   echo;
27 fi
28 #
29 #
30 export PEGASUS_ROOT=$PEGASUS_HOME
31
32 cd $PEGASUS_HOME
33 if make clean; then
34   echo "Sources are cleaned up"
35 else 
36   echo "Cleanup hasn't been successful"
37   exit 
38 fi
39 #
40 PEGASUS_BASE=`basename $PEGASUS_ROOT`
41 PEGASUS_DIR=`dirname $PEGASUS_ROOT`
42 if test "$PEGASUS_BASE" != "pegasus-1.0"; then
43   echo "I'm going to make sure that pegasus is found in */pegasus-1.0/ "
44   #cp -a $PEGASUS_ROOT $PEGASUS_ROOT/../pegasus-1.0
45   mv $PEGASUS_ROOT $PEGASUS_DIR/pegasus-1.0
46   export PEGASUS_ROOT=$PEGASUS_DIR/pegasus-1.0
47 fi
48 # pack the entire source, but first clean it up
49 #
50 # and copy it into /usr/src/packages/SOURCES
51 #
52 #pushd ..
53 cd $PEGASUS_DIR
54 if tar cfz /usr/src/packages/SOURCES/pegasus-1.0.tar.gz pegasus-1.0 ;then
55   echo "/usr/src/packages/SOURCES/pegasus-1.0.tar.gz created"
56 else
57   echo "Didn't succeed in tarring"
58   mv $PEGASUS_ROOT $PEGASUS_DIR/$PEGASUS_BASE
59   exit
60 fi
61
62 mv $PEGASUS_ROOT $PEGASUS_DIR/$PEGASUS_BASE
63 cd $PEGASUS_BASE
64 #popd
65 export PEGASUS_ROOT=$PEGASUS_DIR/$PEGASUS_BASE
66 #
67 #
68 #
69 chmod +x rpm/pegasus
70 if cp $PEGASUS_ROOT/rpm/pegasus-1.0.spec /usr/src/packages/SPECS/; then
71   echo "Copied spec file"
72 else
73   echo "Spec file missing ???"
74   exit
75 fi
76 #
77 #
78 #chmod +x rpm/buildincludes
79 #if cp $PEGASUS_ROOT/rpm/buildincludes /var/tmp; then
80 #  echo "Copied buildincludes script"
81 #else
82 #  echo "buildincludes script missing ???"
83 #  exit
84 #fi
85 #
86 #
87 echo "Start building ...."
88
89 if rpm -ba /usr/src/packages/SPECS/pegasus-1.0.spec; then
90   echo "Package built as /usr/src/packages/RPMS/pegasus-1.0.rpm"
91 else
92   echo "Build error !"
93 fi
94 echo "Finished"
95
96