Date: Wed, 16 Nov 2005 07:13:56 +0100 From: Anton Berezin <tobez@FreeBSD.org> To: Dan Langille <dan@langille.org> Cc: freebsd-ports@freebsd.org Subject: Re: Latest __FREEBSD__ value for each release Message-ID: <20051116061356.GA13386@heechee.tobez.org> In-Reply-To: <437A74A7.21874.1F3E90C0@localhost> References: <437A74A7.21874.1F3E90C0@localhost>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Nov 15, 2005 at 11:52:07PM -0500, Dan Langille wrote: > For an upcoming FreshPorts project, I want to extract the latest > value for __FREEBSD__ for each branch. I'm hoping someone can save > me some time and write a small perl script for me. Thanks. > > Given the release tags for the 4, 5, 6, and 7 branches[1], grab > src/sys/sys/param.h from cvsweb[2], and grep for __FreeBSD_version. > > What I need printed out on a single line is something like this. > > 4 492100 > 5 504104 > 6 600100 > 7 700006 > > Try starting with something like this: > > my %Branches = ('HEAD' => 7, 'RELENG_6' => 6, 'RELENG_5' => 5, > 'RELENG_4' => 4); > > Thank you. > > [1] - http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/cvs- > tags.html > > [2] - http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/param.h I took a liberty to revert the branches hash in your specs, since it is more natural to do it this way. #! /usr/bin/perl use 5.006; use warnings; use strict; use WWW::Mechanize; my %branches = ( 4 => 'RELENG_4', 5 => 'RELENG_5', 6 => 'RELENG_6', 7 => 'HEAD', ); for my $b (sort { $a <=> $b } keys %branches) { my $ver = retrieve_branch($branches{$b}); print "$b\t$ver\n" if $ver; } sub retrieve_branch { my ($branch) = @_; my $mech = WWW::Mechanize->new(); my $url = "http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/sys/param.h"; $mech->get("$url?only_with_tag=$branch"); my $x = $mech->follow_link(text_regex => qr/[\d.]+/); return $1 if $mech->content() =~ /^#define\s+__FreeBSD_version\s+(\d+)\s*/m; return ""; } Cheers, \Anton. -- An undefined problem has an infinite number of solutions. -- Robert A. Humphrey
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20051116061356.GA13386>