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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
|
#!/usr/bin/env bash
#
# Author: Mattias Gaertner
#
# Usage: ./create_lazarus_deb.sh [gtk1] [append-revision] [chmhelp]
#
# Options:
# gtk1 compile IDE and programs for gtk1.
# qt compile IDE and programs for qt.
# qt5 compile IDE and programs for qt5.
# append-revision append the svn revision to the .deb version
# chmhelp add package chmhelp and add chm,kwd files in docs/chm
# pas2jszip <pas2js-linux-version.zip>
# unzip pas2js release zip to "pas2js/version"
set -e
LCLWidgetset=
LazVersionPostfix=
UseCHMHelp=
Pas2jsZip=
LazRelease='0'
while [ $# -gt 0 ]; do
echo "param=$1"
case "$1" in
gtk1)
echo "Compile for gtk1"
if [ -n "$LCLWidgetset" ]; then
echo "widgetset already set to $LCLWidgetset"
exit -1
fi
LCLWidgetset=gtk
LazVersionPostfix=${LazVersionPostfix}-gtk
;;
qt)
echo "Compile for qt"
if [ -n "$LCLWidgetset" ]; then
echo "widgetset already set to $LCLWidgetset"
exit -1
fi
LCLWidgetset=qt
LazVersionPostfix=${LazVersionPostfix}-qt
;;
qt5)
echo "Compile for qt5"
if [ -n "$LCLWidgetset" ]; then
echo "widgetset already set to $LCLWidgetset"
exit -1
fi
LCLWidgetset=qt5
LazVersionPostfix=${LazVersionPostfix}-qt5
;;
append-revision)
LazRevision=$(./get_svn_revision_number.sh .)
if [ -n "$LazRevision" ]; then
LazVersionPostfix=$LazVersionPostfix.$LazRevision
fi
echo "Appending svn revision $LazVersionPostfix to deb name"
;;
chmhelp)
echo "using package chmhelp"
UseCHMHelp=1
;;
pas2jszip)
shift
echo "param=$1"
Pas2jsZip=$1
Pattern="*pas2js*.zip"
if [[ $Pas2jsZip == $Pattern ]]; then
echo "using pas2js zip file $Pas2jsZip"
else
echo "invalid pas2js zip file $Pas2jsZip"
exit -1
fi
if [ ! -f $Pas2jsZip ]; then
echo "missing pas2js zip file $Pas2jsZip"
exit -1
fi
;;
*)
echo "invalid parameter $1"
echo "Usage: ./create_lazarus_deb.sh [chmhelp] [gtk1] [qt] [qt5] [qtlib=<dir>] [release=YourPostfix] "
exit 1
;;
esac
shift
done
# get date
Date=`date +%Y%m%d`
ChangeLogDate=`date --rfc-822`
# get FPC version
Arch=`dpkg --print-architecture`
echo "debian architecture=$Arch"
targetos=$Arch
case "$Arch" in
i386) ppcbin=ppc386;;
amd64) ppcbin=ppcx64; targetos=x86_64;;
powerpc) ppcbin=ppcppc;;
sparc) ppcbin=ppcsparc;;
arm) ppcbin=ppcarm;;
arm64) ppcbin=ppca64;;
*) echo "$Arch is not supported."
exit -1;;
esac
FPCVersion=$($ppcbin -v | grep version| sed 's/.*\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/')
# get Lazarus version
LazVersion=$(./get_lazarus_version.sh | sed -e 's/RC[0-9]/.0/')
# get consistent major.minor.release version, to avoid dpkg install an older version
if [ $(echo $LazVersion | egrep '^[^.]*\.[^.]*$') ]; then
LazVersion=${LazVersion}.0
fi
LazVersion=$LazVersion$LazVersionPostfix
PkgName=lazarus-project
SrcTGZ=$PkgName-$LazVersion-$LazRelease.tar.gz
CurDir=`pwd`
TmpDir=~/tmp/$PkgName$LazVersion
LazBuildDir=$TmpDir/${PkgName}_build
LazDeb=$CurDir/${PkgName}_${LazVersion}-${LazRelease}_$Arch.deb
DebianSrcDir=$CurDir/debian_lazarus
EtcSrcDir=$CurDir/linux
LazSrcDir=../..
LazDestDir=$LazBuildDir/usr/share/lazarus/${LazVersion}
LazDestDirInstalled=/usr/share/lazarus/${LazVersion}
Pas2jsVer=
EnvOpts=$EtcSrcDir/environmentoptions-$Arch.xml
if [ ! -f $EnvOpts ]; then
EnvOpts=$EtcSrcDir/environmentoptions.xml
fi
echo "ppcbin=$ppcbin"
echo "LazVersion=$LazVersion"
echo "FPCVersion=$FPCVersion"
echo "ChangeLogDate=$ChangeLogDate"
# export lazarus git
./create_lazarus_export_tgz.sh $SrcTGZ
echo "Build directory is $LazBuildDir"
if [ x$LazBuildDir = x/ ]; then
echo "ERROR: invalid build directory"
exit
fi
rm -rf $LazBuildDir
# Unpack lazarus source
echo "unpacking $SrcTGZ ..."
ls -l $SrcTGZ
mkdir -p $LazDestDir
cd $LazDestDir
tar xzf $CurDir/$SrcTGZ --strip 1
cd -
if [ "$UseCHMHelp" = "1" ]; then
echo
echo "Copying chm files"
mkdir -p $LazDestDir/docs/chm
cd $LazSrcDir/docs/chm
cp -v *.kwd *.chm $LazDestDir/docs/chm/
cd -
fi
if [ ! "x$Pas2jsZip" = "x" ]; then
# unzip pas2jszip to pas2js/version
mkdir $LazDestDir/pas2js # fails if already there -> good
unzip $Pas2jsZip -d $LazDestDir/pas2js
Pas2jsBin="$LazDestDir/pas2js/*pas2js*/bin/pas2js"
if [ ! -f $Pas2jsBin ]; then
echo "missing $Pas2jsZip/*pas2js*/bin/pas2js"
exit 1
fi
Pas2jsVer=$($Pas2jsBin -iV | tr -d '\n')
mv $LazDestDir/pas2js/*pas2js* $LazDestDir/pas2js/$Pas2jsVer
fi
rm -rf $LazDestDir/debian
rm -rf $LazDestDir/components/aggpas/gpc
rm -rf $LazDestDir/components/mpaslex
rm -rf $LazDestDir/lcl/interfaces/carbon
find $LazDestDir -name .gitignore -delete
find $LazDestDir -name .gitattributes -delete
# compile
echo
echo "Compiling may take a while ... =========================================="
cd $LazDestDir
MAKEOPTS="-Fl/opt/gnome/lib"
if [ -n "$FPCCfg" ]; then
MAKEOPTS="$MAKEOPTS -n @$FPCCfg"
fi
echo "MAKEOPTS=$MAKEOPTS"
# build
export LCL_PLATFORM=$LCLWidgetset
make bigide PP=$ppcbin OPT="$MAKEOPTS"
# create directories for building alternative widgetsets
mkdir -p units/${targetos}-linux/qt
export LCL_PLATFORM=
find . -name '*.or' -delete
strip lazarus
strip startlazarus
strip lazbuild
strip tools/lazres
strip tools/updatepofiles
strip tools/lrstolfm
# Note: svn2revisioninc supports git too
strip tools/svn2revisioninc
if [ -f components/chmhelp/lhelp/lhelp ]; then
strip components/chmhelp/lhelp/lhelp
fi
cd -
# get installed size in kb
LazSize=$(du -s $LazDestDir | cut -f1)
# create control file
echo "========================================================================="
echo "copying control file"
mkdir -p $LazBuildDir/DEBIAN
cat $DebianSrcDir/control$LCLWidgetset | \
sed -e "s/FPCVERSION/$FPCVersion/g" \
-e "s/LAZVERSION/$LazVersion/g" \
-e "s/ARCH/$Arch/g" \
-e "s/LAZSIZE/$LazSize/g" \
-e "s/PKGNAME/$PkgName/g" \
> $LazBuildDir/DEBIAN/control
cp $DebianSrcDir/conffiles $LazBuildDir/DEBIAN/
# copyright and changelog files
echo "copying copyright and changelog files"
LazBuildDocDir=$LazBuildDir/usr/share/doc/$PkgName
mkdir -p $LazBuildDocDir
cp $DebianSrcDir/copyright $LazBuildDocDir/
cat $LazSrcDir/tools/install/debian_lazarus/changelog.Debian | sed -e "s/^lazarus (/$PkgName (/" > $LazBuildDocDir/changelog
cp $LazBuildDocDir/changelog $LazBuildDocDir/changelog.Debian
gzip -n --best $LazBuildDocDir/changelog
gzip -n --best $LazBuildDocDir/changelog.Debian
mkdir -p $LazBuildDir/usr/share/lintian/overrides
cat $DebianSrcDir/lintian.overrides | sed -e "s/^lazarus:/$PkgName:/" > $LazBuildDir/usr/share/lintian/overrides/$PkgName
# icons, links
mkdir -p $LazBuildDir/usr/share/pixmaps
mkdir -p $LazBuildDir/usr/share/applications
mkdir -p $LazBuildDir/usr/share/mime/packages
mkdir -p $LazBuildDir/usr/bin/
install -m 644 $LazDestDir/images/icons/lazarus128x128.png $LazBuildDir/usr/share/pixmaps/lazarus.png
install -m 644 $LazDestDir/install/lazarus.desktop $LazBuildDir/usr/share/applications/lazarus.desktop
install -m 644 $LazDestDir/install/lazarus-mime.xml $LazBuildDir/usr/share/mime/packages/lazarus.xml
ln -s $LazDestDirInstalled/lazarus $LazBuildDir/usr/bin/lazarus-ide
ln -s $LazDestDirInstalled/startlazarus $LazBuildDir/usr/bin/startlazarus
ln -s $LazDestDirInstalled/lazbuild $LazBuildDir/usr/bin/lazbuild
# docs
mkdir -p $LazBuildDir/usr/share/man/man1
for exe in lazbuild lazarus-ide startlazarus lazres svn2revisioninc updatepofiles; do
cat $LazDestDir/install/man/man1/$exe.1 | gzip -n --best > $LazBuildDir/usr/share/man/man1/$exe.1.gz
done
# default configs
mkdir -p $LazBuildDir/etc/lazarus
cat $EnvOpts | \
sed -e "s#__LAZARUSDIR__#$LazDestDirInstalled/#" \
-e "s#__FPCSRCDIR__#/usr/share/fpcsrc/\$(FPCVER)/#" \
> $LazBuildDir/etc/lazarus/environmentoptions.xml
if [ -n $Pas2jsZip ]; then
cat $EtcSrcDir/pas2jsdsgnoptions.xml | \
sed -e "s#__PAS2JSVERSION__#$Pas2jsVer#" \
> $LazBuildDir/etc/lazarus/pas2jsdsgnoptions.xml
cat $LazBuildDir/etc/lazarus/pas2jsdsgnoptions.xml
fi
chmod 644 $LazBuildDir/etc/lazarus/*.xml
# fixing permissions
echo "fixing permissions ..."
find $LazBuildDir -type d -exec chmod 755 {} \;
find $LazBuildDir -perm 775 -exec chmod 755 {} \;
find $LazBuildDir -perm 664 -exec chmod 644 {} \;
# postinst + postrm:
# don't know
# creating deb
echo "creating deb ..."
cd $TmpDir
fakeroot dpkg-deb --build $LazBuildDir
mv $LazBuildDir.deb $LazDeb
echo "you can now test it with lintian $LazDeb"
cd -
# removing temporary files
rm -r $TmpDir
# end.
|