org.freecompany.redline
Class Builder

java.lang.Object
  extended by org.freecompany.redline.Builder

public class Builder
extends Object

The normal entry point to the API used for building and RPM. The API provides methods to configure and add contents to a new RPM. The current version of the RPM format (3.0) requires numerous headers to be set for an RPM to be valid. All of the required fields are either set automatically or exposed through setters in this builder class. Any required fields are marked in their respective method API documentation.


Field Summary
protected  Contents contents
           
protected  Map<String,CharSequence> dependencies
           
protected  Map<String,Integer> flags
           
protected  Format format
           
protected  AbstractHeader.Entry<byte[]> immutable
           
protected  AbstractHeader.Entry<byte[]> signature
           
protected  Set<PrivateKey> signatures
           
protected  List<Integer> triggerflags
           
protected  List<Integer> triggerindexes
           
protected  List<String> triggernames
           
protected  List<String> triggerscriptprogs
           
protected  List<String> triggerscripts
           
protected  List<String> triggerversions
           
 
Constructor Summary
Builder()
          Initializes the builder and sets some required fields to known values.
 
Method Summary
protected  void addDependency(CharSequence name, CharSequence version, int flag)
          Adds a dependency to the RPM package.
 void addDependency(String name, int comparison, String version)
          Adds a dependency to the RPM package.
 void addDependencyLess(CharSequence name, CharSequence version)
          Adds a dependency to the RPM package.
 void addDependencyMore(CharSequence name, CharSequence version)
          Adds a dependency to the RPM package.
 void addDirectory(String path)
          Adds the directory to the repository with the default mode of 644.
 void addDirectory(String path, Directive directive)
          Adds the directory to the repository with the default mode of 644.
 void addDirectory(String path, int permissions, Directive directive, String uname, String gname)
          Adds the directory to the repository.
 void addDirectory(String path, int permissions, Directive directive, String uname, String gname, boolean addParents)
          Adds the directory to the repository.
 void addFile(String path, File source)
          Adds the file to the repository with the default mode of 644.
 void addFile(String path, File source, int mode)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, Directive directive)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, Directive directive, String uname, String gname)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, int dirmode)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, int dirmode, Directive directive, String uname, String gname)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, int dirmode, Directive directive, String uname, String gname, boolean addParents)
          Add the specified file to the repository payload in order.
 void addFile(String path, File source, int mode, int dirmode, String uname, String gname)
          Add the specified file to the repository payload in order.
 void addHeaderEntry(AbstractHeader.Tag tag, String value)
          Adds a header entry value to the header.
 void addLink(String path, String target)
          Adds a symbolic link to the repository.
 void addLink(String path, String target, int permissions)
          Adds a symbolic link to the repository.
 void addSignature(PrivateKey key)
          Add a key to generate a new signature for the header and payload portions of the rpm file.
 void addTrigger(File script, String prog, Map<String,IntString> depends, int flag)
          Adds a trigger to the RPM package.
 void addURL(String path, URL source, int mode, int dirmode)
          Add the specified file to the repository payload in order by URL.
 void addURL(String path, URL source, int mode, int dirmode, Directive directive, String username, String group)
          Add the specified file to the repository payload in order by URL.
 void addURL(String path, URL source, int mode, int dirmode, String username, String group)
          Add the specified file to the repository payload in order by URL.
 String build(File directory)
          Generates an RPM with a standard name consisting of the RPM package name, version, release, and type in teh given directory.
 void build(FileChannel original)
          Generates the rpm file to the provided file channel.
protected  int[] convert(Integer[] ints)
          Converts an array of Integer objects into an equivalent array of int primitives.
protected  byte[] getImmutable(int count)
           
protected  byte[] getSignature(int count)
           
