mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-13 21:39:39 +02:00
rpm build scripts now automatically fixes versions in fpc Makefiles
git-svn-id: trunk@5542 -
This commit is contained in:
parent
a6b8098122
commit
f9eb700429
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -1392,6 +1392,7 @@ tools/install/create_lazarus_rpm.sh -text svneol=native#application/x-sh
|
||||
tools/install/create_lazarus_tgz_from_local_dir.sh -text svneol=native#application/x-sh
|
||||
tools/install/do_nothing.sh -text svneol=native#application/x-sh
|
||||
tools/install/file_filter.sh -text svneol=native#application/x-sh
|
||||
tools/install/replace_in_files.pl -text svneol=native#application/x-perl
|
||||
tools/install/smart_strip.sh -text svneol=native#application/x-sh
|
||||
tools/lazarusmake.ini svneol=native#text/plain
|
||||
tools/lazres.lpi svneol=native#text/plain
|
||||
|
@ -59,6 +59,7 @@ VersionFile="$TmpDir/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"
|
||||
LazVersion="$CompilerVersion.$CompilerRelease"
|
||||
if [ "$CompilerPatch" != "0" ]; then
|
||||
LazVersion="$LazVersion.$CompilerPatch"
|
||||
@ -71,6 +72,11 @@ fi
|
||||
|
||||
FPCMakefile=$TmpDir/Makefile
|
||||
SmartStripScript=smart_strip.sh
|
||||
ReplaceScript=replace_in_files.pl
|
||||
|
||||
|
||||
# set version numbers in all Makefiles
|
||||
perl replace_in_files.pl -nsR -f '=\d.\d.\d' -r =1.9.5 -m 'Makefile.*' $TmpDir/*
|
||||
|
||||
# update smart_strip.sh
|
||||
#cp $SmartStripScript $TmpDir/install/
|
||||
@ -124,7 +130,6 @@ else
|
||||
|
||||
SpecFile=$TmpDir/install/fpc.spec
|
||||
SrcPatch=fpcsrc-patch
|
||||
SmartSripScript=smart_strip.sh
|
||||
|
||||
# update smart_strip.sh
|
||||
# ATM not needed: cp $SmartSripScript $TmpDir/install/
|
||||
|
146
tools/install/replace_in_files.pl
Normal file
146
tools/install/replace_in_files.pl
Normal file
@ -0,0 +1,146 @@
|
||||
#!/usr/bin/env perl
|
||||
#
|
||||
# Copyright 2004 Mattias Gaertner
|
||||
#
|
||||
# Search and replace in multiple files with perl syntax
|
||||
|
||||
use vars qw/ %opt /;
|
||||
use Getopt::Std;
|
||||
my $opt_string = 'hvsinbRf:r:m:';
|
||||
getopts( "$opt_string", \%opt ) or usage();
|
||||
usage() if $opt{h};
|
||||
|
||||
sub usage(){
|
||||
print STDERR << "EOF";
|
||||
|
||||
Replace strings in files with perl search and replace syntax
|
||||
|
||||
usage: $0 [-hRvnb] -t text -r replacetext -f filemask file1 file2 ...
|
||||
|
||||
-h : this (help) message
|
||||
-f : find text
|
||||
-r : replace with this text
|
||||
-R : recursive
|
||||
-i : case insensitive
|
||||
-v : verbose
|
||||
-s : write summary
|
||||
-n : simulate, do not change files
|
||||
-b : replace in binary files too
|
||||
-m : file mask, useful for recursive
|
||||
|
||||
examples:
|
||||
Replace in file1.txt and file2.txt all a with b
|
||||
$0 -vsn -f 'a' -r 'b' file1.txt file2.txt
|
||||
|
||||
Replace in file1.txt all a([0-9]) with b$1
|
||||
$0 -vsn -f 'a([0-9])' -r 'b$1' file1.txt
|
||||
|
||||
EOF
|
||||
exit;
|
||||
}
|
||||
|
||||
usage() unless $opt{f}; # Text needed
|
||||
usage() unless $opt{r}; # Replacetext needed
|
||||
|
||||
$FindText=$opt{f};
|
||||
$ReplaceText=$opt{r};
|
||||
$FileMask=$opt{m};
|
||||
|
||||
if($opt{v}){
|
||||
print "Parameters:";
|
||||
print "FindText=$FindText\n";
|
||||
print "ReplaceText=$ReplaceText\n";
|
||||
print "FileMask=$FileMask\n";
|
||||
print "\n";
|
||||
}
|
||||
|
||||
$TotalFiles=0;
|
||||
$ChangedFiles=0;
|
||||
$TotalLines=0;
|
||||
$ChangedLines=0;
|
||||
for $Filename(@ARGV){
|
||||
DoFile($Filename,1);
|
||||
}
|
||||
if($opt{s}){
|
||||
print "\nSummary:\n";
|
||||
print "changed files: $ChangedFiles/$TotalFiles\n";
|
||||
print "changed lines: $ChangedLines/$TotalLines\n";
|
||||
}
|
||||
|
||||
#==============================================================================
|
||||
|
||||
sub DoFile(){
|
||||
(my $Filename,$Level) = @_;
|
||||
|
||||
# skip special files
|
||||
if($Filename eq "."){ return; }
|
||||
if($Filename eq ".."){ return; }
|
||||
|
||||
#
|
||||
if(-d $Filename){
|
||||
if($opt{R}){
|
||||
if($opt{v}){
|
||||
#print "Entering directory $Filename\n";
|
||||
}
|
||||
$Filenames=`ls -1 $Filename`;
|
||||
for $SubFilename(split("\n",$Filenames)){
|
||||
DoFile($Filename."/".$SubFilename,$Level+1);
|
||||
}
|
||||
if($opt{v}){
|
||||
#print "Leaving directory $Filename\n";
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((! $opt{b}) && (-B $Filename)){
|
||||
if($opt{v} && ($Level==1)){
|
||||
print "Skipping binary file $Filename\n";
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(($FileMask) && ($Filename !~ /$FileMask/)){
|
||||
return;
|
||||
}
|
||||
|
||||
if($opt{v}){
|
||||
print "Editing $Filename ...\n";
|
||||
}
|
||||
|
||||
$TotalFiles++;
|
||||
open F, "< $Filename" or die "Unable to read file $Filename: $!";
|
||||
$NewText="";
|
||||
$LineNumber=1;
|
||||
$FileChanged=0;
|
||||
while ($Line=<F>){
|
||||
$TotalLines++;
|
||||
$OldLine=$Line;
|
||||
if($opt{i}){
|
||||
$Line=~s/$FindText/$ReplaceText/goi;
|
||||
} else {
|
||||
$Line=~s/$FindText/$ReplaceText/go;
|
||||
}
|
||||
if($OldLine ne $Line){
|
||||
$ChangedLines++;
|
||||
$FileChanged=1;
|
||||
if($opt{v}){
|
||||
print "($LineNumber,old):".$OldLine;
|
||||
print "($LineNumber,new):".$Line;
|
||||
}
|
||||
}
|
||||
$NewText.=$Line;
|
||||
$LineNumber++;
|
||||
}
|
||||
if($FileChanged==1){
|
||||
$ChangedFiles++;
|
||||
}
|
||||
close F;
|
||||
|
||||
if(! $opt{n}){
|
||||
open F, "> $Filename" or die "Unable to write file $Filename: $!";
|
||||
print F $NewText;
|
||||
close F;
|
||||
}
|
||||
}
|
||||
|
||||
# end.
|
||||
|
Loading…
Reference in New Issue
Block a user