create_lazarus_rpm.sh can now build the rpm without being root

git-svn-id: trunk@7724 -
This commit is contained in:
mattias 2005-09-17 11:58:38 +00:00
parent 62c2006012
commit b9f7eda6de
10 changed files with 88 additions and 136 deletions

View File

@ -47,48 +47,49 @@ Creating the lazarus tgz:
RPM: RPM:
How to create RPM packages as normal user / non root:
You don't need to be root to built rpm packages.
You only need a ~/.rpmacros file overriding some values. The script
<lazarusdir>/tools/install/rpm/create_nonroot_macros.sh will setup one. Do:
[]$ cd <lazarusdir>/tools/install/rpm
[]$ ./create_nonroot_macros.sh
From now all new rpms will be built in ~/rpm/.
Creating the fpc and the fpcsrc rpm: Creating the fpc and the fpcsrc rpm:
There are two versions of the compiler: the old 2..0.x and the new (but not There are two versions of the compiler: the old 2.0.x and the new (but not
yet released) developer version 2.1.x. To build them, you must install fpc yet released) developer version 2.1.x. To build them, you must install fpc
first. Install the stable fpc release (2.0.x). Note: The 2.0.x can not be first. Install the stable fpc release (2.0.x).
built with a 2.1.x compiler and the recommended startup compiler for the 2.1.x Note: The 2.0.x can not be built with a 2.1.x compiler and the recommended
is the released fpc 2.0.x. startup compiler for the 2.1.x is the released fpc 2.0.x.
If you have your own fpc sources you can build the fpc rpm with: If you have your own fpc sources you can build the fpc rpm with:
Become root and do:
cd <lazarus_directory>/tools/install []$ cd <lazarus_directory>/tools/install
./build_fpc_rpm.sh nodocs /path/to/your/fpc/sources/fpc 050601 []$ ./build_fpc_rpm.sh nodocs /path/to/your/fpc/sources/fpc
The 050601 stands for: 2005 june 1st Then build the fpcsrc rpm:
Then build the fpcsrc rpm. Become root and do: []$ ./build_fpcsrc_rpm.sh /path/to/your/fpc/sources/fpc
cd <lazarus_directory>/tools/install Normally you can find the rpms under /usr/src/redhat/RPMS/i386/
./build_fpcsrc_rpm.sh /path/to/your/fpc/sources/fpc 050601 and /usr/src/redhat/SRPMS/.
Or if you have a ~/.rpmmacros file the new rpm will be in ~/rpm/RPMS/i386/
and ~/rpm/SRPMS/.
The create_fpc_rpm.sh works nearly automatically. Become root and execute it.
For 2.0.x: ./create_fpc_rpm.sh stable
For 2.1.x: ./create_fpc_rpm.sh devel
What it does: First it checks if the fpc source tgz is already created and
if not, it automatically downloads it. The script does not use the current
version, but the latest known to work with lazarus. Then it unpacks the
source, compiles it and builds the rpm. Normally you can find the rpms under
/usr/src/redhat/RPMS/i386/ and /usr/src/redhat/SRPMS/.
Creating the lazarus rpm: Creating the lazarus rpm:
Important: Important:
If you have created a new fpc RPM, then you should install it, *before* you If you have created a new fpc RPM, then you should install it *before* you
build the lazarus RPM. Otherwise the compiled lazarus RPM is not compatible build the lazarus RPM. Otherwise the compiled lazarus RPM is not compatible
to the fpc RPM. to the fpc RPM.
As root: []$ ./create_lazarus_rpm.sh.
Execute create_lazarus_rpm.sh.
Creating other system specific rpms: Creating other system specific rpms:

View File