protected  byte[] getSpecial(int tag, int count)
          Returns the special header expected by RPM for a particular header.
 void setBuildHost(CharSequence host)
          Required Field.
 void setDescription(CharSequence description)
          Required Field.
 void setDistribution(CharSequence distribution)
          Required Field.
 void setFiles(Contents contents)
          Sets the group of contents to include in this RPM.
 void setGroup(CharSequence group)
          Required Field.
 void setLicense(CharSequence license)
          Required Field.
 void setPackage(CharSequence name, CharSequence version, CharSequence release)
          Required Field.
 void setPackager(CharSequence packager)
          Required Field.
 void setPlatform(Architecture arch, CharSequence osName)
          Required Field.
 void setPlatform(Architecture arch, Os os)
          Required Field.
 void setPostInstallProgram(String program)
          Declares the interpretter to be used when invoking the RPM post-installation script that can be set with the setPreInstallScript(String) method.
 void setPostInstallScript(File file)
          Declares a script file to be run as part of the RPM post-installation.
 void setPostInstallScript(String script)
          Declares a script to be run as part of the RPM post-installation.
 void setPostTransProgram(String program)
          Declares the interpreter to be used when invoking the RPM post-transaction script that can be set with the setPostTransScript(String) method.
 void setPostTransScript(File file)
          Declares a script file to be run as part of the RPM post-transaction.
 void setPostTransScript(String script)
          Declares a script to be run as part of the RPM post-transaction.
 void setPostUninstallProgram(String program)
          Declares the interpretter to be used when invoking the RPM post-uninstallation script that can be set with the setPostUninstallScript(String) method.
 void setPostUninstallScript(File file)
          Declares a script file to be run as part of the RPM post-uninstallation.
 void setPostUninstallScript(String script)
          Declares a script to be run as part of the RPM post-uninstallation.
 void setPrefixes(String... prefixes)
          Sets the package prefix directories to allow any files installed under them to be relocatable.
 void setPreInstallProgram(String program)
          Declares the interpretter to be used when invoking the RPM pre-installation script that can be set with the setPreInstallScript(String) method.
 void setPreInstallScript(File file)
          Declares a script file to be run as part of the RPM pre-installation.
 void setPreInstallScript(String script)
          Declares a script to be run as part of the RPM pre-installation.
 void setPreTransProgram(String program)
          Declares the interpreter to be used when invoking the RPM pre-transaction script that can be set with the setPreTransScript(String) method.
 void setPreTransScript(File file)
          Declares a script file to be run as part of the RPM pre-transaction.
 void setPreTransScript(String script)
          Declares a script to be run as part of the RPM pre-transaction.
 void setPreUninstallProgram(String program)
          Declares the interpretter to be used when invoking the RPM pre-uninstallation script that can be set with the setPreUninstallScript(String) method.
 void setPreUninstallScript(File file)
          Declares a script file to be run as part of the RPM pre-uninstallation.
 void setPreUninstallScript(String script)
          Declares a script to be run as part of the RPM pre-uninstallation.
 void setProvides(CharSequence provides)
          Declares a dependency that this package exports, and that other packages can use to provide library functions.
 void setSourceRpm(String rpm)
          Adds a source rpm.
 void setSummary(CharSequence summary)
          Required Field.
 void setType(RpmType type)
          Required Field.
 void setUrl(CharSequence url)
          Required Field.
 void setVendor(CharSequence vendor)
          Required Field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

format

protected final Format format

signatures

protected final Set<PrivateKey> signatures

dependencies

protected final Map<String,CharSequence> dependencies

flags

protected final Map<String,Integer> flags

triggerscripts

protected final List<String> triggerscripts

triggerscriptprogs

protected final List<String> triggerscriptprogs

triggernames

protected final List<String> triggernames

triggerversions

protected final List<String> triggerversions

triggerflags

protected final List<Integer> triggerflags

triggerindexes

protected final List<Integer> triggerindexes

signature

protected final AbstractHeader.Entry<byte[]> signature

immutable

protected final AbstractHeader.Entry<byte[]> immutable

contents

protected Contents contents
Constructor Detail

Builder

public Builder()
Initializes the builder and sets some required fields to known values.

Method Detail

addDependency

public void addDependency(String name,
                          int comparison,
                          String version)
Adds a dependency to the RPM package. This dependency version will be marked as the exact requirement, and the package will require the named dependency with exactly this version at install time.

Parameters:
name - the name of the dependency.
comparison - the comparison flag.
version - the version identifier.

addDependencyLess

public void addDependencyLess(CharSequence name,
                              CharSequence version)
Adds a dependency to the RPM package. This dependecy version will be marked as the maximum allowed, and the package will require the named dependency with this version or lower at install time.

Parameters:
name - the name of the dependency.
version - the version identifier.

addDependencyMore

public void addDependencyMore(CharSequence name,
                              CharSequence version)
Adds a dependency to the RPM package. This dependecy version will be marked as the minimum allowed, and the package will require the named dependency with this version or higher at install time.

Parameters:
name - the name of the dependency.
version - the version identifier.

addDependency

protected void addDependency(CharSequence name,
                             CharSequence version,
                             int flag)
Adds a dependency to the RPM package. This dependecy version will be marked as the exact requirement, and the package will require the named dependency with exactly this version at install time.

Parameters:
name - the name of the dependency.
version - the version identifier.

addHeaderEntry

public void addHeaderEntry(AbstractHeader.Tag tag,
                           String value)
Adds a header entry value to the header. For example use this to set the source RPM package name on your RPM

