Bug 3244

Summary: find-lang uses hardcoded path patterns
Product: Sisyphus Reporter: Sir Raorn <raorn>
Component: rpm-buildAssignee: placeholder <placeholder>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: enhancement    
Priority: P2 CC: arseny, glebfm, imz, ldv, placeholder, vt
Version: unstable   
Hardware: all   
OS: Linux   

Description Sir Raorn 2003-11-06 19:00:23 MSK
/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 Dmitry V. Levin 2004-06-27 04:15:27 MSD
Please suggest some syntax.
Comment 2 Sir Raorn 2004-06-28 10:30:18 MSD
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 Dmitry V. Levin 2004-06-29 19:44:10 MSD
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 Sir Raorn 2004-06-30 09:47:47 MSD
Sounds reasonable.

What about $NAME substitution?
Comment 5 Sir Raorn 2004-06-30 11:38:06 MSD
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 Dmitry V. Levin 2004-06-30 14:50:27 MSD
Я имел в виду -f, а написал -e и не проверил...

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