[Kde-extra-gear] cvsExtract patch

Sebastian Trueg kde-extra-gear@mail.kde.org
Mon, 10 Feb 2003 15:33:41 +0100


--Boundary-00=_Fh7R+2HgIEqHmt3
Content-Type: text/plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Sunday 09 February 2003 18:49, Klas Kalass wrote:
> Am Sonntag, 9. Februar 2003 18:42 schrieb Sebastian Trueg:
> > On Sunday 09 February 2003 17:03, Klas Kalass wrote:
> > > Am Sonntag, 9. Februar 2003 13:28 schrieb Sebastian Trueg:
> > > +       echo "available languages: $LANGUAGES"
> > > +       rm -r kde-i18n
> > > +    fi
> > > +fi
> > >
> > > Please do not put actual code like this above the "MAIN" section, but
> > > rather inside. It does not matter code-wise but I think it is easier to
> > > maintain if the distinction is kept.
> >
> > so should I create a function and call it?
>
> That would be nicest, but I don't care so much for that. It is only that
> the structure of the file used to be (roughly):
> - option handling
> - functions
> - "main" code
> and it would be nice if you moved that code around so it fits in that
> structure.

Is this ok?
--Boundary-00=_Fh7R+2HgIEqHmt3
Content-Type: text/x-diff;
  charset="iso-8859-1";
  name="cvsExtract_patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cvsExtract_patch"

Index: cvsExtract.sh
===================================================================
RCS file: /home/kde/kdeextragear-1/scripts/cvsExtract.sh,v
retrieving revision 1.9
diff -u -p -r1.9 cvsExtract.sh
--- cvsExtract.sh	21 Oct 2002 21:17:42 -0000	1.9
+++ cvsExtract.sh	10 Feb 2003 14:33:10 -0000
@@ -36,6 +36,8 @@ LANGUAGES=""
 
 # misc
 KDECOMMON=kde-common
+GETDOC="yes"
+GETI18N="yes"
 
 # CVS settings
 RETRIEVAL_METHOD=LOCAL
@@ -77,7 +79,8 @@ Following Options are needed
     -a|--app <APPNAME>        The name of the application to extract from cvs
 
 Following Options are optional
-    -l|--languages <LANGUAGES> space seperated list of languages to include
+    -l|--languages <LANGUAGES> Space seperated list of languages to search for translations.
+                               If no languages are specified all available languages are searched.
     -b|--builddir <DIRNAME>   Name of the temporary working directory where all files will be put
     -v|--version <VERSION>    version of the application (only for correct naming of the tar archive)
     -cb|--cvsbase <DIRNAME>   Directory in which the cvs modules 
@@ -88,6 +91,8 @@ Following Options are optional
 					    current directory (DEFAULT).
     -d <CVSROOT>              Use the specified CVSROOT instead of the environment variable. 
                               Implies \"-r CVS\".
+    --nodoc                   Do not try to get any documentation.
+    --noi18n                  Do not search for any translations.
     -h|--help                 This Help"
 }
 
@@ -145,6 +150,12 @@ do
 	RETRIEVAL_METHOD="CVS"
 	shift
       ;;
+    --nodoc)
+        GETDOC="no"
+      ;;
+    --noi18n)
+        GETI18N="no"
+      ;;
     -h|--help)
 	showHelp
 	exit 0
@@ -325,12 +336,13 @@ function getTranslation {
 	    echo -e "   $lang"
 	    mkdir ${lang}
 
+   	    gotTranslations="no"
+
 	    case $1 in 
 		CVS)
 		    if cvs co -d ${lang}_tmp ${KDEI18N}/${lang}/messages/${MODULENAME_I18N} 2>/dev/null ; then
-			mv ${lang}_tmp/${APPNAME}*.po ${lang} 2>/dev/null ||echo -e "No Translation for Language $lang"
-			mv ${lang}_tmp/Makefile.am ${lang}
-			gotTranslations="yes"
+			mv ${lang}_tmp/${APPNAME}*.po ${lang} 2>/dev/null && gotTranslations="yes"
+			mv ${lang}_tmp/Makefile.am ${lang} 2>/dev/null
 		    fi
 		    rm -rf ${lang}_tmp
 		;;
@@ -386,6 +398,28 @@ function mergeToplevelFiles {
     fi
 }
 
+
+
+#
+# Retrieve list of available languages from kde-i18n cvs
+#
+# $1: where to get the files from (CVS|LOCAL)
+#
+function getAvailableLanguages {
+    echo "Retrieving complete list of available languages..."
+    case $1 in
+	CVS)
+	    cvs -z4 -q -d "$CVSROOT" co -P kde-i18n/subdirs > /dev/null 2>&1
+	    ;;
+	LOCAL)
+	    cp  -a ${CVSBASEDIR}/${KDEI18N}/subdirs kde-i18n
+	    ;;
+    esac
+    LANGUAGES="$(cat kde-i18n/subdirs)"
+    echo "available languages: $LANGUAGES"
+    rm -r kde-i18n
+}
+
 #----------------------------------------------------------#
 #                          MAIN                            #
 #----------------------------------------------------------#
@@ -442,9 +476,20 @@ cd ${APPDIR}
 
 getAdminDir "${RETRIEVAL_METHOD}" "admin"
 
-getDocumentation "${RETRIEVAL_METHOD}" "doc"
+# if no languages are specified get the complete list from kde-i18n
+if [ $GETI18N = "yes" ]; then
+    if [ -z "$LANGUAGES" ]; then
+	getAvailableLanguages "${RETRIEVAL_METHOD}"
+    fi
+fi
+
+if [ $GETDOC = "yes" ]; then
+    getDocumentation "${RETRIEVAL_METHOD}" "doc"
+fi
 
-getTranslation "${RETRIEVAL_METHOD}" "po"
+if [ $GETI18N = "yes" ]; then
+    getTranslation "${RETRIEVAL_METHOD}" "po"
+fi
 
 # remove all "CVS/*" files
 cd "$BUILDDIR"
@@ -453,7 +498,7 @@ cleanUpFiles
 cd ${APPDIR}
 
 # create Makefile.am for doc and all Languages
-( 
+if [ $GETDOC = "yes" ]; then
     cd doc 
     DOC_SUBDIRS=`listsubdirs`
     if [ -n "`echo $DOC_SUBDIRS|sed 's/ //g'`" ]; then
@@ -461,14 +506,15 @@ cd ${APPDIR}
 	for lang in $LANGUAGES ; do 
 	    ( test -d $lang && cd $lang && echo "SUBDIRS = `listsubdirs`" > Makefile.am )
 	done
+	cd ..
     else 
 	cd ..
 	rmdir doc 2> /dev/null
     fi
-)
+fi
     
 # create Makefile.am for po
-( 
+if [ $GETI18N = "yes" ]; then
     cd po 
     PO_SUBDIRS=`listsubdirs`
     if [ -n "`echo $PO_SUBDIRS|tr -d '\n'`" ] ;then
@@ -482,11 +528,12 @@ SUBDIRS = \$(AUTODIRS)
 POFILES = AUTO" > Makefile.am 
 	)
 	done
+	cd ..
     else
 	cd ..
 	rm -rf po
     fi
-)
+fi
 
 # 
 echo -e "Building configure script\n"

--Boundary-00=_Fh7R+2HgIEqHmt3--