X-Git-Url: http://git.jankratochvil.net/?p=macros.git;a=blobdiff_plain;f=AutoGen.pm;h=09e274444b5a454567997c35c6b69e67ea0ade81;hp=0947a21437a7be5d805699c406e154c0d8aee9a1;hb=refs%2Ftags%2Fcaptive-0_9_4;hpb=064fdbb8baee75503ef5b3d37cc20ec93c7ccb0d diff --git a/AutoGen.pm b/AutoGen.pm index 0947a21..09e2744 100644 --- a/AutoGen.pm +++ b/AutoGen.pm @@ -1,8 +1,8 @@ #! /usr/bin/perl # # $Id$ -# Module to generate all the initial makefiles etc. -# Copyright (C) 2002 Jan Kratochvil +# autoautotools aware of CVS and rpm/deb. +# Copyright (C) 2002-2003 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -59,9 +59,12 @@ Beware: '.basename($0).' is a tool only for maintainers! Supported parameters: --rpm Build RPM packages locally (needs /usr/src/(redhat|packages)/ access) --rpmtest Build RPM like "rpm" but w/o gpg/pgp signing + --deb Build DEB packages locally + --debtest Build DEB like "deb" but w/o gpg/pgp signing + --dist Prepare all build files but do not run the final "./configure" + --copy Behave exactly like in default mode but copy all instead of symlinks --clean Standard cleanup method --fullclean Like clean but even the .cvsignore files are removed - --copy Behave exactly like in default mode but copy all instead of symlinks -h|--help Print this help message. '.($Options{"help"} || ""); } @@ -228,21 +231,28 @@ my($class,%args)=@_; @origs=glob $glob; confess "Invalid glob $glob: ".join(",",@origs) if 1!=@origs; } - my($base,$ext)=($origs[0]=~/^orig-(.*)[.]tar[.](gz|Z|bz2)$/); + my($origbase,$ext)=($origs[0]=~/^orig-(.*)[.]tar[.](gz|Z|bz2)$/); _copy $origs[0],_rpmeval("_sourcedir")."/".($origs[0]=~/^orig-(.*)$/)[0]; _system "tar x".($ext eq "bz2" ? "j" : "z")."f ".$origs[0]; - _mkdir $base."-orig"; + _mkdir $origbase."-orig"; # FIXME: Copy also dot-prefixed files! - _move \1,$base."/*",$base."-orig/"; - _system "tar xzf $name-*.tar.gz"; + _move \1,$origbase."/*",$origbase."-orig/"; + rmdir $origbase or confess "rmdir $origbase: $!"; + my @ours; + for my $glob ("$name-*.tar.gz") { + @ours=glob $glob; + confess "Invalid glob $glob: ".join(",",@ours) if 1!=@ours; + } + my($ourbase)=($ours[0]=~/^(.*)[.]tar[.]gz$/); + _system "tar xzf ".$ours[0]; # Use single-argument system() as we need shell redirection. # FIXME: Use directory-independent _cleanfiles(), not root-directory '.cvsignore'. # "-X -" does not work, it needs to be stat(2)able file. _system "diff -ruP -X .cvsignore -I '".'[$]\(Id\|RCSfile\)\>.*[$]'."'" - ." $base-orig/ $base/" + ." $origbase-orig/ $ourbase/" ." >"._rpmeval("_sourcedir")."/".$patch, sub { $_[0]==0 || $_[0]==1; }; # diff(1) returns non-zero return code on any diffs. - _remove \1,$base,$base."-orig"; + _remove \1,$ourbase,$origbase."-orig"; } _system(join(" ","rpmbuild", "-ba", @@ -270,11 +280,14 @@ my($class,%args)=@_; _system "make distdir"; # Copy 'orig' archive after &_prepdist which would delete it. my @origs; - for my $glob ("orig-$name-*.tar.{gz,Z}") { + my $base; + for my $glob ("orig-$name-*.tar.{gz,Z,bz2}") { @origs=glob $glob; if (@origs) { confess "Invalid glob $glob: ".join(",",@origs) if 1!=@origs; - (my $deborig=$origs[0])=~s/^orig-([^-]+)-(.*)([.]tar[.][^.]+)$/$1_$2.orig$3/; + $origs[0]=~/^orig-([^-]+)-(.*)([.]tar[.][^.]+)$/; + my $deborig="$1_$2.orig$3"; + $base="$1-$2"; _copy $origs[0],$deborig; } } @@ -283,11 +296,13 @@ my($class,%args)=@_; @subdirs=glob $glob; confess "Invalid glob $glob: ".join(",",@subdirs) if 1!=@subdirs; } - _system(join(" ","cd ".$subdirs[0].";dpkg-buildpackage", + $base||=$subdirs[0]; + rename $subdirs[0],$base or confess "$!"; + _system(join(" ","cd ".$base.";dpkg-buildpackage", "-rfakeroot", ($args{"sign"} ? () : ("-us","-uc")), )); - _remove \1,$subdirs[0]; + _remove \1,$base; _system "ls -l ${name}*_[0-9]*"; exit 0; # should never return } @@ -344,6 +359,7 @@ sub _cleanfiles ./debian/tmp ./debian/ ./*_[0-9]* ./macros/macros.dep + ./macros/glade-w.sh ./po/Makefile.in.in ./po/POTFILES* ./po/cat-id-tbl.c ./po/cat-id-tbl.tmp ./po/*.gmo ./po/*.mo ./po/stamp-cat-id ./po/.pot ./po/ChangeLog ./po/Makevars ./po/Makevars.template ./po/Rules-quot ./po/*.sed ./po/*.sin ./po/*.header @@ -478,8 +494,8 @@ my($class,%options)=@_; "cleanfilesfordir=s",sub { print "$_\n" for (_cleanfilesfordir $_[1]); exit 0; }, "dist" ,\$Options{"ARGV_dist"}, "copy!" ,\$Options{"ARGV_copy"}, - "fullclean",\$Options{"ARGV_fullclean"}, "clean" ,\$Options{"ARGV_clean"}, + "fullclean",\$Options{"ARGV_fullclean"}, "h|help" ,sub { print _help(); exit 0; }, $Options{"GetOptions_args"}, ) || @ARGV; @@ -588,6 +604,7 @@ my($class,%options)=@_; cat $tmp/out rm -f $tmp/out CONFIGURE_SUBST_X_EOF + _remove "nocheck","./configure.orig"; # It is usually produced by 'CONFIGURE_SUBST_X'. # Why it is left there after RedHat autoconf-2.53-8 ? _remove "nocheck",\1,"autom4te-*.cache"; @@ -606,9 +623,283 @@ CONFIGURE_SUBST_X_EOF 1; __END__ -Tested with: - RedHat autoconf-2.53-8 - RedHat automake-1.6.3-1 - RedHat gettext-0.11.4-3 - RedHat libtool-1.4.2-12 - RedHat perl-5.8.0-48 +=head1 NAME + +AutoGen - autoautotools aware of CVS and rpm/deb + + +=head1 SYNOPSIS + + use lib "./macros/"; + use AutoGen; + AutoGen->run( + "name"=>"fooproject", + "COPYRIGHT_HOLDER"=>'Joe ', + "ARGV"=>\@ARGV, + ); + + +=head1 ABSTRACT + +Projects usually have their B script files to run B(1), +B(1) and similiar tools. This project has some additional features: + +=over + +=item + +Clean the checkout directory without Bs for 'make clean'. + +=item + +Maintain B<.cvsignore> files containing the files being cleaned. + +=item + +Single-command package building of B<.rpm>/B<.deb> out of CVS checkout. + +=item + +Supports: B, B, B, B, B. + +=back + + +=head1 OPTIONS + +B module itself parses its command-line arguments from B<"ARGV"> field +of the hash passed to B<&AutoGen->run>. Its initial double-dash ('B<-->') +prefixes can be omitted. + +B will build the sources for development purposes in the current +directory if no other packaging options were given. + +=over + +=item B<--rpm> + +Build B<.rpm> packages. Either you need access to directory B +(or B etc.) or you should set B<%_usrsrc> (default +B) elsewhere in your B<$HOME/.rpmmacros>: + %_usrsrc /home/joe/src + +As the resulting package will be digitally signed you should also set signing +properties in your B<$HOME/.rpmmacros>: + %_signature gpg + %_gpg_name Joe + +=item B<--rpmtest> + +The same as B<--rpm> but the resulting package will not be I digitally +signed. I passphrase is requested in the middle of package building +which would be very discomfortable during project development. + +=item B<--deb> + +Build B<.deb> packages. + +=item B<--debtest> + +The same as B<--deb> but the resulting package will not be I digitally +signed. I passphrase is requested in the middle of package building +which would be very discomfortable during project development. + +=item B<--dist> + +Prepare all build files but do not run the final B<./configure>. The resulting +directory is similiar to the one produced by B but DO NOT +INTERCHANGE THEM! + +=item B<--copy> + +Some distribution files are created just as symlinks to the system ones by +default. This option forces their copy such as B does. + +=item B<--clean> + +Clean all files not belonging to the CVS repository. You SHOULD backup your +directory first during B bootstrap. Only B<.cvsignore> files are +left in our directory tree. + +=item B<--fullclean> + +Similiar to B<--clean> option but even B<.cvsignore> files get deleted. + +=item B<-h|--help> + +Print short help message describing these I. + +=back + + +=head1 CONFIGURATION + +B<&AutoGen->run> method is passed configuration hash by your B. +Its possible fields: + +=over + +=item B + +Project basename - it should contain no special characters. + + +=item B + +Pass here B<\@ARGV> from the user. + + +=item B + +Array specifying files to be cleaned during B<./autogen.pl clean> and put into +B<.cvsignore> files. You still should add these entries also to B, +B or B variables of Bs. + +There are several formats of B field possible entries: + +=over + +=item B<./path/to/file.c> + +Full project-basedir relative path to the deleted file. Rule applies only to +the one specified directory. Although B would be also possible +it is not recommended to have unified format with B<./only_basedir.c> entries +to delete file just in the root directory (as B would delete +it in ALL subdirectories incl. the root one). + +=item B + +Delete B found in any subdirectory of the project. +It has the same effect as B<./*/basename_generated.c> entry. + +=item B<./subdir/*/name.c> + +Delete B in B<./subdir> and all of its subdirector descendants. +Entry B would have the same effect. + +=back + + +=item B + +B reference run to prepare the sources being built in the current +directory (if no packaging options given). Check for needed B +versions required to build B script by +Bcheckcommandversion>. Other version checks belong to B +instead. + +Referenced B must return true value. + + +=item B + +Alternative name of B, defaults to "B". You should define +alternative name if patching existing package with its own B. + + +=item B + +Optional directory name where B(1) generated files reside. + + +=back + + +=head1 FUNCTIONS + +=over + +=item Bcheckcommandversion>(B<$command>,B<$minimal_version>) + +Functions runs B<$command --version> and checks the resulting version number +against given B<$minimal_version>. Currently only the first 2 version numbers +are parsed. + + +=back + + +=head1 PATCHED PACKAGES + +This section applies to projects where you patch foreign existing packages. + +=over + +=item + +Use the following alternate B prolog if your branch does not belong +to the B
CVS branch: + BEGIN { + # 'macros' could got checked out empty by our '-r captive' tag. + if (!-f "./macros/AutoGen.pm") { + do { system $_ and die "$_: $!"; } for ("cvs co -A macros"); + } + } + use lib "./macros/"; + use AutoGen; + +=item + +Put B archive to the project root directory +as B. + +=item + +Set B<$VERSION> in B file with you vendor prefix such as +B<1.2.3joe1>. Set B<$VERSION_BASE> to B<1.2.3> and B<$VERSION_EXT> to B. +B() them both. + +=item B<.spec> file changes + +=over + +=item + +Change B to B. + +=item + +Change (expected) line B to B. + +=item + +Change B to B. + +=item + +Add line B. +This patch file name is not mandatory. + +=item + +Remember to call B commands manually in the B<%build> +section if their source files were modified in your vendor branch. + +=back + +=item B-specific changes + +=over + +=item + +Include both B and B to B. + +=item + +Include B to B field in B. + +=item + +Use B<@VERSION@> in B. Package will be built as +Debian-native package (no I<.diff> file) as the patches are not just for Debian +packages, it is a new package (read: dpkg does not support branch patches). + +=back + +=back + +=head1 AUTHOR + +Jan Kratochvil >, + I