Parameters:
tag - the header tag to set
value - the value to set the header entry with

setPackage

public void setPackage(CharSequence name,
                       CharSequence version,
                       CharSequence release)
Required Field. Sets the package information, such as the rpm name, the version, and the release number.

Parameters:
name - the name of the RPM package.
version - the version of the new package.
release - the release number, specified after the version, of the new RPM.

setType

public void setType(RpmType type)
Required Field. Sets the type of the RPM to be either binary or source.

Parameters:
type - the type of RPM to generate.

setPlatform

public void setPlatform(Architecture arch,
                        Os os)
Required Field. Sets the platform related headers for the resulting RPM. The platform is specified as a combination of target architecture and OS.

Parameters:
arch - the target architecture.
os - the target operating system.

setPlatform

public void setPlatform(Architecture arch,
                        CharSequence osName)
Required Field. Sets the platform related headers for the resulting RPM. The platform is specified as a combination of target architecture and OS.

Parameters:
arch - the target architecture.
osName - the non-standard target operating system.

setSummary

public void setSummary(CharSequence summary)
Required Field. Sets the summary text for the file. The summary is generally a short, one line description of the function of the package, and is often shown by RPM tools.

Parameters:
summary - summary text.

setDescription

public void setDescription(CharSequence description)
Required Field. Sets the description text for the file. The description is often a paragraph describing the package in detail.

Parameters:
description - description text.

setBuildHost

public void setBuildHost(CharSequence host)
Required Field. Sets the build host for the RPM. This is an internal field.

Parameters:
host - hostname of the build machine.

setLicense

public void setLicense(CharSequence license)
Required Field. Lists the license under which this software is distributed. This field may be displayed by RPM tools.

Parameters:
license - the chosen distribution license.

setGroup

public void setGroup(CharSequence group)
Required Field. Software group to which this package belongs. The group describes what sort of function the software package provides.

Parameters:
group - target group.

setDistribution

public void setDistribution(CharSequence distribution)
Required Field. Distribution tag listing the ditributable package.

Parameters:
distribution - the distribution.

setVendor

public void setVendor(CharSequence vendor)
Required Field. Vendor tag listing the organization providing this software package.

Parameters:
vendor - software vendor.

setPackager

public void setPackager(CharSequence packager)
Required Field. Build packager, usually the username of the account building this RPM.

Parameters:
packager - packager name.

setUrl

public void setUrl(CharSequence url)
Required Field. Website URL for this package, usually a project site.

Parameters:
url -

setProvides

public void setProvides(CharSequence provides)
Declares a dependency that this package exports, and that other packages can use to provide library functions.

Parameters:
provides - dependency provided by this package.

setFiles

public void setFiles(Contents contents)
Sets the group of contents to include in this RPM. Note that this method causes the existing file set to be overwritten and therefore should be called before adding any other contents via the #addFile() methods.

Parameters:
contents - the set of contents to use in constructing this RPM.

setSourceRpm

public void setSourceRpm(String rpm)
Adds a source rpm.

Parameters:
rpm - name of rpm source file

setPrefixes

public void setPrefixes(String... prefixes)
Sets the package prefix directories to allow any files installed under them to be relocatable.

Parameters:
prefixes - Path prefixes which may be relocated

setPreTransScript

public void setPreTransScript(String script)
Declares a script to be run as part of the RPM pre-transaction. The script will be run using the interpreter declared with the setPreTransProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPreTransScript

public void setPreTransScript(File file)
                       throws IOException
Declares a script file to be run as part of the RPM pre-transaction. The script will be run using the interpreter declared with the setPreTransProgram(String) method.

Parameters:
file - Script to run (i.e. shell commands)
Throws:
IOException

setPreTransProgram

public void setPreTransProgram(String program)
Declares the interpreter to be used when invoking the RPM pre-transaction script that can be set with the setPreTransScript(String) method.

Parameters:
program - Path to the interpreter

setPreInstallScript

public void setPreInstallScript(String script)
Declares a script to be run as part of the RPM pre-installation. The script will be run using the interpretter declared with the setPreInstallProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPreInstallScript

public void setPreInstallScript(File file)
                         throws IOException
Declares a script file to be run as part of the RPM pre-installation. The script will be run using the interpretter declared with the setPreInstallProgram(String) method.

Parameters:
file - Script to run (i.e. shell commands)
Throws:
IOException

setPreInstallProgram

public void setPreInstallProgram(String program)
Declares the interpretter to be used when invoking the RPM pre-installation script that can be set with the setPreInstallScript(String) method.

Parameters:
program - Path to the interpretter

setPostInstallScript

