2014-04-18 09:42:36 +02:00
|
|
|
#!/bin/bash
|
2014-09-11 15:01:17 +02:00
|
|
|
# DOWNLOAD='no' when testing this script or spec.in
|
2014-04-18 09:42:36 +02:00
|
|
|
DOWNLOAD='yes'
|
|
|
|
GIT_DIR='dictionaries'
|
|
|
|
VERBOSE='no'
|
|
|
|
|
2014-04-22 13:02:10 +02:00
|
|
|
declare -A provides_map=(
|
|
|
|
["myspell-af_ZA"]="myspell-african"
|
|
|
|
["myspell-ar"]="myspell-arabic"
|
|
|
|
["myspell-be_BY"]="myspell-belarusian"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-bg_BG"]="myspell-bulgarian libreoffice-thesaurus-bg"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-bn_BD"]="myspell-bengali"
|
|
|
|
["myspell-br_FR"]="myspell-breton"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-ca"]="myspell-catalan myspell-valencian libreoffice-thesaurus-ca"
|
|
|
|
["myspell-cs_CZ"]="myspell-czech libreoffice-thesaurus-cs"
|
|
|
|
["myspell-da_DK"]="myspell-danish libreoffice-thesaurus-da"
|
2014-04-28 16:50:36 +02:00
|
|
|
["myspell-de"]="myspell-german myspell-nswiss myspell-austrian"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-el_GR"]="myspell-greek libreoffice-thesaurus-el"
|
|
|
|
["myspell-en"]="myspell-american myspell-australian myspell-canadian myspell-british myspell-new-zaeland myspell-south-african-english libreoffice-thesaurus-en-AU libreoffice-thesaurus-en-GB libreoffice-thesaurus-US"
|
|
|
|
["myspell-es"]="myspell-spanish myspell-mexican myspell-spanish-argentine myspell-spanish-bolivian myspell-spanish-chilean myspell-spanish-colombian myspell-spanish-costa-rican myspell-spanish-dominican myspell-spanish-ecuadorian myspell-spanish-guatemalan myspell-spanish-honduran myspell-spanish-nicaraguan myspell-spanish-panamanian myspell-spanish-paraguayan myspell-spanish-peruvian myspell-spanish-puerto-rican myspell-spanish-salvadorean myspell-spanish-uruguayan myspell-spanish-venezuelan libreoffice-thesaurus-es libreoffice-thesaurus-es-AR libreoffice-thesaurus-VE"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-et_EE"]="myspell-estonian"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-fr_FR"]="myspell-french libreoffice-thesaurus-fr"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-gd_GB"]="myspell-gaelic"
|
|
|
|
["myspell-gl"]="myspell-galician"
|
|
|
|
["myspell-gu_IN"]="myspell-gujarati"
|
|
|
|
["myspell-he_IL"]="myspell-hebrew"
|
|
|
|
["myspell-hi_IN"]="myspell-hindi"
|
|
|
|
["myspell-hr_HR"]="myspell-croatian"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-hu_HU"]="myspell-hungarian libreoffice-thesaurus-hu"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-is"]="myspell-icelandic"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-it_IT"]="myspell-italian libreoffice-thesaurus-it"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-lt_LT"]="myspell-lithuanian"
|
|
|
|
["myspell-lv_LV"]="myspell-latvian"
|
|
|
|
["myspell-nl_NL"]="myspell-dutch"
|
|
|
|
["myspell-no"]="myspell-norsk-bokmaal myspell-norsk-nynorsk"
|
|
|
|
["myspell-oc_FR"]="myspell-occitan-lengadocian"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-pl_PL"]="myspell-polish libreoffice-thesaurus-pl"
|
|
|
|
["myspell-pt_BR"]="myspell-brazilian libreoffice-thesaurus-pt"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-pt_PT"]="myspell-portuguese"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-ro"]="myspell-romanian libreoffice-thesaurus-ro"
|
|
|
|
["myspell-ru_RU"]="myspell-russian libreoffice-thesaurus-ru"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-si_LK"]="myspell-sinhala"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-sk_SK"]="myspell-slovak libreoffice-thesaurus-sk"
|
|
|
|
["myspell-sl_SI"]="myspell-slovene libreoffice-thesaurus-sl"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-sr"]="myspell-serbian-latin myspell-serbian-cyrillic"
|
2014-04-25 10:44:32 +02:00
|
|
|
["myspell-sv_SE"]="myspell-swedish libreoffice-thesaurus-sv"
|
2014-04-22 13:02:10 +02:00
|
|
|
["myspell-sw_TZ"]="myspell-kiswahili"
|
|
|
|
["myspell-th_TH"]="myspell-thai"
|
|
|
|
["myspell-uk_UA"]="myspell-ukrainian"
|
|
|
|
["myspell-vi"]="myspell-vietnamese"
|
|
|
|
["myspell-zu_ZA"]="myspell-zulu"
|
|
|
|
)
|
|
|
|
|
2014-05-07 11:27:23 +02:00
|
|
|
# directories under $GIT_DIR, which holds dictionaries
|
2014-04-18 09:42:36 +02:00
|
|
|
function directories()
|
|
|
|
{
|
|
|
|
ls $GIT_DIR/*/dictionaries.xcu | sed -e 's:dictionaries/::' -e 's:/dictionaries.xcu::' | tr '\n' ' '
|
|
|
|
}
|
|
|
|
|
2014-05-07 11:27:23 +02:00
|
|
|
# create central mapping dir <-> locales <-> files
|
2014-04-18 09:42:36 +02:00
|
|
|
function locale_to_file_map()
|
|
|
|
{
|
|
|
|
cd $GIT_DIR
|
|
|
|
rm -f locale_to_file_map.txt
|
|
|
|
for dir in $dirs; do
|
|
|
|
cat $dir/dictionaries.xcu \
|
|
|
|
| grep -v '<!--' \
|
|
|
|
| grep -A1 'Locations\|Locales' \
|
|
|
|
| grep -v '\-\-\|Locations\|Locales' \
|
|
|
|
| sed s:%origin%:$dir:g \
|
|
|
|
| sed 's:.*<value>\(.*\)</value>.*:\1:' \
|
|
|
|
| while read files; do
|
|
|
|
read locs
|
|
|
|
echo $dir: $locs @ $files | tr '-' '_' >> locale_to_file_map.txt
|
|
|
|
done
|
|
|
|
done
|
2014-05-06 17:22:24 +02:00
|
|
|
# add idx files for every dat (where doesn't exist)
|
|
|
|
# we will generate them
|
|
|
|
sed -i '/\.idx/!s/\([^ ]*\)\.dat/\1.dat \1.idx/g' locale_to_file_map.txt
|
2014-04-18 09:42:36 +02:00
|
|
|
cd ..
|
|
|
|
}
|
|
|
|
|
2014-05-07 11:27:23 +02:00
|
|
|
# for given dir: which locales provides
|
2014-04-18 09:42:36 +02:00
|
|
|
function dir_locales()
|
|
|
|
{
|
|
|
|
dir=$1
|
|
|
|
grep "^$dir:" $GIT_DIR/locale_to_file_map.txt | sed 's/.*: //' | sed 's/ @.*//' | tr ' ' '\n' | sort -u | tr '\n' ' '
|
|
|
|
}
|
|
|
|
|
2014-05-07 11:27:23 +02:00
|
|
|
# for given dir: which dictionary relevant files (dic, aff, th*, hyph*) provides
|
|
|
|
function dir_files()
|
2014-04-18 09:42:36 +02:00
|
|
|
{
|
2014-05-07 11:27:23 +02:00
|
|
|
dir=$1
|
|
|
|
grep "$dir:" $GIT_DIR/locale_to_file_map.txt | sed 's:.*@ ::' | tr ' ' '\n' | sort -u | tr '\n' ' '
|
|
|
|
}
|
|
|
|
|
|
|
|
# for given dictionary file: which locales provides
|
|
|
|
function file_locales()
|
|
|
|
{
|
|
|
|
file=$1
|
|
|
|
# there should be only one occurence of a file in locale_to_file_map.txt
|
|
|
|
grep $file $GIT_DIR/locale_to_file_map.txt | sed -e 's/.*: //' -e 's/@.*//'
|
2014-04-18 09:42:36 +02:00
|
|
|
}
|
|
|
|
|
2014-05-07 11:27:23 +02:00
|
|
|
# for given dir: description of the dictionary
|
2014-04-18 09:42:36 +02:00
|
|
|
function description()
|
|
|
|
{
|
|
|
|
dir=$1
|
|
|
|
grep '<name lang="en.*">' dictionaries/$dir/description.xml | sed -e 's:.*<name lang="en.*">::' -e 's:</name>.*::' | tr '\n' ' ' | sed 's:[ \t]*$::'
|
|
|
|
}
|
|
|
|
|
2014-05-06 17:22:24 +02:00
|
|
|
# all thesaurus dat files
|
|
|
|
function dat_files()
|
|
|
|
{
|
|
|
|
grep '\.dat' $GIT_DIR/locale_to_file_map.txt | sed 's:.* \([^ ]\+\.dat\).*:\1:'
|
|
|
|
}
|
|
|
|
|
|
|
|
# for dat file return corresponding idx file name
|
|
|
|
function idx_file()
|
|
|
|
{
|
|
|
|
dat_file=$1
|
|
|
|
grep "$dat_file" $GIT_DIR/locale_to_file_map.txt | sed 's:.* \([^ ]\+\.idx\).*:\1:'
|
|
|
|
}
|
|
|
|
|
2014-09-11 15:01:17 +02:00
|
|
|
# arch package?
|
|
|
|
function have_lightproof()
|
|
|
|
{
|
|
|
|
dir=$1
|
|
|
|
[ -f $GIT_DIR/$dir/Lightproof.py ]
|
|
|
|
}
|
|
|
|
|
2014-04-18 09:42:36 +02:00
|
|
|
#
|
2014-05-06 17:22:24 +02:00
|
|
|
# prepare 'dictionaries' directory
|
2014-04-18 09:42:36 +02:00
|
|
|
#
|
2014-05-06 17:22:24 +02:00
|
|
|
|
|
|
|
# download present git version, remove .git, unify layout
|
2014-04-18 09:42:36 +02:00
|
|
|
if [ $DOWNLOAD == "yes" ]; then
|
2014-05-06 17:22:24 +02:00
|
|
|
echo '--- Download current git version'
|
2014-04-18 09:42:36 +02:00
|
|
|
rm -rf $GIT_DIR
|
|
|
|
git clone git://anongit.freedesktop.org/libreoffice/$GIT_DIR
|
|
|
|
rm -rf $GIT_DIR/.git
|
|
|
|
for dir in ca gd_GB; do
|
|
|
|
cp --force $GIT_DIR/$dir/dictionaries/* dictionaries/$dir
|
|
|
|
sed -i 's:dictionaries/::' dictionaries/$dir/dictionaries.xcu
|
|
|
|
done
|
2014-04-28 16:50:36 +02:00
|
|
|
date=`date +%Y%m%d`
|
2014-04-18 09:42:36 +02:00
|
|
|
elif [ ! -e $GIT_DIR ]; then
|
2014-05-06 10:08:19 +02:00
|
|
|
echo "ERROR: DOWNLOAD=$DOWNLOAD and '$GIT_DIR' does not exist"
|
|
|
|
echo "Run quilt setup or so."
|
2014-04-18 09:42:36 +02:00
|
|
|
exit 1
|
2014-04-28 16:50:36 +02:00
|
|
|
else
|
2014-05-06 17:22:24 +02:00
|
|
|
echo "--- Do not download, using '$GIT_DIR'"
|
2014-04-28 16:50:36 +02:00
|
|
|
date=`rpmspec -q --qf "%{VERSION}\n" *.spec | head -n 1`
|
2014-04-18 09:42:36 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# create dir <-> locales <-> files mapping
|
|
|
|
# in $GIT_DIR/locale_to_file_map.txt
|
|
|
|
dirs=$(directories)
|
|
|
|
[ "$VERBOSE" == "yes" ] && echo directiories: $dirs
|
|
|
|
locale_to_file_map
|
|
|
|
|
2014-05-06 17:22:24 +02:00
|
|
|
# create *.idx files from *.dat files
|
|
|
|
echo '--- Creating idx files'
|
2014-05-12 11:06:16 +02:00
|
|
|
if [ ! -x /usr/bin/th_gen_idx.pl ]; then
|
|
|
|
echo "ERROR: /usr/bin/th_gen_idx.pl not found"
|
|
|
|
echo "Install mythes-devel package."
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-05-06 17:22:24 +02:00
|
|
|
for datf in $(dat_files); do
|
|
|
|
idxf=$(idx_file $datf)
|
2014-05-12 11:06:16 +02:00
|
|
|
[ "$VERBOSE" == "yes" ] && echo "th_gen_idx.pl < $GIT_DIR/$datf > $GIT_DIR/$idxf"
|
2014-05-06 17:22:24 +02:00
|
|
|
th_gen_idx.pl < $GIT_DIR/$datf > $GIT_DIR/$idxf
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "ERROR: failed th_gen_idx.pl -o $GIT_DIR/$idxf < $GIT_DIR/$datf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo '--- Creating symlinks'
|
2014-04-18 09:42:36 +02:00
|
|
|
# create symlinks in $GIT_DIR/$dir, e. g. es_GT -> es_ANY
|
|
|
|
for dir in $dirs; do
|
2014-05-07 11:27:23 +02:00
|
|
|
files=$(dir_files $dir)
|
|
|
|
[ "$VERBOSE" == "yes" ] && echo "DICTIONARY: $dir ($files)"
|
|
|
|
for file in $files; do
|
|
|
|
locales=$(file_locales $file)
|
|
|
|
[ "$VERBOSE" == "yes" ] && echo " $file: $locales"
|
|
|
|
for locale in $locales; do
|
|
|
|
fname=`basename $file`
|
|
|
|
# work around which is bug imho in dictionaries.xcu.
|
|
|
|
# It references file that doesn't exist.
|
|
|
|
if [ ! -e "$GIT_DIR/$dir/$fname" ]; then
|
|
|
|
[ "$VERBOSE" == "yes" ] && echo "WARNING: $GIT_DIR/$dir/$f doesn't exist"
|
|
|
|
continue;
|
|
|
|
fi
|
|
|
|
|
2014-04-18 09:42:36 +02:00
|
|
|
prefix=""
|
2014-05-12 11:06:16 +02:00
|
|
|
version=""
|
2014-05-07 11:27:23 +02:00
|
|
|
if [[ $fname == th* ]]; then
|
2014-04-18 09:42:36 +02:00
|
|
|
# nice collision with th_ for thesaurus
|
2014-05-07 11:27:23 +02:00
|
|
|
if [ "$fname" != "th_TH.aff" ] && [ "$fname" != "th_TH.dic" ]; then
|
|
|
|
prefix="th_"
|
2014-05-13 13:45:24 +02:00
|
|
|
# it seems suffix have to be _v2, even if target is named _v3 :)
|
|
|
|
version='_v2'
|
2014-04-18 09:42:36 +02:00
|
|
|
fi
|
|
|
|
fi
|
2014-05-07 11:27:23 +02:00
|
|
|
if [[ $fname == hyph* ]]; then
|
|
|
|
prefix="hyph_"
|
2014-04-18 09:42:36 +02:00
|
|
|
fi
|
2014-05-07 11:27:23 +02:00
|
|
|
ext=`echo $fname | sed 's:.*\.::'`
|
2014-05-12 11:06:16 +02:00
|
|
|
linkname=$prefix$locale$version.$ext
|
2014-05-07 11:27:23 +02:00
|
|
|
|
|
|
|
[ "$VERBOSE" == "yes" ] && echo -n " link: $linkname -> $fname .. "
|
|
|
|
|
|
|
|
# regular file or link for this locale/extension exist yet,
|
|
|
|
# do not create symlink
|
|
|
|
if ls $GIT_DIR/$dir/$linkname &> /dev/null; then
|
2014-05-12 11:06:16 +02:00
|
|
|
[ "$VERBOSE" == "yes" ] && echo "regular file or link exists yet"
|
2014-04-18 09:42:36 +02:00
|
|
|
continue;
|
|
|
|
fi
|
2014-05-07 11:27:23 +02:00
|
|
|
|
|
|
|
ln -sf $fname $GIT_DIR/$dir/$linkname
|
2014-05-12 11:06:16 +02:00
|
|
|
[ "$VERBOSE" == "yes" ] && echo "created"
|
2014-04-18 09:42:36 +02:00
|
|
|
done
|
|
|
|
done
|
|
|
|
done
|
2014-05-06 17:22:24 +02:00
|
|
|
|
2014-04-18 09:42:36 +02:00
|
|
|
#
|
|
|
|
# generate myspell-dictionaries.spec
|
|
|
|
#
|
2014-05-06 17:22:24 +02:00
|
|
|
echo '--- Generating spec file'
|
2014-04-18 09:42:36 +02:00
|
|
|
cp myspell-dictionaries.spec.in myspell-dictionaries.spec
|
|
|
|
|
|
|
|
sed -i "s:@DO_NOT_EDIT_COMMENT@:DO NOT EDIT THIS SPEC FILE:" myspell-dictionaries.spec
|
|
|
|
sed -i "s:@VERSION@:$date:" myspell-dictionaries.spec
|
|
|
|
|
|
|
|
for subpackage in $dirs; do
|
|
|
|
desc=$(description $subpackage)
|
|
|
|
sum="MySpell $subpackage Dictionary"
|
|
|
|
dir_locs=$(dir_locales $subpackage)
|
|
|
|
sed -i "s#@METADATA@#%package -n myspell-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Summary: $sum\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Group: Productivity/Text/Spell\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Requires: myspell-dictionaries\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Provides: myspell-dictionary\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
for l in $dir_locs; do
|
|
|
|
sed -i "s#@METADATA@#Provides: locale(libreoffice:$l)\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Provides: locale(seamonkey-spellchecker:$l)\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
done
|
2014-04-22 13:02:10 +02:00
|
|
|
for p in ${provides_map["myspell-$subpackage"]}; do
|
|
|
|
sed -i "s#@METADATA@#Provides: $p\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
done
|
2014-09-11 15:01:17 +02:00
|
|
|
sed -i "s#@METADATA@#BuildArch: noarch\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
if have_lightproof $subpackage; then
|
|
|
|
sed -i "s#@METADATA@#Recommends: myspell-lightproof-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
fi
|
2014-04-18 09:42:36 +02:00
|
|
|
sed -i "s#@METADATA@#\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#%description -n myspell-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#$desc.\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#\n@METADATA@#" myspell-dictionaries.spec
|
2014-09-11 15:01:17 +02:00
|
|
|
# lightproof subpackage
|
|
|
|
if have_lightproof $subpackage; then
|
|
|
|
sed -i "s#@METADATA@#%package -n myspell-lightproof-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Summary: Lightproof for $subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Group: Productivity/Text/Spell\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Requires: myspell-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#%description -n myspell-lightproof-$subpackage\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#Lightproof grammar checker information for $subpackage.\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
sed -i "s#@METADATA@#\n@METADATA@#" myspell-dictionaries.spec
|
|
|
|
fi
|
2014-04-18 09:42:36 +02:00
|
|
|
done
|
|
|
|
sed -i "s:@METADATA@::" myspell-dictionaries.spec
|
|
|
|
|
|
|
|
sed -i "s:@LANG_DIRS@:$dirs:" myspell-dictionaries.spec
|
|
|
|
|
|
|
|
for subpackage in $dirs; do
|
|
|
|
sed -i "s:@FILES@:%files -n myspell-$subpackage -f $subpackage.list\n@FILES@:" myspell-dictionaries.spec
|
|
|
|
sed -i "s:@FILES@:\n@FILES@:" myspell-dictionaries.spec
|
2014-09-11 15:01:17 +02:00
|
|
|
if have_lightproof $subpackage; then
|
|
|
|
sed -i "s:@FILES@:%files -n myspell-lightproof-$subpackage -f lightproof.$subpackage.list\n@FILES@:" myspell-dictionaries.spec
|
|
|
|
sed -i "s:@FILES@:\n@FILES@:" myspell-dictionaries.spec
|
|
|
|
fi
|
2014-04-18 09:42:36 +02:00
|
|
|
done
|
|
|
|
sed -i "s:@FILES@::" myspell-dictionaries.spec
|
|
|
|
|
|
|
|
#
|
|
|
|
# creating source archive
|
|
|
|
#
|
2014-05-06 17:22:24 +02:00
|
|
|
if [ $DOWNLOAD == "yes" ]; then
|
|
|
|
echo '--- Creating archive'
|
|
|
|
tar cJf dictionaries.tar.xz dictionaries
|
|
|
|
rm -r dictionaries
|
|
|
|
fi
|
2014-04-18 09:42:36 +02:00
|
|
|
|
2014-05-06 17:22:24 +02:00
|
|
|
echo --- Done
|
2014-04-18 09:42:36 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# advice at the end ..
|
|
|
|
#
|
|
|
|
echo
|
|
|
|
echo With osc diff, figure out if there is a new package.
|
|
|
|
echo If yes, add its license in License: tag of both
|
|
|
|
echo *.spec and *.spec.in
|
|
|
|
echo if this license is not there yet.
|
|
|
|
echo
|