automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch]: automatically buiding rpm (and others) with automake


From: Christophe Tronche
Subject: [patch]: automatically buiding rpm (and others) with automake
Date: Sun, 4 Nov 2001 20:25:33 +0100
User-agent: SEMI/1.13.7 (Awazu) CLIME/1.13.6 (وخ±) Emacs/20.7 (i386-redhat-linux-gnu) (with unibyte mode)

"Why are there so many of these? Are they fun to write or something?"
(Tom Tromey ? about packager programs, 1996).

Ok, the week-end is over, and I had promised something, so here it is.

There's been discussion for years on this list about the benefits of
adding some rules to automake so that generated Makefiles would be
able to handle automatically the building of packages with the various
available packagers. This is my humble contribution to the debate. It
takes the form of a (rather long) discussion of what I've done and the
diff against today's CVS tree. This first attempt is directed toward
"RPM" (the RedHat Package Manager) because it's the one I'm using the
most these days.

Note that

1) this is alpha code,

2) I know close to nothing to the bowels of automake (the program),

3) I haven't written texi doc yet, but I'll do it if the patch gets
   its way to the automake distribution.

*** THE NAME OF THE GAME ***

I've picked "autopack" as the name for the stuff. It comes from
discussions on the automake mailing list dating back to January 2001.

*** PACKAGING AS A SOCIAL PROCESS ***

There are at least half a dozen of packaging systems, and it's very
unlikely someone alone can get access to every of them (think only to
RPM, which is used on at least half a dozen of processors). What is
likely is that if a package is written by someone, it's gonna be
distributed in either tarball or cvs form, and different people will
package it for different architectures and packagers. So, ideally,
one should be able to get a tarball, compile it on a new architecture,
and add a little something (like AUTOMAKE_OPTIONS = my-packager) to
build the package without further intervention. This implies that the
"autopack" shouldn't require anything more than what's already
necessary to build the binaries from the source, and, of course, the
packager itself.

However, I'm an idiot and a lazy man, so this leads to:

*** WAR (what is it good for ?) ***

There's one choice I've made deliberately, but I'm expecting heavy
fire for this: if you want to build a package, Perl is required. May
be it's okay with you, may be it's a firm "no way". If you're on the
former side, read point 4 of "what as been done" below, and you may
well join the side of those who don't want this work ever appear into
the mainstream automake distribution.

Well, of course, what is coded in Perl could be coded with a large
mess of shell and m4 but I'm too lazy to do it, so I've made up an
invincible argument, and here it is (drums, please): someone not
having Perl on his or her machine doesn't deserve to be able to build
a package. Isn't this such a great argument ?

Autopack sometimes needs some temporary files, so it creates a
directory autopack.cache at the top of the hierarchy.

autopack also has very definitive ideas on how to build a package from
the source distribution. It does so by performing

./configure --prefix=<your build prefix>
make
make install prefix=<potential-build-root><your-prefix>.

The package must support this (it's the case if you don't do anything
particular). Also, everything must be contained in the
distribution. In particular man pages are _not_ included by default in
the dist target (am I mistaking here ?), so you must put them in the
EXTRA_DIST target (actually, I hardly understand why man and info
pages aren't included in the distribution by default).

*** I'M AN IDIOT (in case you don't know) ***

So I started with RPM, a one I'm practicing a lot these days.  Michael
Sweet's EPM packager may have been a much better choice.

*** WHAT HAS BEEN DONE ***

Five things:

- Rules have been added to the existing .am files so that the targets
  list-install outputs the list of every installed files (including
  the documentation) and list-install-doc outputs only the
  documentation files. At least RPM makes this distinction. The files
  are written on stderr, since make trashes stdout. I've used the
  "uninstall" target as a guide by the way, so basically, you find
  list-install anywhere you'd have found uninstall.

- There's a new rpm.am file with rules to build a $(PACKAGE).spec from
  a $(PACKAGE).spec.in, and $(PACKAGE).spec.in in case it doesn't
  exist. And of course, to build an RPM.

