X-Git-Url: http://git.jankratochvil.net/?p=macros.git;a=blobdiff_plain;f=AutoGen.pm;h=17c1483b405b2a17663fc93c5d4304f929746049;hp=8f5399d2ee8e2102cafcda1c66f2c9c30f4ca4c1;hb=38afe711acc16741ac20d9002e00626b7fe6d088;hpb=a836346ee6fb7a12766559562a00b0675ad48a59 diff --git a/AutoGen.pm b/AutoGen.pm index 8f5399d..17c1483 100644 --- a/AutoGen.pm +++ b/AutoGen.pm @@ -43,6 +43,9 @@ HERE } die "You are missing some modules - install them by:\n" ."\tperl -MCPAN -e 'install qw(".join(" ",@missing).")'\n" + ."If you see messages: Writing Makefile for -- NOT OK\n" + ."you may did not have installed make(1) while configuring Perl CPAN.\n" + ."Install make(1) and type 'o conf init' in: perl -MCPAN -e shell\n" if @missing; } @@ -56,6 +59,9 @@ 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" --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 @@ -214,32 +220,39 @@ my($class,%args)=@_; $class->_prepdist($name); _system "make $name.spec"; my $spec=_readfile "$name.spec"; - my $patch=($spec=~/^Patch\d*:\s*(.*)$/m)[0]; + my $patch=($spec=~/^Patch\d*\s*:\s*(.*)$/m)[0]; _system "make dist"; if (!$patch) { _copy "$name-*.tar.gz",_rpmeval("_sourcedir"); } else { my @origs; - for my $glob ("orig-$name-*.tar.{gz,Z}") { - @origs=glob "orig-$name-*.tar.{gz,Z,bz2}"; + for my $glob ("orig-$name-*.tar.{gz,Z,bz2}") { + @origs=glob $glob; confess "Invalid glob $glob: ".join(",",@origs) if 1!=@origs; } - my $base=($origs[0]=~/^orig-(.*)[.]tar[.](?:gz|Z)$/)[0]; + my($origbase,$ext)=($origs[0]=~/^orig-(.*)[.]tar[.](gz|Z|bz2)$/); _copy $origs[0],_rpmeval("_sourcedir")."/".($origs[0]=~/^orig-(.*)$/)[0]; - _system "tar xzf ".$origs[0]; - _mkdir $base."-orig"; + _system "tar x".($ext eq "bz2" ? "j" : "z")."f ".$origs[0]; + _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", @@ -265,12 +278,27 @@ my($class,%args)=@_; my $name=$Options{"name"}; $class->_prepdist($name); _system "make distdir"; - _system(join(" ","cd $name-*;dpkg-buildpackage", + # Copy 'orig' archive after &_prepdist which would delete it. + my @origs; + 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/; + _copy $origs[0],$deborig; + } + } + my @subdirs; + for my $glob ("$name-*") { + @subdirs=glob $glob; + confess "Invalid glob $glob: ".join(",",@subdirs) if 1!=@subdirs; + } + _system(join(" ","cd ".$subdirs[0].";dpkg-buildpackage", "-rfakeroot", ($args{"sign"} ? () : ("-us","-uc")), )); - _remove \1,"$name-*"; - _system "ls -l ${name}_*"; + _remove \1,$subdirs[0]; + _system "ls -l ${name}*_[0-9]*"; exit 0; # should never return } @@ -321,11 +349,12 @@ sub _cleanfiles ./mkinstalldirs ./libtool ./ltconfig ./ltmain.sh ./ABOUT-NLS - ./-[0-9]* ./-devel-[0-9]* + ./-[0-9]* ./-*-[0-9]* ./.spec ./.m4 ./.spec.m4 ./debian/tmp ./debian/ - ./_[0-9]* + ./*_[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 @@ -457,6 +486,7 @@ my($class,%options)=@_; "rpmtest" ,sub { $class->_rpmbuild("sign"=>0); }, "deb" ,sub { $class->_debbuild("sign"=>1); }, "debtest" ,sub { $class->_debbuild("sign"=>0); }, + "cleanfilesfordir=s",sub { print "$_\n" for (_cleanfilesfordir $_[1]); exit 0; }, "dist" ,\$Options{"ARGV_dist"}, "copy!" ,\$Options{"ARGV_copy"}, "fullclean",\$Options{"ARGV_fullclean"}, @@ -480,14 +510,18 @@ my($class,%options)=@_; return if $Options{"ARGV_clean"} || $Options{"ARGV_fullclean"}; $Options{"aclocal_args"}=[qw(-I macros),map((!$_ ? () : @$_),$Options{"aclocal_args"})]; - my $configure_in=_readfile("configure.in"); - do { $$_=1 if !defined($$_) && $configure_in=~/^AM_GNU_GETTEXT\b/m; } + my $configure_name; + do { $configure_name||=$_ if -f $_ } for ("configure.in"); + do { $configure_name||=$_ if -f $_ } for ("configure.ac"); + $configure_name or confess "Cannot find configure.{in,ac}"; + my $configure_in=_readfile($configure_name); + do { $$_=1 if !defined($$_) && $configure_in=~/^\s*AM_GNU_GETTEXT\b/m; } for (\$Options{"want-gettextize"}); - do { $$_=1 if !defined($$_) && $configure_in=~/^AM_GLIB_GNU_GETTEXT\b/m; } + do { $$_=1 if !defined($$_) && $configure_in=~/^\s*AM_GLIB_GNU_GETTEXT\b/m; } for (\$Options{"want-glib-gettextize"}); - do { $$_=1 if !defined($$_) && $configure_in=~/^AM_PROG_LIBTOOL\b/m; } + do { $$_=1 if !defined($$_) && $configure_in=~/^\s*AM_PROG_LIBTOOL\b/m; } for (\$Options{"want-libtoolize"}); - do { $$_=1 if !defined($$_) && $configure_in=~/^A[CM]_CONFIG_HEADER\b/m; } + do { $$_=1 if !defined($$_) && $configure_in=~/^\s*A[CM]_CONFIG_HEADER\b/m; } for (\$Options{"want-autoheader"}); my @copy_arg=(!$Options{"ARGV_copy"} ? () : "--copy"); @@ -501,7 +535,7 @@ my($class,%options)=@_; ."'") { _system $_ and confess $_; } - for ("configure.in","Makefile.am") { + for ($configure_name,"Makefile.am") { STDERR->printflush("gettextize recovery rename \"$_~\"->\"$_\"... "); rename "$_~","$_" or confess "$!"; STDERR->printflush("ok\n"); @@ -565,6 +599,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";