Class: RPM::File

Inherits:
Object
  • Object
show all
Defined in:
lib/rpm/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, md5sum, link_to, size, mtime, owner, group, rdev, mode, attr, state) ⇒ File

Returns a new instance of File.



120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/rpm/file.rb', line 120

def initialize(path, md5sum, link_to, size, mtime, owner, group, rdev, mode, attr, state)
  @path = path
  @md5sum = md5sum
  # If link_to is "" save it as nil
  @link_to = ((link_to && link_to.empty?) ? nil : link_to)
  @size = size
  @mtime = mtime
  @owner = owner
  @group = group
  @rdev = rdev
  @mode = mode
  @attr = attr
  @state = state
end

Instance Attribute Details

#attrObject

Returns the value of attribute attr.



26
27
28
# File 'lib/rpm/file.rb', line 26

def attr
  @attr
end

#groupString

Returns Group that owns the file. Nil may be returned.

Returns:

  • (String)

    Group that owns the file. Nil may be returned.



22
23
24
# File 'lib/rpm/file.rb', line 22

def group
  @group
end
Note:

This path is sometimes relative. To convert an absolute path from relative path: File.expand_path (file.link_to, File.dirname (file.path))

Returns Path to the destination if the file is a symbolic link.

Returns:

  • (String)

    Path to the destination if the file is a symbolic link



14
15
16
# File 'lib/rpm/file.rb', line 14

def link_to
  @link_to
end

#md5sumString

Returns md5sum as string.

Returns:

  • (String)

    md5sum as string



9
10
11
# File 'lib/rpm/file.rb', line 9

def md5sum
  @md5sum
end

#modeNumber

Returns Device type of the file.

Returns:

  • (Number)

    Device type of the file



24
25
26
# File 'lib/rpm/file.rb', line 24

def mode
  @mode
end

#mtimeTime

Returns File modification time.

Returns:

  • (Time)

    File modification time.



18
19
20
# File 'lib/rpm/file.rb', line 18

def mtime
  @mtime
end

#ownerString

Returns File owner. Nil may be returned.

Returns:

  • (String)

    File owner. Nil may be returned.



20
21
22
# File 'lib/rpm/file.rb', line 20

def owner
  @owner
end

#pathString

Returns file path.

Returns:

  • (String)

    file path



7
8
9
# File 'lib/rpm/file.rb', line 7

def path
  @path
end

#rdevObject

Returns the value of attribute rdev.



28
29
30
# File 'lib/rpm/file.rb', line 28

def rdev
  @rdev
end

#sizeNumber

Returns File size.

Returns:

  • (Number)

    File size



16
17
18
# File 'lib/rpm/file.rb', line 16

def size
  @size
end

#stateObject

Returns the value of attribute state.



27
28
29
# File 'lib/rpm/file.rb', line 27

def state
  @state
end

Instance Method Details

#config?Boolean

Returns True if the file is marked as a configuration file.

Returns:

  • (Boolean)

    True if the file is marked as a configuration file



36
37
38
# File 'lib/rpm/file.rb', line 36

def config?
  ! (@attr & RPM::C::FileAttrs[:config]).zero?
end

#doc?Boolean

Returns True if the file is marked as documentation.

Returns:

  • (Boolean)

    True if the file is marked as documentation



41
42
43
# File 'lib/rpm/file.rb', line 41

def doc?
  ! (@attr & RPM::C::FileAttrs[:doc]).zero?
end

#donotuse?Boolean

Deprecated.

RPMFILE_DONOTUSE was removed in recent versions of RPM.

Returns True if the file is marked as do not use.

Returns:

  • (Boolean)

    True if the file is marked as do not use

Raises:

  • (NotImplementedError)


47
48
49
50
51
# File 'lib/rpm/file.rb', line 47

def donotuse?
  msg = "RPMFILE_DONOTUSE was removed in recent versions of RPM."
  warn "#{Kernel.caller.first} #{msg}"
  raise NotImplementedError
end

#exclude?Boolean

Deprecated.

RPMFILE_EXCLUDE was removed in recent versions of RPM.

Returns:

  • (Boolean)

Raises:

  • NotImplementedError



99
100
101
102
103
# File 'lib/rpm/file.rb', line 99

def exclude?
  msg = "RPMFILE_EXCLUDE was removed in recent versions of RPM."
  warn "#{Kernel.caller.first} #{msg}"
  raise NotImplementedError
end

#ghost?Boolean

This flag indicates the file should not be included in the package. It can be used to name the needed attributes for a file that the program, when installed,

will create.

For example, you may want to ensure that a program’s log file has certain attributes.

Returns:

  • (Boolean)

    True if the file is marked as ghost



83
84
85
# File 'lib/rpm/file.rb', line 83

def ghost?
  ! (@attr & RPM::C::FileAttrs[:ghost]).zero?
end

#is_missingok?Boolean

This modifier is used for files or links that are created during the %post scripts but will need to be removed if the package is removed

Returns:

  • (Boolean)

    True if the file is marked that can be missing on disk



57
58
59
# File 'lib/rpm/file.rb', line 57

def is_missingok?
  ! (@attr & RPM::C::FileAttrs[:missingok]).zero?
end

#is_noreplace?Boolean

This flag is used to protect local modifications. If used, the file will not overwrite an existing file that has been modified. If the file has not been modified on disk, the rpm command will overwrite the file. But,

if the file has been modified on disk, the rpm command will copy the new file with an extra
file-name extension of .rpmnew.

Returns:

  • (Boolean)

    True if the file is marked as configuration not to be replaced



68
69
70
# File 'lib/rpm/file.rb', line 68

def is_noreplace?
  ! (@attr & RPM::C::FileAttrs[:noreplace]).zero?
end

#is_specfile?Boolean

Returns True if the file is marked as a spec file.

Returns:

  • (Boolean)

    True if the file is marked as a spec file



73
74
75
# File 'lib/rpm/file.rb', line 73

def is_specfile?
  ! (@attr & RPM::C::FileAttrs[:specfile]).zero?
end

#license?Boolean

Returns True if the file is a license.

Returns:

  • (Boolean)

    True if the file is a license



88
89
90
# File 'lib/rpm/file.rb', line 88

def license?
  ! (@attr & RPM::C::FileAttrs[:license]).zero?
end

#netshared?Boolean

Returns True if the file is shared over the network.

Returns:

  • (Boolean)

    True if the file is shared over the network



116
117
118
# File 'lib/rpm/file.rb', line 116

def netshared?
  ! (@attr & RPM::C::FileState[:netshared]).zero?
end

#notinstalled?Boolean

Returns True if the file is not installed.

Returns:

  • (Boolean)

    True if the file is not installed



111
112
113
# File 'lib/rpm/file.rb', line 111

def notinstalled?
  ! (@attr & RPM::C::FileState[:notinstalled]).zero?
end

#readme?Boolean

Returns True if the file is a README.

Returns:

  • (Boolean)

    True if the file is a README



93
94
95
# File 'lib/rpm/file.rb', line 93

def readme?
  ! (@attr & RPM::C::FileAttrs[:readme]).zero?
end

#replaced?Boolean

Returns True if the file is replaced during installation.

Returns:

  • (Boolean)

    True if the file is replaced during installation



106
107
108
# File 'lib/rpm/file.rb', line 106

def replaced?
  ! (@attr & RPM::C::FileState[:replaced]).zero?
end

#symlink?Boolean

Returns True if the file is a symbolic link.

Returns:

  • (Boolean)

    True if the file is a symbolic link



31
32
33
# File 'lib/rpm/file.rb', line 31

def symlink?
  ! @link_to.nil?
end