- A few things have been changed in automake.in (the precursor of
  automake). In particular, there's a new handle_packager function
  that does what its name implies. There's everything I believe
  necessary to handle the AUTOMAKE_OPTIONS = package-rpm. There are
  also a few things that I'm not sure to understand, but that seems
  necessary in order for the whole thing to work. For example I've
  only an "intuitive" (read: none) understanding as to why it's
  necessary to have a 'list-install-am' entry in %dependencies (to
  collect the various entries, right ? I haven't bother tracing the
  variable through the code, though). 

- There's a brand new perl program called "packager-helper" that
  should be distributed with the rest of the code in order for the
  package to be built. I've put in it everything that I've found
  useful and easy to write in Perl. For now, it does four things:
  substituting variables to rewrite $(PACKAGE).spec.in into
  $(PACKAGE).spec (including some "magic" substitutions), generating a
  working default $(PACKAGE).spec.in, extracting RPM variables from
  rpm --showrc and printing long error messages.  One may find that
  packager-helper shouldn't exist. It does.

- The macro AP_INIT_AUTOPACK and a few ancillary macros have been
  added (in autopack.m4 in the aclocal m4 directory). AP_INIT_AUTOPACK
  takes 8 argument, see "Using the beast" below.

*** USING THE BEAST ***

Let's say that you've a set of programs making up a program called
"autopack" (surprise). Makefiles are built with automake, of
course. Now, we want to build an RPM package. Here are the required
steps:

In the top Makefile.am, put

AUTOMAKE_OPTIONS = package-rpm

In the configure.ac, chances are that you've something like:

AM_INIT_AUTOMAKE(autopack, 0.1.1)

You've to add this (for example):

AP_INIT_AUTOPACK(An automake package generation module,
        0,
        GPL,
        Applications/Multimedia,
        Christophe Tronche <address@hidden>,
        http://gnu.org/automake/,
        [This is an extension to automake to let make build
        effortlessly (hopefully !) packages such as RPM, .deb, System
        V, etc... packages. To use this, put AUTOMAKE_OPTIONS =
        package-xxx in your Makefile.am])

The first parameter is a short (one-line) description of the package,
the 2nd ("0") is the package version,
the 3rd ("GPL") is the license type (some packagers require it, so
   give some thoughts and pick one)
the 4th ("Applications/Multimedia"), is basically where to put it in
   the menus (called the "group" in some snobbish way). Some packagers
   may not handle it, but some require it, so it's better to put one;
the 5th is your address, so that you can be congratulated... or flamed !
the 6th is an URL pointing to the project;
the 7th is a long description of the package;
the 8th (not present in the example) is the path to an icon file, that
   some packager can use.

As you, beloved reader, may have noticed, this is very "RPM-centric",
and some parameters may be added (or removed, or changed) in the
future.

That's almost all ! Perform an autoreconf; automake --add-missing

Then comes an important point: if you just type ./configure now, the
files in the future rpm will go to some default location (such as
/usr/bin), and you may prefer to chose another one. To do so, just
type

./configure --prefix=<your-prefix-here>

Now, you can type "make rpm". If you're lucky enough, you shoud get an
rpm called autopack-0.1.1-0.xxx.rpm (you put the name and version in
AM_INIT_AUTOMAKE, remember ?).

If it doesn't work, at least you've a way to avoid a nervous
breakdown, send me an insulting mail ! This doesn't do much good, but
you'll feel better after that, and I think I can take it.

*** WHAT HASN'T BEEN DONE (the future) ***

For now, there's no provision for pre- and post-install
scripts. There's no provision for RPM "configuration files", whatever
they are. All of these should be done.

I haven't implemented the stuff for "lisp" and "python" targets yet.

No -hook nor other utterly necessary stuff like that (yet).

If you're using additional data (such as htmldir = stuff; html_DATA =
foobar); autopack doesn't classify the files as "documentation", while
they may very well be. There should have something like AP_DOC =
$(html_DATA) to explain this.

Support for much more packagers needs to be added to "abstract" the
details of the various packagers from the general process. I think EPM
is the next on my list, since Michael has such a broad vision of the
various available package managers, there's certainly much to learn
there.

