[LON-CAPA-cvs] cvs: modules /sharrison/autocpan make_source_cpan_rpms.pl

harris41 lon-capa-cvs@mail.lon-capa.org
Sun, 11 Aug 2002 23:02:32 -0000


harris41		Sun Aug 11 19:02:32 2002 EDT

  Added files:                 
    /modules/sharrison/autocpan	make_source_cpan_rpms.pl 
  Log:
  makes cpansrc_* RPMs for automated installation of individual CPAN distributions
  
  

Index: modules/sharrison/autocpan/make_source_cpan_rpms.pl
+++ modules/sharrison/autocpan/make_source_cpan_rpms.pl
# make_source_cpan_rpms.pl - compiles cpan source contents as RPMs

# Scott Harrison, sharrison@users.sourceforge.net, 2002
# $Id: make_source_cpan_rpms.pl,v 1.1 2002/08/11 23:02:32 harris41 Exp $

# I am not using the CPAN.pm module because I do not want to introduce
# a software dependency.  There would also be the multiple versions of
# CPAN.pm on existing RH6.* and RH7.* machines to account for.

# Temporary directory.
my $sdir="tarballs/usr/local/cpansource/";

use RPM::Make;

# Get download location ready.
# `rm -Rf $sdir`;
`install -d $sdir`;

# Loop through and process the different cpan distributions.
open(IN,'<../../../loncom/build/system_dependencies/cpan_distributions.txt');
while(<IN>) {
    next if /^\#/;
    next unless /\S/;
    my ($dname,$dversion)=split(/\s+/);
    my $tag="cpansrc-$dname";
    $tag=~s/\-/\_/g;
    next if -e "$tag-$dversion-1.i386.rpm";
    `rm -f cpanpage.html`;
    `wget -nc -O cpanpage.html http://search.cpan.org/dist/$dname 2>\&1 > /dev/null`;
    $a=`cat cpanpage.html`;
    $a=~/href\=\"\/CPAN\/(.*?)\" title=Download/;
    my $tardownload=$1;
    $tardownload=~/\-([^\-]*)\.tar\.gz/;
    my $mostrecent=$1;
    my $tardownload2=$tardownload;
    $tardownload2=~s/\-([^\-]*)\.tar\.gz/-$dversion.tar.gz/;
    print "Most Recent=$mostrecent; Version requested=$dversion\n";
    print "Download... $tardownload2\n";
    `cd $sdir; wget -nc http://www.cpan.org/$tardownload2 2>\&1 > /dev/null`;
    if ($?) {
       print "**** ERROR **** Cannot find http://www.cpan.org/$tardownload2\n";
	exit(1);
    }
    $tardownload2=~/([^\/]*)$/;
    my $tarfile=$1;
    $tarfile=~/^(.*)\.tar\.gz/;
    my $tardir=$1;
    `cd $sdir; tar --no-same-owner -xzf $tarfile`;
    # Try and make an RPM.
    print "Vee shall try and make an RPM ya...\n";
    my @filelist=`cd $sdir; tar tzvf $tarfile`;
    my $tmptardir=$tardir;
    $tmptardir=~s/\-[^\-]*$//;
    foreach my $file (@filelist) {chomp $file;$file=~s/^.*?($tmptardir.*)/$1/;$file="$sdir/$file";print "file $file\n";}
    my %metadata=(
		  'vendor'=>'CPAN distribution processed by RPM-Tools',
		  'summary'=>"http://search.cpan.org/dist/$dname",
		  'name'=>$tag,
		  'copyrightname'=>'...',
		  'group'=>'Utilities/System',
		  'AutoReqProv'=>'no',
		  'requires'=>[('PreReq: setup',
				'PreReq: passwd',
				'PreReq: util-linux'
				)],
		  'description'=>'This package is generated by RPM::Make. '.                             'This implements the '.$tag.' software package',
               'pre'=>'echo "Installing CPAN source into /usr/local/cpansource/.  This is only the source of a CPAN distribution.  It is not compiled and will not yet add functionality to your system."',
		  );
    my %doc;
    my %conf;
    my %confnoreplace;
    my $version=$dversion;
    my $release=1;
    my $arch="i386";
    my $buildloc="TempBuildLoc";
    my $pathprefix="tarballs";
    RPM::Make::execute($tag,$version,$release,$arch,$buildloc,$pathprefix,
                              \@filelist,\%doc,\%conf,\%confnoreplace,
                              \%metadata);

}
close(IN);