public void setPostInstallScript(String script)
Declares a script to be run as part of the RPM post-installation. The script will be run using the interpretter declared with the setPostInstallProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPostInstallScript

public void setPostInstallScript(File file)
                          throws IOException
Declares a script file to be run as part of the RPM post-installation. The script will be run using the interpretter declared with the setPostInstallProgram(String) method.

Parameters:
file - Script to run (i.e. shell commands)
Throws:
IOException

setPostInstallProgram

public void setPostInstallProgram(String program)
Declares the interpretter to be used when invoking the RPM post-installation script that can be set with the setPreInstallScript(String) method.

Parameters:
program - Path to the interpretter

setPreUninstallScript

public void setPreUninstallScript(String script)
Declares a script to be run as part of the RPM pre-uninstallation. The script will be run using the interpretter declared with the setPreUninstallProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPreUninstallScript

public void setPreUninstallScript(File file)
                           throws IOException
Declares a script file to be run as part of the RPM pre-uninstallation. The script will be run using the interpretter declared with the setPreUninstallProgram(String) method.

Parameters:
file - Script to run (i.e. shell commands)
Throws:
IOException

setPreUninstallProgram

public void setPreUninstallProgram(String program)
Declares the interpretter to be used when invoking the RPM pre-uninstallation script that can be set with the setPreUninstallScript(String) method.

Parameters:
program - Path to the interpretter

setPostUninstallScript

public void setPostUninstallScript(String script)
Declares a script to be run as part of the RPM post-uninstallation. The script will be run using the interpretter declared with the setPostUninstallProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPostUninstallScript

public void setPostUninstallScript(File file)
                            throws IOException
Declares a script file to be run as part of the RPM post-uninstallation. The script will be run using the interpretter declared with the setPostUninstallProgram(String) method.

Parameters:
file - Script contents to run (i.e. shell commands)
Throws:
IOException

setPostUninstallProgram

public void setPostUninstallProgram(String program)
Declares the interpretter to be used when invoking the RPM post-uninstallation script that can be set with the setPostUninstallScript(String) method.

Parameters:
program - Path to the interpretter

setPostTransScript

public void setPostTransScript(String script)
Declares a script to be run as part of the RPM post-transaction. The script will be run using the interpreter declared with the setPostTransProgram(String) method.

Parameters:
script - Script contents to run (i.e. shell commands)

setPostTransScript

public void setPostTransScript(File file)
                        throws IOException
Declares a script file to be run as part of the RPM post-transaction. The script will be run using the interpreter declared with the setPostTransProgram(String) method.

Parameters:
file - Script contents to run (i.e. shell commands)
Throws:
IOException

setPostTransProgram

public void setPostTransProgram(String program)
Declares the interpreter to be used when invoking the RPM post-transaction script that can be set with the setPostTransScript(String) method.

Parameters:
program - Path to the interpreter

addTrigger

public void addTrigger(File script,
                       String prog,
                       Map<String,IntString> depends,
                       int flag)
                throws IOException
Adds a trigger to the RPM package.

Parameters:
script - the script to add.
prog - the interpreter with which to run the script.
depends - the map of rpms and versions that will trigger the script
flag - the trigger type (SCRIPT_TRIGGERPREIN, SCRIPT_TRIGGERIN, SCRIPT_TRIGGERUN, or SCRIPT_TRIGGERPOSTUN)
Throws:
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    int dirmode)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    int dirmode,
                    String uname,
                    String gname)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
uname - user owner for the given file
gname - group owner for the given file
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    int dirmode,
                    Directive directive,
                    String uname,
                    String gname)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
uname - user owner for the given file
gname - group owner for the given file
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    int dirmode,
                    Directive directive,
                    String uname,
                    String gname,
                    boolean addParents)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation, or -1 for default.
dirmode - the mode of the parent directories in standard three octet notation, or -1 for default.
uname - user owner for the given file, or null for default user.
gname - group owner for the given file, or null for default group.
addParents - whether to create parent directories for the file, defaults to true for other methods.
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    Directive directive,
                    String uname,
                    String gname)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
directive - directive indicating special handling for this file.
uname - user owner for the given file
gname - group owner for the given file
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source,
                    int mode,
                    Directive directive)
             throws NoSuchAlgorithmException,
                    IOException
Add the specified file to the repository payload in order. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
directive - directive indicating special handling for this file.
Throws:
NoSuchAlgorithmException
IOException

addFile

public void addFile(String path,
                    File source)
             throws NoSuchAlgorithmException,
                    IOException
Adds the file to the repository with the default mode of 644.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
Throws:
NoSuchAlgorithmException
IOException

addURL