This is all I think for now, but certainly, I'm missing a lot.

-- 
Christophe Tronche      address@hidden
                        http://tronche.com/

*** THE PATCH ***

diff -uNrbB --exclude-from=diff-exclude automake/automake.in 
automake.new/automake/automake.in
--- automake/automake.in        Wed Oct 31 19:39:34 2001
+++ automake.new/automake/automake.in   Sun Nov  4 16:07:17 2001
@@ -208,7 +208,8 @@
    'mdate-sh', 'mkinstalldirs', 'install-sh', 'texinfo.tex',
    'ansi2knr.c', 'ansi2knr.1', 'elisp-comp',
    'ylwrap', 'acinclude.m4', @libtool_files, @libtool_sometimes,
-   'missing', 'depcomp', 'compile', 'py-compile'
+   'missing', 'depcomp', 'compile', 'py-compile',
+   'packager-helper'
   );
 
 # Commonly used files we auto-include, but only sometimes.
@@ -703,13 +703,19 @@
 
        'install-man'         => [],
        'uninstall-man'       => [],
+       'list-install-man'     => [],
 
        'install-info'         => [],
        'install-info-am'      => [],
        'uninstall-info'       => [],
+       'list-install-info'    => [],
 
        'installcheck-am'      => [],
 
+       # Packaging
+       'list-install-am'      => [],
+       'list-install-doc-am'  => [],
+
        # Cleaning.
        'clean-am'             => [],
        'mostlyclean-am'       => [],
@@ -1196,6 +1202,8 @@
     &check_gnu_standards;
     &check_gnits_standards;
 
+    &handle_packager;
+
     &handle_configure ($output, $makefile, @secondary_inputs);
     &handle_gettext;
     &handle_libraries;
@@ -1380,7 +1393,8 @@
                   || $_ eq 'dejagnu' || $_ eq 'no-texinfo.tex'
                   || $_ eq 'readme-alpha' || $_ eq 'check-news'
                   || $_ eq 'subdir-objects' || $_ eq 'nostdinc'
-                  || $_ eq 'no-exeext')
+                  || $_ eq 'no-exeext'
+                  || $_ eq 'package-rpm')
            {
                # Explicitly recognize these.
            }
@@ -2849,6 +2863,16 @@
     }
 }
 
+# Handle packager specs
+
+sub handle_packager {
+    if ($relative_dir eq '.') {
+       &require_file ('', $FOREIGN, 'packager-helper');
+    }
+    if ($options{'package-rpm'}) {
+       $output_rules .= &file_contents ('rpm');
+    }
+}
 
 # Handle scripts.
 sub handle_scripts
@@ -6971,7 +7002,9 @@
                     'HOST'     => $seen_canonical,
                     'TARGET'   => $seen_canonical == $AC_CANONICAL_SYSTEM,
 
-                    'LIBTOOL'      => defined $configure_vars{'LIBTOOL'})
+                    'LIBTOOL'      => defined $configure_vars{'LIBTOOL'},
+                    'PACKAGE-RPM'  => $options{'package-rpm'} || 0
+                    )
          # We don't need more than two consecutive new-lines.
          . 's/\n{3,}/\n\n/g';
 
diff -uNrbB --exclude-from=diff-exclude automake/lib/Makefile.am 
automake.new/automake/lib/Makefile.am
--- automake/lib/Makefile.am    Sat Sep 22 18:05:36 2001
+++ automake.new/automake/lib/Makefile.am       Wed Oct 24 23:16:01 2001
@@ -28,7 +28,8 @@
 ## what we want.  So we make them executable by hand.
 scriptdir = $(pkgdatadir)
 dist_script_DATA = config.guess config.sub install-sh mdate-sh missing \
-mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile
+mkinstalldirs elisp-comp ylwrap acinstall depcomp compile py-compile \
+packager-helper
 
 install-data-hook:
        @$(POST_INSTALL)
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/Makefile.am 
automake.new/automake/lib/am/Makefile.am
--- automake/lib/am/Makefile.am Sat Sep 22 18:05:36 2001
+++ automake.new/automake/lib/am/Makefile.am    Thu Oct 18 23:10:50 2001
@@ -26,5 +26,5 @@
 footer.am header-vars.am header.am install.am java.am lang-compile.am \
 lex.am library.am libs.am libtool.am lisp.am ltlib.am ltlibrary.am \
 mans-vars.am mans.am multilib.am program.am progs.am python.am \
-remake-hdr.am scripts.am subdirs.am tags.am texi-vers.am texibuild.am \
+remake-hdr.am rpm.am scripts.am subdirs.am tags.am texi-vers.am texibuild.am \
 texinfos.am yacc.am
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/data.am 
automake.new/automake/lib/am/data.am
--- automake/lib/am/data.am     Thu May  3 09:28:20 2001
+++ automake.new/automake/lib/am/data.am        Sun Nov  4 19:27:04 2001
@@ -43,6 +43,18 @@
 endif %?INSTALL%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+if %?INSTALL%
+.PHONY list-install-am: list-install-%DIR%%PRIMARY%
+list-install-%DIR%%PRIMARY%:
+       @list='$(%DIR%_%PRIMARY%)'; for p in $$list; do \
+               echo $(DESTDIR)$(%NDIR%dir)/$$p; \
+       done 1>&2
+endif %?INSTALL%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/install.am 
automake.new/automake/lib/am/install.am
--- automake/lib/am/install.am  Fri May 18 03:14:53 2001
+++ automake.new/automake/lib/am/install.am     Fri Nov  2 17:02:56 2001
@@ -33,18 +33,22 @@
 ## Install targets.  ##
 ## ----------------- ##
 
-.PHONY: install install-exec install-data uninstall
+.PHONY: install install-exec install-data list-install list-install-doc 
uninstall
 
-?SUBDIRS?.PHONY: install-recursive install-exec-recursive 
install-data-recursive uninstall-recursive
+?SUBDIRS?.PHONY: install-recursive install-exec-recursive 
install-data-recursive list-install-recursive list-install-doc-recursive 
uninstall-recursive
 ?SUBDIRS?install: install-recursive
 ?SUBDIRS?install-exec: install-exec-recursive
 ?SUBDIRS?install-data: install-data-recursive
+?SUBDIRS?list-install: list-install-recursive
+?SUBDIRS?list-install-doc: list-install-doc-recursive
 ?SUBDIRS?uninstall: uninstall-recursive
 
-.PHONY: install-exec-am install-data-am uninstall-am
+.PHONY: install-exec-am install-data-am list-install-am list-install-doc-am 
uninstall-am
 ?!SUBDIRS?install: install-am
 ?!SUBDIRS?install-exec: install-exec-am
 ?!SUBDIRS?install-data: install-data-am
+?!SUBDIRS?list-install: list-install-am
+?!SUBDIRS?list-install-doc: list-install-doc-am
 ?!SUBDIRS?uninstall: uninstall-am
 
 .PHONY: install-am
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/java.am 
automake.new/automake/lib/am/java.am
--- automake/lib/am/java.am     Wed May 30 04:02:50 2001
+++ automake.new/automake/lib/am/java.am        Sun Nov  4 19:27:04 2001
@@ -53,6 +53,18 @@
 endif %?INSTALL%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+if %?INSTALL%
+.PHONY list-install-am: list-install-%DIR%JAVA
+list-install-%DIR%JAVA:
+       @for p in *.class; do \
+               echo $(DESTDIR)$(%NDIR%dir)/$$p; \
+       done 1>&2
+endif %?INSTALL%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/libs.am 
automake.new/automake/lib/am/libs.am
--- automake/lib/am/libs.am     Thu Jun 28 17:06:50 2001
+++ automake.new/automake/lib/am/libs.am        Sun Nov  4 19:27:03 2001
@@ -62,6 +62,18 @@
 endif %?INSTALL%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+if %?INSTALL%
