summaryrefslogtreecommitdiffstats
path: root/bin/devel-tools
diff options
context:
space:
mode:
Diffstat (limited to 'bin/devel-tools')
-rwxr-xr-xbin/devel-tools/determineMinimumPackageSet.pl154
-rwxr-xr-xbin/devel-tools/extractTranslations.pl242
-rwxr-xr-xbin/devel-tools/parseSusePatterns.pl152
3 files changed, 274 insertions, 274 deletions
diff --git a/bin/devel-tools/determineMinimumPackageSet.pl b/bin/devel-tools/determineMinimumPackageSet.pl
index e2747674..52d13fc5 100755
--- a/bin/devel-tools/determineMinimumPackageSet.pl
+++ b/bin/devel-tools/determineMinimumPackageSet.pl
@@ -28,26 +28,26 @@ use Getopt::Long;
use Pod::Usage;
my (
- $helpReq,
- $verbose,
- $versionReq,
+ $helpReq,
+ $verbose,
+ $versionReq,
- %pkgs,
- @leafPkgs,
+ %pkgs,
+ @leafPkgs,
);
my $rpmOutFile = "/tmp/minpkgset.rpmout";
my $rpmErrFile = "/tmp/minpkgset.rpmerr";
GetOptions(
- 'help|?' => \$helpReq,
- 'verbose' => \$verbose,
- 'version' => \$versionReq,
+ 'help|?' => \$helpReq,
+ 'verbose' => \$verbose,
+ 'version' => \$versionReq,
) or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
if ($versionReq) {
- system('slxversion');
- exit 1;
+ system('slxversion');
+ exit 1;
}
determineMinimumPackageSet();
@@ -60,90 +60,90 @@ exit;
sub slurpFile
{
- my $file = shift;
-
- my $fh;
- open($fh, '<', $file)
- or die _tr("could not open file '%s' for reading! (%s)", $file, $!);
- local $/ = undef;
- my $text = <$fh>;
- close($fh);
- return $text;
+ my $file = shift;
+
+ my $fh;
+ open($fh, '<', $file)
+ or die _tr("could not open file '%s' for reading! (%s)", $file, $!);
+ local $/ = undef;
+ my $text = <$fh>;
+ close($fh);
+ return $text;
}
sub rpmDie
{
- my $rpmCmd = shift;
-
- print "\n*** An error occurred when executing the following rpm-command:\n";
- print "\t$rpmCmd\n";
- my $err = slurpFile($rpmErrFile);
- print "*** The error was:\n";
- print "\t$err\n";
- exit 5;
+ my $rpmCmd = shift;
+
+ print "\n*** An error occurred when executing the following rpm-command:\n";
+ print "\t$rpmCmd\n";
+ my $err = slurpFile($rpmErrFile);
+ print "*** The error was:\n";
+ print "\t$err\n";
+ exit 5;
}
sub callRpm
{
- my $rpmCmd = shift;
+ my $rpmCmd = shift;
- my $res = system("$rpmCmd >$rpmOutFile 2>$rpmErrFile");
- exit 1 if ($res & 127); # child caught a signal
- rpmDie($rpmCmd) if -s $rpmErrFile;
- my $out = slurpFile($rpmOutFile);
- return ($res, $out);
+ my $res = system("$rpmCmd >$rpmOutFile 2>$rpmErrFile");
+ exit 1 if ($res & 127); # child caught a signal
+ rpmDie($rpmCmd) if -s $rpmErrFile;
+ my $out = slurpFile($rpmOutFile);
+ return ($res, $out);
}
sub handlePackage
{
- my $pkgName = shift;
-
- # if any other package requires it, the current package is not a leaf!
- print "\tdirectly required..." if $verbose;
- my ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --whatrequires "$pkgName"]);
- print $rpmRes ? "no\n" : "yes\n" if $verbose;
- return 0 unless $rpmRes;
-
- print "\tany of its provides required..." if $verbose;
- ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --provides "$pkgName"]);
- my $provides
- = join ' ',
- map {
- my $rpm = $_;
- $rpm =~ s[^\s*(.+?)\s*$][$1];
- qq["$rpm"];
- }
- split "\n", $rpmOut;
- ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --whatrequires $provides]);
- if ($rpmRes == 0) {
- # ignore if rpm tells us that a provides is required by
- # the package that provides it:
- $rpmRes = 1;
- while($rpmOut =~ m[^\s*(.+?)\s*]gm) {
- if ($1 ne $pkgName) {
- $rpmRes = 0;
- last;
- }
- }
- }
- print $rpmRes ? "no\n" : "yes\n" if $verbose;
- return 0 unless $rpmRes;
-
- print "!!! adding $pkgName\n" if $verbose;
- push @leafPkgs, $pkgName;
- return 1;
+ my $pkgName = shift;
+
+ # if any other package requires it, the current package is not a leaf!
+ print "\tdirectly required..." if $verbose;
+ my ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --whatrequires "$pkgName"]);
+ print $rpmRes ? "no\n" : "yes\n" if $verbose;
+ return 0 unless $rpmRes;
+
+ print "\tany of its provides required..." if $verbose;
+ ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --provides "$pkgName"]);
+ my $provides
+ = join ' ',
+ map {
+ my $rpm = $_;
+ $rpm =~ s[^\s*(.+?)\s*$][$1];
+ qq["$rpm"];
+ }
+ split "\n", $rpmOut;
+ ($rpmRes, $rpmOut) = callRpm(qq[rpm -q --whatrequires $provides]);
+ if ($rpmRes == 0) {
+ # ignore if rpm tells us that a provides is required by
+ # the package that provides it:
+ $rpmRes = 1;
+ while($rpmOut =~ m[^\s*(.+?)\s*]gm) {
+ if ($1 ne $pkgName) {
+ $rpmRes = 0;
+ last;
+ }
+ }
+ }
+ print $rpmRes ? "no\n" : "yes\n" if $verbose;
+ return 0 unless $rpmRes;
+
+ print "!!! adding $pkgName\n" if $verbose;
+ push @leafPkgs, $pkgName;
+ return 1;
}
sub determineMinimumPackageSet
{
- my ($rpmRes, $allPkgs)
- = callRpm(qq[rpm -qa --queryformat "%{NAME}\n"]);
- foreach my $p (sort split "\n", $allPkgs) {
- print "$p...\n" if $verbose;
- print "." unless $verbose;
- handlePackage($p);
- }
- return;
+ my ($rpmRes, $allPkgs)
+ = callRpm(qq[rpm -qa --queryformat "%{NAME}\n"]);
+ foreach my $p (sort split "\n", $allPkgs) {
+ print "$p...\n" if $verbose;
+ print "." unless $verbose;
+ handlePackage($p);
+ }
+ return;
}
__END__
diff --git a/bin/devel-tools/extractTranslations.pl b/bin/devel-tools/extractTranslations.pl
index eab71f04..789a70ad 100755
--- a/bin/devel-tools/extractTranslations.pl
+++ b/bin/devel-tools/extractTranslations.pl
@@ -11,8 +11,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# extractTranslations.pl
-# - OpenSLX-script to extract translatable strings from other scripts
-# and modules.
+# - OpenSLX-script to extract translatable strings from other scripts
+# and modules.
# -----------------------------------------------------------------------------
use strict;
use warnings;
@@ -36,34 +36,34 @@ use Pod::Usage;
use OpenSLX::Utils;
my (
- $helpReq,
- $show,
- $update,
- $verbose,
- $versionReq,
-
- %translatableStrings,
- $fileCount,
+ $helpReq,
+ $show,
+ $update,
+ $verbose,
+ $versionReq,
+
+ %translatableStrings,
+ $fileCount,
);
GetOptions(
- 'help|?' => \$helpReq,
- 'update' => \$update,
- 'show' => \$show,
- 'verbose' => \$verbose,
- 'version' => \$versionReq,
+ 'help|?' => \$helpReq,
+ 'update' => \$update,
+ 'show' => \$show,
+ 'verbose' => \$verbose,
+ 'version' => \$versionReq,
) or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
if ($versionReq) {
- system('slxversion');
- exit 1;
+ system('slxversion');
+ exit 1;
}
# chdir to the repository's root folder:
use FindBin;
my $path = "$FindBin::RealBin/../..";
chdir($path)
- or die "can't chdir to repository-root <$path> ($!)";
+ or die "can't chdir to repository-root <$path> ($!)";
print "searching in ".cwd()."\n";
find(\&ExtractTrStrings, '.');
@@ -72,122 +72,122 @@ my $trCount = scalar keys %translatableStrings;
print "Found $trCount translatable strings in $fileCount files.\n";
if ($show) {
- foreach my $tr (sort {lc($a) cmp lc($b)} keys %translatableStrings) {
- print "\tqq{$tr}\n\t\t=> qq{$tr}\n";
- }
+ foreach my $tr (sort {lc($a) cmp lc($b)} keys %translatableStrings) {
+ print "\tqq{$tr}\n\t\t=> qq{$tr}\n";
+ }
}
if ($update) {
- find(\&UpdateTrModule, 'lib/OpenSLX/Translations');
+ find(\&UpdateTrModule, 'lib/OpenSLX/Translations');
}
exit;
sub ExtractTrStrings
{
- $File::Find::prune = 1 if ($_ eq '.svn'
- || $_ eq 'Translations'
- || $_ eq 'devel-tools');
- return if -d;
- my $text = slurpFile($_);
- if ($File::Find::name !~ m[\.pm$] && $text !~ m[^#!.+/perl]im) {
- # ignore anything other than perl-modules and -scripts
- return;
- }
- print "$File::Find::name...\n";
- $fileCount++;
- while($text =~ m[_tr\s*\(\s*(.+?)\s*\);]gos) {
- # NOTE: that cheesy regex relies on the string ');' not being used
- # inside of translatable strings... so SLX_DONT_DO_THAT!
- # As an alternative, we could implement a real parser, but
- # I'd like to postpone that until the current scheme proves
- # simply not good enough.
- my $tr = $1;
- if (!($tr =~ m[^'([^']+)'\s*(,.+?)*\s*$]os
- || $tr =~ m[^\"([^"]+)\"\s*(,.+?)*\s*$]os
- || $tr =~ m{^qq?\[([^\]]+)\]\s*(,.+?)*\s*$}os)) {
- die "$File::Find::name: could not parse _tr()-argument \n"
- ."\t$tr\nPlease correct and retry.\n";
- }
- $tr = $1;
- if ($tr =~ m[(\$\w+)]) {
- die "$File::Find::name: _tr()-argument\n\t$tr\n"
- ."contains variable '$1'.\nPlease correct and retry.\n";
- }
- $tr =~ s[\n][\\n]g;
- $tr =~ s[\t][\\t]g;
- $translatableStrings{$tr} = $tr;
- print "\t$tr\n" if $verbose;
- }
+ $File::Find::prune = 1 if ($_ eq '.svn'
+ || $_ eq 'Translations'
+ || $_ eq 'devel-tools');
+ return if -d;
+ my $text = slurpFile($_);
+ if ($File::Find::name !~ m[\.pm$] && $text !~ m[^#!.+/perl]im) {
+ # ignore anything other than perl-modules and -scripts
+ return;
+ }
+ print "$File::Find::name...\n";
+ $fileCount++;
+ while($text =~ m[_tr\s*\(\s*(.+?)\s*\);]gos) {
+ # NOTE: that cheesy regex relies on the string ');' not being used
+ # inside of translatable strings... so SLX_DONT_DO_THAT!
+ # As an alternative, we could implement a real parser, but
+ # I'd like to postpone that until the current scheme proves
+ # simply not good enough.
+ my $tr = $1;
+ if (!($tr =~ m[^'([^']+)'\s*(,.+?)*\s*$]os
+ || $tr =~ m[^\"([^"]+)\"\s*(,.+?)*\s*$]os
+ || $tr =~ m{^qq?\[([^\]]+)\]\s*(,.+?)*\s*$}os)) {
+ die "$File::Find::name: could not parse _tr()-argument \n"
+ ."\t$tr\nPlease correct and retry.\n";
+ }
+ $tr = $1;
+ if ($tr =~ m[(\$\w+)]) {
+ die "$File::Find::name: _tr()-argument\n\t$tr\n"
+ ."contains variable '$1'.\nPlease correct and retry.\n";
+ }
+ $tr =~ s[\n][\\n]g;
+ $tr =~ s[\t][\\t]g;
+ $translatableStrings{$tr} = $tr;
+ print "\t$tr\n" if $verbose;
+ }
}
sub UpdateTrModule
{
- $File::Find::prune = 1 if ($_ eq '.svn');
- return if -d || !/.pm$/;
- print "updating $File::Find::name...\n";
- my $trModule = $_;
- my $useKeyAsTranslation = ($trModule eq 'posix.pm');
- my $text = slurpFile($trModule);
- if ($text !~ m[%translations\s*=\s*\(\s*(.+)\s*\);]os) {
- print "\t*** No translations found - file will be skipped! ***\n";
- return;
- }
- my %translations;
- # evaluate the hash read from file into %translations:
- if (!eval "$&") {
- print "\t*** translations can't be evaluated - file will be skipped! ***\n";
- return;
- }
- my $updatedTranslations = "%translations = (\n";
- my $keepCount = 0;
- my $newCount = 0;
- foreach my $tr (sort {lc($a) cmp lc($b)} keys %translatableStrings) {
- if (!length($translations{$tr})) {
- if ($useKeyAsTranslation) {
- # POSIX language (English): use key as translation:
- $updatedTranslations
- .= "\tq{$tr}\n\t=>\n\tqq{$tr},\n\n";
- $newCount++;
- } else {
- # no translation available, we mark the key, such that a
- # search for this key will fall back to the english message:
- my $trMark = "NEW:$tr";
- if (exists $translations{$trMark}) {
- # the marked string already exists, we keep the translation
- # if any (usually, of course, there is none):
- my $trValue = $translations{$trMark};
- $trValue =~ s[\n][\\n]g;
- $trValue =~ s[\t][\\t]g;
- $updatedTranslations
- .= "\tq{$trMark}\n\t=>\n\tqq{$trValue},\n\n";
- $keepCount++;
- } else {
- $updatedTranslations
- .= "\tq{$trMark}\n\t=>\n\tqq{},\n\n";
- $newCount++;
- }
- }
- } else {
- # use existing translation for key:
- my $trValue = $translations{$tr};
- $trValue =~ s[\n][\\n]g;
- $trValue =~ s[\t][\\t]g;
- $updatedTranslations
- .= "\tq{$tr}\n\t=>\n\tqq{$trValue},\n\n";
- $keepCount++;
- }
- }
- my $delCount = scalar(keys %translations) - $keepCount;
- $text =~ s[%translations\s*=\s*\(\s*(.+)\s*\);]
- [$updatedTranslations);]os;
- if ($newCount + $delCount) {
- chomp $text;
- spitFile($trModule, $text."\n");
- print "\tadded $newCount strings, kept $keepCount and removed $delCount.\n";
- } else {
- print "\tnothing changed\n";
- }
+ $File::Find::prune = 1 if ($_ eq '.svn');
+ return if -d || !/.pm$/;
+ print "updating $File::Find::name...\n";
+ my $trModule = $_;
+ my $useKeyAsTranslation = ($trModule eq 'posix.pm');
+ my $text = slurpFile($trModule);
+ if ($text !~ m[%translations\s*=\s*\(\s*(.+)\s*\);]os) {
+ print "\t*** No translations found - file will be skipped! ***\n";
+ return;
+ }
+ my %translations;
+ # evaluate the hash read from file into %translations:
+ if (!eval "$&") {
+ print "\t*** translations can't be evaluated - file will be skipped! ***\n";
+ return;
+ }
+ my $updatedTranslations = "%translations = (\n";
+ my $keepCount = 0;
+ my $newCount = 0;
+ foreach my $tr (sort {lc($a) cmp lc($b)} keys %translatableStrings) {
+ if (!length($translations{$tr})) {
+ if ($useKeyAsTranslation) {
+ # POSIX language (English): use key as translation:
+ $updatedTranslations
+ .= "\tq{$tr}\n\t=>\n\tqq{$tr},\n\n";
+ $newCount++;
+ } else {
+ # no translation available, we mark the key, such that a
+ # search for this key will fall back to the english message:
+ my $trMark = "NEW:$tr";
+ if (exists $translations{$trMark}) {
+ # the marked string already exists, we keep the translation
+ # if any (usually, of course, there is none):
+ my $trValue = $translations{$trMark};
+ $trValue =~ s[\n][\\n]g;
+ $trValue =~ s[\t][\\t]g;
+ $updatedTranslations
+ .= "\tq{$trMark}\n\t=>\n\tqq{$trValue},\n\n";
+ $keepCount++;
+ } else {
+ $updatedTranslations
+ .= "\tq{$trMark}\n\t=>\n\tqq{},\n\n";
+ $newCount++;
+ }
+ }
+ } else {
+ # use existing translation for key:
+ my $trValue = $translations{$tr};
+ $trValue =~ s[\n][\\n]g;
+ $trValue =~ s[\t][\\t]g;
+ $updatedTranslations
+ .= "\tq{$tr}\n\t=>\n\tqq{$trValue},\n\n";
+ $keepCount++;
+ }
+ }
+ my $delCount = scalar(keys %translations) - $keepCount;
+ $text =~ s[%translations\s*=\s*\(\s*(.+)\s*\);]
+ [$updatedTranslations);]os;
+ if ($newCount + $delCount) {
+ chomp $text;
+ spitFile($trModule, $text."\n");
+ print "\tadded $newCount strings, kept $keepCount and removed $delCount.\n";
+ } else {
+ print "\tnothing changed\n";
+ }
}
__END__
diff --git a/bin/devel-tools/parseSusePatterns.pl b/bin/devel-tools/parseSusePatterns.pl
index 317a9c47..a286cd71 100755
--- a/bin/devel-tools/parseSusePatterns.pl
+++ b/bin/devel-tools/parseSusePatterns.pl
@@ -11,8 +11,8 @@
# General information about OpenSLX can be found at http://openslx.org/
# -----------------------------------------------------------------------------
# parseSusePatterns.pl
-# - OpenSLX script to extract a package list from a given list of
-# SUSE-pattern-files (*.pat).
+# - OpenSLX script to extract a package list from a given list of
+# SUSE-pattern-files (*.pat).
# -----------------------------------------------------------------------------
use strict;
use warnings;
@@ -27,30 +27,30 @@ use Getopt::Long;
use Pod::Usage;
my (
- $helpReq,
- $versionReq,
+ $helpReq,
+ $versionReq,
- %patternNames,
- %packageNames,
+ %patternNames,
+ %packageNames,
);
GetOptions(
- 'help|?' => \$helpReq,
- 'version' => \$versionReq,
+ 'help|?' => \$helpReq,
+ 'version' => \$versionReq,
) or pod2usage(2);
pod2usage(-msg => $abstract, -verbose => 0, -exitval => 1) if $helpReq;
if ($versionReq) {
- system('slxversion');
- exit 1;
+ system('slxversion');
+ exit 1;
}
if ($ARGV[0] !~ m[^(\w+)-(.+)$]) {
- die "can't extract architecture from pattern file name '$ARGV[0]'";
+ die "can't extract architecture from pattern file name '$ARGV[0]'";
}
my $arch = $2;
foreach my $patternFile (@ARGV) {
- parsePatternFile($patternFile, 1);
+ parsePatternFile($patternFile, 1);
}
print join("\n", sort keys %packageNames)."\n";
@@ -59,78 +59,78 @@ exit;
sub parsePatternFile
{
- my $patternFile = shift;
- my $outmost = shift;
-
- my $patFH;
- if (!open($patFH, '<', $patternFile)) {
- return unless $outmost;
- die "unable to open $patternFile";
- }
- undef $/;
- my $content = <$patFH>;
- close($patFH);
- $patternNames{$patternFile} = 1;
-
- if ($content =~ m[^\=Sum.de:\s*(.+?)\s*$]ms) {
- print "+ $1\n";
- }
- if ($content =~ m[^\+Sug:\s*?$(.+?)^\-Sug:\s*?$]ms) {
- addSubPatterns($1);
- }
- if ($content =~ m[^\+Req:\s*?$(.+?)^\-Req:\s*?$]ms) {
- addSubPatterns($1);
- }
- if ($content =~ m[^\+Rec:\s*?$(.+?)^\-Rec:\s*?$]ms) {
- addSubPatterns($1);
- }
- if ($content =~ m[^\+Prq:\s*?$(.+?)^\-Prq:\s*?$]ms) {
- addPkgNames($1);
- }
- if ($content =~ m[^\+Prc:\s*?$(.+?)^\-Prc:\s*?$]ms) {
- addPkgNames($1);
- }
- return;
+ my $patternFile = shift;
+ my $outmost = shift;
+
+ my $patFH;
+ if (!open($patFH, '<', $patternFile)) {
+ return unless $outmost;
+ die "unable to open $patternFile";
+ }
+ undef $/;
+ my $content = <$patFH>;
+ close($patFH);
+ $patternNames{$patternFile} = 1;
+
+ if ($content =~ m[^\=Sum.de:\s*(.+?)\s*$]ms) {
+ print "+ $1\n";
+ }
+ if ($content =~ m[^\+Sug:\s*?$(.+?)^\-Sug:\s*?$]ms) {
+ addSubPatterns($1);
+ }
+ if ($content =~ m[^\+Req:\s*?$(.+?)^\-Req:\s*?$]ms) {
+ addSubPatterns($1);
+ }
+ if ($content =~ m[^\+Rec:\s*?$(.+?)^\-Rec:\s*?$]ms) {
+ addSubPatterns($1);
+ }
+ if ($content =~ m[^\+Prq:\s*?$(.+?)^\-Prq:\s*?$]ms) {
+ addPkgNames($1);
+ }
+ if ($content =~ m[^\+Prc:\s*?$(.+?)^\-Prc:\s*?$]ms) {
+ addPkgNames($1);
+ }
+ return;
}
sub addSubPatterns
{
- my $patternNames = shift;
-
- my @subPatterns
- = grep { length($_) > 0 }
- map {
- my $pattern = $_;
- $pattern =~ s[^\s*(.+?)\s*$][$1];
- $pattern;
- }
- split "\n", $patternNames;
-
- foreach my $subPattern (@subPatterns) {
- my $subPatternFile = "$subPattern-$arch";
- if (!exists $patternNames{$subPatternFile}) {
- parsePatternFile($subPatternFile);
- }
- }
- return;
+ my $patternNames = shift;
+
+ my @subPatterns
+ = grep { length($_) > 0 }
+ map {
+ my $pattern = $_;
+ $pattern =~ s[^\s*(.+?)\s*$][$1];
+ $pattern;
+ }
+ split "\n", $patternNames;
+
+ foreach my $subPattern (@subPatterns) {
+ my $subPatternFile = "$subPattern-$arch";
+ if (!exists $patternNames{$subPatternFile}) {
+ parsePatternFile($subPatternFile);
+ }
+ }
+ return;
}
sub addPkgNames
{
- my $pkgs = shift;
-
- my @pkgNames
- = grep { length($_) > 0 }
- map {
- my $pkg = $_;
- $pkg =~ s[^\s*(.+?)\s*$][$1];
- $pkg;
- }
- split "\n", $pkgs;
- foreach my $pkgName (@pkgNames) {
- $packageNames{$pkgName} = 1;
- }
- return;
+ my $pkgs = shift;
+
+ my @pkgNames
+ = grep { length($_) > 0 }
+ map {
+ my $pkg = $_;
+ $pkg =~ s[^\s*(.+?)\s*$][$1];
+ $pkg;
+ }
+ split "\n", $pkgs;
+ foreach my $pkgName (@pkgNames) {
+ $packageNames{$pkgName} = 1;
+ }
+ return;
}
=head1 NAME