File: makefpcsrcsnapshot.sh

package info (click to toggle)
lazarus 2.0.10%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 219,188 kB
  • sloc: pascal: 1,867,962; xml: 265,716; cpp: 56,595; sh: 3,005; java: 609; makefile: 568; perl: 297; sql: 222; ansic: 137
file content (117 lines) | stat: -rwxr-xr-x 3,171 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/env bash
#
# Usage:
#  ./makefpcsrcsnapshot.sh <FPCSrcDir>
#
# FPCSrcDir/fpcsrc  (http://svn.freepascal.org/svn/fpc/tags/release_2_6_4)
# FPCSrcDir/install (http://svn.freepascal.org/svn/fpcbuild/trunk/install)


set -e
set -x

HDIUTIL=/usr/bin/hdiutil
UPDATELIST=~/tmp/updatelist

FPCSVNDIR=$1
if [ ! -d "$FPCSVNDIR" ]; then
  echo "Usage: ./makefpcsrcsnapshot.sh <FPCSrcDir>"
  exit 1
fi
if [ ! -d "$FPCSVNDIR/fpcsrc" ]; then
  echo "invalid fpc source directory $FPCSVNDIR/fpcsrc"
  exit 1
fi
if [ ! -f "$FPCSVNDIR/install/macosx/resources/ReadMe.txt" ]; then
  echo "invalid fpc source directory $FPCSVNDIR/install/macosx/resources/ReadMe.txt"
  exit 1
fi

PPCARCH=ppcppc
ARCH=`uname -p`
if [ "$ARCH" = "i386" ]; then
  PPCARCH=ppc386
fi

SVN=`which svn`
if [ ! -e "$SVN" ]; then
  SVN=/usr/local/bin/svn
fi

if [ ! -e "$SVN" ]; then
  SVN=/sw/bin/svn
fi

if [ ! -e "$SVN" ]; then
  echo "Cannot find a svn executable"
fi

FREEZE=/usr/local/bin/freeze
if [ ! -e "$FREEZE" ]; then
  FREEZE=/usr/bin/freeze
fi
if [ ! -e "$FREEZE" ]; then
  echo "Cannot find freeze"
fi

TEMPLATEDIR=`dirname $0`

FPCSOURCEDIR=$FPCSVNDIR/fpcsrc
INSTALLDIR=~/tmp/fpcsrc

DATESTAMP=`date +%Y%m%d`
PACKPROJ=fpcsrc.packproj.template

# get FPC source version
echo -n "getting FPC version from local svn ..."
VersionFile="$FPCSOURCEDIR/compiler/version.pas"
CompilerVersion=$(cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g')
CompilerRelease=$(cat $VersionFile | grep ' *release_nr *=.*;' | sed -e 's/[^0-9]//g')
CompilerPatch=$(cat $VersionFile | grep ' *patch_nr *=.*;' | sed -e 's/[^0-9]//g')
CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch"
FPCVERSION="$CompilerVersion.$CompilerRelease.$CompilerPatch"
echo " $CompilerVersionStr"

FPCFULLVERSION=$FPCVERSION
OLDIFS=$IFS
IFS=.
FPCMAJORVERSION=`set $FPCVERSION;  echo $1`
FPCMINORVERSION=`set $FPCVERSION;  echo $2$3`
IFS=$OLDIFS

# clean installdir: since I am not root and the install dir can contain files owned by root 
# created by a previous freeze, I just move it out of the way
TRASHDIR=~/tmp/trash
mkdir -p $TRASHDIR
if [ -d $INSTALLDIR ] ; then
  mv $INSTALLDIR $TRASHDIR/fpcsrc-`date +%Y%m%d%H%M%S`
fi

# copy sources
mkdir -p $INSTALLDIR/fpcsrc
for dir in rtl compiler packages utils; do
  $SVN export $FPCSOURCEDIR/$dir $INSTALLDIR/fpcsrc/$dir
done
if [ -d $FPCSOURCEDIR/fcl ] ; then
  $SVN export $FPCSOURCEDIR/fcl $INSTALLDIR/fpcsrc/fcl
fi

# fill in packproj template.

sed -e "s|_FPCSRCDIR_|$FPCSVNDIR|g" -e "s|_DATESTAMP_|$DATESTAMP|g" \
  -e "s|_FPCVERSION_|$FPCVERSION|g" -e "s|_FPCFULLVERSION_|$FPCFULLVERSION|g" \
  -e s/_FPCMAJORVERSION_/$FPCMAJORVERSION/g -e s/_FPCMINORVERSION_/$FPCMINORVERSION/g \
  $TEMPLATEDIR/$PACKPROJ  > $INSTALLDIR/$PACKPROJ

# build package
$FREEZE -v $INSTALLDIR/$PACKPROJ

DMGFILE=~/pkg/fpcsrc-$FPCFULLVERSION-$DATESTAMP-$PPCARCH-macosx.dmg
rm -rf $DMGFILE

$HDIUTIL create -anyowners -volname fpcsrc-$FPCVERSION -imagekey zlib-level=9 -format UDZO -srcfolder $INSTALLDIR/build $DMGFILE

if [ -e $DMGFILE ]; then
  #todo: update lazarus snapshot web page
  echo "$DMGFILE fpcsrc-$FPCFULLVERSION-*-$PPCARCH-macosx.dmg" >> $UPDATELIST
fi