+.PHONY list-install-am: list-install-%DIR%LIBRARIES
+list-install-%DIR%LIBRARIES:
+       @list='$(%DIR%_LIBRARIES)'; for p in $$list; do \
+               echo $(DESTDIR)$(%NDIR%dir)/$$p; \
+       done 1>&2
+endif %?INSTALL%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/ltlib.am 
automake.new/automake/lib/am/ltlib.am
--- automake/lib/am/ltlib.am    Mon Apr  9 11:50:33 2001
+++ automake.new/automake/lib/am/ltlib.am       Sun Nov  4 19:27:03 2001
@@ -45,6 +45,18 @@
 endif %?INSTALL%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+if %?INSTALL%
+.PHONY list-install-am: list-install-%DIR%LTLIBRARIES
+list-install-%DIR%LTLIBRARIES:
+       @list='$(%DIR%_LTLIBRARIES)'; for p in $$list; do \
+               echo $(DESTDIR)$(%NDIR%dir)/$$p; \
+       done 1>&2
+endif %?INSTALL%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/mans.am 
automake.new/automake/lib/am/mans.am
--- automake/lib/am/mans.am     Sun May  6 07:40:47 2001
+++ automake.new/automake/lib/am/mans.am        Sun Nov  4 19:27:03 2001
@@ -56,6 +56,36 @@
          $(INSTALL_DATA) $$file $(DESTDIR)$(man%SECTION%dir)/$$inst; \
        done
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+
+.PHONY: list-install-man
+?INSTALL-MAN?list-install-doc-am: list-install-man
+?INSTALL-MAN?list-install-am: list-install-man
+.PHONY list-install-man: list-install-man%SECTION%
+list-install-man%SECTION%:
+       @list='$(man%SECTION%_MANS) $(dist_man%SECTION%_MANS) 
$(nodist_man%SECTION%_MANS)'; \
+## Extract all items from man_MANS that should go in this section.
+## This must be done dynamically to support conditionals.
+       l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
+       for i in $$l2; do \
+         case "$$i" in \
+## Have to accept files like `foo.1c'.
+           *.%SECTION%*) list="$$list $$i" ;; \
+         esac; \
+       done; \
+       for i in $$list; do \
+## Extract basename of man page and run it through the program rename
+## transform.
+         ext=`echo $$i | sed -e 's/^.*\\.//'`; \
+         inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
+         inst=`echo $$inst | sed -e 's/^.*\///'`; \
+         inst=`echo $$inst | sed '$(transform)'`.$$ext; \
+         echo "$(DESTDIR)$(man%SECTION%dir)/$$inst"; \
+       done 1>&2
+
 
 ## -------------- ##
 ## Uninstalling.  ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/progs.am 
automake.new/automake/lib/am/progs.am
--- automake/lib/am/progs.am    Sun Jul 22 23:50:18 2001
+++ automake.new/automake/lib/am/progs.am       Sun Nov  4 19:27:02 2001
@@ -51,6 +51,18 @@
 endif %?INSTALL%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+if %?INSTALL%
