- Timestamp:
- May 26, 2009, 3:49:35 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dassbuild/build.sh
r735 r744 45 45 BUILDSCRIPT=/usr/local/bin/buildscript 46 46 BUILD_CMD=/usr/bin/build 47 48 # 49 # setting build variables 50 # 47 51 BUILDUSER=$USER 52 [ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER" 53 BUILDTEMP=$DEST_DIR/buildsrc/ 48 54 55 [ -z "$BUILD_USES_SVN" ] && BUILD_USES_SVN="yes" 49 56 [ -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" 52 59 [ -z "$BUILD_PREPARE_SPEC" ] && BUILD_PREPARE_SPEC="no" 53 60 54 [ -z $DEST_DIR ] && DEST_DIR="/tmp/build.$BUILDUSER"55 BUILDTEMP=$DEST_DIR/buildsrc/56 61 BUILDVARS=$BUILDTEMP/build.vars 57 62 58 [ -z "$BUILD_USES_SVN" ] && BUILD_USES_SVN="yes" 63 # 64 # create source archive file 65 # 66 svn_build_prepare.sh $* 67 RT=$? 68 if [ $RT -eq 1 ]; then 69 echo "nothing more to do" 70 exit 0 71 elif [ $RT -gt 1 ]; then 72 echo "error: failed to prepare sources" 73 exit 1 74 fi 59 75 60 76 … … 82 98 83 99 if [ -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) 88 107 elif [ -r "$1" ]; then 89 90 91 108 # parameter is src.rpm file 109 PACKAGE=`rpm -qp --qf "%{NAME}" $1` 110 VERSION=`rpm -qp --qf "%{VERSION}" $1` 92 111 fi 93 112 … … 100 119 101 120 102 103 rm -rf ${BUILDTEMP}/src/${PACKAGE}104 mkdir -p ${BUILDTEMP}/src/${PACKAGE}105 106 107 if [ "$1" ]; then108 EXPECTED_DEST_RPM_FILENAME=${DEST_DIR}/${BUILD_DIST}/`echo $1 | sed 's/\.src\./.*./'`109 if [ -f $EXPECTED_DEST_RPM_FILENAME ]; then110 echo111 echo "Build of \"${PACKAGE}\" unnecessary. Current RPM already at " $EXPECTED_DEST_RPM_FILENAME112 echo113 exit 1114 else115 cp -a "$1" ${BUILDTEMP}/src/${PACKAGE}116 cd ${BUILDTEMP}/src/${PACKAGE}; rpm2cpio $1 | cpio -i117 fi118 else119 cp -a $SPECFILE ${BUILDTEMP}/src/${PACKAGE}120 121 # uses Subversion (svn) to generate more information for the RPM122 if [ "$BUILD_USES_SVN" = "yes" ]; then123 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 number128 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 performed131 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 ]; then133 SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}m134 elif [ $SVN_LAST_MODIFICATION -ne $SVN_BUILD_RELEASE ]; then135 SVN_BUILD_RELEASE=${SVN_BUILD_RELEASE}p136 else # check if RPM has been build already137 EXPECTED_DEST_RPM_FILENAME=${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-${VERSION}-${SVN_BUILD_RELEASE}.*.rpm138 if [ -f $EXPECTED_DEST_RPM_FILENAME ]; then139 echo140 echo "Build of \"${PACKAGE}\" unnecessary. Current RPM already at " $EXPECTED_DEST_RPM_FILENAME141 echo142 exit 1143 fi144 fi145 if [ "$SVN_BUILD_RELEASE" ]; then146 sed "s/^Release:.*/Release: $SVN_BUILD_RELEASE/ig" $SPECFILE > ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE147 fi148 echo "SVN_BUILD_RELEASE: $SVN_BUILD_RELEASE"149 150 # changelog header151 DATE=`unset LANG; date +"%a %b %d %Y"`152 echo -e "* $DATE -\n" > Changes153 echo "- Subversion status:" >> Changes154 # additional infos for the Changes file (see if everything is checked in)155 svn status -v | grep -v '^? ' >> Changes156 echo >> Changes157 echo "- ChangeLog:" >> Changes158 # requires connection to the subversion server159 svn log -v . > ChangeLog.new && mv ChangeLog.new ChangeLog160 cat ChangeLog >> Changes161 162 # if there is no changelog section in the spec file,163 # also append the Changes there164 if ! grep -q -i "%changelog" $SPECFILE ; then165 # paste "Changes" into SPEC file.166 echo "%changelog" >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE167 # without trailing *, except for the initial168 echo -n "*" >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE169 cat Changes | sed 's/\(^[\*]\+\)//g' >> ${BUILDTEMP}/src/${PACKAGE}/$SPECFILE170 fi171 fi172 # just make sure, that the Changes file exist173 touch Changes174 175 # if "SOURCES" file exist, create tar file on the fly176 if [ -r "SOURCES" ]; then177 # create a tar file from the sources178 tar cvjf ${BUILDTEMP}/src/${PACKAGE}/$PACKAGE-$VERSION.tar.bz2 --files-from SOURCES --exclude .svn --exclude "*~"179 180 elif [ -r "SPECSOURCES" ]; then181 # SPECSOURCES has to list the files182 # that are referenced in the .spec file183 # these files are copied to the build environment184 cp -av `cat SPECSOURCES` ${BUILDTEMP}/src/${PACKAGE}185 186 else187 # legacy method:188 # call the existing Makefile189 # to generate a tar file190 test -e Makefile && make191 TARFILE=$(ls *.tar.[gb]z*| awk '{print $1}')192 cp -av $TARFILE ${BUILDTEMP}/src/${PACKAGE}193 fi194 fi195 121 196 122 # create file for buildvars (see $BUILDSCRIPT) … … 220 146 fi 221 147 done 222 #rm -f ${DEST_DIR}/src/${PACKAGE}-*.src.rpm223 148 224 149 if !(cp -a ${BUILD_ROOT}/usr/src/packages/SRPMS/${PACKAGE}-${VERSION}-*.src.rpm ${DEST_DIR}/src 2> /dev/null); then … … 233 158 fi 234 159 done 235 #rm -f ${DEST_DIR}/${BUILD_DIST}/${PACKAGE}-*.rpm236 160 237 161 if !(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.