4 # Webpage: http://www.katzbrown.com/shiritsu/programming/cvs2dist/
5 # Newest version is always available there!
6 # Please report bugs to <jason@katzbrown.com>.
8 # Original author (of cvs2pack.sh) was Sebastian Stein <seb.stein@hpfsc.de>
9 # Heavy, heavy modifications by Jason Katz-Brown <jason@katzbrown.com>
10 # Some modifications for i18n inclusion by Dominique Devriese <devriese@kde.org>
11 # Added --no-i18n-lang and --replace-files by Michael Buesch <mbuesch@freenet.de>
12 # License: GPL (http://www.gnu.org/)
13 # Last modification: 2004/10/13
18 override
="README ChangeLog INSTALL AUTHORS AUTHOR COPYING COPYING.LIB TODO"
19 remove
="config.cache config.log config.status Makefile configure inst-apps CVS acinclude.m4 aclocal.m4 config.h config.h.bot config.h.in configure.files libtool stamp-h stamp-h.in stamp-h1 subdirs *.moc *.la .libs .deps .cvsignore autom4te.cache {arch} .arch-ids"
20 toplevelremove
="configure.in.bot"
21 # whitespace seperated list of languages to never include.
22 always_skip_languages
="xx"
24 pofilenames
="kttsd kttsd_commandplugin kttsd_eposplugin kttsd_festivalintplugin
25 kttsd_fliteplugin kttsd_freettsplugin kttsd_hadifixplugin kttsd_sbdplugin
26 kttsd_stringreplacerplugin kttsd_talkerchooserplugin kttsd_xmltransformerplugin
27 kttsjobmgr kttsmgr kcmkttsd khtmlkttsd ktexteditor_kttsd"
31 echo -n "Cleaning up... "
32 if [ -d $temp_dir ]; then
33 test -z "$debug" && rm -Rf $temp_dir
38 trap "exit_cleanup; exit 1" SIGINT SIGTERM
40 test -e ~
/.cvs2distrc
&& extraoptions
=`cat ~/.cvs2distrc`
42 # getopt usage from the getopt bash example
43 # --log has optional argument
45 -o v:n:r:e:a:B:dhmbgol \
46 --long log::,version:,name:,required-header:,required-header-error-message:,make-unpackaged,help,no-bz2,no-bzip2,no-gzip,only-directory,remove-hidden,admin-dir:,branch:,no-i18n,no-i18n-lang:,cvs-root:,debug,replace-files: \
47 -n cvs2dist -- $extraoptions "$@"`
66 -v|
--version) version
=$2; shift 2 ;;
67 -n|
--name) name
=$2; shift 2 ;;
68 -a|
--admin-dir) admindir
=$2;
69 if [ `echo $admindir | sed -e 's#^/##'` = $admindir ]; then
70 admindir
="`pwd`/$admindir"
73 -B|
--branch) branch
="-r$2"; shift 2;;
74 --debug) debug
="non-empty"; shift 1 ;;
75 --cvs-root) cvsroot
="$2"; shift 2 ;;
76 -r|
--required-header) requiredheader
=$2; shift 2 ;;
77 --no-i18n) doi18n
="no"; shift 1 ;;
78 --no-i18n-lang) noi18nlang
="$2"; shift 2 ;;
79 -e|
--required-header-error-message) requiredmsg
=$2; shift 2 ;;
80 -m|
--make-unpackaged) leavedir
="non-empty"; shift 1 ;;
81 -h|
--help) showhelp
="non-empty"; shift 1 ;;
82 -b|
--no-bz2|
--no-bzip2) nobzip2
="non-empty"; shift 1 ;;
88 -g|
--no-gzip) nogzip
="non-empty"; shift 1 ;;
89 -d|
--remove-hidden) removehidden
="non-empty"; shift 1 ;;
90 -l) calclog
=1; shift 1 ;;
94 "") calclog
=1; shift 2 ;;
95 # something, should be a file
98 if [ `echo $log | sed -e 's#^/##'` = $log ]; then
104 --replace-files) replace_files
="$2"; shift 2 ;;
114 test $count = 0 && module
=$arg
115 test $count = 1 && directory
=$arg
117 if [ $count -ge 2 ]; then
119 if [ `echo $modarg | sed -e 's#^/##'` = $modarg ]; then
120 modarg
="`pwd`/$modarg"
122 addfiles
="$addfiles $modarg"
128 # test if a module and directory name was given
129 if [ ! -z $showhelp ] ||
[ -z $module ] ||
[ -z $directory ]; then
130 echo "Usage: cvs2dist module directory [options] [addfile1] [addfile2] ..."
132 echo " -n --name <name>"
133 echo " -v --version <version>"
134 echo " --cvs-root <root> the value to use as cvs root"
135 echo " variable. It is not necessary if you use --no-i18n."
136 echo " if this is not given, it is taken from the CVSROOT "
137 echo " environment variable."
138 echo " --admin-dir <dir> admin/ location (default is module/admin)"
139 echo " (symbolic links are OK.)"
140 echo " -B --branch <branch> use branch for i18n checkouts."
141 echo " --no-i18n don't try to automatically checkout the translations from cvs."
142 echo " --no-i18n-lang <languages> exclude all languages in the given comma"
143 echo " seperated list. example:"
144 echo " --no-i18n-lang uk,de,en_GB"
145 echo " --log=<logfile> If logfile unspecified, default file is used."
146 echo " (The '=' is essential and may not be ommited"
147 echo " when specifying the logfile.)"
148 echo " -l Log to default logfile."
149 echo " -m --make-unpackaged Also makes an unpacked distribution"
150 echo " in the current directory."
151 echo " -g --no-gzip Do not create gzip package."
152 echo " -b --no-bz2 Do not create bzip2 package."
153 echo " --no-bzip2 Alias for the above."
154 echo " -o --only-directory Alias for -mbg (no packages, only a directory.)"
155 echo " -r --required-header <header> Errors if header is not installed."
156 echo " -e --required-header-error-message <message>"
157 echo " Error message for above."
158 echo " -d --remove-hidden Remove hidden files/directories from packages"
159 echo " --replace-files <file-pair-list>"
160 echo " <file-pair-list> is a comma separated list of file pairs"
161 echo " which should be replaced in the final distribution package."
162 echo " Each element of a pair is separated by an @"
163 echo -n " Example: --replace-files take_this_file@and_move_it_here,"
164 echo "configure.in.bot.dist@configure.in.bot"
165 echo " The filenames are all relative to your package root."
166 echo " Please be careful! Try to avoid the usage of .. in the path. It"
167 echo " may break stuff! There can not be blank characters in the paths."
168 echo " -h --help Show this help"
170 echo " Name defaults to the last part of the directory."
171 echo "By default, creates name[-version].tar.gz if gzip is installed"
172 echo "and/or name[-version].tar.bz2 if bzip2 is installed in the current"
173 echo "directory. Removes all temporary files it creates. Produces"
174 echo "tarballs that are standard distribution tarballs with a"
175 echo "configure script."
176 echo " Unless --no-i18n is given, it automatically tries to check out "
177 echo "strings and documentation translation from cvs."
178 echo " Arguments after the second are added to the toplevel directory"
179 echo "in the package. Short options can be combined, eg -dm to create"
180 echo "a directory and remove hidden files. ~/.cvs2distrc is added to"
181 echo "the beginning of command line arguments if it exists."
182 echo " '--' signifies the end of options."
184 echo "Example: cvs2dist /sources/kdegames kolf/objects/picture \\"
185 echo " -n kolf-picture -v 0.9 -r \"kolf/game.h\" \\"
186 echo " --log ~/tmp/extra-file"
188 echo " Creates packages of the kolf picture plugin, naming the"
189 echo " packages kolf-picture-0.9 and logging the process. For configure"
190 echo " to succeed, kolf/game.h must be installed or an error will occur."
191 echo " ~/tmp/extra-file is added to the packages."
193 echo "Webpage: http://www.katzbrown.com/shiritsu/programming/cvs2dist/"
194 echo "Authors: Jason Katz-Brown <jason@katzbrown.com>,"
195 echo " Sebastian Stein <seb.stein@hpfsc.de>,"
196 echo " Dominique Devriese <devriese@kde.org>"
201 module
=`echo $module | sed -e 's#/$##'`
202 if [ `echo $module | sed -e 's#^/##'` = $module ]; then
203 module
="`pwd`/$module"
206 # test if the given module is a directory
208 if [ $?
-ne 0 ]; then
209 echo "$module is not a directory."
217 directory
=`echo $directory | sed -e 's#^/##'`
219 if [ -z $name ]; then
221 # get rid of trailing slash
222 name
=`echo $name | sed -e 's#/$##'`
224 name
=`echo $name | sed -e 's#^/##'`
226 if [ `echo $name | sed -e 's#/##'` != $name ]; then
227 name
=`echo $name | sed -e 's#^.*/##'`
231 test $calclog = 1 && log
="$returndir/cvs2dist-$name.log" && origlog
="cvs2dist-$name.log"
233 # test if the given name is a sub-directory
234 if [ ! -d "$directory" ]; then
235 echo "$directory is not a sub-directory of $module."
240 test $log != "/dev/null" && echo "Logging to $log."
242 echo "cvs2dist log on "`date` > $log
243 echo "http://katzbrown.com/shiritsu/programming/cvs2dist/" >> $log
244 echo -n "Module: $module; Directory: $directory; Name: $name; " >> $log
245 if [ -z $version ]; then
246 echo "Version unspecified." >> $log
248 echo "Version $version." >> $log
250 echo $cmdline >> $log
251 echo "--------" >> $log
253 if [ -z $version ]; then
256 filename
="$name-$version"
259 if [ -z $cvsroot ]; then
262 if [ $doi18n = "yes" ]; then
263 # a little warning...
264 echo "Will try to fetch i18n files from KDE's CVS."
265 echo "If this doesn't work, use --no-i18n."
267 if [ -z "$cvsroot" ]; then
268 echo "No cvs root specified, CVSROOT env var is empty, " >> $log
269 echo "and --no-i18n option is not given.." >> $log
270 echo "Using anonymous cvs.." >> $log
271 cvsroot
=":pserver:anonymous@anoncvs.kde.org:/home/kde"
272 # append an entry to ~/.cvspass so the user will not be asked
273 # for a pwd. Thanks to coolo for the idea..
274 if ! grep "anoncvs.kde.org" ~
/.cvspass
>/dev
/null
2>&1; then
275 echo "/1 :pserver:anonymous@anoncvs.kde.org:2401/home/kde A" >> ~
/.cvspass
280 # the temporary directory
281 temp_dir
="$module/cvs2dist-tmp"
282 temp_dist
="$temp_dir/$filename"
284 echo "Temporary directory is $temp_dir." >> $log
286 # make a temporary directory
287 test -d $temp_dir && rm -Rf $temp_dir
291 # check if we were able to create temp_dir
293 if [ $?
-ne 0 ]; then
294 echo "Could not create temporary directory $temp_dist."
295 echo "$temp_dist could not be created." >> $log
300 test -z "$requiredmsg" && requiredmsg
="Install development package needed first! $requiredheader, for one, is missing."
303 if [ ! -z $requiredheader ]; then
304 naiyou
="KDE_CHECK_HEADER(
307 [AC_MSG_ERROR(\"$requiredmsg\")]
309 echo $naiyou > $temp_dir/configure.
in.
in
310 echo "configure.in.in contents: " >> $log
311 echo "--------" >> $log
313 appaddfiles
="$appaddfiles $temp_dir/configure.in.in"
316 # copy all files of the module to temp_dir/name
317 cp -RL $module/$directory $temp_dist/$name
319 echo "cp -R $module/$directory $temp_dist/$name" >> $log
322 # get rid of trailing slash
323 modulename
=`echo $modulename | sed -e 's#/$##'`
325 modulename
=`echo $modulename | sed -e 's#^.*/##'`
327 remove
="$remove $modulename.lsm"
329 # we check out kde-i18n/subdirs in temp_dir/kde-i18n..
330 if [ $doi18n = "yes" ]; then
332 echo "cvs co kde-i18n/subdirs" >> $log
333 cvs
-z4 -q -d "$cvsroot" co
$branch -P kde-i18n
/subdirs
> /dev
/null
2>&1
334 i18nlangs_tmp
="$(cat kde-i18n/subdirs)"
335 skiplist
="`echo $noi18nlang | sed -e 's/,/ /g'`"
336 skiplist
="$skiplist $always_skip_languages"
337 for lang
in $i18nlangs_tmp; do
339 for skip
in $skiplist; do
340 if [ "$lang" = "$skip" ]; then
344 if [ "$must_skip" = "no" ]; then
345 i18nlangs
="$i18nlangs $lang"
348 echo "available languages: $i18nlangs" >> $log
352 # if a handbook exists, we also copy it to the directory
353 if [ -d $module/doc
/$name ]; then
354 mkdir
-p $temp_dist/doc
/$name
355 cp -Rf $module/doc
/$name $temp_dist/doc
356 find $module/doc
/ ! -xtype d
-maxdepth 1 |
xargs --replace={} cp {} $temp_dist/doc
358 if [ $doi18n = "yes" ]; then
360 for lang
in $i18nlangs; do
361 test -d $temp_dist/doc
/$lang && rm -Rf $temp_dist/doc
/$lang
362 docdirname
="kde-i18n/$lang/docs/$modulename/$name"
363 echo "cvs co $docdirname" >> $log
364 cvs
-z4 -q -d "$cvsroot" co
$branch -P "$docdirname" > /dev
/null
2>&1
365 if [ ! -d "$docdirname" ]; then
366 echo "$lang's $name documentation does not exist." >> $log
369 echo -n "Copying $lang's $name documentation over... "
370 cp -R $docdirname $temp_dist/doc
/$lang
371 # we don't want KDE_DOCS = AUTO, cause that makes the
372 # build system assume that the name of the app is the
373 # same as the name of the dir the Makefile.am is in.
374 # Instead, we explicitly pass the name..
375 cat $temp_dist/doc
/$lang/Makefile.am |
sed -e "s/AUTO/$name/" > $temp_dist/doc
/$lang/Makefile.am.nw
376 mv $temp_dist/doc
/$lang/Makefile.am.nw
$temp_dist/doc
/$lang/Makefile.am
378 echo "$lang documentation included." >> $log
384 # clean up doc directory
385 if [ -d $temp_dist/doc
/$name ]; then
386 pushd $temp_dist/doc
/$name
387 echo -n "make clean in $temp_dist/doc/$name/... "
389 echo "make clean in $temp_dist/doc/$name/" >> $log
391 echo "--------" >> $log
396 if [ $doi18n = "yes" ]; then
397 test -d $temp_dist/po
&& rm -Rf $temp_dist/po
401 for lang
in $i18nlangs; do
402 dest
=$temp_dist/po
/$lang
403 for poname
in $pofilenames; do
404 pofilename
="kde-i18n/$lang/messages/$modulename/$poname.po";
405 echo "cvs co $pofilename" >> $log
406 cvs
-z4 -q -d "$cvsroot" co
$branch -P "$pofilename" > /dev
/null
2>&1
407 if [ ! -f "$pofilename" ]; then
408 echo "$lang's $poname.po does not exist." >> $log
412 if [ ! -d $dest ]; then
415 echo -n "Copying $lang's $poname.po over... "
416 echo "$lang's $poname.po file included." >> $log
421 echo "KDE_LANG = $lang
422 SUBDIRS = \$(AUTODIRS)
423 POFILES = AUTO" > $dest/Makefile.am
428 if [ -z "$subdirs" ]; then
431 echo "SUBDIRS = \$(AUTODIRS)" > $temp_dist/po
/Makefile.am
435 # copy the admin directory
436 if [ -z $admindir ]; then
437 cp -pRL $module/admin
$temp_dist
438 echo "cp -pRL $module/admin $temp_dist" >> $log
440 cp -pRL $admindir $temp_dist
441 echo "cp -pRL $admindir $temp_dist" >> $log
444 # and all files from the base dir, except directories
445 echo "Copying over files from the module directory:" >> $log
446 find $module ! -xtype d
-maxdepth 1 |
xargs --verbose --replace={} cp {} $temp_dist 2>> $log
447 echo "--------" >> $log
449 # we now enter the temp_dist and delete all unwanted files
450 # and add wanted files
453 # override top-level files
454 echo "Override files: " >> $log
455 for file in $override; do
456 test -e $temp_dist/$name/$file && mv $temp_dist/$name/$file .
&& echo "mv $temp_dist/$name/$file ." >> $log
459 test ! -z "$addfiles" && echo "Addfiles: " >> $log
460 for file in $addfiles; do
461 test -e $file && cp -R $file $temp_dist && echo "cp -R $file $temp_dist" >> $log
464 test ! -z "$appaddfiles" && echo "Application addfiles: " >> $log
465 for file in $appaddfiles; do
466 test -e $file && cp -R $file $temp_dist/$name/ && echo "cp -R $file $temp_dist/$name/" >> $log
469 echo "--------" >> $log
471 # replace all user requested files
472 if [ -n "$replace_files" ]; then
473 echo "Replace user requested files" >> $log
474 pair_list
="`echo $replace_files | sed -e 's/,/ /g'`"
475 for pair
in $pair_list; do
476 pair_tmp
="`echo $pair | sed -e 's/@/ /g'`"
477 from
="`echo $pair_tmp | awk '//{print $1}'`"
478 to
="`echo $pair_tmp | awk '//{print $2}'`"
479 if [ -z "$from" ] ||
[ -z "$to" ]; then
480 echo "bogus pair \"$from@$to\"" >> $log
483 echo "Replacing \"$to\" by \"$from\"" >> $log
484 from_path
="$temp_dist/$name/$from"
485 to_path
="$temp_dist/$name/$to"
486 if [ ! -f "$from_path" ]; then
487 echo "$from_path does not exist!" >> $log
489 echo "Warning: \"$from\" does not exist!"
490 echo -n "Please enter the path in --replace-files relative "
491 echo "to the package root of your project."
492 echo "Your package root is: \"$module/$directory\""
496 rm -f "$to_path" && \
497 mv "$from_path" "$to_path"
498 if [ $?
-ne 0 ]; then
499 echo -n "Moving \"$from_path\" failed! " >> $log
500 echo -n "This should not happen." >> $log
501 if [ -f "$to_path" ]; then
504 echo " No \"$to\" will exist in the archive!" >> $log
508 echo "--------" >> $log
511 # version file, if it doesn't exist
512 test ! -z $version && test ! -e VERSION
&& echo "$name version $version" > VERSION
515 echo "make clean in $temp_dist/$name/:" >> $log
517 echo -n "make clean in $temp_dist/$name/... "
519 echo "--------" >> $log
525 echo "Remove files: " >> $log
526 for file in $remove; do
527 find .
-name $file |
xargs rm -Rf
528 echo "find . -name $file | xargs rm -Rf" >> $log
532 echo "Remove toplevel files: " >> $log
533 for file in $toplevelremove; do
534 test -e $file && rm -Rf $file && echo "rm -Rf $file" >> $log
538 # remove hidden files
539 test ! -z $removehidden && echo "Remove hidden files: " >> $log && find $temp_dist -name ".*" -and ! -name "." |
xargs --verbose rm -Rf 2>> $log
541 echo "--------" >> $log
545 # create the configure script
546 # working directory is $temp_dist
547 echo "make -f Makefile.cvs in $temp_dist/:" >> $log
549 echo -n "make -f Makefile.cvs in $temp_dist/... "
550 make -f Makefile.cvs
>> $log 2>> $log
551 echo "rm Makefile.cvs" >> $log
553 echo "rm autom4te.cache" >> $log
554 rm -Rf autom4te.cache
555 echo "--------" >> $log
558 echo "Directory will be $filename."
560 # play around with our tar file in temp_dir
563 if [ ! -z $leavedir ]; then
564 test -e $returndir/$filename && rm -Rf $returndir/$filename
565 cp -R $filename $returndir
568 # make a tar of temp_dist
569 if [ -z $nogzip ] ||
[ -z $nobzip2 ]; then
570 echo -n "Tarring... "
571 echo "tar cf $filename.tar $filename" >> $log
572 tar cf
$filename.
tar $filename >> $log
576 if [ -z $nogzip ] && [ ! -z `which gzip 2> /dev/null` ]; then
577 cp $filename.
tar $filename.
tar.tmp
578 echo -n "running gzip... "
579 echo "gzip $filename.tar" >> $log
582 mv $filename.
tar.tmp
$filename.
tar
583 mv $filename.
tar.gz
$returndir
584 echo "mv $filename.tar.gz $returndir" >> $log
586 if [ -z $nobzip2 ] && [ ! -z `which bzip2 2> /dev/null` ]; then
587 echo -n "running bzip2... "
588 echo "bzip2 $filename.tar" >> $log
591 mv $filename.
tar.bz2
$returndir
592 echo "mv $filename.tar.bz2 $returndir" >> $log
595 test -e $filename.
tar && rm -f $filename.
tar
597 # cleanup all tempoaries
602 test -z $leavedir && test ! -z $nobzip2 && test ! -z $nogzip && echo "Finished - no created files." && exit 1
604 # cool, everything went ok!
605 if [ -z $leavedir ]; then
606 echo "Finished. Created packages:"
608 if [ -z $nogzip ] ||
[ -z $nobzip2 ]; then
609 echo "Finished. Created packages/directories:"
611 echo "Finished. Created directory:"
615 echo "--------" >> $log
616 echo "Done: " >> $log
617 echo "Files are in `pwd`." >> $log
619 if [ ! -z $leavedir ] && [ -d $filename ]; then
621 ls -ld $filename >> $log
623 if [ -z $nogzip ] && [ -e $filename.
tar.gz
]; then
624 ls -l $filename.
tar.gz
625 ls -l $filename.
tar.gz
>> $log
627 if [ -z $nobzip2 ] && [ -e $filename.
tar.bz2
]; then
628 ls -l $filename.
tar.bz2
629 ls -l $filename.
tar.bz2
>> $log
631 if [ $log != "/dev/null" ]; then