+.PHONY list-install-am: list-install-%DIR%PROGRAMS
+list-install-%DIR%PROGRAMS:
+       @list='$(%DIR%_PROGRAMS)'; for p in $$list; do \
+               echo $(DESTDIR)$(%NDIR%dir)/$$p; \
+       done 1>&2
+endif %?INSTALL%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/rpm.am 
automake.new/automake/lib/am/rpm.am
--- automake/lib/am/rpm.am      Thu Jan  1 01:00:00 1970
+++ automake.new/automake/lib/am/rpm.am Sun Nov  4 18:51:17 2001
@@ -0,0 +1,57 @@
+## automake - create Makefile.in from Makefile.am
+## Copyright 2001 Free Software Foundation, Inc.
+
+## 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
+## the Free Software Foundation; either version 2, or (at your option)
+## any later version.
+
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+## 02111-1307, USA.
+
+if %?PACKAGE-RPM%
+$(PACKAGE).spec: $(PACKAGE).spec.in $(top_builddir)/config.status
+       perl -w $(top_srcdir)/packager-helper \
+               < $(PACKAGE).spec.in > $(PACKAGE).spec \
+               subst -do-magic-files \
+               -s AP_SUMMARY '$(AP_SUMMARY)' \
+               -s PACKAGE '$(PACKAGE)' \
+               -s VERSION '$(VERSION)' \
+               -s AP_RELEASE '$(AP_RELEASE)' \
+               -s AP_COPYRIGHT '$(AP_COPYRIGHT)' \
+               -s AP_GROUP '$(AP_GROUP)' \
+               -s AP_PACKAGER '$(AP_PACKAGER)' \
+               -s AP_URL '$(AP_URL)' \
+               -s AP_ICON '$(AP_ICON)' \
+               -s AP_DESCRIPTION '' \
+               -s prefix '$(prefix)'
+
+rpm: $(PACKAGE).spec.in dist
+       make $(PACKAGE).spec
+       rpmtopdir=`perl -w $(top_srcdir)/packager-helper rpm-get-variable 
_topdir` ; \
+       arch=`perl -w $(top_srcdir)/packager-helper rpm-get-variable _arch` ; \
+       $(mkinstalldirs) "$$rpmtopdir/SOURCES" "$$rpmtopdir/BUILD" 
"$$rpmtopdir/RPMS" "$$rpmtopdir/RPMS/$arch" ; \
+       if cp -p $(distdir).tar.gz "$$rpmtopdir/SOURCES"; then \
+               echo Copying of files to sources ok > /dev/null ; \
+       else \
+               perl -w $(top_srcdir)/packager-helper rpm-write-error 
"$$rpmtopdir" ; \
+       fi
+       rpm -bb $(PACKAGE).spec | tee rpm.log
+       @rpm=`awk '/^Wrote: [^ ]*\.rpm$$/ { print $$NF }' rpm.log` ; \
+       if [ "$$rpm" != "" ]; then \
+               cp -p "$$rpm" . ; \
+       fi ; \
+       echo `basename "$$rpm"` built
+
+$(PACKAGE).spec.in:
+       perl -w $(top_srcdir)/packager-helper rpm-generic-spec > 
$(PACKAGE).spec.in
+
+endif %?PACKAGE-RPM%
+
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/subdirs.am 
automake.new/automake/lib/am/subdirs.am
--- automake/lib/am/subdirs.am  Mon Apr  9 16:44:04 2001
+++ automake.new/automake/lib/am/subdirs.am     Fri Nov  2 16:49:07 2001
@@ -20,7 +20,8 @@
 RECURSIVE_TARGETS += \
 all-recursive install-data-recursive install-exec-recursive \
 installdirs-recursive install-recursive uninstall-recursive \
-check-recursive installcheck-recursive
+check-recursive installcheck-recursive \
+list-install-recursive list-install-doc-recursive
 
 .PHONY: $(RECURSIVE_TARGETS)
 
diff -uNrbB --exclude-from=diff-exclude automake/lib/am/texinfos.am 
automake.new/automake/lib/am/texinfos.am
--- automake/lib/am/texinfos.am Tue Oct  2 18:00:04 2001
+++ automake.new/automake/lib/am/texinfos.am    Sun Nov  4 18:33:45 2001
@@ -150,6 +150,31 @@
 endif ! %?LOCAL-TEXIS%
 
 
+## ----------------------------- ##
+## Listing what gets installed.  ##
+## ----------------------------- ##
+
+?SUBDIRS?RECURSIVE_TARGETS += list-install-info-recursive
+?SUBDIRS?.PHONY list-install-info: list-install-info-recursive
+?INSTALL-INFO?list-install-doc-am: list-install-info-am
+?INSTALL-INFO?list-install-am: list-install-info-am
+
+.PHONY: list-install-info-am
+
+if %?LOCAL-TEXIS%
+list-install-info-am:
+         list='$(INFO_DEPS)'; \
+         for file in $$list; do \
+## install-info needs the actual info file.  We use the installed one,
+## rather than relying on one still being in srcdir or builddir.
+           for f in $$file*; do \
+               echo $(DESTDIR)$(infodir)/$$f; \
+            done ; \
+         done 1>&2
+else ! %?LOCAL-TEXIS%
+list-install-info-am:
+endif ! %?LOCAL-TEXIS%
+
 ## -------------- ##
 ## Uninstalling.  ##
 ## -------------- ##
