perfsonar-dev - perfsonar: r3683 - branches/rpm
Subject: perfsonar development work
List archive
- From:
- To:
- Subject: perfsonar: r3683 - branches/rpm
- Date: Wed, 16 Apr 2008 03:50:22 -0400
Author: fernandes
Date: 2008-04-16 03:50:22 -0400 (Wed, 16 Apr 2008)
New Revision: 3683
Modified:
branches/rpm/package_maker.pl
Log:
New version of the package maker script
# v0.2:
# - RPM packages now install services in /opt/perfsonar/services
# - Services are added to tomcat's context by symlinks in tomcat's webapps
directory
# (no modification done to server.xml)
# - Service description can now be given in multiple lines.
Modified: branches/rpm/package_maker.pl
===================================================================
--- branches/rpm/package_maker.pl 2008-04-16 01:54:22 UTC (rev 3682)
+++ branches/rpm/package_maker.pl 2008-04-16 07:50:22 UTC (rev 3683)
@@ -1,5 +1,17 @@
#!/usr/bin/perl
+# Author: Guilherme Fernandes
<>
+# Version: 0.2
+# Contributions: Gijs Molenaar
<>
(RPM SPECS file template)
+#
+# Changelog:
+#
+# v0.2:
+# - RPM packages now install services in /opt/perfsonar/services
+# - Services are added to tomcat's context by symlinks in tomcat's webapps
directory
+# (no modification done to server.xml)
+# - Service description can now be given in multiple lines.
+
use strict;
my $serviceSummary;
@@ -7,11 +19,11 @@
my $serviceVersion;
my $serviceMaintainer;
my $serviceDependencies;
-my $serviceDescription;
+my $serviceArch = 'noarch';
my $packageType;
+my @serviceDescription;
my @serviceMessage;
my @directoryListing;
-my @fileListing;
print "-- perfSONAR web services package maker --\n";
@@ -23,7 +35,7 @@
if($packageType eq "rpm"){
getFilesListing();
createRpmBuildTree();
- chdir("rpm");
+ chdir("rpmbuild");
createSpecFile();
createSourceFile();
buildRpm();
@@ -60,7 +72,10 @@
print "Maintainer: $serviceMaintainer\n";
print "Depends: $serviceDependencies\n"; #TODO: Check depends
print "Description: $serviceSummary\n";
- print " $serviceDescription\n";
+ for my $messageLine (@serviceDescription){
+ $messageLine =~ s/"/\\"/g;
+ print "$messageLine\n";
+ }
close(CONTROLFILE);
select STDOUT;
}
@@ -98,6 +113,7 @@
sub getLastServiceInfo(){
open(INFOFILE, "< .package_maker.info") or return;
my $readingServiceMessage;
+ my $readingServiceDesc;
while(<INFOFILE>){
if($readingServiceMessage){
if(/^\.$/){
@@ -106,6 +122,13 @@
chomp($_);
push(@serviceMessage, $_);
}
+ }elsif($readingServiceDesc){
+ if(/^\.$/){
+ undef $readingServiceDesc;
+ }else{
+ chomp($_);
+ push(@serviceDescription, $_);
+ }
}elsif(/^serviceSummary=(.*)$/){
$serviceSummary = $1;
}elsif(/^serviceName=(.*)$/){
@@ -117,7 +140,9 @@
}elsif(/^serviceDependencies=(.*)$/){
$serviceDependencies = $1;
}elsif(/^serviceDescription=(.*)$/){
- $serviceDescription = $1;
+ $readingServiceDesc = '1';
+ }elsif(/^serviceArch=(.*)$/){
+ $serviceArch = $1;
}elsif(/^serviceMessage=(.*)$/){
$readingServiceMessage = '1';
}
@@ -133,7 +158,12 @@
print "serviceVersion=$serviceVersion\n";
print "serviceMaintainer=$serviceMaintainer\n";
print "serviceDependencies=$serviceDependencies\n";
- print "serviceDescription=$serviceDescription\n";
+ print "serviceArch: $serviceArch\n";
+ print "serviceDescription=\n";
+ for my $line (@serviceDescription){
+ print $line."\n";
+ }
+ print ".\n";
print "serviceMessage=\n";
for my $line (@serviceMessage){
print $line."\n";
@@ -166,6 +196,13 @@
$serviceDependencies = $answer;
}
+ print "Enter the architecture for this package [$serviceArch]: ";
+ $answer = <STDIN>;
+ chomp($answer);
+ if($answer){
+ $serviceArch = $answer;
+ }
+
print "Enter service maintainer (e.g. Me
<me\@mail.com>)
[$serviceMaintainer]: ";
$answer = <STDIN>;
chomp($answer);
@@ -180,11 +217,20 @@
$serviceSummary = $answer;
}
- print "Enter service description [$serviceDescription]: ";
+ print "Last entered service description: \n";
+ for my $line (@serviceDescription){
+ print $line . "\n";
+ }
+ print "Use that one (y/n) [n]?";
$answer = <STDIN>;
- chomp($answer);
- if($answer){
- $serviceDescription = $answer;
+ if (!($answer =~ /^y$/)){
+ print "Enter service description (end with a single dot): \n";
+ undef @serviceDescription;
+ while ( <STDIN> ) {
+ last if /^.$/;
+ chomp $_;
+ push @serviceDescription, $_;
+ }
}
print "Last entered message to user after installation: \n";
@@ -227,8 +273,13 @@
}
sub getFilesListing(){
- @directoryListing = `find webapps -type d`;
- @fileListing = `find webapps -type f`;
+ if(!chdir("webapps/$serviceName-$serviceVersion")){
+ print "Couldn't change directories to
webapps/$serviceName-$serviceVersion.\n";
+ print "Are you sure you have the right setup? Check build-guide for
more information.\n";
+ exit;
+ }
+ @directoryListing = `find WEB-INF/classes/perfsonar -type d`;
+ chdir("../..");
}
sub printPostScript(){
@@ -296,87 +347,124 @@
sub createSpecFile(){
open( SPECFILE, "> SPECS/$serviceName-$serviceVersion.spec" );
select SPECFILE;
-
- print "Summary: $serviceSummary\n";
+ print "\%define base /opt/perfsonar\n";
+ print "\%define prefix \%{base}/services/\%{name}\n";
+ print "\n";
print "Name: ".lc($serviceName)."\n";
print "Version: $serviceVersion\n";
+ print "License: GPL\n";
print "Release: 1\n";
- print "License: GPL\n";
+ print "Summary: $serviceSummary\n";
+ print "Source0: \%{name}-\%{version}.tar.gz\n";
+ print "BuildRoot: \%{_tmppath}/\%{name}-\%{version}-\%{release}\n";
print "Group: Network/Web service\n";
- print "Source: $serviceName-$serviceVersion.tar.gz\n";
- print "Prefix: /home/perfsonar\n";
+ print "Packager: $serviceMaintainer\n";
+ print "URL: http://www.perfsonar.org\n";
print "Requires: $serviceDependencies\n";
- print "Packager: $serviceMaintainer\n";
+ print "BuildArch: $serviceArch\n";
print "\n";
print "\%description\n";
- print "$serviceDescription\n";
+ for my $messageLine (@serviceDescription){
+ $messageLine =~ s/"/\\"/g;
+ print "$messageLine\n";
+ }
print "\n";
print "\%prep\n";
- print "\%setup\n";
+ print "\%{__rm} -rf \${RPM_BUILD_DIR}/\%{name}-\%{version}\n";
+ print "\%setup -q\n";
+ print "\n";
print "\%build\n";
+ print "\n";
print "\%install\n";
+ print "# make the directory\n";
+ print "rm -rf \$RPM_BUILD_ROOT\n";
+ print "\%{__install} -d -m 755 \${RPM_BUILD_ROOT}\%{prefix}\n";
+ print "# copy the service content to the tomcat webapps directory\n";
+ print "pushd \${RPM_BUILD_DIR}/\%{name}-\%{version}\n";
+ print " \%{__cp} -a $serviceName-\%{version}/*
\${RPM_BUILD_ROOT}\%{prefix}\n";
+ print "popd\n";
print "\n";
print "\%post\n";
- print "ln -fns /home/perfsonar/webapps/$serviceName-$serviceVersion
/home/perfsonar/webapps/$serviceName\n";
+ print "# make symlink so service shows up in tomcat\n";
+ print "\%{__ln_s} \%{prefix} \%{base}/tomcat/webapps/\%{name}\n";
+ print "echo \"\"\n";
+ for my $messageLine (@serviceMessage){
+ $messageLine =~ s/"/\\"/g;
+ print "echo \"$messageLine\"\n";
+ }
print "\n";
- print "if [ \$1 -eq 1 ]; then\n";
- printPostScript();
- print "fi\n";
- print "chown -R perfsonar:perfsonar /home/perfsonar/webapps
/home/perfsonar/perfsonar-tomcat\n";
+ print "\%preun\n";
+ print "## remove symlink\n";
+ print "\%{__rm} -rf \%{base}/tomcat/webapps/\%{name}\n";
print "\n";
- print "\%postun\n";
- print "if [ \$1 -eq 0 ]; then\n";
- printPostRmScript();
- print "\n";
+ print "%clean\n";
+ print "# clean up the durt\n";
+ print "rm -rf \$RPM_BUILD_ROOT\n";
+ print "\n";
print "\%files\n";
- print "\%defattr(-,perfsonar,perfsonar,-)\n";
- print "\n";
- for my $directory (@directoryListing){
+ print "\%defattr(0644,root,perfsonar,0755)\n";
+ print "\%config(noreplace)
\%{prefix}/WEB-INF/classes/perfsonar/conf/*.properties\n";
+ print "\%{prefix}\n";
+ print "\%attr(640,perfsonar,perfsonar)
\%{prefix}/WEB-INF/classes/perfsonar\n";
+ print "\%attr(755,perfsonar,perfsonar) \%dir
\%{prefix}/WEB-INF/logs\n";
+ for my $directory (@directoryListing){
chomp $directory;
- print "\%dir %{prefix}/$directory\n";
+ print "\%attr(755,perfsonar,perfsonar) \%dir
\%{prefix}/$directory\n";
}
- for my $file (@fileListing){
- chomp $file;
- print "%{prefix}/$file\n";
- }
+ print "\n";
select STDOUT;
close SPECFILE;
}
sub createSourceFile(){
- unless(-d lc($serviceName)."-$serviceVersion"){
+ if(!(-d lc($serviceName)."-$serviceVersion")){
if( system("mkdir ".lc($serviceName)."-$serviceVersion") != 0 ){
print "There was a problem creating the source file directory
(which will have the webapps directory inside it).\n";
print "Try doing it manually (mkdir
".lc($serviceName)."-$serviceVersion) and check what's wrong.\n";
exit;
}
+ }else{
+ if( system("rm -rf ".lc($serviceName)."-$serviceVersion/*")
!= 0 ){
+ print "There was a problem cleaning the source file
directory.\n";
+ print "Try doing it manually (rm -rf
".lc($serviceName)."-$serviceVersion)/* and check what's wrong.\n";
+ exit;
+ }
}
- if( system("tar -zcvf SOURCES/$serviceName-$serviceVersion.tar.gz
".lc($serviceName)."-$serviceVersion") != 0 ){
+ if( system("cp -R ../webapps/* ".lc($serviceName)."-$serviceVersion/
&> /dev/null") != 0 ){
+ print "There was a problem copying the webapps directory's
content.\n";
+ print "Try doing it manually (cp -R webapps/*
rpmbuild/".lc($serviceName)."-$serviceVersion/ and check what's wrong.\n";
+ exit;
+ }
+
+ if( system("tar -zcf SOURCES/".lc($serviceName)."-$serviceVersion.tar.gz
".lc($serviceName)."-$serviceVersion") != 0 ){
print "There was a problem creating the source file (it is a tar.gz
of the webapps directory)\n";
- print "Try doing it manually (tar -zcvf
$serviceName-$serviceVersion.tar.gz webapps) and check what's wrong.\n";
+ print "Try doing it manually (tar -zcf
rpmbuild/SOURCES/$serviceName-$serviceVersion.tar.gz ";
+ print "rpmbuild/".lc($serviceName)."-$serviceVersion) and check
what's wrong.\n";
exit;
}
}
sub createRpmBuildTree(){
- open( RPMMACROS, "> .rpmmacros");
- print RPMMACROS "\%_topdir /home/perfsonar/rpm\n";
- print RPMMACROS "\%_tmppath /home/perfsonar/rpm/tmp";
+ my $currdir = `pwd`;
+
+ open( RPMMACROS, "> ~/.rpmmacros");
+ print RPMMACROS "\%_topdir $currdir/rpmbuild\n";
+ print RPMMACROS "\%_tmppath $currdir/rpmbuild/TMP";
close RPMMACROS;
- unless(-d "rpm/SPECS"){
- system("mkdir -p rpm/tmp");
- system("mkdir rpm/BUILD");
- system("mkdir rpm/RPMS");
- system("mkdir rpm/SOURCES");
- system("mkdir rpm/SPECS");
- system("mkdir rpm/SRPMS");
+ unless(-d "rpmbuild/SPECS"){
+ system("mkdir -p rpmbuild/TMP");
+ system("mkdir rpmbuild/BUILD");
+ system("mkdir rpmbuild/RPMS");
+ system("mkdir rpmbuild/SOURCES");
+ system("mkdir rpmbuild/SPECS");
+ system("mkdir rpmbuild/SRPMS");
}
}
sub buildRpm(){
- `rpmbuild -ba SPECS/$serviceName-$serviceVersion.spec`;
+ `rpmbuild -bb SPECS/$serviceName-$serviceVersion.spec`;
}
- perfsonar: r3683 - branches/rpm, svnlog, 04/16/2008
Archive powered by MHonArc 2.6.16.