Module org.xbib.rpm

Class Contents

java.lang.Object
org.xbib.rpm.payload.Contents

public class Contents extends Object
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 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 string
      permissions - the permissions flags.
      uname - user owner for the given link
      gname - group owner for the given link
      uid - the user id or -1 for the default value
      gid - the group id or -1 for the default value
      addParents - 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 directory
      gname - group owner of the directory
      uid - user owner for the given file
      gid - group owner for the given file
      addParents - 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 file
      gname - group owner of the file
      uid - 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 found
      IOException
    • 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 added
      permissions - the permissions flags.
      directive - directive indicating special handling for this file.
      uname - user owner of the URL
      gname - group owner of the URL
      uid - user owner for the given file
      gid - group owner for the given file
      dirmode - permission flags for parent directories, use -1 to leave as default.
    • addLocalBuiltinDirectory

      public void addLocalBuiltinDirectory(String directory)
      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

      public Iterable<CpioHeader> headers()
      Retrieve the archive headers. The returned Iterable will iterate in the correct order for the archive.
      Returns:
      the headers
    • getSource

      public Object getSource(CpioHeader header)
      Retrieves the content for this archive entry, which may be a Path if the entry is a regular file or a CharSequence containing 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

      public StringList getDirNames()
      Gets the dirnames headers values.
      Returns:
      the dirnames headers values
    • getDirIndexes

      public IntegerList getDirIndexes()
      Gets the dirindexes headers values.
      Returns:
      the dirindexes
    • getBaseNames

      public StringList getBaseNames()
      Gets the basenames header values.
      Returns:
      the basename header values
    • getSizes

      public IntegerList getSizes()
      Gets the sizes header values.
      Returns:
      the sizes header values
    • getModes

      public ShortList getModes()
      Gets the modes header values.
      Returns:
      the modes header values
    • getRdevs

      public ShortList getRdevs()
      Gets the rdevs header values.
      Returns:
      the rdevs header values
    • getMtimes

      public IntegerList getMtimes()
      Gets the mtimes header values.
      Returns:
      the mtimes header values
    • getDigests

      public StringList getDigests(HashAlgo hashAlgo) throws IOException, NoSuchAlgorithmException
      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 supported
      IOException - there was an IO error
    • getLinkTos

      public StringList getLinkTos()
      Get the linktos header.
      Returns:
      the linktos header
    • getFlags

      public IntegerList getFlags()
      Gets the flags header values.
      Returns:
      the flags header values
    • getUsers

      public StringList getUsers()
      Gets the users.
      Returns:
      the users
    • getGroups

      public StringList getGroups()
      Gets the groups.
      Returns:
      the groups
    • getVerifyFlags

      public IntegerList getVerifyFlags()
      Gets the verifyflags header values.
      Returns:
      the verifyflags header values
    • getClasses

      public IntegerList getClasses()
      Gets the classes header values.
      Returns:
      the classes header values
    • getDevices

      public IntegerList getDevices()
      Gets the devices header values.
      Returns:
      the devices header values
    • getInodes

      public IntegerList getInodes()
      Gets the inodes header values.
      Returns:
      the iNodes header values
    • getLangs

      public StringList getLangs()
      Gets the langs header values.
      Returns:
      the langs header values
    • getContexts

      public StringList getContexts()
      Gets the contexts header values.
      Returns:
      the contexts header values
    • listParents

      protected void listParents(List<String> parents, Path path)
      Generates a list of parent paths given a starting path.
      Parameters:
      parents - the list to add the parents to
      path - the file to search for parents of