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.



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

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.



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

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.



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

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



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

def link_to
  @link_to
end

#md5sumString

Returns md5sum as string.

Returns:

  • (String)

    md5sum as string



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

def md5sum
  @md5sum
end

#modeNumber

Returns Device type of the file.

Returns:

  • (Number)

    Device type of the file



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

def mode
  @mode
end

#mtimeTime

Returns File modification time.

Returns:

  • (Time)

    File modification time.



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

def mtime
  @mtime
end

#ownerString

Returns File owner. Nil may be returned.

Returns:

  • (String)

    File owner. Nil may be returned.



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

def owner
  @owner
end

#pathString

Returns file path.

Returns:

  • (String)

    file path



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

def path
  @path
end

#rdevObject

Returns the value of attribute rdev.



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

def rdev
  @rdev
end

#sizeNumber

Returns File size.

Returns:

  • (Number)

    File size



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

def size
  @size
end

#stateObject

Returns the value of attribute state.



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

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



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

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



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

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)


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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

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



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

def symlink?
  !@link_to.nil?
end