Bug 279869

Summary: Extending yast2-devtools - create-spec
Product: [openSUSE] openSUSE 10.3 Reporter: Karl Eichwalder <ke>
Component: YaST2Assignee: Martin Vidner <mvidner>
Status: RESOLVED FIXED QA Contact: Jiri Srain <jsrain>
Severity: Enhancement    
Priority: P5 - None CC: coolo
Version: Alpha 4plus   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: Documentation Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Karl Eichwalder 2007-06-01 08:46:18 UTC
[Adding to bugzilla to make sure we do not forget about it.]

Ahoj Martin,

I once again need an extension to create-spec.  coolo wants me to add a
language tag to the %files list.  In the end, it must look as follows:

%files
...
%lang($LL) /usr/share/YaST2/locale
...

Since I am not familiar with perl, I can only propose a sed hack (the
tricky part is to throw away the country code).  I hope my assumption is
right that only yast2-trans packages use @localedir@:

Index: create-spec
===================================================================
--- create-spec	(revision 36673)
+++ create-spec	(working copy)
@@ -47,7 +47,8 @@
 
 $provides_locale = "";
 if ($RPMNAME =~ /^yast2-trans-(.*)/) {
-    $provides_locale = "Provides:\tlocale(yast2:$1)\n"
+    $provides_locale = "Provides:\tlocale(yast2:$1)\n";
+    $my_iso639 = `echo -n $1 | sed -e 's/_.*//'`;
 }
 
 if ($#ARGV > 0)
@@ -204,7 +205,7 @@
     "\@ydatadir\@" => "${yast2dir}/data",
     "\@imagedir\@" => "${yast2dir}/images",
     "\@themedir\@" => "${yast2dir}/theme",
-    "\@localedir\@" => "${yast2dir}/locale",
+    "\@localedir\@" => "%lang($my_iso639) ${yast2dir}/locale",
     "\@clientdir\@" => "${yast2dir}/clients",
     "\@moduledir\@" => "${yast2dir}/modules",
     "\@yncludedir\@" => "${yast2dir}/include",
Comment 1 Martin Vidner 2007-06-01 12:46:38 UTC
> I hope my assumption is
> right that only yast2-trans packages use @localedir@:

unfortunately not:
mvidner@valkyrie:yt$ grep localedir */*.spec.in
yast2/yast2.spec.in:mkdir -p "$RPM_BUILD_ROOT"@localedir@
yast2/yast2.spec.in:%dir @localedir@

As you have to resubmit the packages anyway, I think it is better to apply the change to all the yast2-trans*.spec.in files in SVN.

Something like this (untested!)

for f in */yast2-trans*.spec.in; do
  ll=$f{#*/yast-trans-}
  ll=${ll%.spec.in}
  ll=${ll%_*}
  sed -i "s/^@localedir@"/%lang($ll) @localedir@" $f
done
Comment 2 Karl Eichwalder 2007-06-01 13:16:08 UTC
Thanks for checking and advise.  I'd like to avoid hardcoding the language info in *.spec.in.  I think we better add it to the y2autoconf layer and I will change existing *spec.in accordingly (not sure, whether I got it right):

Index: skeletons/trans/yast2-trans-XXpkgXX.spec.in
===================================================================
--- skeletons/trans/yast2-trans-XXpkgXX.spec.in	(revision 38224)
+++ skeletons/trans/yast2-trans-XXpkgXX.spec.in	(working copy)
@@ -22,4 +22,5 @@
 %files
 %defattr(-,root,root)
 %doc @docdir@
-@localedir@
+%dir @localedir@
+%lang(@ISO639@) @localedir@/@ISO639@
Index: bin/y2autoconf
===================================================================
--- bin/y2autoconf	(revision 38224)
+++ bin/y2autoconf	(working copy)
@@ -185,6 +185,8 @@
     '@YAST2-INIT-PO@' =>
 'LL=${RPMNAME##*-}
 AC_SUBST(LL)
+ISO639=${LL%_*}
+AC_SUBST(ISO639)
 
 AC_ARG_WITH(own_compendium,
 	    AS_HELP_STRING([--with-own_compendium=FILE],

Comment 3 Karl Eichwalder 2007-06-01 13:18:59 UTC
Replace 

+%lang(@ISO639@) @localedir@/@ISO639@

with
+%lang(@ISO639@) @localedir@/@LL@

Comment 4 Karl Eichwalder 2007-06-01 14:13:40 UTC
It probably won't hurt adding this to y2autoconf, but we also must change create-spec; something as follows might work:

Index: create-spec
===================================================================
--- create-spec	(revision 38224)
+++ create-spec	(working copy)
@@ -47,7 +47,9 @@
 
 $provides_locale = "";
 if ($RPMNAME =~ /^yast2-trans-(.*)/) {
-    $provides_locale = "Provides:\tlocale(yast2:$1)\n"
+    $provides_locale = "Provides:\tlocale(yast2:$1)\n";
+    $LL = "$1";
+    $ISO639 = `echo -n $1 | sed -e 's/_.*//'`;
 }
 
 if ($#ARGV > 0)
@@ -212,6 +214,10 @@
     "\@scrconfdir\@" => "${yast2dir}/scrconf",
     "\@desktopdir\@" => "%{prefix}/share/applications/YaST2",
     '@fillupdir@' => '/var/adm/fillup-templates',
+
+    "\@LL\@" => "$LL",
+    "\@ISO639\@" => "$ISO639",
+
 );
 
 # The main program
Comment 5 Martin Vidner 2007-08-15 12:38:36 UTC
Karl has committed it to SVN yesterday, I will submit yast2-devtools-2.15.6 today.