From cfd087f5ce8e31cc42747a35a6248265123383e7 Mon Sep 17 00:00:00 2001 From: Guillaume Rousse Date: Tue, 29 Jan 2008 21:13:16 +0000 Subject: rename translate_menu.pl to translate_menu, for consistency --- spec-helper.macros.in | 2 +- translate_menu | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++ translate_menu.pl | 72 --------------------------------------------------- 3 files changed, 73 insertions(+), 73 deletions(-) create mode 100755 translate_menu delete mode 100755 translate_menu.pl diff --git a/spec-helper.macros.in b/spec-helper.macros.in index 3182852..23914d4 100644 --- a/spec-helper.macros.in +++ b/spec-helper.macros.in @@ -11,7 +11,7 @@ %{?!dont_symlinks_libs: [ -n "$DONT_SYMLINK_LIBS" ] || %_spec_helper_dir/lib_symlinks} \ %{?!dont_gprintify: [ -n "$DONT_GPRINTIFY" ] || %_spec_helper_dir/gprintify} \ %{?!dont_fix_mo: [ -n "$DONT_FIX_MO" ] || %_spec_helper_dir/fix-mo} \ - %{?!dont_translate_menu: [ -n "$DONT_TRANSLATE_MENU" ] || %_spec_helper_dir/translate_menu.pl} \ + %{?!dont_translate_menu: [ -n "$DONT_TRANSLATE_MENU" ] || %_spec_helper_dir/translate_menu} \ %{?!dont_fix_pamd: [ -n "$DONT_FIX_PAMD_CONFIGS" ] || %_spec_helper_dir/fixpamd} \ %{?!dont_remove_info_dir: [ -n "$DONT_REMOVE_INFO_DIR" ] || %_spec_helper_dir/remove_info_dir} \ %{?!dont_fix_eol: [ -n "$DONT_FIX_EOL" ] || %_spec_helper_dir/fix-eol} \ diff --git a/translate_menu b/translate_menu new file mode 100755 index 0000000..2d661c6 --- /dev/null +++ b/translate_menu @@ -0,0 +1,72 @@ +#!/usr/bin/perl -w +#--------------------------------------------------------------- +# Project : Mandrake Linux +# Module : spec-helper +# File : translate_menu.pl +# Version : $Id$ +# Author : Frederic Lepied +# Created On : Mon Jan 26 13:37:49 2004 +# Purpose : change the menu sections +#--------------------------------------------------------------- + +my $menudir = `rpm --eval %_menudir`; +chomp($menudir); + +$ENV{RPM_BUILD_ROOT} or exit(0); +! -d "$ENV{RPM_BUILD_ROOT}/$menudir/" || exit(0); + +my @nested = (["Configuration", "System/Configuration"], + + ["Applications/Monitoring", "System/Monitoring"], + ["Applications/Publishing", "Office/Publishing"], + ["Applications/File tools", "System/File Tools"], + ["Applications/Text tools", "System/Text Tools"], + ["Applications/Archiving", "System/Archiving"], + ["Applications", "More Applications"], + + ["Terminals", "System/Terminals"], + + ["Documentation", "More Applications/Documentation"], + + ["Office/PDA", "Office/Communications/PDA"], + + ["Networking/IRC", "Internet/Chat"], + ["Networking/WWW", "Internet/Web Browsers"], + ["^Networking", "Internet"], + + ["Amusement", "More Applications/Games"], + ["Session/Windowmanagers", "System/Session/Windowmanagers"], + ); + +sub translate { + my ($str) = @_; + + foreach my $t (@nested) { + if ($str =~ /(.*)$t->[0](.*)/ && $str !~ /$t->[1]/) { + print "$str => $1$t->[1]$2\n"; + return "$1$t->[1]$2"; + } + } + return $str; +} + +# process each file passed on cli: + +foreach my $file (glob("$ENV{RPM_BUILD_ROOT}/$menudir/*")) { + open(my $FILE, "<$file") or die $!; + my @lines = <$FILE>; + close($FILE); + open($FILE, ">$file") or die $!; + foreach my $l (@lines) { + chomp($l); + if ($l =~ /(.*section=)"([^"]+)"(\s*.*)/ || $l =~ /(.*section=)([^"].+?)((\s|\\)+.*)/) { + my ($beg, $section, $end) = ($1, $2, $3); + $section = translate($section); + $l = qq($beg"$section"$end); + } + print $FILE "$l\n"; + } + close($FILE); +} + +# translate_menu.pl ends here diff --git a/translate_menu.pl b/translate_menu.pl deleted file mode 100755 index 2d661c6..0000000 --- a/translate_menu.pl +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/perl -w -#--------------------------------------------------------------- -# Project : Mandrake Linux -# Module : spec-helper -# File : translate_menu.pl -# Version : $Id$ -# Author : Frederic Lepied -# Created On : Mon Jan 26 13:37:49 2004 -# Purpose : change the menu sections -#--------------------------------------------------------------- - -my $menudir = `rpm --eval %_menudir`; -chomp($menudir); - -$ENV{RPM_BUILD_ROOT} or exit(0); -! -d "$ENV{RPM_BUILD_ROOT}/$menudir/" || exit(0); - -my @nested = (["Configuration", "System/Configuration"], - - ["Applications/Monitoring", "System/Monitoring"], - ["Applications/Publishing", "Office/Publishing"], - ["Applications/File tools", "System/File Tools"], - ["Applications/Text tools", "System/Text Tools"], - ["Applications/Archiving", "System/Archiving"], - ["Applications", "More Applications"], - - ["Terminals", "System/Terminals"], - - ["Documentation", "More Applications/Documentation"], - - ["Office/PDA", "Office/Communications/PDA"], - - ["Networking/IRC", "Internet/Chat"], - ["Networking/WWW", "Internet/Web Browsers"], - ["^Networking", "Internet"], - - ["Amusement", "More Applications/Games"], - ["Session/Windowmanagers", "System/Session/Windowmanagers"], - ); - -sub translate { - my ($str) = @_; - - foreach my $t (@nested) { - if ($str =~ /(.*)$t->[0](.*)/ && $str !~ /$t->[1]/) { - print "$str => $1$t->[1]$2\n"; - return "$1$t->[1]$2"; - } - } - return $str; -} - -# process each file passed on cli: - -foreach my $file (glob("$ENV{RPM_BUILD_ROOT}/$menudir/*")) { - open(my $FILE, "<$file") or die $!; - my @lines = <$FILE>; - close($FILE); - open($FILE, ">$file") or die $!; - foreach my $l (@lines) { - chomp($l); - if ($l =~ /(.*section=)"([^"]+)"(\s*.*)/ || $l =~ /(.*section=)([^"].+?)((\s|\\)+.*)/) { - my ($beg, $section, $end) = ($1, $2, $3); - $section = translate($section); - $l = qq($beg"$section"$end); - } - print $FILE "$l\n"; - } - close($FILE); -} - -# translate_menu.pl ends here -- cgit v1.2.1