@ -6,7 +6,7 @@ set -e
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# parse parameters # parse parameters
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Usage="Usage: $0 [nodocs] [notemp] [deb] <FPCSrcDir> <release>" Usage="Usage: $0 [nodocs] [notemp] [deb] <FPCSrcDir> [release]"
WithDOCS=yes WithDOCS=yes
if [ "x$1" = "xnodocs" ]; then if [ "x$1" = "xnodocs" ]; then
@ -27,17 +27,17 @@ if [ "x$1" = "xdeb" ]; then
fi fi
FPCSrcDir=$1 FPCSrcDir=$1
shift
if [ "x$FPCSrcDir" = "x" ]; then if [ "x$FPCSrcDir" = "x" ]; then
echo $Usage echo $Usage
exit -1 exit -1
fi fi
shift
LazRelease=$1 LazRelease=$1
shift
if [ "x$LazRelease" = "x" ]; then if [ "x$LazRelease" = "x" ]; then
echo $Usage LazRelease=$(date +%y%m%d)
exit -1 else
shift
fi fi
if [ ! -d $FPCSrcDir/compiler ]; then if [ ! -d $FPCSrcDir/compiler ]; then
@ -52,7 +52,10 @@ fi
# create a temporary copy of the fpc sources to patch it # create a temporary copy of the fpc sources to patch it
TmpDir=/tmp/fpc_patchdir TmpDir=/tmp/fpc_patchdir
if [ "$WithTempDir" = "yes" ]; then if [ "$WithTempDir" = "yes" ]; then
rm -rf $TmpDir if [ -d $TmpDir ]; then
rm -rf $TmpDir/*
rm -r $TmpDir
fi
mkdir -p $TmpDir mkdir -p $TmpDir
#ppc386 -Fu../../lcl/units/i386/linux cvsexportlocal.pas #ppc386 -Fu../../lcl/units/i386/linux cvsexportlocal.pas
@ -65,6 +68,7 @@ else
fi fi
# retrieve the version information # retrieve the version information
echo -n "getting FPC version from local svn ..."
VersionFile="$TmpDir/fpc/compiler/version.pas" VersionFile="$TmpDir/fpc/compiler/version.pas"
CompilerVersion=`cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g'` CompilerVersion=`cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g'`
CompilerRelease=`cat $VersionFile | grep ' *release_nr *=.*;' | sed -e 's/[^0-9]//g'` CompilerRelease=`cat $VersionFile | grep ' *release_nr *=.*;' | sed -e 's/[^0-9]//g'`
@ -74,6 +78,7 @@ LazVersion="$CompilerVersion.$CompilerRelease"
if [ "$CompilerPatch" != "0" ]; then if [ "$CompilerPatch" != "0" ]; then
LazVersion="$LazVersion.$CompilerPatch" LazVersion="$LazVersion.$CompilerPatch"
fi fi
echo " $CompilerVersionStr-$LazRelease"
@ -85,6 +90,7 @@ ReplaceScript=replace_in_files.pl
# set version numbers in all Makefiles # set version numbers in all Makefiles
echo "set version numbers in all Makefiles ..."
perl replace_in_files.pl -sR -f '=\d.\d.\d' -r =$CompilerVersionStr -m 'Makefile(.fpc)?' $TmpDir/fpc/* perl replace_in_files.pl -sR -f '=\d.\d.\d' -r =$CompilerVersionStr -m 'Makefile(.fpc)?' $TmpDir/fpc/*
# update smart_strip.sh # update smart_strip.sh
@ -135,9 +141,9 @@ if [ "$PkgType" = "deb" ]; then
else else
# build fpc rpm # build fpc rpm
echo "creating spec file ..."
SpecFileTemplate=rpm/fpc.spec.template SpecFileTemplate=rpm/fpc.spec.template
SpecFile=rpm/fpc.spec SpecFile=rpm/fpc.spec
SrcPatch=fpcsrc-patch
# change spec file # change spec file
cat $SpecFileTemplate | \ cat $SpecFileTemplate | \
@ -148,6 +154,7 @@ else
# -e 's/^\%{fpcdir}\/samplecfg .*/%{fpcdir}\/samplecfg %{_libdir}\/fpc\/\\\$version/' \ # -e 's/^\%{fpcdir}\/samplecfg .*/%{fpcdir}\/samplecfg %{_libdir}\/fpc\/\\\$version/' \
SrcTGZ=$(rpm/get_rpm_source_dir.sh)/SOURCES/fpc-$CompilerVersionStr-$LazRelease.source.tar.gz SrcTGZ=$(rpm/get_rpm_source_dir.sh)/SOURCES/fpc-$CompilerVersionStr-$LazRelease.source.tar.gz
echo "creating $SrcTGZ ..."
tar czf $SrcTGZ -C $TmpDir fpc tar czf $SrcTGZ -C $TmpDir fpc
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
@ -156,11 +163,9 @@ else
if [ "$WithDOCS" = "no" ]; then if [ "$WithDOCS" = "no" ]; then
export NODOCS=1 export NODOCS=1
fi fi
cd $TmpDir
cd -
rpmbuild --nodeps -ba $SpecFile rpmbuild --nodeps -ba $SpecFile
echo "The new rpm can be found in $(../rpm/get_rpm_source_dir.sh)/RPMS/i386/fpc-$LazVersion-$LazRelease.i386.rpm" echo "The new rpm can be found in $(./rpm/get_rpm_source_dir.sh)/RPMS/i386/fpc-$LazVersion-$LazRelease.i386.rpm"
fi fi
# end. # end.

