1#!/bin/bash 2 3#set -x 4set -e 5 6#------------------------------------------------------------------------------ 7# parse parameters 8#------------------------------------------------------------------------------ 9Usage="Usage: $0 [nodocs] [notemp] <FPCSrcDir> [release]" 10 11WithDOCS=yes 12if [ "x$1" = "xnodocs" ]; then 13 WithDOCS=no 14 shift 15fi 16 17WithTempDir=yes 18if [ "x$1" = "xnotemp" ]; then 19 WithTempDir=no 20 shift 21fi 22 23PkgType=rpm 24 25FPCSrcDir=$1 26if [ "x$FPCSrcDir" = "x" ]; then 27 echo $Usage 28 exit -1 29fi 30FPCSrcDir=$(echo $FPCSrcDir) 31shift 32 33FPCRelease=$1 34if [ "x$FPCRelease" = "x" ]; then 35 FPCRelease=$(date +%y%m%d) 36else 37 shift 38fi 39 40if [ ! -d $FPCSrcDir/compiler ]; then 41 echo "The directory $FPCSrcDir does not look like a fpc source directory (missing subdirectory compiler)" 42 exit -1 43fi 44 45# checking for needed tools 46rpmbuild --version 47 48#------------------------------------------------------------------------------ 49# patching 50#------------------------------------------------------------------------------ 51 52# create a temporary copy of the fpc sources to patch it 53TmpDir=~/tmp/fpc_patchdir 54if [ "$WithTempDir" = "yes" ]; then 55 if [ -d $TmpDir ]; then 56 rm -rf $TmpDir 57 fi 58 mkdir -p $TmpDir 59 60 echo "extracting FPC from local svn ..." 61 svn export $FPCSrcDir $TmpDir/fpc 62else 63 TmpDir=$FPCSrcDir 64fi 65 66# retrieve the version information 67echo -n "getting FPC version from local svn ..." 68VersionFile="$TmpDir/fpc/compiler/version.pas" 69CompilerVersion=$(cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g') 70CompilerRelease=$(cat $VersionFile | grep ' *release_nr *=.*;' | sed -e 's/[^0-9]//g') 71CompilerPatch=$(cat $VersionFile | grep ' *patch_nr *=.*;' | sed -e 's/[^0-9]//g') 72CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch" 73FPCVersion="$CompilerVersion.$CompilerRelease.$CompilerPatch" 74echo " $CompilerVersionStr-$FPCRelease" 75 76Arch=$(rpm --eval "%{_arch}") 77 78 79#------------------------------------------------------------------------------ 80# patch sources 81 82SmartStripScript=smart_strip.sh 83ReplaceScript=replace_in_files.pl 84 85 86# set version numbers in all Makefiles 87echo "set version numbers in all Makefiles ..." 88perl replace_in_files.pl -sR -f 'version=\d.\d.\d' -r version=$CompilerVersionStr -m 'Makefile(.fpc)?' $TmpDir/fpc/* 89 90# update smart_strip.sh 91#ATM: not needed: cp $SmartStripScript $TmpDir/fpc/install/ 92 93# build fpc rpm 94 95echo "creating spec file ..." 96SpecFileTemplate=rpm/fpc.spec.template 97SpecFile=rpm/fpc.spec 98 99# change spec file 100cat $SpecFileTemplate | \ 101 sed -e 's/^Version: .*/Version: '"$FPCVersion/" \ 102 -e 's/^Release: .*/Release: '"$FPCRelease/" \ 103 -e 's/^%define fpcversion .*/%define fpcversion '"$FPCVersion/" \ 104 > $SpecFile 105# -e 's/\(%define builddocdir.*\)/%define __strip smart_strip.sh\n\n\1/' \ 106# -e 's/^\%{fpcdir}\/samplecfg .*/%{fpcdir}\/samplecfg %{_libdir}\/fpc\/\\\$version/' \ 107 108SrcTGZ=$(rpm/get_rpm_source_dir.sh)/SOURCES/fpc-$CompilerVersionStr-$FPCRelease.source.tar.gz 109echo "creating $SrcTGZ ..." 110tar czf $SrcTGZ -C $TmpDir fpc 111 112#---------------------------------------------------------------------------- 113# compile 114#---------------------------------------------------------------------------- 115if [ "$WithDOCS" = "no" ]; then 116 export NODOCS=1 117fi 118rpmbuild --nodeps -ba $SpecFile 119 120echo "The new rpm can be found in $(./rpm/get_rpm_source_dir.sh)/RPMS/$Arch/fpc-$FPCVersion-$FPCRelease.$Arch.rpm" 121 122# end. 123 124