#!/bin/sh ## ## Common section ## function GeneratePackageFilelist() { cat << EOF %files -n $PACKAGE %defattr(-,root,root) %doc doc/$PTYPE/$FILE/* %{dictdir}/$FILE.* EOF } function GeneratePackageScripts() { echo "%post -n $PACKAGE" for country in $ISOCOUNTRY; do cat << EOF if [[ ! -f "%{dictdir}/dictionary.lst" ]] || \ ! grep -q "^$PTYPE[ \t]*$ISOCODE[ \t]*$country[ \t]*$FILE" %{dictdir}/dictionary.lst then echo "$PTYPE $ISOCODE $country $FILE" >> %{dictdir}/dictionary.lst fi EOF done echo "%preun -n $PACKAGE" for country in $ISOCOUNTRY; do cat << EOF if [[ "\$1" = "0" ]]; then perl -ni -e "/^$PTYPE\s*$ISOCODE\s*$country\s*$FILE\$/ or print" %{dictdir}/dictionary.lst fi EOF done } ## ## Handle spelling dictionaries ## function DICTGeneratePackageInfo() { cat << EOF %package -n $PACKAGE Summary: MySpell spelling dictionaries for $PNAME Version: %{myversion} Release: 0.$PDATE.%{myrelease} License: $LICENSE Group: System/Internationalization Requires: locales-$LOCALECODE Provides: myspell-dictionary = %{version} Obsoletes: myspell-$LOCALECODE Provides: myspell-$LOCALECODE = %{version} %description -n $PACKAGE $PACKAGE contains spell checking data in $PNAME to be used by OpenOffice.org or MySpell-capable applications like Mozilla. With this extension, you can compose a document in $SHORT_LANGNAME and check for the typos easily. EOF } ## ## Handle hyphenation ## function HYPHGeneratePackageInfo() { cat << EOF %package -n $PACKAGE Summary: MySpell hyphenation dictionaries for $PNAME Version: %{myversion} Release: 0.$PDATE.%{myrelease} License: $LICENSE Group: System/Internationalization Provides: myspell-hyphenation = %{version} Requires: locales-$LOCALECODE %description -n $PACKAGE $PACKAGE contains hyphenation data for $PNAME to be used by OpenOffice.org or MySpell-capable applications like Mozilla. EOF } ## ## Main ## COMMAND=$1 PTYPE=$2 PLANG=$3 PDATE=$4 PNAME=$5 LICENSE=$6 [[ -z "$COMMAND$PTYPE$PLANG$PDATE$PNAME$LICENSE" ]] && { echo "%{error: ${0##*/}: Bad arguments}" exit 0 } ISOCODE=${PLANG%%_*} ISOCOUNTRY=${PLANG#*_} [[ "$ISOCODE" = "$ISOCOUNTRY" ]] && ISOCOUNTRY="" case $ISOCODE:$ISOCOUNTRY in nb:NO|nn:NO) LOCALECODE=no ;; *) LOCALECODE=$ISOCODE ;; esac PACKAGE="myspell" [[ "$PTYPE" = "HYPH" ]] && PACKAGE="$PACKAGE-hyph" PACKAGE="$PACKAGE-$PLANG" FILE=$PLANG [[ "$PTYPE" = "HYPH" ]] && FILE="hyph_$ISOCODE" case $COMMAND in DESC) SHORT_LANGNAME=`echo "$PNAME" | sed -e "s/\([A-Z][^ ]*\).*/\1/"` ${PTYPE}GeneratePackageInfo ;; SCRIPTS) [[ "$PTYPE" = "HYPH" ]] && ISOCOUNTRY="$PDATE" GeneratePackageScripts ;; FILES) GeneratePackageFilelist ;; esac exit 0