View File

@ -1,13 +1,13 @@
#!/bin/bash #!/bin/bash
set -x #set -x
set -e set -e
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# parse parameters # parse parameters
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
Usage="Usage: $0 [deb] <FPCSrcDir> <release>" Usage="Usage: $0 [deb] <FPCSrcDir> [release]"
PkgType=rpm PkgType=rpm
if [ "x$1" = "xdeb" ]; then if [ "x$1" = "xdeb" ]; then
@ -16,17 +16,17 @@ if [ "x$1" = "xdeb" ]; then
fi fi
FPCSourceDir=$1 FPCSourceDir=$1
shift
if [ "x$FPCSourceDir" = "x" ]; then if [ "x$FPCSourceDir" = "x" ]; then
echo $Usage echo $Usage
exit -1 exit -1
fi fi
shift
LazRelease=$1 LazRelease=$1
shift
if [ "x$LazRelease" = "x" ]; then if [ "x$LazRelease" = "x" ]; then
echo $Usage LazRelease=$(date +%y%m%d)
exit -1 else
shift
fi fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -34,14 +34,16 @@ fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# retrieve the version information # retrieve the version information
echo -n "getting FPC version from local svn ..."
VersionFile="$FPCSourceDir/compiler/version.pas" VersionFile="$FPCSourceDir/compiler/version.pas"
CompilerVersion=`cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g'` CompilerVersion=`cat $VersionFile | grep ' *version_nr *=.*;' | sed -e 's/[^0-9]//g'`
CompilerRelease=`cat $VersionFile | grep ' *release_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'` CompilerPatch=`cat $VersionFile | grep ' *patch_nr *=.*;' | sed -e 's/[^0-9]//g'`
LazVersion="$CompilerVersion.$CompilerRelease" CompilerVersionStr="$CompilerVersion.$CompilerRelease.$CompilerPatch"
LazVersion="$LazVersion.$CompilerPatch" LazVersion=$CompilerVersionStr
echo " $CompilerVersionStr-$LazRelease"
FPCTGZ=fpcsrc-$LazVersion-$LazRelease.tgz FPCTGZ=$(rpm/get_rpm_source_dir.sh)/SOURCES/fpcsrc-$CompilerVersionStr-$LazRelease.source.tar.gz
CurDir=`pwd` CurDir=`pwd`
# pack the directory # pack the directory
@ -104,13 +106,10 @@ if [ "$PkgType" = "deb" ]; then
else else
# build fpcsrc rpm # build fpcsrc rpm
echo building fpcsrc rpm ... echo "building fpcsrc rpm ..."
# copy src tgz into rpm building directory
cp $FPCTGZ /usr/src/redhat/SOURCES/
# create spec file # create spec file
SpecFile=fpcsrc-$LazVersion-$LazRelease.spec SpecFile=rpm/fpcsrc-$LazVersion-$LazRelease.spec
cat fpcsrc.spec | \ cat fpcsrc.spec | \
sed -e "s/LAZVERSION/$LazVersion/g" -e "s/LAZRELEASE/$LazRelease/" \ sed -e "s/LAZVERSION/$LazVersion/g" -e "s/LAZRELEASE/$LazRelease/" \
> $SpecFile > $SpecFile
@ -124,6 +123,7 @@ else
# build rpm # build rpm
rpmbuild -ba $SpecFile || rpm -ba $SpecFile rpmbuild -ba $SpecFile || rpm -ba $SpecFile
echo "The new rpm can be found in $(./rpm/get_rpm_source_dir.sh)/RPMS/i386/fpcsrc-$LazVersion-$LazRelease.i386.rpm"
fi fi
# end. # end.

View File