diff -uNrbB --exclude-from=diff-exclude automake/lib/packager-helper 
automake.new/automake/lib/packager-helper
--- automake/lib/packager-helper        Thu Jan  1 01:00:00 1970
+++ automake.new/automake/lib/packager-helper   Sun Nov  4 19:04:22 2001
@@ -0,0 +1,178 @@
+# -*- perl -*-
+#
+
+use strict 'refs', 'subs';
+
+$command = shift;
+$topdir = $0;
+$topdir =~ s@/[^/]+$@@;
+&subst if $command eq 'subst';
+&rpm_generic_spec if $command eq 'rpm-generic-spec';
+
+if ($command eq 'rpm-get-variable') {
+    &rpm_get_variable(shift);
+} elsif ($command eq 'rpm-write-error') {
+    &rpm_write_error(shift);
+    exit(-1);
+} else {
+    die "Unknown command $command";
+}
+
+################################################################################
+#
+# Subst
+#
+################################################################################
+
+sub subst {
+    &substUsage unless $#ARGV;
+    local(%subst);
+    my ($from, $to);
+    while(@ARGV) {
+       if ($ARGV[0] eq '-do-magic-files') {
+           shift @ARGV;
+
+           $_ = `make list-install 2>&1 >/dev/null`;
+           die "make list-install failed: unable to get list of files to 
install" unless $_;
+           chop;
+           my @list = split /\n/o;
+           my %list;
+           foreach(@list) {
+               $list{$_} = 1;
+           }
+
+           $_ = `make list-install-doc 2>&1 >/dev/null`;
+           chop;
+           my @doc = split /\n/o; 
+           foreach(@doc) {
+               delete $list{$_};
+           }
+
+           $subst{'AP_MAGIC_FILES'} = join("\n", keys %list)."\n";
+               #
+               # Oh, oh, we've some RPM things here
+               #
+           $subst{'AP_MAGIC_DOC'} = '%doc '.join("\n%doc ", @doc)."\n";
+
+       } elsif ($ARGV[0] eq '-s') {
+           &substUsage unless $#ARGV >= 2;
+           shift @ARGV;
+           $from = shift @ARGV;
+           $to = shift @ARGV;
+           if ($to eq '' && open(SUBSTITUTION_FILE, 
"<$topdir/autopack.cache/$from")) {
+               $to .= $_ while(<SUBSTITUTION_FILE>);
+           }
+           $subst{$from} = $to;
+       } else {
+           die "$0 subst: unknown option $ARGV[0]";
+       }
+    }
+    $re = join('|', keys %subst);
+    while(<>) {
+       if (/\@($re)\@/o) {
+           if ($subst{$1} ne '') {
+               s//$subst{$1}/ego;
+           } else {
+               s/^/#/go;
+           }
+       }
+       print;
+    }
+    exit;
+}
+
+sub substUsage {
+    die <<END
+Usage: $0 subst [-do-magic-files] [ -s var substitution... ]
+       $0 rpm-generic-spec
+       $0 rpm-get-variable variable
+       $0 rpm-write-error
+END
+}
+
+################################################################################
+##
+## RPM stuff
+##
+################################################################################
+
+sub rpm_generic_spec {
+    print 'Summary: @AP_SUMMARY@
+Name: @PACKAGE@
+Version: @VERSION@
+Release: @AP_RELEASE@
+Copyright: @AP_COPYRIGHT@
+Group: @AP_GROUP@
+Packager: @AP_PACKAGER@
+Url: @AP_URL@
+Icon: @AP_ICON@
+
+Source: %{name}-%version.tar.gz
+
+%description
address@hidden@
+
+%prep
+%setup
+
+%build
+./configure address@hidden@
+make
+
+%clean
+
+echo you should rm -rf `pwd`
+echo $RPM_BUILD_ROOT
+
+%install
+
+if [ "$RPM_BUILD_ROOT" = "/tmp/%{name}-buildroot" ]; then
+    rm -rf $RPM_BUILD_ROOT
+fi
+
+make install address@hidden@
+
+%files
address@hidden@
+
address@hidden@
+
+%changelog
+';
+exit;
+}
+
+sub rpm_get_variable {
+    my ($variable) = @_;
+    open(DATA, "rpm --showrc|") || die "Unable to execute rpm --showrc";
+    local(%var);
+    while(<DATA>) {
+       next unless /^\S+:\s+(\S+)\s+(.*)/o;
+       $var{$1} = $2;
+    }
+    local($_) = $var{$variable};
+    die "Unknown RPM variable $variable" unless defined $_;
+    while(s/%{([^\}]+)}/&rpm_subst($1)/ego) { }
+    print $_;
+}
+
+sub rpm_subst {
+    my $result = $var{$_[0]};
+    die "Unable to substitute RPM variable $_[0] in $_" unless defined $result;
+    return $result;
+}
+
+sub rpm_write_error {
+    my $topdir = $_[0];
+    my $home = $ENV{'HOME'};
+    print STDERR <<END;
+You must be able to write to $topdir/SOURCES and
+$topdir/BUILD to create an RPM. 
+Generally, this means that you must be root. If you
+can't be, however, or you don't want to be, you can edit .rpmmacros in
+your home directory ($home), and put in it the line:
+\%_topdir      /absolute/path/to/your/directory
+
+The RPM build process will then take place into this directory.
+END
+}
diff -uNrbB --exclude-from=diff-exclude automake/m4/Makefile.am 
automake.new/automake/m4/Makefile.am
--- automake/m4/Makefile.am     Sat Oct 20 13:14:37 2001
+++ automake.new/automake/m4/Makefile.am        Sat Nov  3 18:06:24 2001
@@ -21,7 +21,7 @@
 
 m4datadir = $(datadir)/aclocal
 
