Is there an RPM or two (or more!) that after every installtion of
them, you go perform the same "clean up" tasks?

For example, perhaps you have some device driver(s) that you want on
your system that MDK does not ship in their kernel RPM.  After every
new kernel/kernel-source install/upgrade you need to go manually build
and install the driver.

Or perhaps you run vmware and need to build new kernel modules for it
everytime you upgrade your kernel and kernel-source.

Well I have found a way to make RPM do all of the work for you.

You need to create a "meta" package with "triggers" in it for each of
the packages you want some kind of "post installation" task to be
done.

Here is an example RPM spec file that I am using:

    %define version 8.1
    %define release 2bjm
    %define name cleanup
    
    Summary: An RPM that takes care of routine tasks that get done when various RPMS 
are installed and removed.
    Name: %{name}
    Version: %{version}
    Release: %{release}
    Copyright: None
    Group: None/None
    BuildRoot: /var/tmp/root-%{name}
    BuildArch: noarch
    
    %changelog
    * Fri Jul 20 2001 Brian J. Murrell <[EMAIL PROTECTED]>
    - initial concept
    
    %description
    This is a package full of "triggers" to do things that we always have to do when 
various packages are added/removed/upgraded.
    
    %prep
    rm -rf $RPM_BUILD_DIR/%{name}
    
    %install
    mkdir -p $RPM_BUILD_ROOT/%{name}
    
    %triggerin -- kernel-source
    # $1 == "2" when installing "cleanup", "1" when installing kernel-source
    if [ "$1" == "2" ]; then
        # only perform tasks on intall/upgrade of "kernel-source", and initial
        # install of "cleanup"and not upgrades of "cleanup"
        exit 0
    fi
    # what version of kenrel-source is being installed?
    # can't use rpm -q because rpm blocks usage beyond 1
    #pkg=$(rpm -q kernel-source)
    #ver=${pkg##kernel-source-}
    ver=`uname -r`
    ver=${ver%%-*}
    # change the ownership of the kernel source and /usr/src to brian.brian
    echo "changing ownerships of /usr/src/ and /usr/src/linux-$ver to brian.brian"
    chown brian.brian /usr/src
    chown -R brian.brian /usr/src/linux-$ver
    # configure the kernel source
    echo "configuring kernel source"
    cd /usr/src/linux-$ver
    make mrproper >/dev/null 2>&1 
    make oldconfig >/dev/null 2>&1 
    make dep >/dev/null 2>&1 
    # now make various drivers we like to use
    # v4l2 and bttv2
    echo "building videodevX"
    cd /usr/src/videodevX
    (su brian -c "make" && make install) >/dev/null 2>&1 
    echo "building bttv2"
    cd /usr/src/bttv2
    (su brian -c "make" && make install) >/dev/null 2>&1
    # build new VMware modules
    vmware-config.pl --default >/dev/null 2>&1
    
    %files

If you build this with "rpm -ba cleanup.spec" and then install it, the
next time you update kernel-source, the above script (after the
%%triggerin -- kernel-source) will be executed, automatically taking
care of your post kernel-source steps.  You can then add as many
"%triggerin -- <package>" scripts as you have "post-<package>"
procedures that you want done for given packages.

It would be nice if this technique was "generalized" with a meta
package that included triggers for all known MDK packages that hooked
into user editable scripts in a given directory.  That way a new
meta-package RPM would not need to be created everytime somebody
changed their "post-<package>" process.

Perhaps a meta packge such as the following would be useful:

    %define version 8.1
    %define release 1mdk
    %define name rpm-post-process
    
    Summary: An RPM that takes care of routine tasks that get done when various RPMS 
are installed and removed.
    Name: %{name}
    Version: %{version}
    Release: %{release}
    Copyright: None
    Group: None/None
    BuildRoot: /var/tmp/root-%{name}
    BuildArch: noarch
    
    %changelog
    * Fri Jul 20 2001 Brian J. Murrell <[EMAIL PROTECTED]>
    - initial concept
    
    %description
    This is a package full of "triggers" to do things that we always have to do when 
various packages are added/removed/upgraded.
    
    %prep
    rm -rf $RPM_BUILD_DIR/%{name}
    
    %install
    mkdir -p $RPM_BUILD_ROOT/%{name}
    
    %triggerin -- <package-1>
    /usr/lib/rpm-post-process/package-1 install $1 $2
    
    %triggerin -- <package-2>
    /usr/lib/rpm-post-process/package-2 install $1 $2
    
    %triggerin -- <package-n>
    /usr/lib/rpm-post-process/package-n install $1 $2
    
    %files

where package-1, package-2, ..., package-n are each and every package
in the MDK distro.  It would be nice if the meta-rpm could use:

    %triggerin -- *
    /usr/lib/rpm-post-process/%{pkgname} $1 $2
    
and cover every package, but I don't think that is possible.  A
%triggerin for every package is necessary I believe.

Thots?

b.


-- 
Brian J. Murrell

Reply via email to