[LON-CAPA-cvs] cvs: modules /matthew/LON-CAPA_rpm buildnew.pl
matthew
lon-capa-cvs@mail.lon-capa.org
Thu, 05 Aug 2004 19:13:16 -0000
matthew Thu Aug 5 15:13:16 2004 EDT
Added files:
/modules/matthew/LON-CAPA_rpm buildnew.pl
Log:
Silly script to build a new rpm. Run it as root.
Index: modules/matthew/LON-CAPA_rpm/buildnew.pl
+++ modules/matthew/LON-CAPA_rpm/buildnew.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 $specdir = $rpmbuilddir.'SPECS/';
my $name = 'LONCAPA-prerequisites';
my $specfile = $name.'.spec';
my $version = `grep '^Version:' $specfile`;
$version =~ s/^Version: (\w+)\s*$/$1/;
my $release = `grep '^Release:' $specfile`;
$release =~ s/^Release: (\w+)\s*$/$1/;
my $olddir = $name;
my $dirname = $name.'-'.$version;
my $rpmname = $name.'-'.$version.'-'.$release.'.i386.rpm';
my $rpmfile = $rpmdir.$rpmname;
my $tarball = $dirname.'.tar.gz';
if (-e $rpmfile) {
unlink($rpmfile);
}
system("ln -s $olddir $dirname");
system("tar zcf $tarball $dirname --dereference --exclude $dirname/CVS");
copy($tarball,$srcdir);
system("rpmbuild -bb $specfile");
copy($rpmfile,'.');
unlink($rpmfile);