summaryrefslogtreecommitdiffstats
path: root/src/dist/createPackage.sh
blob: 99d160da76c42398fdb4a8c6c30cf8685148a03b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
#!/bin/bash
#
# Extract an application from KDE svn, including documentation and translations.
#
# Authors: Michael Buesch <[email protected]>
#          Jeroen Wijnhout <[email protected]>
#          Sebastian Trueg
#          Aurelien Gateau
#          Klas Kalass
# License: GPL (http://www.gnu.org/)
#
#
# Directory lay-out of packages
# Application:
# + name-version
#        + admin
#        + src
#        + doc
#        + translations
#            + nl
#                + messages
#                + doc
#            + de (etc.)
#
# If the --notoplevel parameter is used everything under src is put into the root dir
#
# Translations:
#        + nl
#            + messages
#            + doc
#        + de (etc.)

COPYRIGHT="2005 Michael Buesch <[email protected]>
          2004-2005 Jeroen Wijnhout <[email protected]>
          2003-2004 Sebastian Trueg
          2002 Aurelien Gateau
          2002-2004 Klas Kalass"
LICENSE="GNU General Public License v2 or later"

SCRIPTNAME="createPackage.sh"
SCRIPTVERSION='$Revision$'
SCRIPTVERSION="`echo $SCRIPTVERSION | cut -d ' ' -f2`"


function showVersion
{
    echo "$SCRIPTNAME revision $SCRIPTVERSION"
}

function showHelp
{
    showVersion
    echo -e "
Extract an application from KDE svn, including documentation and translations.

Copyright $COPYRIGHT
License: $LICENSE

usage:
    $0 -ab <PATH> -a <NAME> [OPTIONS]

These parameters are mandatory:

    -ab|--app-base <PATH>       Relative (to svnroot) path to the KDE or extragear module.
                                Example:
                                    trunk/extragear/utils
                                If you want to checkout from a branch, you might use:
                                    branches/foobar/1.2

    -a|--app <NAME>             Name of the application to checkout.
                                This is the subdir you want to checkout in --app-base.

The following options are available:

    -d|--svnroot <URL>          Base URL of the svn repository.
                                svn://anonsvn.kde.org/home/kde is the default.

    -ib|--i18n-base <PATH>      Path to the i18n translations base.
                                Default:
                                    trunk/l10n

    -is|--i18n-sub <PATH>       Path to the i18n files under the
                                \$i18n-base/\$LANGUAGE/messages
                                directories. Example:
                                    extragear-office

    -ids|--i18n-docsub <PATH>   Path to the i18n docbook files under the
                                \$i18n-base/\$LANGUAGE/docs
                                directories. Example:
                                    kdeextragear-2
                                Default:
                                    path of --i18n-sub

    --admin <PATH>              Path to the /admin/ directory.
                                Default:
                                    trunk/KDE/kde-common/admin

    -b|--builddir <DIRNAME>     Name of the temporary working directory where
                                all files will be put. Default is \"./build\"

    -av|--appversion <VERSION>  Version of the application (only for correct
                                naming of the tar archives).

    --nodoc                     Do not try to get any documentation.

    --noi18n                    Do not search for any translations.

    --split                     Make separate packages for the application and translations.

    --package [TYPE]            Create tarballs (.tar.gz and/or .tar.bz2).
                                You can specify an optional package type: \"gzip\" or \"bzip2\"
                                If no type is given, both types will be generated.

    --packagedir <TARBALLDIR>   Place a copy of the packages into TARBALLDIR.

    --postprocess <SCRIPT>      Runs SCRIPT on the package, after all data is gathered, but before
                                the tarball is generated. This allows packagers to give the
                                \"final touch\" to the package.

    --pofiles <POFILES>         Space seperated list of pofiles this application uses without the extension.
                                Defaults to the name of the application.

    -l|--languages <LANGUAGES>  Space seperated list of languages to search for
                                translations. If no languages are specified, all
                                available languages will be included.

    -el|--exclude-languages <LANGUAGES> Space seperated list of languages not to include
                                        in the package.

    --logfile <FILE>            Write all logging information to FILE.
                                If FILE is \"no\", no logfile will be created.

    --notoplevel                Do not create an additional src directory. Do not checkout the top level files.
                                Use configure.in.in and Makefile.am from the application's root directory.

    -v|--version                Version of this script
    -h|--help                   This Help"
}

