Skip to content

Commit

Permalink
Merge pull request #2483 from bastelfreak/FACT-3114
Browse files Browse the repository at this point in the history
(FACT-3114) Arch Linux: Implement os version facts
  • Loading branch information
joshcooper authored Jun 20, 2024
2 parents ccd3d6d + d1ad005 commit 3ccc831
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/facter/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module Config
Sled
]
},
'Archlinux',
'Gentoo',
'Alpine',
'Photon',
Expand Down
21 changes: 21 additions & 0 deletions lib/facter/facts/archlinux/os/release.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# frozen_string_literal: true

module Facts
module Archlinux
module Os
class Release
FACT_NAME = 'os.release'

def call_the_resolver
# Arch Linux is rolling release and has no version numbers
# For historical reasons facter used the kernel version as OS version on Arch Linux
kernelrelease = Facter::Resolvers::Uname.resolve(:kernelrelease)
versions = kernelrelease.split('.')
hash = { full: kernelrelease, major: versions[0], minor: versions[1] }

Facter::ResolvedFact.new(FACT_NAME, hash)
end
end
end
end
end
3 changes: 3 additions & 0 deletions lib/facter/framework/core/file_loader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@

require_relative '../../resolvers/amzn/os_release_rpm'

when 'archlinux'
require_relative '../../facts/archlinux/os/release'

when 'bsd'
require_relative '../../facts/bsd/kernelmajversion'
require_relative '../../facts/bsd/kernelversion'
Expand Down
1 change: 1 addition & 0 deletions lib/facter/framework/detector/os_detector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def detect_family

def detect_based_on_release_file
@identifier = :devuan if File.readable?('/etc/devuan_version')
@identifier = :archlinux if File.readable?('/etc/arch-release')
end

def detect_distro
Expand Down

0 comments on commit 3ccc831

Please sign in to comment.