java.lang.Object
org.xbib.rpm.RpmBuilder
-
Constructor Summary
ConstructorsConstructorDescriptionRpmBuilder(HashAlgo privateKeyHashAlgo, CompressionType compressionType) Initializes the builder and sets some required fields to known values. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBuiltinDirectory(String builtinDirectory) voidaddChangelog(InputStream changelogInputStream) Adds the supplied Changelog file as a Changelog to the header.voidaddChangelog(String changelogContents) Adds the supplied Changelog path as a Changelog to the header.voidaddChangelog(Path changelogFile) Adds the supplied Changelog path as a Changelog to the header.voidaddConflicts(String name, int comparison, String version) voidaddConflicts(String name, String version, int flag) voidaddConflictsLess(String name, String version) voidaddConflictsMore(String name, String version) voidaddDependency(String name, int flags, String version) Adds a dependency to the RPM package.voidaddDependencyLess(String name, String version) Adds a dependency to the RPM package.voidaddDependencyMore(String name, String version) Adds a dependency to the RPM package.voidaddDirectory(String path, int permissions, EnumSet<Directive> directives, String uname, String gname, boolean addParents) Adds the directory to the repository.voidaddFile(String path, Path source, int mode, int dirmode, EnumSet<Directive> directive, String uname, String gname, boolean addParents) Add the specified file to the repository payload in order.voidaddFile(String path, Path source, int mode, int dirmode, EnumSet<Directive> directive, String uname, String gname, boolean addParents, int verifyFlags) Add the specified file to the repository payload in order.voidaddHeaderEntry(EntryType entryType, byte value) Adds a header entry byte (8-bit) value to the header.voidaddHeaderEntry(EntryType entryType, byte[] value) Adds a header entry byte array (8-bit) value to the header.voidaddHeaderEntry(EntryType entryType, char value) Adds a header entry char (8-bit) value to the header.voidaddHeaderEntry(EntryType entryType, long value) Adds a header entry long (64-bit) value to the header.voidaddHeaderEntry(EntryType entryType, short value) Adds a header entry short (16-bit) value to the header.voidaddHeaderEntry(EntryType entryType, Integer value) Adds a header entry int (32-bit) value to the header.voidaddHeaderEntry(EntryType entryType, String value) Adds a header entry value to the header.voidaddHeaderEntry(EntryType entryType, IntegerList value) Adds a header entry int (32-bit) array value to the header.voidaddHeaderEntry(EntryType entryType, LongList value) Adds a header entry long (64-bit) array value to the header.voidaddHeaderEntry(EntryType entryType, ShortList value) Adds a header entry short array (16-bit) value to the header.voidAdds a symbolic link to the repository.voidAdds a symbolic link to the repository.voidaddObsoletes(String name, int comparison, String version) voidaddObsoletes(String name, String version, int flag) voidaddObsoletesLess(String name, String version) voidaddObsoletesMore(String name, String version) voidaddProvides(String name, int flag, String version) voidaddProvides(String name, String version) voidaddTrigger(Path script, String prog, Map<String, Trigger.IntString> depends, int flag) Adds a trigger to the RPM package.voidaddURL(String path, URL source, int permissions, int dirmode, EnumSet<Directive> directives, String uname, String gname) Adds an URL (from a jar) to the repository.voidbuild(SeekableByteChannel channel) Generates the RPM archive to the provided file channel.voidGenerates an RPM with a standard name consisting of the RPM package name, version, release, and type in the given directory.Get the contents.Get package name.voidsetBuildHost(String host) Sets the build host for the RPM.voidsetDescription(String description) Sets the description text for the file.voidsetDistribution(String distribution) Distribution tag listing the distributable package.voidSets the group of contents to include in this RPM.voidSoftware group to which this package belongs.voidsetLicense(String license) Lists the license under which this software is distributed.voidsetPackage(String name, String version, String release) voidsetPackage(String name, String version, String release, Integer epoch) Required Field.voidsetPackageName(String packageName) Set RPM package name.voidsetPackager(String packager) Build packager, usually the username of the account building this RPM.voidsetPlatform(Architecture arch, String osName) Sets the platform related headers for the resulting RPM.voidsetPlatform(Architecture arch, Os os) Sets the platform related headers for the resulting RPM.voidsetPostInstall(String script) Declares a script to be run as part of the RPM post-installation.voidsetPostInstall(Path path) Declares a script file to be run as part of the RPM post-installation.voidsetPostInstallProgram(String program) Declares the interpreter to be used when invoking the RPM post-installation script that can be set with thesetPostInstall(String)method.voidsetPostTrans(String content) Declares a script to be run as part of the RPM post-transaction.voidsetPostTrans(Path path) Declares a script file to be run as part of the RPM post-transaction.voidsetPostTransProgram(String program) Declares the interpreter to be used when invoking the RPM post-transaction script that can be set with thesetPostTrans(String)method.voidsetPostUninstall(String content) Declares a script to be run as part of the RPM post-uninstallation.voidsetPostUninstall(Path path) Declares a script file to be run as part of the RPM post-uninstallation.voidsetPostUninstallProgram(String program) Declares the interpreter to be used when invoking the RPM post-uninstallation script that can be set with thesetPostUninstall(String)method.voidsetPrefixes(List<String> prefixes) Sets the package prefix directories to allow any files installed under them to be relocatable.voidsetPreInstall(String content) Declares a script to be run as part of the RPM pre-installation.voidsetPreInstall(Path path) Declares a script file to be run as part of the RPM pre-installation.voidsetPreInstallProgram(String program) Declares the interpreter to be used when invoking the RPM pre-installation script that can be set with thesetPreInstall(String)method.voidsetPreTrans(String content) Declares a script to be run as part of the RPM pre-transaction.voidsetPreTrans(Path path) Declares a script file to be run as part of the RPM pre-transaction.voidsetPreTransProgram(String program) Declares the interpreter to be used when invoking the RPM pre-transaction script that can be set with thesetPreTrans(String)method.voidsetPreUninstall(String script) Declares a script to be run as part of the RPM pre-uninstallation.voidsetPreUninstall(Path path) Declares a script file to be run as part of the RPM pre-uninstallation.voidsetPreUninstallProgram(String program) Declares the interpreter to be used when invoking the RPM pre-uninstallation script that can be set with thesetPreUninstall(String)method.voidsetPrivateKeyHashAlgo(String privateKeyHashAlgo) Hash algo for the private key.voidsetPrivateKeyId(Long privateKeyId) Selects a private key from the currentprivate key ring.voidsetPrivateKeyId(String privateKeyId) Selects a private key from the currentprivate key ring.voidsetPrivateKeyPassphrase(String privateKeyPassphrase) Passphrase for the private key.voidsetPrivateKeyRing(InputStream privateKeyRing) Sets the PGP key ring used for header and header + payload signature.voidsetPrivateKeyRing(String privateKeyRing) Sets the PGP key ring used for header and header + payload signature.voidsetPrivateKeyRing(Path privateKeyRing) Sets the PGP key ring used for header and header + payload signature.voidsetProvides(String provides) Declares a dependency that this package exports, and that other packages can use to provide library functions.voidsetSourceRpm(String sourceRpm) Adds a source rpm.voidsetSummary(String summary) Sets the summary text for the file.voidsetType(PackageType type) Required Field.voidWebsite URL for this package, usually a project site.voidVendor tag listing the organization providing this software package.
-
Constructor Details
-
RpmBuilder
public RpmBuilder() -
RpmBuilder
Initializes the builder and sets some required fields to known values.- Parameters:
privateKeyHashAlgo- the hash algocompressionType- compression type
-
-
Method Details
-
addBuiltinDirectory
-
addObsoletes
-
addObsoletesLess
-
addObsoletesMore
-
addObsoletes
-
addConflicts
-
addConflictsLess
-
addConflictsMore
-
addConflicts
-
addProvides
-
addProvides
-
addDependency
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 dependencyflags- the comparison flagversion- the version identifier
-
addDependencyLess
Adds a dependency to the RPM package. This dependency 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 dependencyversion- the version identifier
-
addDependencyMore
Adds a dependency to the RPM package. This dependency 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.
-
addHeaderEntry
Adds a header entry value to the header. For example use this to set the source RPM package name on your RPM- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with
-
addHeaderEntry
Adds a header entry byte (8-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not byte[]
-
addHeaderEntry
Adds a header entry char (8-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not byte[]
-
addHeaderEntry
Adds a header entry short (16-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not short[]
-
addHeaderEntry
Adds a header entry int (32-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- if the type required by tag.type() is not IntegerList
-
addHeaderEntry
Adds a header entry long (64-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not LongList
-
addHeaderEntry
Adds a header entry byte array (8-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not byte[]
-
addHeaderEntry
Adds a header entry short array (16-bit) value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not ShortList
-
addHeaderEntry
Adds a header entry int (32-bit) array value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not IntegerList
-
addHeaderEntry
Adds a header entry long (64-bit) array value to the header.- Parameters:
entryType- the header tag to setvalue- the value to set the header entry with- Throws:
ClassCastException- - if the type required by tag.type() is not LongList
-
setPackage
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.epoch- the epoch number of the new RPM- Throws:
IllegalArgumentException- if version or release contain dashes, as they are explicitly disallowed by RPM file format.
-
setPackage
-
setType
Required Field. Sets the type of the RPM to be either binary or source.- Parameters:
type- the type of RPM to generate.
-
setPlatform
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
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
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
Sets the description text for the file. The description is often a paragraph describing the package in detail.- Parameters:
description- description text.
-
setBuildHost
Sets the build host for the RPM. This is an internal field.- Parameters:
host- hostname of the build machine.
-
setLicense
Lists the license under which this software is distributed. This field may be displayed by RPM tools.- Parameters:
license- the chosen distribution license.
-
setGroup
Software group to which this package belongs. The group describes what sort of function the software package provides.- Parameters:
group- target group.
-
setDistribution
Distribution tag listing the distributable package.- Parameters:
distribution- the distribution.
-
setVendor
Vendor tag listing the organization providing this software package.- Parameters:
vendor- software vendor.
-
setPackager
Build packager, usually the username of the account building this RPM.- Parameters:
packager- packager name.
-
setUrl
Website URL for this package, usually a project site.- Parameters:
url- the URL
-
setProvides
Declares a dependency that this package exports, and that other packages can use to provide library functions. Note that this method causes the existing provides set to be overwritten and therefore should be called before adding any other contents via theaddProvides()methods. You should useaddProvides()instead.- Parameters:
provides- dependency provided by this package.
-
setFiles
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 theaddFile()methods.- Parameters:
contents- the set of contents to use in constructing this RPM.
-
getContents
Get the contents.- Returns:
- the contents
-
setSourceRpm
Adds a source rpm.- Parameters:
sourceRpm- name of rpm source file
-
setPrefixes
Sets the package prefix directories to allow any files installed under them to be relocatable.- Parameters:
prefixes- Path prefixes which may be relocated
-
setPreTrans
Declares a script file to be run as part of the RPM pre-transaction. The script will be run using the interpreter declared with thesetPreTransProgram(String)method.- Parameters:
path- Script to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPreTrans
Declares a script to be run as part of the RPM pre-transaction. The script will be run using the interpreter declared with thesetPreTransProgram(String)method.- Parameters:
content- Script contents to run (i.e. shell commands)
-
setPreTransProgram
Declares the interpreter to be used when invoking the RPM pre-transaction script that can be set with thesetPreTrans(String)method.- Parameters:
program- Path to the interpreter
-
setPreInstall
Declares a script file to be run as part of the RPM pre-installation. The script will be run using the interpreter declared with thesetPreInstallProgram(String)method.- Parameters:
path- Script to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPreInstall
Declares a script to be run as part of the RPM pre-installation. The script will be run using the interpreter declared with thesetPreInstallProgram(String)method.- Parameters:
content- Script contents to run (i.e. shell commands)
-
setPreInstallProgram
Declares the interpreter to be used when invoking the RPM pre-installation script that can be set with thesetPreInstall(String)method.- Parameters:
program- Path to the interpretter
-
setPostInstall
Declares a script file to be run as part of the RPM post-installation. The script will be run using the interpreter declared with thesetPostInstallProgram(String)method.- Parameters:
path- Script to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPostInstall
Declares a script to be run as part of the RPM post-installation. The script will be run using the interpreter declared with thesetPostInstallProgram(String)method.- Parameters:
script- Script contents to run (i.e. shell commands)
-
setPostInstallProgram
Declares the interpreter to be used when invoking the RPM post-installation script that can be set with thesetPostInstall(String)method.- Parameters:
program- Path to the interpreter
-
setPreUninstall
Declares a script file to be run as part of the RPM pre-uninstallation. The script will be run using the interpreter declared with thesetPreUninstallProgram(String)method.- Parameters:
path- Script to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPreUninstall
Declares a script to be run as part of the RPM pre-uninstallation. The script will be run using the interpreter declared with thesetPreUninstallProgram(String)method.- Parameters:
script- Script contents to run (i.e. shell commands)
-
setPreUninstallProgram
Declares the interpreter to be used when invoking the RPM pre-uninstallation script that can be set with thesetPreUninstall(String)method.- Parameters:
program- Path to the interpreter
-
setPostUninstall
Declares a script file to be run as part of the RPM post-uninstallation. The script will be run using the interpreter declared with thesetPostUninstallProgram(String)method.- Parameters:
path- Script contents to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPostUninstall
Declares a script to be run as part of the RPM post-uninstallation. The script will be run using the interpreter declared with thesetPostUninstallProgram(String)method.- Parameters:
content- Script contents to run (i.e. shell commands)
-
setPostUninstallProgram
Declares the interpreter to be used when invoking the RPM post-uninstallation script that can be set with thesetPostUninstall(String)method.- Parameters:
program- Path to the interpreter
-
setPostTrans
Declares a script file to be run as part of the RPM post-transaction. The script will be run using the interpreter declared with thesetPostTransProgram(String)method.- Parameters:
path- Script contents to run (i.e. shell commands)- Throws:
IOException- there was an IO error
-
setPostTrans
Declares a script to be run as part of the RPM post-transaction. The script will be run using the interpreter declared with thesetPostTransProgram(String)method.- Parameters:
content- Script contents to run (i.e. shell commands)
-
setPostTransProgram
Declares the interpreter to be used when invoking the RPM post-transaction script that can be set with thesetPostTrans(String)method.- Parameters:
program- Path to the interpreter
-
addTrigger
public void addTrigger(Path script, String prog, Map<String, Trigger.IntString> depends, int flag) throws IOExceptionAdds 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 scriptflag- the trigger type (SCRIPT_TRIGGERPREIN, SCRIPT_TRIGGERIN, SCRIPT_TRIGGERUN, or SCRIPT_TRIGGERPOSTUN)- Throws:
IOException- there was an IO error
-
addFile
public void addFile(String path, Path source, int mode, int dirmode, EnumSet<Directive> directive, String uname, String gname, boolean addParents) throws 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 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.directive- directive indicating special handling for this file.uname- user owner of the filegname- group owner of the fileaddParents- whether to create parent directories for the file, defaults to true for other methods.- Throws:
IOException- there was an IO error
-
addFile
public void addFile(String path, Path source, int mode, int dirmode, EnumSet<Directive> directive, String uname, String gname, boolean addParents, int verifyFlags) throws 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 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.directive- directive indicating special handling for this file.uname- user owner of the directorygname- group owner of the directoryaddParents- whether to create parent directories for the file, defaults to true for other methods.verifyFlags- verify flags- Throws:
IOException- there was an IO error
-
addDirectory
public void addDirectory(String path, int permissions, EnumSet<Directive> directives, String uname, String gname, boolean addParents) 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.directives- directives 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
-
addURL
public void addURL(String path, URL source, int permissions, int dirmode, EnumSet<Directive> directives, String uname, String gname) Adds an URL (from a jar) to the repository.- Parameters:
path- the absolute pathsource- the URL sourcepermissions- the file modedirmode- the directory modedirectives- directives indicating special handling for this fileuname- user owner of the entrygname- group owner of the entry
-
addLink
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.permissions- the permissions flags
-
addLink
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.permissions- the permissions flagsusername- user owner of the linkgroupname- group owner of the link
-
addChangelog
Adds the supplied Changelog path as a Changelog to the header.- Parameters:
changelogContents- File containing the Changelog information- Throws:
IOException- if file does not exist or cannot be readChangelogParseException- if file is not of the correct format.
-
addChangelog
Adds the supplied Changelog path as a Changelog to the header.- Parameters:
changelogFile- File containing the Changelog information- Throws:
IOException- if file does not exist or cannot be readChangelogParseException- if file is not of the correct format.
-
addChangelog
public void addChangelog(InputStream changelogInputStream) throws IOException, ChangelogParseException Adds the supplied Changelog file as a Changelog to the header.- Parameters:
changelogInputStream- input stream containing the Changelog information- Throws:
IOException- if file does not exist or cannot be readChangelogParseException- if file is not of the correct format.
-
setPrivateKeyRing
Sets the PGP key ring used for header and header + payload signature.- Parameters:
privateKeyRing- the private key ring input stream- Throws:
IOException- if file does not exist or cannot be read
-
setPrivateKeyRing
Sets the PGP key ring used for header and header + payload signature.- Parameters:
privateKeyRing- the private key ring input stream- Throws:
IOException- if file does not exist or cannot be read
-
setPrivateKeyRing
Sets the PGP key ring used for header and header + payload signature.- Parameters:
privateKeyRing- the private key ring input stream
-
setPrivateKeyId
Selects a private key from the currentprivate key ring. If no key is specified, the first signing key will be selected.- Parameters:
privateKeyId- long value from hex key id
-
setPrivateKeyId
Selects a private key from the currentprivate key ring. If no key is specified, the first signing key will be selected.- Parameters:
privateKeyId- long value from hex key id
-
setPrivateKeyPassphrase
Passphrase for the private key.- Parameters:
privateKeyPassphrase- the private key pass phrase
-
setPrivateKeyHashAlgo
Hash algo for the private key.- Parameters:
privateKeyHashAlgo- the private key hash algo
-
setPackageName
Set RPM package name.- Parameters:
packageName- the RPM package name
-
getPackageName
Get package name.- Returns:
- the RPM package name or null
-
build
Generates an RPM with a standard name consisting of the RPM package name, version, release, and type in the given directory.- Parameters:
directory- the destination path for the new RPM file.- Throws:
IOException- there was an IO errorRpmException- if RPM could not be generatedNoSuchAlgorithmException
-
build
public void build(SeekableByteChannel channel) throws RpmException, IOException, NoSuchAlgorithmException Generates the RPM archive to the provided file channel.- Parameters:
channel- theSeekableByteChannelto which the resulting RPM archive will be written.- Throws:
IOException- there was an IO errorRpmException- if RPM generation failsNoSuchAlgorithmException
-