#
# Some simple helper functions.
#

function printlog
{
    if [ -n "$LOGFILE" ]; then
        echo -e "$SCRIPTNAME: $*" >> $LOGFILE
    fi
}

function printnlog
{
    if [ -n "$LOGFILE" ]; then
        echo -n -e "$SCRIPTNAME: $*" >> $LOGFILE
    fi
}

function print
{
    echo -e "$SCRIPTNAME: $*"
    printlog $*
}

function printn
{
    echo -n -e "$SCRIPTNAME: $*"
    printnlog $*
}

function runCommand
{
    stdoutlog="$LOGFILE"
    if [ -z "$stdoutlog" ]; then
        stdoutlog="/dev/null"
    fi
    $* >> $stdoutlog 2>&1
    LASTRESULT=$?
    print "         [$1 returned $LASTRESULT]"
}

function runCommandRedirect
{
    destinationfile=$1
    shift

    stdoutlog="$LOGFILE"
    if [ -z "$stdoutlog" ]; then
        stdoutlog="/dev/null"
    fi
    $* > $destinationfile 2>>$stdoutlog
    LASTRESULT=$?
    if [ $LASTRESULT -ne 0 ]; then
        rm $destinationfile
    fi
    print "         [$1 returned $LASTRESULT]"
}

function testParameter
{
    if [ -z "$2" ]; then
        echo "Please give a value to parameter $1"
        exit 1
    fi
}

function makeDir
{
    cd $BUILDDIR
    print "                  Creating directory $*"
    runCommand mkdir $*
}


#
# Removes the .svn directories
#
function removeVCDirs
{
    if ! [ -d "$BUILDDIR/$*" ]; then
        return
    fi
    print "                  Removing VCDirs $*"
    cd $BUILDDIR/$*
    find . -type d -a -name '.svn' | xargs rm -rf
}

#
# This is our work-horse. getResource retrieves all
# data needed to assemble a working package.
# Available resources:
# topleveldir, admindir, source, documentation,
# languagelist, guitranslation, doctranslation
#
function getResource
{
    DESTINATION=$2
    SINGLEFILEHACK="no"
    case $1 in
        topleveldir)
            COMMAND="svn export -N $SVN_CHECKOUT_OPTIONS $SVNROOT/$APPBASE $DESTINATION"
        ;;
        admindir)
            COMMAND="svn export $SVN_CHECKOUT_OPTIONS $SVNROOT/$ADMINDIR $DESTINATION"
        ;;
        source)
            COMMAND="svn export $SVN_CHECKOUT_OPTIONS $SVNROOT/$APPBASE/$APPNAME $DESTINATION"
        ;;
        documentation)
            COMMAND="svn export $SVN_CHECKOUT_OPTIONS $SVNROOT/$APPBASE/doc/$APPNAME $DESTINATION"
        ;;
        languagelist)
            SINGLEFILEHACK="yes"
            COMMAND="svn cat $SVN_CHECKOUT_OPTIONS $SVNROOT/$I18NBASE/subdirs"
        ;;
        guitranslation)
            DESTINATION=$3/$4.po
            SINGLEFILEHACK="yes"
            COMMAND="svn cat $SVN_CHECKOUT_OPTIONS $SVNROOT/$I18NBASE/$2/messages/$I18NSUB/$4.po"
        ;;
        doctranslation)
            DESTINATION=$3
            COMMAND="svn export $SVN_CHECKOUT_OPTIONS $SVNROOT/$I18NBASE/$2/docs/$I18NDOCSUB/$APPNAME $DESTINATION"
        ;;
        *)
            print "ERROR: Unknown resource $1"
            exit 1
        ;;
    esac

    print "         Retrieving resource: $1"
    printlog "         getResource $1: $COMMAND"

    cd $BUILDDIR

    if [ $SINGLEFILEHACK = "yes" ]; then
       runCommandRedirect $DESTINATION $COMMAND
    else
       runCommand $COMMAND
    fi

    if [ $LASTRESULT != "0" ]; then
        print "Warning: Resource \"$1\" is not available."
    fi
    return $LASTRESULT
}

#
# Creates the build dir, the dir where the packages
# are assembled.
#
function setupBuildDir
{
    print "Creating the build directory..."
    print "         ($BUILDDIR)"

    # clean up first
    if [ -d $BUILDDIR ]; then
        print "         Removing the old build directory"
        rm -rf $BUILDDIR
    fi

    mkdir $BUILDDIR
}

#
# Gather all data in the build dir needed to build
# the application (without translations).
#
function assembleApplicationData
{
    print "Assembling the source code..."
    APPDIR=$APPNAME-$APPVERSION
    print "         ($APPDIR)"

    if [ $TOPLEVEL = "yes" ]; then
        getResource "topleveldir" $APPDIR
    fi

    getResource "admindir" $APPDIR/admin

    if [ $TOPLEVEL = "yes" ]; then
        getResource "source" $APPDIR/src
    else
        getResource "source" $APPDIR
    fi
}

#
# Copies the GNU (README, TODO, Changelog, etc.) files.
#
function moveGNUFiles
{
    print "         Moving the standard GNU files"
    for file in $GNUFiles
    do
        if [ -f $BUILDDIR/$APPDIR/src/$file ]; then
            mv $BUILDDIR/$APPDIR/src/$file $BUILDDIR/$1
        fi
    done
}

#
# Cleanup the application or i18n directory by removing
# unneccessary files and directories.
#
function cleanupDirectory
{
    dir="$1"
    print "Removing unneccessary files and directories"
    for file in $CLEANUPFILES
    do
        path="$dir/$file"
        if [ -f "$path" ]; then
            rm -f $path
            printlog "         Removed file: $path"
        elif [ -d "$path" ]; then
            rm -Rf $path
            printlog "         Removed directory: $path"
        fi
    done
}

#
# After all data for the app is gathered, some files
# still need to be shuffled around.
#
function postProcessApplicationDir
{
    print "Post-processing the application directory..."
    if [ $TOPLEVEL = "yes" ]; then
        moveGNUFiles $APPDIR
    fi

    if [ ! -z "$POSTPROCESSSCRIPT" ]; then
        print "Running post-processing script..."
        cd $BUILDDIR/$APPDIR
        $POSTPROCESSSCRIPT
        err="$?"
        if [ $err -ne 0 ]; then
            print "ERROR: Post-processing script failed (return status: $err)"
            exit $err
        fi
        print "Post-processing script finished."
    fi
}

function retrieveDocumentation
{
    if [ $GETDOC = "no" ]; then
        return
    fi

    print "Retrieving the documentation..."
    DOCDIR=$APPDIR/doc
    print "         ($DOCDIR)"

    getResource "documentation" $DOCDIR
}

#
# Determines what languages need to be retrieved.
# If LANGUAGES was not set using the -l switch,
# the tde-i18n/subdirs file is used.
#
function getLanguageList
{
    print "         Determining which languages to include..."
    if [ -z "$LANGUAGES" ]; then
        getResource "languagelist" languagelist
        if [ -e $BUILDDIR/languagelist ]; then
            LANGUAGES=`cat $BUILDDIR/languagelist`
            rm $BUILDDIR/languagelist
        else
            print "ERROR:"
            print "ERROR: Failed to automatically detect which languages to include."
            print "ERROR:"
            exit 1
        fi
    fi

    # Remove the excluded languages from the list
    LANGLIST=""
    for language in $LANGUAGES ; do
        EXCLUDE="false"
        for exclang in $EXCLUDELANGUAGES ; do
            if [ "$exclang" = "$language" ]; then
                EXCLUDE="true"
                break
            fi
        done
        if [ $EXCLUDE = "false" ]; then
            LANGLIST="$LANGLIST $language"
        fi
    done
    LANGUAGES=$LANGLIST
    print "Language list: $LANGUAGES"
}

