[51684] users/devans

devans at macports.org devans at macports.org
Sun May 31 10:15:29 PDT 2009


Revision: 51684
          http://trac.macports.org/changeset/51684
Author:   devans at macports.org
Date:     2009-05-31 10:15:28 -0700 (Sun, 31 May 2009)
Log Message:
-----------
utils/gnome-latest-version.pl: perl script to get latest version for modules in the GNOME repository, works but needs to be more robust.

Added Paths:
-----------
    users/devans/utils/
    users/devans/utils/gnome-latest-version.pl

Added: users/devans/utils/gnome-latest-version.pl
===================================================================
--- users/devans/utils/gnome-latest-version.pl	                        (rev 0)
+++ users/devans/utils/gnome-latest-version.pl	2009-05-31 17:15:28 UTC (rev 51684)
@@ -0,0 +1,100 @@
+#!/opt/local/bin/perl
+
+use Getopt::Long;
+use Net::FTP;
+
+my $ftp_host   = "ftp.gnome.org";
+my $ftp_user   = "anonymous";
+my $ftp_passwd = "devans\@macports.org";
+my $ftp_base   = "/pub/gnome/sources";
+my $branch     = "";
+my $debug      = 0;
+
+my $result = GetOptions(
+	"host=s"     => \$ftp_host,
+	"user=s"     => \$ftp_user,
+	"password=s" => \$ftp_passwd,
+	"base=s"     => \$ftp_base,
+	"branch=s"   => \$branch,
+	"debug"      => \$debug
+);
+
+my $nargs  = scalar(@ARGV);
+my @gnames = @ARGV;
+
+my $ftp = Net::FTP->new( $ftp_host, Debug => $debug );
+$ftp->login( $ftp_user, $ftp_passwd );
+
+if ( $nargs < 1 ) {
+	$ftp->cwd($ftp_base);
+	@gnames = $ftp->ls;
+	$nargs  = scalar(@gnames);
+}
+
+if ($debug) {
+	print "$nargs arguments:";
+	if ( $nargs > 0 ) {
+		foreach my $gname (@gnames) { print "    $gname\n"; }
+	}
+	if ( $branch ne "" ) { print "Print branch $branch only.\n"; }
+}
+
+foreach my $gname (@gnames) {
+	$ftp->cwd("$ftp_base/$gname")
+	  or die "cannot change to working directory $gname: ",
+	  $ftp->message;
+	my @lines = $ftp->ls;
+
+	my $major = -1;
+	my $minor = -1;
+
+	foreach my $line (@lines) {
+		if ( $line =~ m/^(\d+)\.(\d+)$/ ) {
+			if ( $1 > $major ) {
+				$major = $1;
+				$minor = $2;
+			}
+			elsif ( ( $1 == $major ) && ( $2 > $minor ) ) {
+				$minor = $2;
+			}
+		}
+	}
+
+	undef @lines;
+
+	if ($debug) { print "Latest branch for $gname is $major.$minor\n"; }
+
+	if ( ( $major >= 0 ) && ( $minor >= 0 ) ) {
+
+		if ( ( $branch eq "" ) || ( $branch eq "$major.$minor" ) ) {
+
+			$ftp->cwd("$ftp_base/$gname/$major.$minor")
+			  or die
+			  "$gname: cannot change to working directory $major.$minor: ",
+			  $ftp->message;
+
+			my @lines = $ftp->ls;
+			
+			$version = "$major.$minor";
+
+			foreach my $line (@lines) {
+				if ( $line =~ m/^LATEST-IS-(.*)$/ ) {
+					$version = $1;
+				}
+			}
+
+			if ($debug) {
+				print "Latest version for $gname is $version\n";
+			}
+			else {
+				print "$gname $version\n";
+			}
+
+		}
+
+	}
+
+}
+
+$ftp->quit;
+


Property changes on: users/devans/utils/gnome-latest-version.pl
___________________________________________________________________
Added: svn:executable
   + *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090531/cb4d0083/attachment.html>


More information about the macports-changes mailing list