public void addURL(String path,
                   URL source,
                   int mode,
                   int dirmode)
            throws NoSuchAlgorithmException,
                   IOException
Add the specified file to the repository payload in order by URL. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
Throws:
NoSuchAlgorithmException
IOException

addURL

public void addURL(String path,
                   URL source,
                   int mode,
                   int dirmode,
                   String username,
                   String group)
            throws NoSuchAlgorithmException,
                   IOException
Add the specified file to the repository payload in order by URL. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
username - ownership of added file
group - ownership of added file
Throws:
NoSuchAlgorithmException
IOException

addURL

public void addURL(String path,
                   URL source,
                   int mode,
                   int dirmode,
                   Directive directive,
                   String username,
                   String group)
            throws NoSuchAlgorithmException,
                   IOException
Add the specified file to the repository payload in order by URL. The required header entries will automatically be generated to record the directory names and file names, as well as their digests.

Parameters:
path - the absolute path at which this file will be installed.
source - the file content to include in this rpm.
mode - the mode of the target file in standard three octet notation
username - ownership of added file
group - ownership of added file
Throws:
NoSuchAlgorithmException
IOException

addDirectory

public void addDirectory(String path)
                  throws NoSuchAlgorithmException,
                         IOException
Adds the directory to the repository with the default mode of 644.

Parameters:
path - the absolute path to add as a directory.
Throws:
NoSuchAlgorithmException
IOException

addDirectory

public void addDirectory(String path,
                         int permissions,
                         Directive directive,
                         String uname,
                         String gname)
                  throws NoSuchAlgorithmException,
                         IOException
Adds the directory to the repository.

Parameters:
path - the absolute path to add as a directory.
permissions - the mode of the directory in standard three octet notation.
directive - directive indicating special handling for this file.
uname - user owner of the directory
gname - group owner of the directory
Throws:
NoSuchAlgorithmException
IOException

addDirectory

public void addDirectory(String path,
                         int permissions,
                         Directive directive,
                         String uname,
                         String gname,
                         boolean addParents)
                  throws NoSuchAlgorithmException,
                         IOException
Adds the directory to the repository.

Parameters:
path - the absolute path to add as a directory.
permissions - the mode of the directory in standard three octet notation.
directive - directive indicating special handling for this file.
uname - user owner of the directory
gname - group owner of the directory
addParents - whether to add parent directories to the rpm
Throws:
NoSuchAlgorithmException
IOException

addDirectory

public void addDirectory(String path,
                         Directive directive)
                  throws NoSuchAlgorithmException,
                         IOException
Adds the directory to the repository with the default mode of 644.

Parameters:
path - the absolute path to add as a directory.
directive - directive indicating special handling for this file.
Throws:
NoSuchAlgorithmException
IOException

addLink

public void addLink(String path,
                    String target)
             throws NoSuchAlgorithmException,
                    IOException
Adds a symbolic link to the repository.

Parameters:
path - the absolute path at which this link will be installed.
target - the path of the file this link will point to.
Throws:
NoSuchAlgorithmException
IOException

addLink

public void addLink(String path,
                    String target,
                    int permissions)
             throws NoSuchAlgorithmException,
                    IOException
Adds a symbolic link to the repository.

Parameters:
path - the absolute path at which this link will be installed.
target - the path of the file this link will point to.
Throws:
NoSuchAlgorithmException
IOException

addSignature

public void addSignature(PrivateKey key)
Add a key to generate a new signature for the header and payload portions of the rpm file. Supported algorithms are "MD5withRSA" and "SHAwithDSA".

Parameters:
key - private key to use in generating a signature.

build

public String build(File directory)
             throws NoSuchAlgorithmException,
                    IOException
Generates an RPM with a standard name consisting of the RPM package name, version, release, and type in teh given directory.

Parameters:
directory - the destination directory for the new RPM file.
Throws:
NoSuchAlgorithmException
IOException

build

public void build(FileChannel original)
           throws NoSuchAlgorithmException,
                  IOException
Generates the rpm file to the provided file channel. This file channel must support memory mapping and therefore should be created from a RandomAccessFile, otherwise an IOException will be generated.

Parameters:
original - the FileChannel to which the resulting RPM will be written.
Throws:
NoSuchAlgorithmException
IOException

getSignature

protected byte[] getSignature(int count)

getImmutable

protected byte[] getImmutable(int count)

getSpecial

protected byte[] getSpecial(int tag,
                            int count)
Returns the special header expected by RPM for a particular header.


convert

protected int[] convert(Integer[] ints)
Converts an array of Integer objects into an equivalent array of int primitives.



Copyright © 2012. All Rights Reserved.