NAME

RPM::Make::DWIW - Create an RPM from a hashref

SYNOPSIS

use RPM::Make::DWIW;

    my $spec = {
        tags => {
            Summary     => 'ACME DB client',
            Name        => 'acmedb_client',
            Version     => '1.3',
            Release     => '3',
            License     => 'GPL',
            Group       => 'Applications/Database',
            #Source     => 'ftp://ftp.acme.com/acmedb_client-1.3.tar.gz',
            #URL        => 'http://www.acme.com/acmedb_client/',
            #Distribution => 'ACME',
            #Vendor     => 'ACME Software, Inc.',
            #Packager   => 'Adam Acme <aa@acme.com>',
        },
        description => 'Client libraries and binary for ACME DB',
        items => [
            # first set defaults for following items:
            {
                defaults => 1,
                type => 'file',
                mode => '0755',
                owner => 'root',
                group => 'wheel',
            },
            {
                src  => '../src/acme-client',
                dest => '/usr/bin/acme-client',
            },
            {
                src  => '../src/acme-client.conf',
                dest => '/etc/acme-client.conf',
                mode => '0644',
            },
            {
                src  => '../src/acme.so',
                dest => '/usr/lib/libacmeclient.so.1',
                mode => '0644',
            },
            {
                type => 'dir',
                dest => '/var/log/acme-client/transcripts',
            mode => '0777',
            },
        ],
        post => 'ldconfig',
        postun => 'ldconfig',
    };

    RPM::Make::DWIW::write_rpm($spec);

DESCRIPTION

This module creates an RPM package from a description hashref.

It has nothing to do with source code or build processes. It assumes that whatever files you want to include in the RPM already exist.

This module can create RPMs for executable files, shared objects, or any other installable file. It is not specialized for installing Perl.

You control the ownership and permissions of each file as installed, independent of the ownership and permissions in the source tree or build directory. You do not have to be root to create the RPM.

Under the covers, this module uses the rpmbuild command to create the RPM. It also creates a temporary dir, which it removes if all went well.

Functions

write_rpm($spec);

Write an RPM file from the given spec hashref. Spec must contain:

tags

A hashref of metadata specified by RPM. The mandatory tags are Summary, Name, Version, License and Group. The optional tags are Source, URL, Distribution, Vendor and Packager. The meaning of these tags is specified by RPM.

description

The long description of the package. May contain newlines.

items

An array of hashrefs, each representing a file or directory to include in the RPM, or a defaults block which sets defaults for subsequent items.

src

Where you want to copy the file from when building the RPM; typically a relative path into your build directory. Directories have no src.

dest

Location where you want RPM to install the file or create the directory when the RPM is installed.

mode

Access mode that you want the item to have after installation, e.g. '0755' for executables. Must be a string, not a raw octal number.

owner, group

Unix user/group that you want the item to have after installation.

type

May be file or dir. If it's file, the item must have src.

config_p

If config_p=1, this item is marked as a configuration file. RPM handles them differently.

defaults

If defaults=1, this item does not represent a file/dir; it just sets defaults for all items downstream. This way you can avoid repeating mode, user and group when you have several items that share the same settings.

The absence of a key in a defaults block does not remove that key from the current defaults; to do that, set the value to "".

More than one defaults block can occur in the items array. Each defaults block affects items downstream of it. Each defaults block inherits any defaults it does not override.

Spec may also contain:

requirements

An array of hashrefs, each having name and optionally min_ver. Example:

    requirements => [
        {
            name        => 'libxml2',
            min_version => '2.6.0',
        }
    ]

This requires an RPM package called libxml2 or a package offering that capability. The package must have verison 2.6.0 or higher.

Use this to show dependency on other packages. If your package includes executables or shared objects, RPM will examine them with ldd(1) and add dependencies.

pre, post, preun, postun

Shell commands to run pre/post installation and pre/post uninstallation. May contain newlines. If installing a shared object, generally include 'ldconfig' in both post and postun.

cleanup

By default this module removes its temp working directory if the RPM builds successfully. If you want to preserve the directory, for instance to examine the specfile, set cleanup = 0.

get_example_spec()

Get an example spec hashref.

get_rpm_filename()

Get the filename of the created RPM. Only call this after creating an RPM.

ERRORS

This module dies on errors. This leaves the temporary build directory intact for inspection. In some cases, you may want to wrap the module in an eval.

SEE ALSO

rpmbuild(8)

HISTORY

Written by Asher Blum <asher@wildsparx.com> in 2010.

COPYRIGHT

Copyright (C) 2010 Asher Blum. All rights reserved. This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.