From owner-freebsd-ports@FreeBSD.ORG Wed Nov 16 06:14:00 2005 Return-Path: X-Original-To: freebsd-ports@freebsd.org Delivered-To: freebsd-ports@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2547B16A420 for ; Wed, 16 Nov 2005 06:14:00 +0000 (GMT) (envelope-from tobez@tobez.org) Received: from heechee.tobez.org (heechee.tobez.org [217.157.39.226]) by mx1.FreeBSD.org (Postfix) with ESMTP id 63B6343D49 for ; Wed, 16 Nov 2005 06:13:58 +0000 (GMT) (envelope-from tobez@tobez.org) Received: by heechee.tobez.org (Postfix, from userid 1001) id A2C3B125451; Wed, 16 Nov 2005 07:13:56 +0100 (CET) Date: Wed, 16 Nov 2005 07:13:56 +0100 From: Anton Berezin To: Dan Langille Message-ID: <20051116061356.GA13386@heechee.tobez.org> Mail-Followup-To: Anton Berezin , Dan Langille , freebsd-ports@freebsd.org References: <437A74A7.21874.1F3E90C0@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <437A74A7.21874.1F3E90C0@localhost> User-Agent: Mutt/1.4.2.1i X-Powered-By: FreeBSD http://www.freebsd.org/ Cc: freebsd-ports@freebsd.org Subject: Re: Latest __FREEBSD__ value for each release X-BeenThere: freebsd-ports@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting software to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Nov 2005 06:14:00 -0000 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