|
||||||||||
| 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 Map<String,CharSequence> |
conflicts
|
protected Map<String,Integer> |
conflictsFlags
|
protected Contents |
contents
|
protected Map<String,CharSequence> |
dependencies
|
protected Map<String,Integer> |
flags
|
protected Format |
format
|
protected AbstractHeader.Entry<byte[]> |
immutable
|
protected Map<String,CharSequence> |
obsoletes
|
protected Map<String,Integer> |
obsoletesFlags
|
protected org.bouncycastle.openpgp.PGPPrivateKey |
privateKey
|
protected String |
privateKeyId
|
protected String |
privateKeyPassphrase
|
protected File |
privateKeyRingFile
|
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 |
addConflicts(CharSequence name,
CharSequence version,
int flag)
|
void |
addConflicts(String name,
int comparison,
String version)
|
void |
addConflictsLess(CharSequence name,
CharSequence version)
|
void |
addConflictsMore(CharSequence name,
CharSequence version)
|
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. |
protected void |
addObsoletes(CharSequence name,
CharSequence version,
int flag)
|
void |
addObsoletes(String name,
int comparison,
String version)
|
void |
addObsoletesLess(CharSequence name,
CharSequence version)
|
void |
addObsoletesMore(CharSequence name,
CharSequence version)
|
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 SignatureGenerator |
createSignatureGenerator()
|
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 |
setPrivateKey(org.bouncycastle.openpgp.PGPPrivateKey privateKey)
Sets the private key for header and payload signing directly. |
void |
setPrivateKeyId(String privateKeyId)
Selects a private key from the current private ky ring file. |
void |
setPrivateKeyPassphrase(String privateKeyPassphrase)
Passphrase for the private key |
void |
setPrivateKeyRingFile(File privateKeyRingFile)
Sets the PGP key ring file used for header and header + payload signature. |
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 |
|---|
protected final Format format
protected final Set<PrivateKey> signatures
protected final Map<String,CharSequence> dependencies
protected final Map<String,Integer> flags
protected final Map<String,CharSequence> obsoletes
protected final Map<String,Integer> obsoletesFlags
protected final Map<String,CharSequence> conflicts
protected final Map<String,Integer> conflictsFlags
protected final List<String> triggerscripts
protected final List<String> triggerscriptprogs
protected final List<String> triggernames
protected final List<String> triggerversions
protected final List<Integer> triggerflags
protected final List<Integer> triggerindexes
protected final AbstractHeader.Entry<byte[]> signature
protected final AbstractHeader.Entry<byte[]> immutable
protected Contents contents
protected File privateKeyRingFile
protected String privateKeyId
protected String privateKeyPassphrase
protected org.bouncycastle.openpgp.PGPPrivateKey privateKey
| Constructor Detail |
|---|
public Builder()
| Method Detail |
|---|
public void addObsoletes(String name,
int comparison,
String version)
public void addObsoletesLess(CharSequence name,
CharSequence version)
public void addObsoletesMore(CharSequence name,
CharSequence version)
protected void addObsoletes(CharSequence name,
CharSequence version,
int flag)
public void addConflicts(String name,
int comparison,
String version)
public void addConflictsLess(CharSequence name,
CharSequence version)
public void addConflictsMore(CharSequence name,
CharSequence version)
protected void addConflicts(CharSequence name,
CharSequence version,
int flag)
public void addDependency(String name,
int comparison,
String version)
name - the name of the dependency.comparison - the comparison flag.version - the version identifier.
public void addDependencyLess(CharSequence name,
CharSequence version)
name - the name of the dependency.version - the version identifier.
public void addDependencyMore(CharSequence name,
CharSequence version)
name - the name of the dependency.version - the version identifier.
protected void addDependency(CharSequence name,
CharSequence version,
int flag)
name - the name of the dependency.version - the version identifier.
public void addHeaderEntry(AbstractHeader.Tag tag,
String value)
tag - the header tag to setvalue - the value to set the header entry with
public void setPackage(CharSequence name,
CharSequence version,
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.
IllegalArgumentException - if version or release contain
dashes, as they are explicitly disallowed by RPM file format.public void setType(RpmType type)
type - the type of RPM to generate.
public void setPlatform(Architecture arch,
Os os)
arch - the target architecture.os - the target operating system.
public void setPlatform(Architecture arch,
CharSequence osName)
arch - the target architecture.osName - the non-standard target operating system.public void setSummary(CharSequence summary)
summary - summary text.public void setDescription(CharSequence description)
description - description text.public void setBuildHost(CharSequence host)
host - hostname of the build machine.public void setLicense(CharSequence license)
license - the chosen distribution license.public void setGroup(CharSequence group)
group - target group.public void setDistribution(CharSequence distribution)
distribution - the distribution.public void setVendor(CharSequence vendor)
vendor - software vendor.public void setPackager(CharSequence packager)
packager - packager name.public void setUrl(CharSequence url)
url - public void setProvides(CharSequence provides)
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(String rpm)
rpm - name of rpm source filepublic void setPrefixes(String... prefixes)
prefixes - Path prefixes which may be relocatedpublic void setPreTransScript(String script)
setPreTransProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPreTransScript(File file)
throws IOException
setPreTransProgram(String) method.
file - Script to run (i.e. shell commands)
IOExceptionpublic void setPreTransProgram(String program)
setPreTransScript(String) method.
program - Path to the interpreterpublic void setPreInstallScript(String script)
setPreInstallProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPreInstallScript(File file)
throws IOException
setPreInstallProgram(String) method.
file - Script to run (i.e. shell commands)
IOExceptionpublic void setPreInstallProgram(String program)
setPreInstallScript(String) method.
program - Path to the interpretterpublic void setPostInstallScript(String script)
setPostInstallProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPostInstallScript(File file)
throws IOException
setPostInstallProgram(String) method.
file - Script to run (i.e. shell commands)
IOExceptionpublic void setPostInstallProgram(String program)
setPreInstallScript(String) method.
program - Path to the interpretterpublic void setPreUninstallScript(String script)
setPreUninstallProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPreUninstallScript(File file)
throws IOException
setPreUninstallProgram(String) method.
file - Script to run (i.e. shell commands)
IOExceptionpublic void setPreUninstallProgram(String program)
setPreUninstallScript(String) method.
program - Path to the interpretterpublic void setPostUninstallScript(String script)
setPostUninstallProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPostUninstallScript(File file)
throws IOException
setPostUninstallProgram(String) method.
file - Script contents to run (i.e. shell commands)
IOExceptionpublic void setPostUninstallProgram(String program)
setPostUninstallScript(String) method.
program - Path to the interpretterpublic void setPostTransScript(String script)
setPostTransProgram(String) method.
script - Script contents to run (i.e. shell commands)
public void setPostTransScript(File file)
throws IOException
setPostTransProgram(String) method.
file - Script contents to run (i.e. shell commands)
IOExceptionpublic void setPostTransProgram(String program)
setPostTransScript(String) method.
program - Path to the interpreter
public void addTrigger(File script,
String prog,
Map<String,IntString> depends,
int flag)
throws IOException
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 scriptflag - the trigger type (SCRIPT_TRIGGERPREIN, SCRIPT_TRIGGERIN, SCRIPT_TRIGGERUN, or SCRIPT_TRIGGERPOSTUN)
IOException
public void addFile(String path,
File source,
int mode)
throws NoSuchAlgorithmException,
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 notation
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
int dirmode)
throws NoSuchAlgorithmException,
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 notation
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
int dirmode,
String uname,
String gname)
throws NoSuchAlgorithmException,
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 notationuname - user owner for the given filegname - group owner for the given file
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
int dirmode,
Directive directive,
String uname,
String gname)
throws NoSuchAlgorithmException,
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 notationuname - user owner for the given filegname - group owner for the given file
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
int dirmode,
Directive directive,
String uname,
String gname,
boolean addParents)
throws NoSuchAlgorithmException,
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 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.
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
Directive directive,
String uname,
String gname)
throws NoSuchAlgorithmException,
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
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source,
int mode,
Directive directive)
throws NoSuchAlgorithmException,
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.
NoSuchAlgorithmException
IOException
public void addFile(String path,
File source)
throws NoSuchAlgorithmException,
IOException
644.
path - the absolute path at which this file will be installed.source - the file content to include in this rpm.
NoSuchAlgorithmException
IOException
public void addURL(String path,
URL source,
int mode,
int dirmode)
throws NoSuchAlgorithmException,
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 notation
NoSuchAlgorithmException
IOException
public void addURL(String path,
URL source,
int mode,
int dirmode,
String username,
String group)
throws NoSuchAlgorithmException,
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 notationusername - ownership of added filegroup - ownership of added file
NoSuchAlgorithmException
IOException
public void addURL(String path,
URL source,
int mode,
int dirmode,
Directive directive,
String username,
String group)
throws NoSuchAlgorithmException,
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 notationusername - ownership of added filegroup - ownership of added file
NoSuchAlgorithmException
IOException
public void addDirectory(String path)
throws NoSuchAlgorithmException,
IOException
644.
path - the absolute path to add as a directory.
NoSuchAlgorithmException
IOException
public void addDirectory(String path,
int permissions,
Directive directive,
String uname,
String gname)
throws NoSuchAlgorithmException,
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
NoSuchAlgorithmException
IOException
public void addDirectory(String path,
int permissions,
Directive directive,
String uname,
String gname,
boolean addParents)
throws NoSuchAlgorithmException,
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
NoSuchAlgorithmException
IOException
public void addDirectory(String path,
Directive directive)
throws NoSuchAlgorithmException,
IOException
644.
path - the absolute path to add as a directory.directive - directive indicating special handling for this file.
NoSuchAlgorithmException
IOException
public void addLink(String path,
String target)
throws NoSuchAlgorithmException,
IOException
path - the absolute path at which this link will be installed.target - the path of the file this link will point to.
NoSuchAlgorithmException
IOException
public void addLink(String path,
String target,
int permissions)
throws NoSuchAlgorithmException,
IOException
path - the absolute path at which this link will be installed.target - the path of the file this link will point to.
NoSuchAlgorithmException
IOExceptionpublic void addSignature(PrivateKey key)
key - private key to use in generating a signature.public void setPrivateKeyRingFile(File privateKeyRingFile)
setPrivateKey(org.bouncycastle.openpgp.PGPPrivateKey)
privateKeyRingFile - public void setPrivateKeyId(String privateKeyId)
private ky ring file.
If no key is specified, the first signing key will be selected.
privateKeyId - hex key idpublic void setPrivateKeyPassphrase(String privateKeyPassphrase)
privateKeyPassphrase - public void setPrivateKey(org.bouncycastle.openpgp.PGPPrivateKey privateKey)
key ring file, key id
and passphrase directly. Setting the private key has more
priorisation than providing key ring file.
privateKey -
public String build(File directory)
throws NoSuchAlgorithmException,
IOException
directory - the destination directory for the new RPM file.
NoSuchAlgorithmException
IOException
public void build(FileChannel original)
throws NoSuchAlgorithmException,
IOException
RandomAccessFile, otherwise an IOException will be
generated.
original - the FileChannel to which the resulting RPM will be written.
NoSuchAlgorithmException
IOExceptionprotected SignatureGenerator createSignatureGenerator()
protected byte[] getSignature(int count)
protected byte[] getImmutable(int count)
protected byte[] getSpecial(int tag,
int count)
protected int[] convert(Integer[] ints)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||