Bug 3244 - find-lang uses hardcoded path patterns
: find-lang uses hardcoded path patterns
Status: CLOSED FIXED
: Sisyphus
(All bugs in Sisyphus/rpm-build)
: unstable
: all Linux
: P2 enhancement
Assigned To:
:
:
:
:
:
  Show dependency tree
 
Reported: 2003-11-06 19:00 by
Modified: 2008-06-13 12:15 (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2003-11-06 19:00:23
/usr/lib/rpm/find-lang uses hardcoded path patterns to find locale-dependant
files. It will be better if packager may pass file patterns as arguments.

For example:
vim-common contains gettext databases and menus for various locales in
/usr/share/vim/lang/{LOCALE}/LC_MESSAGES/vim.mo and
/usr/share/vim/lang/menu_{locale}.vim, where {LOCALE} - full or partial locale
name in form of language[_COUNTRY[.ENCODING]] and {locale} is lowercased locale
name.
------- Comment #1 From 2004-06-27 04:15:27 -------
Please suggest some syntax.
------- Comment #2 From 2004-06-28 10:30:18 -------
I think simplest way is to allow packager provide his own sed rules:

FindLang(){
...
    if [ -n "$FIND_CUSTOM" ]; then
        find "$TOPDIR" -type f |sed '
s:'"$TOPDIR"'::
<user-defined rules goes here>
        ' |grep -v '^$' >> "$OUTFILE" ||:
    fi
...
}

Maybe, different ruless for different file types (d, f, l).

Example:

%add_custom_find_lang
's:\(.*/share/vim/lang/\)\([^/_]\+\)\(.*vim\.mo$\):%%lang(\2) \1\2\3:'
%add_custom_find_lang 's:^\([^%%].*\)::'

...

%find_lang --custom %name
------- Comment #3 From 2004-06-29 19:44:10 -------
Or maybe this way:
  --custom-dir-script=FILE  look for directories using specified sed script;
  --custom-file-script=FILE look for files using specified sed script;
  --custom-link-script=FILE look for symlinks using specified sed script;
?
------- Comment #4 From 2004-06-30 09:47:47 -------
Sounds reasonable.

What about $NAME substitution?
------- Comment #5 From 2004-06-30 11:38:06 -------
Oops.  According to /usr/lib/rpm/find-lang from rpm-4.0.4-alt40:

s/FILE/CODE/

Argument is a sed script, not file.

To allow $NAME expansion following changes could be applied to FindLang():

    local script
...
    if [ -n "$CUSTOM_XXX_SCRIPT" ]; then
        eval "script=\"$CUSTOM_XXX_SCRIPT\""
        find "$TOPDIR" -type XXX |
            sed -e "s:$TOPDIR::" -e "$script" |
            grep -v '^$' >> "$OUTFILE" ||:
------- Comment #6 From 2004-06-30 14:50:27 -------
Я имел в виду -f, а написал -e и не проверил...

Ну так что,
sed -e "s:$TOPDIR::" -f "$CUSTOM_XXX_SCRIPT" пойдёт?
------- Comment #7 From 2004-06-30 15:45:18 -------
В принципе - да. Огорчает неиспользование $NAME, но думаю это можно решить
другим способом, на уровне спекфайла.
------- Comment #8 From 2005-10-10 18:09:29 -------
Добавлено в 4.0.4-alt40, исправлено в 4.0.4-alt42.