summaryrefslogtreecommitdiff
path: root/lib/dslkeywords
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-02-18 13:27:37 +0200
committerPaul Buetow <paul@buetow.org>2025-02-18 13:27:37 +0200
commitcd1bdda5f963236dac849eb9257812f81c8af8ba (patch)
tree8c79c53e7be0a42f594a53b0e214c3d9023211d7 /lib/dslkeywords
parent967fec48f96e35ec0ea204e68c8aca35a386cbf7 (diff)
test for dup resource
Diffstat (limited to 'lib/dslkeywords')
-rw-r--r--lib/dslkeywords/package.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/dslkeywords/package.rb b/lib/dslkeywords/package.rb
index b28ed50..86903cf 100644
--- a/lib/dslkeywords/package.rb
+++ b/lib/dslkeywords/package.rb
@@ -4,12 +4,25 @@ require 'fileutils'
require_relative 'resource'
module RCM
+ class DNFPackageManager
+ def installed?(pkg) = false
+ def install(pkg) = `dnf install -y "#{pkg}"` unless installed?(pkg)
+ def update(pkg) = `dnf update -y "#{pkg}"`
+ def remove(pkg) = `dnf remove -y "#{pkg}"` if installed?(pkg)
+ end
+
# Managing packages
class Package < Resource
attr_reader :path
+ class UnsupportedOS < StandardError; end
+
def initialize(name)
super(name)
+ raise UnsupportedOS, 'OS is not supported' unless File.file?('/etc/fedora-release')
+
+ @manager = DNFPackageManager.new
+
@name = name
end