#
# Creates the dir that holds the translations. This is either
# a "translations" dir in the application build dir, or, if the
# --split switch is used, the root dir of a separate i18n package.
#
function setupI18NDir
{
    if [ $SPLIT = "yes" ]; then
        I18NDIR="$APPNAME-i18n-$APPVERSION"

        getResource "topleveldir" $I18NDIR
        getResource "admindir" $I18NDIR/admin
        moveGNUFiles $I18NDIR

        TRANSDIR=$I18NDIR
    else
        I18NDIR=$APPDIR
        TRANSDIR="$I18NDIR/translations"
        makeDir $TRANSDIR
    fi
}

function createTranslationDirMakefile
{
    if [ $GETI18N = "no" ]; then
        return
    fi

    print "         Creating Makefile.am in $1."
    CONTENTS="SUBDIRS=$INCLUDED_LANGUAGES"
    echo $CONTENTS > $1/Makefile.am
}

function createTranslationMakefile
{
    print "         Creating Makefile.am in $1."
    CONTENTS="SUBDIRS="
    if [ -d "$1/messages" ]; then
        CONTENTS="$CONTENTS messages"
    fi
    if [ -d "$1/doc" ]; then
        CONTENTS="$CONTENTS doc";
    fi
    echo $CONTENTS > $1/Makefile.am
}

function createTranslationMakefiles
{
    if [ $GETI18N = "no" ]; then
        return
    fi

    for language in $INCLUDED_LANGUAGES ; do
        createTranslationMakefile $BUILDDIR/$TRANSDIR/$language
    done
}

function createGUITranslationMakefile
{
    print "         Creating Makefile.am in $2."
    echo "KDE_LANG = $1
SUBDIRS = \$(AUTODIRS)
POFILES = AUTO" > $2/Makefile.am
}

function createDocTranslationMakefile
{
    print "                  Creating Makefile.am in $2."
    echo "KDE_LANG = $1
KDE_DOCS=$APPNAME" > $2/Makefile.am
}

#
# Get the .po files and put them in xx/messages
# subdirectories, where xx is the language ISO code.
#
function retrieveGUITranslations
{
    if [ $GETI18N = "no" ]; then
        return
    fi

    print "Retrieving GUI translations..."
    setupI18NDir
    print "         ($TRANSDIR)"

    # determine which languages to get
    getLanguageList

    # then get them (its really simple actually)
    INCLUDED_LANGUAGES=""
    for language in $LANGUAGES
    do
        print "         Including language $language"
        makeDir $TRANSDIR/$language
        makeDir $TRANSDIR/$language/messages
        INCLUDE_THIS_LANG="yes"
        for pofile in $APP_POFILES; do
            getResource "guitranslation" $language $TRANSDIR/$language/messages $pofile
            if [ ! -e $BUILDDIR/$TRANSDIR/$language/messages/$pofile.po ]; then
                INCLUDE_THIS_LANG="no"
            fi
        done

        if [ $INCLUDE_THIS_LANG = "yes" ]; then
            createGUITranslationMakefile $language $BUILDDIR/$TRANSDIR/$language/messages
            INCLUDED_LANGUAGES="$INCLUDED_LANGUAGES $language"
        else
            rm -rf $TRANSDIR/$language
        fi
    done
}

function retrieveDocTranslations
{
    if [ $GETI18N = "no" ]; then
        return
    fi

    print "Retrieving documentation translations..."

    for language in $INCLUDED_LANGUAGES ; do
        print "         Including documentation for language $language"
        getResource "doctranslation" $language $TRANSDIR/$language/doc
        if [ -e $BUILDDIR/$TRANSDIR/$language/doc/index.docbook ]
        then
            createDocTranslationMakefile $language $BUILDDIR/$TRANSDIR/$language/doc
        else
            print "                  No translations for $language docs available."
            rm -rf $TRANSDIR/$language/doc
        fi
    done
}

