[Distutils] RPM questions

Greg Ward gward@python.net
Thu, 1 Jun 2000 21:38:49 -0400


[oops, meant to cc this to the sig]

Hi Harry --

[and any other distutils-siggies who know more about RPM than me]

I'm beating the hell out of the bdist_rpm command to make it use config
files rather than the "package_data" file, and naturally a few questions
about RPM arise.  Thought I'd ask you and the SIG instead of RTFM'ing.
(Hey, I don't have a copy of the RPM book at home... and I have to mooch
off someone else's at work.)

  * are the {pre,post}_{install,uninstall} scripts specified as
    raw shell code or filenames?

  * if raw code, d'you think it would be acceptable to specify them as
    filenames for the Distutils instead of trying to deal with shell (or
    Python!) code in a config file?

  * I'm punting on preserving the 'summaries' and 'descriptions'
    dictionaries: either we craft a mapping syntax in config files, or
    we expand 'description' and 'long_description' in the setup script
    so they can be either a string (English description) or a dictionary
    mapping 2-letter language codes to description in that language.
    Opinions?

  * what is "prep" for?  is that a pre-build script?  is it basically
    the same as {pre,post}_{install,uninstall}?

  * what should the default for "packager" be?  I initially made it
    default to "vendor" (which in turn defaults to the "contact" from
    the setup script, ie. maintainer if present, author otherwise), but
    then I had a dim recollection that packagers can set their
    name/address in an RPM config file.  True?  Should "packager"
    default to nothing, so RPM fills it in?
    
  * should "release" be a string or a number?  I've never seen a Red Hat
    RPM with a non-integer "release", but what're the rules?

  * what is "serial"?

  * do you have an example Python module distribution that actually uses
    most of the RPM options?  The Distutils distribution is pretty
    simple, so I can't fully test "bdist_rpm" with it.

  * is it really necessary to pass the "--define _topdir ..." to RPM?
    Recall that this breaks under RPM 2.x, and since I *still* haven't
    gotten around to upgrading my Red Hat 5.2 system, this bites
    me.  (Who? me? procrastinating?)

OK!  Enough of that; the good news is, I've rebuild enough of
"bdist_rpm" that we're back where we started, ie. it fails-to-work for me 
just as it failed-to-work before I started ripping it apart.  IOW, it
creates a reasonable-looking spec file, but dies because of the "rpm
--define" option.  Well, guess what's next on my agenda.

Anyways, using the same ol' Distutils setup script that we're all
familiar with, and this setup.cfg:

"""
[bdist_rpm]
release = 3
packager = Harry Henry Gebel <hgebel@inet.net>
doc_files = CHANGES.txt
            README.txt
            USAGE.txt
            doc/
            examples/

changelog =
  * Wed May 31 2000 Greg Ward <gward@python.net> 0.8.3pre-1
  - Hacked up bdist_rpm.py, moved meta-data into setup.cfg

  * Thu May 10 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-3
  - Added new options to package_data

  * Tue May 09 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-2
  - Include RPM_OPT_FLAGS in distutils

  * Wed Apr 26 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-1
  - First test of bdist_rpm
"""

I can now run "setup.py bdist_rpm --spec-only" and get this spec file:

"""
%define name Distutils
%define version 0.8.3pre
%define release 3

Summary: Python Distribution Utilities
Name: %{name}
Version: %{version}
Release: %{release}
Source0: %{name}-%{version}.tar.gz
Copyright: Python
Group: Development/Libraries
BuildRoot: %{_tmppath}/%{name}-buildroot
Prefix: %{_prefix}
BuildArchitectures: noarch
Vendor: Greg Ward <gward@python.net>
Packager: Harry Henry Gebel <hgebel@inet.net>
Url: http://www.python.org/sigs/distutils-sig/

%description
A collection of modules to aid in the distribution and installation of
Python modules, extensions, and (ultimately) applications.  A standard
part of Python 1.6, but also distributed separately for use with
Python 1.5.

%prep
%setup

%build
python setup.py build

%install
python setup.py install --root=$RPM_BUILD_ROOT --record=INSTALLED_FILES

%clean
rm -rf $RPM_BUILD_ROOT

%files -f INSTALLED_FILES
%defattr(-,root,root)
%doc CHANGES.txt README.txt USAGE.txt doc/ examples/

%changelog

 * Wed May 31 2000 Greg Ward <gward@python.net> 0.8.3pre-1
 - Hacked up bdist_rpm.py, moved meta-data into setup.cfg
 * Thu May 10 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-3
 - Added new options to package_data
 * Tue May 09 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-2
 - Include RPM_OPT_FLAGS in distutils
 * Wed Apr 26 2000 Harry Henry Gebel <hgebel@inet.net> 0.8.2-1
 - First test of bdist_rpm
"""

Cool!  Note that the formatting of the changelog is slightly mutilated
by ConfigParser.  ;-(  I dunno how sensitive RPM is about this; guess
I'll find out soon enough!

        Greg
-- 
Greg Ward - Unix bigot                                  gward@python.net
http://starship.python.net/~gward/
I'd rather have a bottle in front of me than have to have a frontal lobotomy.