public class Builder extends Object
| Modifier and Type | Field and Description |
|---|---|
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 |
| Constructor and Description |
|---|
Builder()
Initializes the builder and sets some required fields to known values.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addDependency(CharSequence name,
CharSequence version,
int flag)
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,
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 |
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,
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 |
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 |
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.
|
protected final Format format
protected final Set<PrivateKey> signatures
protected final Map<String,CharSequence> dependencies
protected final AbstractHeader.Entry<byte[]> signature
protected final AbstractHeader.Entry<byte[]> immutable
protected Contents contents
public Builder()
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 withpublic 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.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(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)
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 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 addFile(String path, File source, int mode) throws NoSuchAlgorithmException, 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 notationNoSuchAlgorithmExceptionIOExceptionpublic void addFile(String path, File source, int mode, int dirmode) throws NoSuchAlgorithmException, 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 notationNoSuchAlgorithmExceptionIOExceptionpublic void addFile(String path, File source, int mode, int dirmode, String uname, String gname) throws NoSuchAlgorithmException, 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 notationuname - user owner for the given filegname - group owner for the given fileNoSuchAlgorithmExceptionIOExceptionpublic void addFile(String path, File source, int mode, int dirmode, Directive directive, String uname, String gname) throws NoSuchAlgorithmException, 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 notationuname - user owner for the given filegname - group owner for the given fileNoSuchAlgorithmExceptionIOExceptionpublic 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 fileNoSuchAlgorithmExceptionIOExceptionpublic 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.NoSuchAlgorithmExceptionIOExceptionpublic void addFile(String path, File source) throws NoSuchAlgorithmException, IOException
644.path - the absolute path at which this file will be installed.file - the file content to include in this rpm.NoSuchAlgorithmExceptionIOExceptionpublic void addURL(String path, URL source, int mode, int dirmode) throws NoSuchAlgorithmException, 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 notationNoSuchAlgorithmExceptionIOExceptionpublic void addURL(String path, URL source, int mode, int dirmode, String username, String group) throws NoSuchAlgorithmException, 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 notationusername - ownership of added filegroup - ownership of added fileNoSuchAlgorithmExceptionIOExceptionpublic void addURL(String path, URL source, int mode, int dirmode, Directive directive, String username, String group) throws NoSuchAlgorithmException, 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 notationusername - ownership of added filegroup - ownership of added fileNoSuchAlgorithmExceptionIOExceptionpublic void addDirectory(String path) throws NoSuchAlgorithmException, IOException
644.path - the absolute path at which this file will be installed.file - the file content to include in this rpm.NoSuchAlgorithmExceptionIOExceptionpublic 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 directoryNoSuchAlgorithmExceptionIOExceptionpublic 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 rpmNoSuchAlgorithmExceptionIOExceptionpublic 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.NoSuchAlgorithmExceptionIOExceptionpublic 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.NoSuchAlgorithmExceptionIOExceptionpublic 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.NoSuchAlgorithmExceptionIOExceptionpublic void addSignature(PrivateKey key)
key - private key to use in generating a signature.public String build(File directory) throws NoSuchAlgorithmException, IOException
directory - the destination directory for the new RPM file.NoSuchAlgorithmExceptionIOExceptionpublic 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.NoSuchAlgorithmExceptionIOExceptionprotected byte[] getSignature(int count)
protected byte[] getImmutable(int count)
protected byte[] getSpecial(int tag,
int count)
protected int[] convert(Integer[] ints)
Copyright © 2023. All rights reserved.