X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm-find-lang;h=a3a19edf1bcc26ab517a48fd39212df1aae055d7;hb=518d1bf96e281e2e6ef438fa6fa09fdb4749d7ba;hp=bfc5a35c9ed2ea997fb92a2add1b97724b159ebf;hpb=4b717e5d4fc029d10f207e4307e2b554ff64c131;p=packages%2Frpm-pld-macros.git diff --git a/rpm-find-lang b/rpm-find-lang index bfc5a35..a3a19ed 100644 --- a/rpm-find-lang +++ b/rpm-find-lang @@ -1,7 +1,7 @@ #!/bin/sh # $Id$ -# findlang - automagically generate list of language specific files +# find-lang - automagically generate list of language specific files # for inclusion in an rpm spec file. # This does assume that the *.mo files are under .../share/locale/... # Run with no arguments gets a usage message. @@ -52,6 +52,7 @@ Additional options: --with-gnome find GNOME help files --with-kde find KDE help files --with-omf find OMF files + --with-qm find QT .qm files --all-name match all package/domain names --without-mo skip *.mo locale files -o NAME output will be saved to NAME @@ -83,12 +84,13 @@ shift GNOME='#' KDE='#' OMF='#' +QM='#' MO='' -MO_NAME=$NAME.lang +OUTPUT=$NAME.lang ALL_NAME='#' NO_ALL_NAME='' APPEND='' -while test $# -gt 0 ; do +while test $# -gt 0; do case "$1" in --with-gnome) GNOME='' @@ -105,6 +107,11 @@ while test $# -gt 0 ; do OMF='' shift ;; + --with-qm) + echo "$PROG: Enabling with Qt QM" + QM='' + shift + ;; --without-mo) echo "$PROG: Disabling .mo files" MO='#' @@ -118,26 +125,28 @@ while test $# -gt 0 ; do ;; -o) shift - MO_NAME=$1 + OUTPUT=$1 shift ;; -a) shift - MO_NAME=$1 + OUTPUT=$1 APPEND='>' shift ;; *) - MO_NAME=$1 + OUTPUT=$1 shift ;; esac done -echo "$PROG/$VERSION: find-lang '$NAME' $APPEND> $MO_NAME" +echo "$PROG/$VERSION: find-lang '$NAME' $APPEND> $OUTPUT" -[ -z "$APPEND" ] && echo '%defattr(644,root,root,755)' > $MO_NAME +MO_NAME=.$OUTPUT.tmp~ +echo '%defattr(644,root,root,755)' > $MO_NAME +# .mo if [ ! -f __find.files ] || [ "$TOP_DIR" -nt __find.files ]; then find $TOP_DIR -xtype f -name '*.mo' | xargs -r file -L | \ sed -e ' @@ -148,6 +157,7 @@ else echo "$PROG: Using cached __find.files" fi +# .omf if [ ! -f __omf.files ] || [ "$TOP_DIR" -nt __omf.files ]; then find $TOP_DIR -type f -name '*.omf' | \ sed -e ' @@ -156,6 +166,16 @@ else echo "$PROG: Using cached __omf.files" fi +# .qm +if [ ! -f __qm.files ] || [ "$TOP_DIR" -nt __qm.files ]; then + find $TOP_DIR -type f -name '*.qm' | \ + sed -e ' + s:'"$TOP_DIR"'::' > __qm.files +else + echo "$PROG: Using cached __qm.files" +fi + +# .mo ( if [ "$ALL_NAME" ]; then fgrep $NAME __find.files @@ -168,6 +188,7 @@ fi /^[^%]/d s:%lang(C) ::' >> $MO_NAME +# .omf ( if [ "$ALL_NAME" ]; then fgrep $NAME __omf.files @@ -180,12 +201,26 @@ s:%lang(C) ::' >> $MO_NAME /^[^%]/d s:%lang(C) ::' >> $MO_NAME +# .qm +( + if [ "$ALL_NAME" ]; then + fgrep $NAME __qm.files + else + cat __qm.files + fi +) | sed ' +'"$ALL_NAME$QM"'s:\(.*/share/locale/\)\([^/@]\+\)\(@quot\|@boldquot\)\?\(@[^/]*\)\?\(/.*\.qm$\):%lang(\2\4) \1\2\3\4\5: +'"$NO_ALL_NAME$QM"'s:\(.*/share/locale/\)\([^/@]\+\)\(@quot\|@boldquot\)\?\(@[^/]*\)\?\(/.*/'"$NAME"'\.qm$\):%lang(\2\4) \1\2\3\4\5: +/^[^%]/d +s:%lang(C) ::' >> $MO_NAME + if [ ! -f __find.dirs ] || [ "$TOP_DIR" -nt __find.dirs ]; then find $TOP_DIR -mindepth 1 -type d | sed 's:'"$TOP_DIR"'::' > __find.dirs else echo "$PROG: Using cached __find.dirs" fi +# gnome ( if [ "$ALL_NAME" ]; then fgrep $NAME __find.dirs @@ -200,6 +235,7 @@ fi /^[^%]/d s:%lang(C) ::' >> $MO_NAME +# kde ( if [ "$ALL_NAME" ]; then fgrep $NAME __find.dirs @@ -228,3 +264,10 @@ if [ "$(egrep -v '(^%defattr|^$)' $MO_NAME | wc -l)" -le 0 ]; then echo >&2 "$PROG: Error: international files not found for '$NAME'!" exit 1 fi + +if [ "$APPEND" ]; then + cat $MO_NAME >> $OUTPUT + rm -f $MO_NAME +else + mv -f $MO_NAME $OUTPUT +fi