Changeset 744


Ignore:
Timestamp:
May 26, 2009, 3:49:35 PM (15 years ago)
Author:
joergs
Message:

use svn_build_prepare.sh

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dassbuild/build.sh

    r735 r744  
    4545BUILDSCRIPT=/usr/local/bin/buildscript
    4646BUILD_CMD=/usr/bin/build
     47
     48#
     49# setting build variables
     50#
    4751BUILDUSER=$USER
     52[ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
     53BUILDTEMP=$DEST_DIR/buildsrc/
    4854
     55[ -z "$BUILD_USES_SVN" ] && BUILD_USES_SVN="yes"
    4956[ -z "$BUILD_MODE" ] && BUILD_MODE="--clean"
    50 [ -z "$BUILD_DIST" ] && BUILD_DIST="sles9-i386"
    51 [ -z "$BUILD_ROOT" ] && BUILD_ROOT="/var/tmp/buildsystem.$USER.$BUILD_DIST"
     57[ -z "$BUILD_DIST" ] && export BUILD_DIST="sles9-i386"
     58[ -z "$BUILD_ROOT" ] && BUILD_ROOT="/var/tmp/buildsystem.$BUILDUSER.$BUILD_DIST"
    5259[ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no"
    5360
    54 [ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"
    55 BUILDTEMP=$DEST_DIR/buildsrc/
    5661BUILDVARS=$BUILDTEMP/build.vars
    5762
    58 [ -z "$BUILD_USES_SVN" ] && BUILD_USES_SVN="yes"
     63#
     64# create source archive file
     65#
     66svn_build_prepare.sh $*
     67RT=$?
     68if [ $RT -eq 1 ]; then
     69    echo "nothing more to do"
     70    exit 0
     71elif [ $RT -gt 1 ]; then
     72    echo "error: failed to prepare sources"
     73    exit 1
     74fi
    5975
    6076
     
    8298
    8399if [ -z "$1" ]; then
    84         # without parameter, we are in source directory
    85         SPECFILE=$(ls *.spec | awk '{print $1}')
    86         PACKAGE=$(sed -n -e 's/^Name:\W*//pi' <$SPECFILE)
    87         VERSION=$(sed -n -e 's/^Version:\W*//pi' <$SPECFILE)
     100    # without parameter, we are in source directory
     101    SPECFILE=$(ls *.spec | awk '{print $1}')
     102    PACKAGE=$(sed -n -e 's/^Name:\W*//pi' <$SPECFILE)
     103    # use Version from BUILDSRC,
     104    # because it has been modified by svn_build_prepare
     105    BUILDSRC_DIR=${BUILDTEMP}/src/${PACKAGE}
     106    VERSION=$(sed -n -e 's/^Version:\W*//pi' <$BUILDSRC_DIR/$SPECFILE)
    88107elif [ -r "$1" ]; then
    89         # parameter is src.rpm file
    90         PACKAGE=`rpm -qp --qf "%{NAME}" $1`
    91         VERSION=`rpm -qp --qf "%{VERSION}" $1`
     108    # parameter is src.rpm file
     109    PACKAGE=`rpm -qp --qf "%{NAME}" $1`
     110    VERSION=`rpm -qp --qf "%{VERSION}" $1`
    92111fi
    93112
     
    100119
    101120
    102 
    103 rm -rf ${BUILDTEMP}/src/${PACKAGE}
    104 mkdir -p ${BUILDTEMP}/src/${PACKAGE}
    105 
    106 
    107 if [ "$1" ]; then
    108         EXPECTED_DEST_RPM_FILENAME=${DEST_DIR}/${BUILD_DIST}/`echo $1 | sed 's/\.src\./.*./'`
    109         if [ -f $EXPECTED_DEST_RPM_FILENAME ]; then
    110                 echo
    111                 echo "Build of \"${PACKAGE}\" unnecessary. Current RPM already at " $EXPECTED_DEST_RPM_FILENAME
    112                 echo
    113                 exit 1
    114         else
    115                 cp -a "$1" ${BUILDTEMP}/src/${PACKAGE}
    116                 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i
    117         fi
    118 else
    119         cp -a $SPECFILE ${BUILDTEMP}/src/${PACKAGE}
    120        
    121         # uses Subversion (svn) to generate more information for the RPM
    122         if [ "$BUILD_USES_SVN" = "yes" ]; then
    123                 echo "receiving subversion information ..."
    124                 # set RELEASE number (last modification in this directory)
    125                 # requires subversion (but connection to server isn't neccessary)
    126                 SVN_BUILD_RELEASE=$(unset LANG; svn info . | sed -n 's/^Last Changed Rev: \([0-9]*\)/\1/p')
    127                 # in case of local modification a "m" is added to the release number
    128                 SVN_BUILD_MODIFIED=$(svn status -v | grep "^ *M" | wc -l)
    129                 # checks if a file is commited,
    130                 # but update on its directory is not performed
    131                 SVN_LAST_MODIFICATION=$(svn status -v | sed -n 's/^ *[0-9]* *\([0-9]*\) .*/\1/p' | sort -n | tail -1)
    132                 if [ $SVN_BUILD_MODIFIED -gt 0 ]; then 
    133                         SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}m
    134                 elif [ $SVN_LAST_MODIFICATION -ne $SVN_BUILD_RELEASE ]; then
    135                         SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}p
    136                 else # check if RPM has been build already
    137                         EXPECTED_DEST_RPM_FILENAME=${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-${VERSION}-${SVN_BUILD_RELEASE}.*.rpm
    138                         if [ -f $EXPECTED_DEST_RPM_FILENAME ]; then
    139                                 echo
    140                                 echo "Build of \"${PACKAGE}\" unnecessary. Current RPM already at " $EXPECTED_DEST_RPM_FILENAME
    141                                 echo
    142                                 exit 1
    143                         fi                     
    144                 fi
    145                 if [ "$SVN_BUILD_RELEASE" ]; then
    146                         sed "s/^Release:.*/Release: $SVN_BUILD_RELEASE/ig" $SPECFILE > ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE
    147                 fi
    148                 echo "SVN_BUILD_RELEASE: $SVN_BUILD_RELEASE"
    149                
    150                 # changelog header
    151                 DATE=`unset LANG; date +"%a %b %d %Y"`
    152                 echo -e "* $DATE -\n" > Changes
    153                 echo "- Subversion status:" >> Changes
    154                 # additional infos for the Changes file (see if everything is checked in)
    155                 svn status -v | grep -v '^? ' >> Changes
    156                 echo >> Changes
    157                 echo "- ChangeLog:" >> Changes
    158                 # requires connection to the subversion server
    159                 svn log -v . > ChangeLog.new && mv ChangeLog.new ChangeLog
    160                 cat ChangeLog >> Changes
    161                
    162                 # if there is no changelog section in the spec file,
    163                 # also append the Changes there
    164                 if ! grep -q -i "%changelog" $SPECFILE ; then
    165                         # paste "Changes" into SPEC file.
    166                         echo "%changelog" >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE
    167                         # without trailing *, except for the initial
    168                         echo -n "*" >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE
    169                         cat Changes | sed 's/\(^[\*]\+\)//g' >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE
    170                 fi
    171         fi
    172         # just make sure, that the Changes file exist
    173         touch Changes
    174        
    175         # if "SOURCES" file exist, create tar file on the fly
    176         if [ -r "SOURCES" ]; then
    177                 # create a tar file from the sources
    178                 tar cvjf ${BUILDTEMP}/src/${PACKAGE}/$PACKAGE-$VERSION.tar.bz2 --files-from SOURCES --exclude .svn --exclude "*~"
    179        
    180         elif [ -r "SPECSOURCES" ]; then
    181                 # SPECSOURCES has to list the files
    182                 # that are referenced in the .spec file
    183                 # these files are copied to the build environment
    184                 cp -av `cat SPECSOURCES` ${BUILDTEMP}/src/${PACKAGE}
    185        
    186         else
    187                 # legacy method:
    188                 # call the existing Makefile
    189                 # to generate a tar file       
    190                 test -e Makefile && make
    191                 TARFILE=$(ls  *.tar.[gb]z*| awk '{print $1}')
    192                 cp -av $TARFILE ${BUILDTEMP}/src/${PACKAGE}
    193         fi
    194 fi
    195121
    196122# create file for buildvars (see $BUILDSCRIPT)
     
    220146        fi
    221147done
    222 #rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm
    223148
    224149if !(cp -a ${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src 2> /dev/null); then
     
    233158        fi
    234159done
    235 #rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm
    236160
    237161if !(cp -a ${BUILD_ROOT}/usr/src/packages/RPMS/*/${PACKAGE}*${VERSION}-*.*.rpm ${DEST_DIR}/${BUILD_DIST} ); then
Note: See TracChangeset for help on using the changeset viewer.