[LON-CAPA-cvs] cvs: modules /matthew/LON-CAPA_rpm buildnew.fc2.pl

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 23 Mar 2005 23:38:53 -0000


matthew		Wed Mar 23 18:38:53 2005 EDT

  Added files:                 
    /modules/matthew/LON-CAPA_rpm	buildnew.fc2.pl 
  Log:
  Modified version of buildnew.pl to deal with fc2 spec file instead.
  
  

Index: modules/matthew/LON-CAPA_rpm/buildnew.fc2.pl
+++ modules/matthew/LON-CAPA_rpm/buildnew.fc2.pl
#!/usr/bin/perl -w
#
# build a new version of the LONCAPA-prerequisites rpm
# greps the specfile for the version and release information.
#
# Quick and dirty.  Feel free to clean it up if/when it bothers you.
#
# Must be run as root, unless you change the $rpmbuilddir below...
#

use strict;
use File::Copy;

my $rpmbuilddir = '/usr/src/redhat/';
my $srcdir = $rpmbuilddir.'SOURCES/';
my $rpmdir = $rpmbuilddir.'RPMS/i386/';
my $srpmdir = $rpmbuilddir.'SRPMS/';
my $specdir = $rpmbuilddir.'SPECS/';

my $name = 'LONCAPA-prerequisites';
my $specfile = $name.'.fc2.spec';

my $version = `grep '^Version:' $specfile`;
$version =~ s/^Version: (.*)\s*$/$1/;
my $release = `grep '^Release:' $specfile`;
$release =~ s/^Release: (.*)\s*$/$1/;

my $olddir = $name;
my $dirname = $name.'-'.$version;
my $rpmname = $name.'-'.$version.'-'.$release.'.i386.rpm';
my $rpmfile = $rpmdir.$rpmname;

my $srcname = $name.'-'.$version.'-'.$release.'.src.rpm';
my $srcrpm  = $srpmdir.$srcname;
my $tarball = $dirname.'.tar.gz';

if (-e $rpmfile) { unlink($rpmfile); }
if (-e $srcrpm ) { unlink($srcrpm); }

if (-e $dirname) {
    if (-l $dirname) {
        unlink($dirname);
    } else {
        die "$dirname already exists and is not a symbolic link";
    }
}

system("ln -s $olddir $dirname");
system("tar zcf $tarball $dirname --dereference --exclude $dirname/CVS");

copy($tarball,$srcdir);

system("rpmbuild -bb $specfile");
system("rpmbuild -bs $specfile");
copy($rpmfile,'.');
unlink($rpmfile);
copy($srcrpm,'.');
print $srcrpm.$/;