From: Zdeněk Šustr Date: Wed, 14 Jul 2010 09:01:53 +0000 (+0000) Subject: A simple script to generate the contents of etics.properties based on versions checke... X-Git-Tag: glite-jobid-api-c_R_1_0_5_1~19 X-Git-Url: http://scientific.zcu.cz/git/?a=commitdiff_plain;h=498e93798aad659c1a7c57f6b79ceb26f2bfa42e;p=jra1mw.git A simple script to generate the contents of etics.properties based on versions checked out locally. --- diff --git a/org.glite.lb/generate-properties.pl b/org.glite.lb/generate-properties.pl new file mode 100644 index 0000000..e51d4fd --- /dev/null +++ b/org.glite.lb/generate-properties.pl @@ -0,0 +1,115 @@ +#!/usr/bin/perl +# +# Copyright (c) Members of the EGEE Collaboration. 2004-2010. +# See http://www.eu-egee.org/partners for details on the copyright holders. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +use Getopt::Std; +use Switch; + +$TMPDIR=$ENV{'TMPDIR'}; + +if ($TMPDIR eq "") {$TMPDIR="/tmp";} + + + +$usage = qq{ +usage: $0 [-p] -a|module.name [module.name ...] + + -h Display this help + -p Single line output for Etics web interface + -a Process all subdirectories in . rather than getting lists + +}; + +if ($#ARGV < 0) {die $usage}; + +getopts('pha'); + +if (defined $opt_h) {die $usage}; +if (defined $opt_p) { + $eq_separator = "="; + $pair_separator_back = " "; + $pair_separator_front = "-p "; } +else { + $eq_separator = " = "; + $pair_separator_back = "\n"; + $pair_separator_front = ""; } + +sub GetDefault { + # ********************************** + # Determine the most recent tag and its components from version.properties + # ********************************** + my($mname) = @_; + + unless (open VP, "$mname/project/version.properties") { + unless (defined $opt_a) { die "$mname/project/version.properties: $?\n"; } + else { return 1; } + } + + while ($_ = ) { + chomp; + + if(/module\.version\s*=\s*(\d*)\.(\d*)\.(\d*)/) { + $current_major=$1; + $current_minor=$2; + $current_revision=$3; + } + if(/module\.age\s*=\s*(\S+)/) { + $current_age=$1; + } + } + close (VP); + + $current_prefix=$mname; + $current_prefix=~s/^org\.//; + $current_prefix=~s/\./-/g; + $current_prefix="$current_prefix" . "_R_"; + $current_tag="$current_prefix" . "$current_major" . "_$current_minor" . "_$current_revision" . "_$current_age"; + + printf "$pair_separator_front$mname.DEFAULT$eq_separator$current_tag$pair_separator_back"; + +} + +if (defined $opt_a) { # All subdirectories + opendir(LOCAL, "."); + @contents = readdir(LOCAL); + closedir(LOCAL); + + foreach $f (@contents) { + unless ( ($f eq ".") || ($f eq "..") ) { + if (-d $f) { + GetDefault ($f); + } + } + } +} +else { # Listed subsystems + while ($module = shift) { + chomp($module); + #Clean possible trailing '/' (even multiple occurrences :-) from module name + $module=~s/\/+$//; + + $module=~/\.([^\.]+?)$/; + + @modules=split(/\s+/, `PATH=\$PATH:./:./org.glite.lb configure --listmodules $1`); + + foreach $m (@modules) { + GetDefault ($m); + } + } +} + +if (defined $opt_p) { printf "\n"; }