-m4data_DATA = as.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 depout.m4 \
+m4data_DATA = as.m4 autopack.m4 auxdir.m4 ccstdc.m4 cond.m4 depend.m4 
depout.m4 \
 dmalloc.m4 gcj.m4 header.m4 init.m4 install-sh.m4 lex.m4 \
 lispdir.m4 make.m4 maintainer.m4 minuso.m4 missing.m4 multi.m4 \
 protos.m4 python.m4 regex.m4 sanity.m4 strip.m4 \
diff -uNrbB --exclude-from=diff-exclude automake/m4/autopack.m4 
automake.new/automake/m4/autopack.m4
--- automake/m4/autopack.m4     Thu Jan  1 01:00:00 1970
+++ automake.new/automake/m4/autopack.m4        Sat Nov  3 19:16:21 2001
@@ -0,0 +1,36 @@
+# Autopack stuff
+
+# Copyright 2001 Free Software Foundation, Inc.
+
+# 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# AP_INIT_AUTOPACK(SUMMARY, RELEASE, COPYRIGHT, GROUP, PACKAGER, URL, 
DESCRIPTION, ICON)
+# 
--------------------------------------------------------------------------------------
+# Init autopack, the automatic packager
+AC_DEFUN([AP_INIT_AUTOPACK],[
+AC_SUBST([AP_SUMMARY])AP_SUMMARY="$1"
+AC_SUBST(AP_RELEASE)AP_RELEASE=$2
+AC_SUBST(AP_COPYRIGHT)AP_COPYRIGHT="$3"
+AC_SUBST(AP_GROUP)AP_GROUP="$4"
+AC_SUBST(AP_PACKAGER)AP_PACKAGER="$5"
+AC_SUBST(AP_URL)AP_URL="$6"
+AC_SUBST(AP_ICON)AP_ICON="$8"
+mkdir $am_aux_dir/autopack.cache 2>/dev/null
+cat > $am_aux_dir/autopack.cache/AP_DESCRIPTION <<END
+$7
+END
+]
+)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]