Author: ranger
Date: Wed Mar 5 04:51:50 2008
New Revision: 1153
URL:
<http://svn.finkproject.org/websvn/listing.php?sc=1&rev=1153&repname=user%3a+ranger>
Log:
a little script to update version numbers in packages
Added:
trunk/experimental/scripts/translate-versions.pl (with props)
Added: trunk/experimental/scripts/translate-versions.pl
URL:
<http://svn.finkproject.org/websvn/filedetails.php?path=/trunk/experimental/scripts/translate-versions.pl&rev=1153&repname=user%3a+ranger>
==============================================================================
--- trunk/experimental/scripts/translate-versions.pl (added)
+++ trunk/experimental/scripts/translate-versions.pl Wed Mar 5 04:51:50 2008
@@ -1,0 +1,80 @@
+#!/usr/bin/perl
+
+use File::Copy;
+
+my $package = shift;
+my $version = shift;
+
+if (not @ARGV)
+{
+ print "usage: $0 <package> <version> [file0..n]\n";
+ exit 1;
+}
+
+for my $file (@ARGV)
+{
+ if (open(FILEIN, $file))
+ {
+ if (open(FILEOUT, '>' . $file . '.tmp'))
+ {
+
+ my $in_heredoc = undef;
+ while (my $line = <FILEIN>)
+ {
+ if ($line =~ /^\s*<<\s*$/ and $in_heredoc)
+ {
+ $in_heredoc .= $line;
+ print FILEOUT
process_section($in_heredoc);
+ $in_heredoc = undef;
+ }
+ elsif ($in_heredoc)
+ {
+ $in_heredoc .= $line;
+ }
+ elsif ($line =~
/^(\s*)(BuildDepends|Depends)\s*:\s*(.*?)\s*$/)
+ {
+ if ($3 =~ /<</)
+ {
+ $in_heredoc = $line;
+ }
+ else
+ {
+ print FILEOUT
process_section($line);
+ }
+ }
+ else
+ {
+ print FILEOUT $line;
+ }
+ }
+
+ close (FILEOUT);
+ }
+ else
+ {
+ warn "unable to write to $file.tmp: $!";
+ }
+ close (FILEIN);
+ }
+ else
+ {
+ warn "unable to open $file for reading: $!";
+ }
+ if (-s $file . '.tmp')
+ {
+ move($file . '.tmp', $file);
+ }
+}
+
+sub process_section
+{
+ my @return;
+ for my $arg (@_)
+ {
+ $arg =~ s/\(([^\)]+)\) \([^\)]+\)/\($1\)/gsi;
+ $arg =~ s/\b(${package}(-shlibs|-dev|-doc|-bin|))(\s*,\s*|$)/$1
\(>= $version\)$3/gsi;
+ $arg =~
s/\b(${package}(-shlibs|-dev|-doc|-bin|))(\s+)\(\>\=[^\)]+\)/$1$3\(\>\=
$version\)/gsi;
+ push(@return, $arg);
+ }
+ return @return;
+}
Propchange: trunk/experimental/scripts/translate-versions.pl
------------------------------------------------------------------------------
svn:executable = *
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fink-commits mailing list
[email protected]
http://news.gmane.org/gmane.os.apple.fink.cvs