|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.freecompany.redline.Builder
public class Builder
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 java.util.Map<java.lang.String,java.lang.CharSequence> |
dependencies
|
protected java.util.Map<java.lang.String,java.lang.Integer> |
flags
|
protected Format |
format
|
protected AbstractHeader.Entry<byte[]> |
immutable
|
protected AbstractHeader.Entry<byte[]> |
signature
|
protected java.util.Set<java.security.PrivateKey> |
signatures
|
Constructor Summary | |
---|---|
Builder()
Initializes the builder and sets some required fields to known values. |
Method Summary | |
---|---|
protected void |
addDependency(java.lang.CharSequence name,
java.lang.CharSequence version,
int flag)
Adds a dependency to the RPM package. |
void |
addDependencyLess(java.lang.CharSequence name,
java.lang.CharSequence version)
Adds a dependency to the RPM package. |
void |
addDependencyMore(java.lang.CharSequence name,
java.lang.CharSequence version)
Adds a dependency to the RPM package. |
void |
addDirectory(java.lang.String path)
Adds the directory to the repository with the default mode of 644 . |
void |
addDirectory(java.lang.String path,
Directive directive)
Adds the directory to the repository with the default mode of 644 . |
void |
addDirectory(java.lang.String path,
int permissions,
Directive directive,
java.lang.String uname,
java.lang.String gname)
Adds the directory to the repository. |
void |
addDirectory(java.lang.String path,
int permissions,
Directive directive,
java.lang.String uname,
java.lang.String gname,
boolean addParents)
Adds the directory to the repository. |
void |
addFile(java.lang.String path,
java.io.File source)
Adds the file to the repository with the default mode of 644 . |
void |
addFile(java.lang.String path,
java.io.File source,
int mode)
Add the specified file to the repository payload in order. |
void |
addFile(java.lang.String path,
java.io.File source,
int mode,
Directive directive)
Add the specified file to the repository payload in order. |
void |
addFile(java.lang.String path,
java.io.File source,
int mode,
Directive directive,
java.lang.String uname,
java.lang.String gname)
Add the specified file to the repository payload in order. |
void |
addLink(java.lang.String path,
java.lang.String target)
Adds a symbolic link to the repository. |
void |
addLink(java.lang.String path,
java.lang.String target,
int permissions)
Adds a symbolic link to the repository. |
void |
addSignature(java.security.PrivateKey key)
Add a key to generate a new signature for the header and payload portions of the rpm file. |
java.lang.String |
build(java.io.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(java.nio.channels.FileChannel original)
Generates the rpm file to the provided file channel. |
protected int[] |
convert(java.lang.Integer[] ints)
|
protected byte[] |
getImmutable(int count)
|
protected byte[] |
getSignature(int count)
|
protected byte[] |
getSpecial(int tag,
int count)
|
void |
setBuildHost(java.lang.CharSequence host)
Required Field. |
void |
setDescription(java.lang.CharSequence description)
Required Field. |
void |
setDistribution(java.lang.CharSequence distribution)
Required Field. |
void |
setFiles(Contents contents)
Sets the group of contents to include in this RPM. |
void |
setGroup(java.lang.CharSequence group)
Required Field. |
void |
setLicense(java.lang.CharSequence license)
Required Field. |
void |
setPackage(java.lang.CharSequence name,
java.lang.CharSequence version,
java.lang.CharSequence release)
Required Field. |
void |
setPackager(java.lang.CharSequence packager)
Required Field. |
void |
setPlatform(Architecture arch,
Os os)
Required Field. |
void |
setPostInstallProgram(java.lang.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(java.lang.String script)
Declares a script to be run as part of the RPM post-installation. |
void |
setPostUninstallProgram(java.lang.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(java.lang.String script)
Declares a script to be run as part of the RPM post-uninstallation. |
void |
setPrefixes(java.lang.String... prefixes)
Sets the package prefix directories to allow any files installed under them to be relocatable. |
void |
setPreInstallProgram(java.lang.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(java.lang.String script)
Declares a script to be run as part of the RPM pre-installation. |
void |
setPreUninstallProgram(java.lang.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(java.lang.String script)
Declares a script to be run as part of the RPM pre-uninstallation. |
void |
setProvides(java.lang.CharSequence provides)
Declares a dependency that this package exports, and that other packages can use to provide library functions. |
void |
setSourceRpm(java.lang.String rpm)
Adds a source rpm. |
void |
setSummary(java.lang.CharSequence summary)
Required Field. |
void |
setType(RpmType type)
Required Field. |
void |
setUrl(java.lang.CharSequence url)
Required Field. |
void |
setVendor(java.lang.CharSequence vendor)
Required Field. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Format format
protected final java.util.Set<java.security.PrivateKey> signatures
protected final java.util.Map<java.lang.String,java.lang.CharSequence> dependencies
protected final java.util.Map<java.lang.String,java.lang.Integer> flags
protected final AbstractHeader.Entry<byte[]> signature
protected final AbstractHeader.Entry<byte[]> immutable
protected Contents contents
Constructor Detail |
---|
public Builder()
Method Detail |
---|
public void addDependencyLess(java.lang.CharSequence name, java.lang.CharSequence version)
name
- the name of the dependency.version
- the version identifier.public void addDependencyMore(java.lang.CharSequence name, java.lang.CharSequence version)
name
- the name of the dependency.version
- the version identifier.protected void addDependency(java.lang.CharSequence name, java.lang.CharSequence version, int flag)
name
- the name of the dependency.version
- the version identifier.public void setPackage(java.lang.CharSequence name, java.lang.CharSequence version, java.lang.CharSequence release)
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.public void setType(RpmType type)
type
- the type of RPM to generate.public void setPlatform(Architecture arch, Os os)
arch
- the target architectur.os
- the target operating system.public void setSummary(java.lang.CharSequence summary)
summary
- summary text.public void setDescription(java.lang.CharSequence description)
description
- description text.public void setBuildHost(java.lang.CharSequence host)
host
- hostname of the build machine.public void setLicense(java.lang.CharSequence license)
license
- the chosen distribution license.public void setGroup(java.lang.CharSequence group)
group
- target group.public void setDistribution(java.lang.CharSequence distribution)
distribution
- the distribution.public void setVendor(java.lang.CharSequence vendor)
vendor
- software vendor.public void setPackager(java.lang.CharSequence packager)
packager
- packager name.public void setUrl(java.lang.CharSequence url)
url
- public void setProvides(java.lang.CharSequence provides)
dependency
- provided by this package.public void setFiles(Contents contents)
#addFile()
methods.
contents
- the set of contents to use in constructing this RPM.public void setSourceRpm(java.lang.String rpm)
rpm
- name of rpm source filepublic void setPrefixes(java.lang.String... prefixes)
prefixes
- Path prefixes which may be relocatedpublic void setPreInstallScript(java.lang.String script)
setPreInstallProgram(String)
method.
script
- Script contents to run (i.e. shell commands)public void setPreInstallProgram(java.lang.String program)
setPreInstallScript(String)
method.
program
- Path to the interpretterpublic void setPostInstallScript(java.lang.String script)
setPostInstallProgram(String)
method.
script
- Script contents to run (i.e. shell commands)public void setPostInstallProgram(java.lang.String program)
setPreInstallScript(String)
method.
program
- Path to the interpretterpublic void setPreUninstallScript(java.lang.String script)
setPreUninstallProgram(String)
method.
script
- Script contents to run (i.e. shell commands)public void setPreUninstallProgram(java.lang.String program)
setPreUninstallScript(String)
method.
program
- Path to the interpretterpublic void setPostUninstallScript(java.lang.String script)
setPostUninstallProgram(String)
method.
script
- Script contents to run (i.e. shell commands)public void setPostUninstallProgram(java.lang.String program)
setPostUninstallScript(String)
method.
program
- Path to the interpretterpublic void addFile(java.lang.String path, java.io.File source, int mode) throws java.security.NoSuchAlgorithmException, java.io.IOException
target
- the absolute path at which this file will be installed.file
- the file content to include in this rpm.mode
- the mode of the target file in standard three octet notation
java.security.NoSuchAlgorithmException
java.io.IOException
public void addFile(java.lang.String path, java.io.File source, int mode, Directive directive, java.lang.String uname, java.lang.String gname) throws java.security.NoSuchAlgorithmException, java.io.IOException
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 notationdirective
- directive indicating special handling for this file.uname
- user owner for the given filegname
- group owner for the given file
java.security.NoSuchAlgorithmException
java.io.IOException
public void addFile(java.lang.String path, java.io.File source, int mode, Directive directive) throws java.security.NoSuchAlgorithmException, java.io.IOException
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 notationdirective
- directive indicating special handling for this file.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addFile(java.lang.String path, java.io.File source) throws java.security.NoSuchAlgorithmException, java.io.IOException
644
.
path
- the absolute path at which this file will be installed.file
- the file content to include in this rpm.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addDirectory(java.lang.String path) throws java.security.NoSuchAlgorithmException, java.io.IOException
644
.
path
- the absolute path at which this file will be installed.file
- the file content to include in this rpm.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addDirectory(java.lang.String path, int permissions, Directive directive, java.lang.String uname, java.lang.String gname) throws java.security.NoSuchAlgorithmException, java.io.IOException
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 directorygname
- group owner of the directory
java.security.NoSuchAlgorithmException
java.io.IOException
public void addDirectory(java.lang.String path, int permissions, Directive directive, java.lang.String uname, java.lang.String gname, boolean addParents) throws java.security.NoSuchAlgorithmException, java.io.IOException
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 directorygname
- group owner of the directoryaddParents
- whether to add parent directories to the rpm
java.security.NoSuchAlgorithmException
java.io.IOException
public void addDirectory(java.lang.String path, Directive directive) throws java.security.NoSuchAlgorithmException, java.io.IOException
644
.
path
- the absolute path to add as a directory.directive
- directive indicating special handling for this file.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addLink(java.lang.String path, java.lang.String target) throws java.security.NoSuchAlgorithmException, java.io.IOException
path
- the absolute path at which this link will be installed.target
- the path of the file this link will point to.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addLink(java.lang.String path, java.lang.String target, int permissions) throws java.security.NoSuchAlgorithmException, java.io.IOException
path
- the absolute path at which this link will be installed.target
- the path of the file this link will point to.
java.security.NoSuchAlgorithmException
java.io.IOException
public void addSignature(java.security.PrivateKey key)
key
- private key to use in generating a signature.public java.lang.String build(java.io.File directory) throws java.security.NoSuchAlgorithmException, java.io.IOException
directory
- the destination directory for the new RPM file.
java.security.NoSuchAlgorithmException
java.io.IOException
public void build(java.nio.channels.FileChannel original) throws java.security.NoSuchAlgorithmException, java.io.IOException
RandomAccessFile
, otherwise an IOException
will be
generated.
original
- the FileChannel
to which the resulting RPM will be written.
java.security.NoSuchAlgorithmException
java.io.IOException
protected byte[] getSignature(int count)
protected byte[] getImmutable(int count)
protected byte[] getSpecial(int tag, int count)
protected int[] convert(java.lang.Integer[] ints)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |