java.lang.Object
org.xbib.rpm.payload.Contents
The contents of an RPM archive. These entries define the files and links that
the RPM archive contains as well as headers those files require.
Note that the RPM format requires that files in the archive be naturally ordered.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDirectory(String path, int permissions, EnumSet<Directive> directive, String uname, String gname, int uid, int gid, boolean addParents) Adds a directory entry to the archive with the specified permissions.voidaddFile(String path, Path source, int permissions, int dirmode, EnumSet<Directive> directives, String uname, String gname, int uid, int gid, boolean addParents, int verifyFlags) Adds a file entry to the archive with the specified permissions.voidaddLink(String path, String target, int permissions, String uname, String gname, int uid, int gid, boolean addParents) Adds a link to the archive with the specified permissions.voidaddLocalBuiltinDirectory(String directory) Add additional directory that is assumed to already exist on system where the RPM will be installed (e.g.voidaddURL(String path, URL source, int permissions, EnumSet<Directive> directive, String uname, String gname, int uid, int gid, int dirmode) Adds a URL entry to the archive with the specified permissions.Gets the basenames header values.Gets the classes header values.Gets the contexts header values.Gets the devices header values.getDigests(HashAlgo hashAlgo) Caclulates a digest hash for each file in the archive.Gets the dirindexes headers values.Gets the dirnames headers values.getFlags()Gets the flags header values.Gets the groups.Gets the inodes header values.getLangs()Gets the langs header values.Get the linktos header.getModes()Gets the modes header values.Gets the mtimes header values.getRdevs()Gets the rdevs header values.getSizes()Gets the sizes header values.getSource(CpioHeader header) Retrieves the content for this archive entry, which may be aPathif the entry is a regular file or aCharSequencecontaining the name of the target path if the entry is a link.intAccumulated size of all files included in the archive.getUsers()Gets the users.Gets the verifyflags header values.headers()Retrieve the archive headers.protected voidlistParents(List<String> parents, Path path) Generates a list of parent paths given a starting path.intsize()Retrieve the size of this archive in number of files.
-
Constructor Details
-
Contents
public Contents()
-
-
Method Details
-
addLink
public void addLink(String path, String target, int permissions, String uname, String gname, int uid, int gid, boolean addParents) Adds a link to the archive with the specified permissions.- Parameters:
path- the destination path for the installed file.target- the target stringpermissions- the permissions flags.uname- user owner for the given linkgname- group owner for the given linkuid- the user id or -1 for the default valuegid- the group id or -1 for the default valueaddParents- whether to add parent directories
-
addDirectory
public void addDirectory(String path, int permissions, EnumSet<Directive> directive, String uname, String gname, int uid, int gid, boolean addParents) Adds a directory entry to the archive with the specified permissions.- Parameters:
path- the destination path for the installed file.permissions- the permissions flags.directive- directive indicating special handling for this directory.uname- user owner of the directorygname- group owner of the directoryuid- user owner for the given filegid- group owner for the given fileaddParents- whether to add parent directories
-
addFile
public void addFile(String path, Path source, int permissions, int dirmode, EnumSet<Directive> directives, String uname, String gname, int uid, int gid, boolean addParents, int verifyFlags) throws IOException Adds a file entry to the archive with the specified permissions.- Parameters:
path- the destination path for the installed file.source- the local file to be included in the package.permissions- the permissions flags, use -1 to leave as default.directives- directives indicating special handling for this file, use null to ignore.uname- user owner of the filegname- group owner of the fileuid- user owner for the given file, use null for default user.gid- group owner for the given file, use null for default group.dirmode- permission flags for parent directories, use -1 to leave as default.addParents- whether to create parent directories for the file, defaults to true for other methods.verifyFlags- verify flags- Throws:
FileNotFoundException- file wasn't foundIOException
-
addURL
public void addURL(String path, URL source, int permissions, EnumSet<Directive> directive, String uname, String gname, int uid, int gid, int dirmode) Adds a URL entry to the archive with the specified permissions.- Parameters:
path- the destination path for the installed file.source- the URL with the data to be addedpermissions- the permissions flags.directive- directive indicating special handling for this file.uname- user owner of the URLgname- group owner of the URLuid- user owner for the given filegid- group owner for the given filedirmode- permission flags for parent directories, use -1 to leave as default.
-
addLocalBuiltinDirectory
Add additional directory that is assumed to already exist on system where the RPM will be installed (e.g. /etc) and should not have an entry in the RPM. The builtin will only be added to this instance of Contents.- Parameters:
directory- the directory to add
-
size
public int size()Retrieve the size of this archive in number of files. This count includes both directory entries and soft links.- Returns:
- the number of files in this archive
-
headers
Retrieve the archive headers. The returnedIterablewill iterate in the correct order for the archive.- Returns:
- the headers
-
getSource
Retrieves the content for this archive entry, which may be aPathif the entry is a regular file or aCharSequencecontaining the name of the target path if the entry is a link. This is the value to be written to the archive as the body of the entry.- Parameters:
header- the header to get the content from- Returns:
- the content
-
getTotalSize
public int getTotalSize()Accumulated size of all files included in the archive.- Returns:
- the size of all files included in the archive
-
getDirNames
Gets the dirnames headers values.- Returns:
- the dirnames headers values
-
getDirIndexes
Gets the dirindexes headers values.- Returns:
- the dirindexes
-
getBaseNames
Gets the basenames header values.- Returns:
- the basename header values
-
getSizes
Gets the sizes header values.- Returns:
- the sizes header values
-
getModes
Gets the modes header values.- Returns:
- the modes header values
-
getRdevs
Gets the rdevs header values.- Returns:
- the rdevs header values
-
getMtimes
Gets the mtimes header values.- Returns:
- the mtimes header values
-
getDigests
Caclulates a digest hash for each file in the archive.- Parameters:
hashAlgo- the hash algo- Returns:
- the digest hashes
- Throws:
NoSuchAlgorithmException- if the algorithm isn't supportedIOException- there was an IO error
-
getLinkTos
Get the linktos header.- Returns:
- the linktos header
-
getFlags
Gets the flags header values.- Returns:
- the flags header values
-
getUsers
Gets the users.- Returns:
- the users
-
getGroups
Gets the groups.- Returns:
- the groups
-
getVerifyFlags
Gets the verifyflags header values.- Returns:
- the verifyflags header values
-
getClasses
Gets the classes header values.- Returns:
- the classes header values
-
getDevices
Gets the devices header values.- Returns:
- the devices header values
-
getInodes
Gets the inodes header values.- Returns:
- the iNodes header values
-
getLangs
Gets the langs header values.- Returns:
- the langs header values
-
getContexts
Gets the contexts header values.- Returns:
- the contexts header values
-
listParents
Generates a list of parent paths given a starting path.- Parameters:
parents- the list to add the parents topath- the file to search for parents of
-