@ -35,14 +35,18 @@ fi
TmpBaseDir=/tmp TmpBaseDir=/tmp
TmpDir=$TmpBaseDir/fpc TmpDir=$TmpBaseDir/fpc
rm -rf $TmpDir
if [ -d $FPCSrcDir/CVS ]; then if [ -d $FPCSrcDir/CVS ]; then
ppc386 -Fu../../lcl/units/i386/linux cvsexportlocal.pas ppc386 -Fu../../lcl/units/i386/linux cvsexportlocal.pas
echo "extracting FPC from local cvs ..." echo "extracting FPC from local cvs ..."
rm -rf $TmpDir
./cvsexportlocal $FPCSrcDir $TmpDir ./cvsexportlocal $FPCSrcDir $TmpDir
else else
rm -rf $TmpDir if [ -d $FPCSrcDir/.svn ]; then
cp -a $FPCSrcDir $TmpDir echo "extracting FPC from local svn ..."
svn export $FPCSrcDir $TmpDir
else
cp -a $FPCSrcDir $TmpDir
fi
fi fi
if [ $RenameSmart = "yes" ]; then if [ $RenameSmart = "yes" ]; then

View File

@ -25,11 +25,9 @@ if [ "x$Download" = "xyes" ]; then
cd - cd -
else else
echo "extracting lazarus from local svn ..." echo "extracting lazarus from local svn ..."
cd ../.. SourceDir=$(pwd | sed -e 's#lazarus/tools.*$#lazarus#')
SourceDir=`pwd`
cd -
rm -rf /tmp/lazarus rm -rf /tmp/lazarus
svn export file://$SourceDir lazarus svn export $SourceDir /tmp/lazarus
fi fi
cd /tmp cd /tmp

View File

@ -4,44 +4,49 @@ set -x
set -e set -e
# get date of day # get date of day
Year=`date +%y` Year=$(date +%y)
Month=`date +%m` Month=$(date +%m)
Day=`date +%d` Day=$(date +%d)
# get installed fpc version # get installed fpc version
FPCRPM=`rpm -qa | egrep '^fpc-'` echo "getting installed fpc version ..."
FPCRPM=$(rpm -qa | egrep '^fpc-')
if [ "x$FPCRPM" = "x" ]; then if [ "x$FPCRPM" = "x" ]; then
echo ERROR: fpc rpm not installed echo ERROR: fpc rpm not installed
exit exit
fi fi
FPCRPMVersion=`echo $FPCRPM | sed -e 's/fpc-//g'` FPCRPMVersion=`echo $FPCRPM | sed -e 's/fpc-//g'`
echo "installed fpc version: $FPCRPMVersion"
Date=$Year$Month$Day Date=$Year$Month$Day
LazVersion=0.9.8 LazVersion=$(./get_lazarus_version.sh)
LazRelease=`echo $FPCRPM | sed -e 's/-/_/g'` LazRelease=$(echo $FPCRPM | sed -e 's/-/_/g')
SrcTGZ=lazarus-$Date.tgz Src=lazarus-$LazVersion-$LazRelease.tar.gz
SrcTGZ=$(./rpm/get_rpm_source_dir.sh)/SOURCES/$Src
TmpDir=/tmp/lazarus$LazVersion TmpDir=/tmp/lazarus$LazVersion
SpecFile=lazarus-$LazVersion-$LazRelease.spec SpecFile=rpm/lazarus-$LazVersion-$LazRelease.spec
# download lazarus cvs if necessary # download lazarus svn if necessary
echo "creating lazarus tgz ..."
if [ ! -f $SrcTGZ ]; then if [ ! -f $SrcTGZ ]; then
sh create_lazarus_export_tgz.sh $SrcTGZ sh create_lazarus_export_tgz.sh $SrcTGZ
fi fi
# put src tgz into rpm build directory
cp $SrcTGZ /usr/src/redhat/SOURCES/
# create spec file # create spec file
cat lazarus.spec | \ echo "creating lazarus spec file ..."
cat rpm/lazarus.spec.template | \
sed -e "s/LAZVERSION/$LazVersion/g" \ sed -e "s/LAZVERSION/$LazVersion/g" \
-e "s/LAZRELEASE/$LazRelease/" \ -e "s/LAZRELEASE/$LazRelease/g" \
-e "s/LAZSOURCE/$SrcTGZ/" \ -e "s/LAZSOURCE/$Src/" \
-e "s/FPCBUILDVERSION/2.0.0/" \ -e "s/FPCBUILDVERSION/2.0.0/" \
-e "s/FPCSRCVERSION/$FPCRPMVersion/" \ -e "s/FPCSRCVERSION/$FPCRPMVersion/" \
> $SpecFile > $SpecFile
# build rpm # build rpm
echo "building rpm ..."
rpm -ba $SpecFile || rpmbuild -ba $SpecFile rpm -ba $SpecFile || rpmbuild -ba $SpecFile
echo "The new rpm can be found at $(./rpm/get_rpm_source_dir.sh)/RPMS/i386/lazarus-$LazVersion-$LazRelease.i386.rpm"
# end. # end.

