build-spec-cps 3.57 KB
Newer Older
Sebastien Robin's avatar
Sebastien Robin committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/bin/bash

PARAMS=1

# Where we can find the RPM directory
# and where we want to store the source code from cvs
CVS_PATH=/home/$USER/cvs
RPM_PATH=/home/$USER/rpm
PRODUCT_PATH=%{_libdir}/zope/lib/python/Products/
FULL_RPM_BUILD_ROOT=\$RPM_BUILD_ROOT$PRODUCT_PATH

if [ $# -lt "$PARAMS" ] || [ $# -gt "$PARAMS" ]
then
  echo
  echo "Give me exactly $PARAMS command-line arguments!"
  echo "build-rpm PACKAGE_NAME"
  exit 0
fi  

if [ -n "$1" ]
then
  echo Starting Building $1
  NAME=$1
Sebastien Robin's avatar
Sebastien Robin committed
24
  VERSION=3.0rc3
Sebastien Robin's avatar
Sebastien Robin committed
25 26 27 28 29 30 31 32 33
  rm -rf $CVS_PATH/$NAME-$VERSION/BTreeFolder2
  rm -rf $CVS_PATH/$NAME-$VERSION/CMFCalendar
  rm -rf $CVS_PATH/$NAME-$VERSION/CMFTopic
  rm -rf $CVS_PATH/$NAME-$VERSION/CMFCore
  rm -rf $CVS_PATH/$NAME-$VERSION/CMFDefault
  rm -rf $CVS_PATH/$NAME-$VERSION/DCWorkflow
  rm -rf $CVS_PATH/$NAME-$VERSION/Localizer
  rm -rf $CVS_PATH/$NAME-$VERSION/TranslationService

Sebastien Robin's avatar
Sebastien Robin committed
34 35 36 37
  cd $CVS_PATH && tar jcvf $NAME-$VERSION.tar.bz2 $NAME-$VERSION && cd -
    cp $CVS_PATH/$NAME-$VERSION.tar.bz2 $RPM_PATH/SOURCES/

  # Remove theses text files in order to hack a small error
Sebastien Robin's avatar
Sebastien Robin committed
38 39 40 41
  mv -f $CVS_PATH/$NAME-$VERSION/Introduction.stx /tmp
  #mv -f $CVS_PATH/$NAME-$VERSION/COPYRIGHT.txt /tmp
  #mv -f $CVS_PATH/$NAME-$VERSION/INSTALL.txt /tmp
  #mv -f $CVS_PATH/$NAME-$VERSION/UPGRADE.txt /tmp
Sebastien Robin's avatar
Sebastien Robin committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

  # We will generate one part of the spec file, so we make sure
  # to not forget any file
  # Generate the folder tree
  rm -f /tmp/build-rpm-install.tmp
  rm -f /tmp/build-rpm-files.tmp
  rm -f /tmp/build-rpm-spec.tmp

  for directory in "" `cd $CVS_PATH/$NAME-$VERSION && find * -type d -not -name "CVS" && cd -`
    do echo install -d $FULL_RPM_BUILD_ROOT/$directory | sed -e "s/\/\//\//g" >> /tmp/build-rpm-install.tmp
      # then add files we want to include into the rpm
      for file_type in py dtml txt png pt stx form zsql gif jpg css html props
        do if (ls $CVS_PATH/$NAME-$VERSION/$directory/*.$file_type > /dev/null 2>&1)
          then echo install %{name}-%{version}/$directory/*.$file_type $FULL_RPM_BUILD_ROOT/$directory | sed -e "s/\/\//\//g" >> /tmp/build-rpm-install.tmp
        fi
      done

      done

Sebastien Robin's avatar
Sebastien Robin committed
61 62 63 64
  cp /tmp/Introduction.stx /$CVS_PATH/$NAME-$VERSION/
  #cp /tmp/COPYRIGHT.txt /$CVS_PATH/$NAME-$VERSION/
  #cp /tmp/INSTALL.txt /$CVS_PATH/$NAME-$VERSION/
  #cp /tmp/UPGRADE.txt /$CVS_PATH/$NAME-$VERSION/
Sebastien Robin's avatar
Sebastien Robin committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

  for directory in `cd $CVS_PATH/$NAME-$VERSION && find * -type d -maxdepth 0 && cd -`
    do echo $PRODUCT_PATH$directory/ >> /tmp/build-rpm-files.tmp
    done
    

  # now we will regenerate the spec file
  # The line where we have %install
  L_INSTALL=`grep -n "%install" $NAME.spec| sed -e "s/:/ /g" |awk '{print $1}'`
  # The line where we have %clean
  L_CLEAN=`grep -n "%clean" $NAME.spec| sed -e "s/:/ /g" |awk '{print $1}'`
  # The line where we have %doc
  L_DOC=`grep -n "%doc" $NAME.spec| sed -e "s/:/ /g" |awk '{print $1}'`
  # The line where we have %changelog
  L_CHANGELOG=`grep -n "%changelog" $NAME.spec| sed -e "s/:/ /g" |awk '{print $1}'`
  # The total number of lines 
  L_TOTAL=`wc -l $NAME.spec | awk '{print $1}'`
  # Take the head of the file
  head -n $L_INSTALL $NAME.spec > /tmp/build-rpm-spec.tmp
  cat /tmp/build-rpm-install.tmp >> /tmp/build-rpm-spec.tmp
  head -n $L_DOC $NAME.spec | tail -n `expr $L_DOC - $L_CLEAN + 1` >> /tmp/build-rpm-spec.tmp
  cat /tmp/build-rpm-files.tmp >> /tmp/build-rpm-spec.tmp
  echo "#----------------------------------------------------------------------" >> /tmp/build-rpm-spec.tmp
  tail -n `expr $L_TOTAL - $L_CHANGELOG + 1` $NAME.spec >> /tmp/build-rpm-spec.tmp

  # now we can replace the spec file
  cp -f /tmp/build-rpm-spec.tmp $RPM_PATH/SPECS/$NAME.spec


fi

exit 0