This commit is contained in:
Artur Gurgul 2025-08-01 12:52:57 +02:00
commit b3dba4542f
44 changed files with 1596 additions and 0 deletions

45
lib/system/debian.rb Normal file
View file

@ -0,0 +1,45 @@
module DebianSystem
def os_name
"Debian Linux"
end
def install(packages)
missing_packages = packages.reject { |pkg| package_installed?(pkg) }
if missing_packages.empty?
puts "All packages are already installed."
return
end
pkg_list = missing_packages.join(' ')
puts "Installing missing packages: #{pkg_list}"
success = system("sudo apt-get update && sudo apt-get install -y #{pkg_list}")
unless success
puts "Failed to install some packages."
end
end
def package_installed?(package)
system("dpkg -s #{package} > /dev/null 2>&1")
end
def uninstall(packages)
installed_packages = packages.select { |pkg| package_installed?(pkg) }
if installed_packages.empty?
puts "None of the specified packages are installed."
return
end
pkg_list = installed_packages.join(' ')
puts "Uninstalling packages: #{pkg_list}"
success = system("sudo apt-get remove -y #{pkg_list}")
unless success
puts "Failed to uninstall some packages."
end
end
end