#
# Create the configure script and Makefile.in's.
#
function packageApplication
{
    cd $BUILDDIR

    print "Creating configure script and Makefile.in files"
    (cd $APPDIR; runCommand make -f admin/Makefile.common cvs)

    cleanupDirectory $APPDIR

    TARNAME="$APPNAME-$APPVERSION.tar"
    if [ $PACKAGE = "gzip" ] || [ $PACKAGE = "yes" ]; then
        print "Packaging application ($TARNAME.gz)..."
        $GZIP $TARNAME.gz $APPDIR
        if [ $BUILDDIR != $TARBALLDIR ]; then
            cp $TARNAME.gz $TARBALLDIR
        fi
    fi
    if [ $PACKAGE = "bzip2" ] || [ $PACKAGE = "yes" ]; then
        print "Packaging application ($TARNAME.bz2)..."
        $BZIP2 $TARNAME.bz2 $APPDIR
        if [ $BUILDDIR != $TARBALLDIR ]; then
            cp $TARNAME.bz2 $TARBALLDIR
        fi
    fi
}

#
# Create the configure script and Makefile.in's.
#
function packageTranslations
{
    if [ $SPLIT != "yes" ] || [ $GETI18N != "yes" ]; then
        return
    fi

    cd $BUILDDIR

    print "Creating translations configure script and Makefile.in files"
    (cd $I18NDIR; runCommand make -f admin/Makefile.common cvs)

    cleanupDirectory $I18NDIR

    TARNAME="$APPNAME-i18n-$APPVERSION.tar"
    if [ $PACKAGE = "gzip" ] || [ $PACKAGE = "yes" ]; then
        print "Packaging translations ($TARNAME.gz)..."
        $GZIP $TARNAME.gz $I18NDIR
        if [ $BUILDDIR != $TARBALLDIR ]; then
            cp $TARNAME.gz $TARBALLDIR
        fi
    fi
    if [ $PACKAGE = "bzip2" ] || [ $PACKAGE = "yes" ]; then
        print "Packaging translations ($TARNAME.bz2)..."
        $BZIP2 $TARNAME.bz2 $I18NDIR
        if [ $BUILDDIR != $TARBALLDIR ]; then
            cp $TARNAME.bz2 $TARBALLDIR
        fi
    fi
}

#
# Force the script to quit
#
function cancelScript
{
    errorcode="$1"
    if [ -z "$errorcode" ]
    then
        errorcode="1"
    fi
    print "Script canceled ($errorcode)"
    exit $errorcode
}

#
# Do basic parameter checks, print some basic stuff
# and initialize basic things.
#
function initBasic
{
    trap "cancelScript" SIGINT SIGTERM

    if [ -n "$LOGFILE" ]; then
        echo "$SCRIPTNAME revision $SCRIPTVERSION  `date`" > $LOGFILE
    fi

    if [ -z "$APPBASE" ]; then
        print "You need to specify an application base path (--app-base). See $SCRIPTNAME --help for more info."
        exit 1
    fi
    if [ -t "$APPNAME" ]; then
        print "You need to specify an application name (--app). See $SCRIPTNAME --help for more info."
        exit 1
    fi
    if [ "$GETI18N" = "yes" ] && [ -z "$I18NSUB" ]; then
        print "You need to specify the i18n subdir or disable i18n checkout (--i18n-sub or --noi18n). See $SCRIPTNAME --help for more info."
        exit 1
    fi
    if [ -z "$I18NDOCSUB" ]; then
        I18NDOCSUB="$I18NSUB"
    fi

    if [ -z "$APP_POFILES" ]; then
        APP_POFILES="$APPNAME"
    fi

    print "Using svn-root: $SVNROOT"
}