View File

@ -3,7 +3,7 @@ Version: LAZVERSION
Release: LAZRELEASE Release: LAZRELEASE
Copyright: LGPL2 Copyright: LGPL2
Group: Development/Languages Group: Development/Languages
Source: %{name}-%{version}-%{release}.tgz Source: %{name}-%{version}-%{release}.source.tar.gz
Summary: FreePascal sources Summary: FreePascal sources
Packager: Mattias Gaertner (mattias@freepascal.org) Packager: Mattias Gaertner (mattias@freepascal.org)
URL: http://www.freepascal.org/ URL: http://www.freepascal.org/

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
grep 'lisLazarusVersionString = ' ../../lazarusidestrconsts.pas \ grep 'lisLazarusVersionString = ' ../../ide/lazarusidestrconsts.pas \
| sed -e 's/.*[^0-9\.]\([0-9\.]\+\)[^0-9\.].*/\1/' | sed -e 's/.*[^0-9\.]\([0-9\.]\+\)[^0-9\.].*/\1/'
# end. # end.

View File

@ -1,60 +0,0 @@
Name: lazarus
Version: LAZVERSION
Release: LAZRELEASE
Copyright: LGPL2/GPL2
Group: Development/Tools
Source: LAZSOURCE
Summary: Lazarus Component Library and IDE
Packager: Mattias Gaertner (mattias@freepascal.org)
URL: http://www.lazarus.freepascal.org/
BuildRoot: %{_tmppath}/lazarus-build
BuildRequires: fpc >= FPCBUILDVERSION
Requires: fpcsrc >= FPCSRCVERSION, fpc >= FPCBUILDVERSION
Requires: gdk-pixbuf-devel >= 0.18.0
%define lazdir %{_datadir}/lazarus
%description
Lazarus is a free and opensource RAD tool for freepascal using the lazarus
component library - LCL, which is also included in this package.
The LCL is licensed under LGPL2, the IDE is licensed under GPL2.
%prep
%setup -c
%build
cd lazarus
make
strip lazarus
%install
if [ %{buildroot} != "/" ]; then
rm -rf %{buildroot}
fi
mkdir -p %{buildroot}%{_datadir}/lazarus
mkdir -p %{buildroot}%{_bindir}
mkdir -p %{buildroot}%{_datadir}/pixmaps
mkdir -p %{buildroot}%{_datadir}/gnome/apps/Development
mkdir -p %{buildroot}%{_datadir}/applications
cp -a lazarus/* %{buildroot}%{_datadir}/lazarus/
install -m 644 lazarus/images/ide_icon48x48.png %{buildroot}%{_datadir}/pixmaps/lazarus.png
install -m 644 lazarus/gnome.ide.desktop %{buildroot}%{_datadir}/gnome/apps/Development/lazarus.desktop
install -m 644 lazarus/gnome.ide.desktop %{buildroot}%{_datadir}/applications/lazarus.desktop
ln -sf %{lazdir}/lazarus %{buildroot}%{_bindir}/lazarus
%clean
if [ %{buildroot} != "/" ]; then
rm -rf %{buildroot}
fi
%files
%defattr(-,root,root)
%{_datadir}/lazarus
%{_bindir}/lazarus
%{_datadir}/pixmaps/lazarus.png
%{_datadir}/gnome/apps/Development/lazarus.desktop
%{_datadir}/applications/lazarus.desktop
%changelog

View File

@ -6,7 +6,7 @@ Summary: Lazarus Component Library and IDE
Group: Development/Languages Group: Development/Languages
License: GPL and modified LGPL License: GPL and modified LGPL
URL: http://www.lazarus.freepascal.org/ URL: http://www.lazarus.freepascal.org/
Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}-%{release}.source.tar.gz Source0: http://prdownloads.sourceforge.net/%{name}/%{name}-%{version}-%{release}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
#BuildRequires: #BuildRequires:
@ -24,8 +24,7 @@ component library - LCL, which is also included in this package.
%build %build
cd lazarus cd lazarus
make OPT="-n @$FPCCfg" make OPT="-Fl/opt/gnome/lib"
# -Fl/opt/gnome/lib
strip lazarus strip lazarus
strip startlazarus strip startlazarus