function initVars
{
    LOGFILE="$PWD/$SCRIPTNAME.log"

    APPBASE=""
    APPNAME=""
    SVNROOT="svn://anonsvn.kde.org/home/kde"
    I18NBASE="trunk/l10n"
    I18NSUB=""
    I18NDOCSUB=""
    APP_POFILES=""
    ADMINDIR="trunk/KDE/kde-common/admin"

    LASTRESULT="0"
    BUILDDIR="$PWD/build"
    TARBALLDIR=$BUILDDIR
    APPVERSION="`date +%d.%m.%y`"
    GETDOC="yes"
    GETI18N="yes"
    SPLIT="no"
    TOPLEVEL="yes"
    PLAINCONFIGURE="no"
    LISTTAGS="no"
    PACKAGE="no"
    LANGUAGES=""
    EXCLUDELANGUAGES="xx"
    GNUFiles="AUTHORS COPYING ChangeLog INSTALL TODO README README.MacOSX README.cwl kile-remote-control.txt Building-with-cmake.txt"
    CLEANUPFILES="autom4te.cache Makefile.cvs"
    POSTPROCESSSCRIPT=""

    SVN_CHECKOUT_OPTIONS=""

    BZIP2="tar jcf"
    GZIP="tar zcf"
}

####################################################################
##                                                                ##
##                       Here we start:                           ##
##                                                                ##
####################################################################

# Set the default values for options.
initVars

# Process the options given on the command-line.
while [ "$#" -gt 0 ]
do
    case $1 in
        -ab|--app-base)
            testParameter $1 $2
            APPBASE="$2"
            shift
        ;;
        -a|--app)
            testParameter $1 $2
            APPNAME="$2"
            shift
        ;;
        -d|--svnroot)
            testParameter $1 $2
            SVNROOT="$2"
            shift
        ;;
        -ib|--i18n-base)
            testParameter $1 $2
            I18NBASE="$2"
            shift
        ;;
        -is|--i18n-sub)
            testParameter $1 $2
            I18NSUB="$2"
            shift
        ;;
        -ids|--i18n-docsub)
            testParameter $1 $2
            I18NDOCSUB="$2"
            shift
        ;;
        --admin)
            testParameter $1 $2
            ADMINDIR="$2"
            shift
        ;;
        -b|--builddir)
            testParameter $1 $2
            BUILDDIR="$2"
            shift
        ;;
        -av|--appversion)
            testParameter $1 $2
            APPVERSION="$2"
            shift
        ;;
        --pofiles)
            testParameter $1 $2
            APP_POFILES="$APP_POFILES $2"
            shift
        ;;
        --nodoc)
            GETDOC="no"
        ;;
        --noi18n)
            GETI18N="no"
        ;;
        --split)
            SPLIT="yes"
        ;;
        --notoplevel)
            TOPLEVEL="no"
        ;;
        --package)
            PKGTYPE="$2"
            if [ "$PKGTYPE" = "gzip" ] || [ "$PKGTYPE" = "bzip2" ]
            then
                shift
                PACKAGE="$PKGTYPE"
            else
                PACKAGE="yes"
            fi
        ;;
        --packagedir)
            testParameter $1 $2
            TARBALLDIR=$2
            shift
        ;;
        --postprocess)
            testParameter $1 $2
            POSTPROCESSSCRIPT=$2
            shift
        ;;
        -l|--languages)
            testParameter $1 $2
            LANGUAGES="$LANGUAGES $2"
            shift
        ;;
        -el|--exclude-languages)
            testParameter $1 $2
            EXCLUDELANGUAGES="$EXCLUDELANGUAGES $2"
            shift
        ;;
        --logfile)
            testParameter $1 $2
            if [ "$2" = "no" ]
            then
                LOGFILE=""
            else
                if [ "`echo $2 | cut -c1`" = "/" ]
                then
                    LOGFILE=$2
                else
                    LOGFILE=$PWD/$2
                fi
            fi
            shift
        ;;
        -h|--help)
            showHelp
            exit 0
        ;;
        -v|--version)
            showVersion
            exit 0
        ;;
        *)
            echo "Invalid parameter $1"
            exit 1
        ;;
    esac
    # process the next parameter
    shift
done

initBasic

# Create the builddir, the place where the package will be assembled.
# If no builddir is specified is specified "./$APPNAME-build" is used.
setupBuildDir

assembleApplicationData
retrieveDocumentation

retrieveGUITranslations
retrieveDocTranslations
createTranslationMakefiles
createTranslationDirMakefile $BUILDDIR/$TRANSDIR

postProcessApplicationDir

packageApplication
packageTranslations

# vim: set et ts=4 sts=4: