gtk+3: fix dependencies for new gnome/accessibility/at-spi2-core
[oi-userland.git] / components / ruby / facter / patches / facter-06-21936192-ipaddress.patch
blob3bafb43c1f214c4245512dc36170cab5ef1541c1
1 Split from BSD method and add getent hosts
2 Also don't try to run `host hostname` if the host command isn't available.
3 No upstream facter 2.x is dead and new bugs are not being accepted.
5 --- facter-2.4.6/lib/facter/ipaddress.rb.orig 2016-04-19 15:19:02.958338799 -0700
6 +++ facter-2.4.6/lib/facter/ipaddress.rb 2016-04-19 15:27:05.519845908 -0700
7 @@ -1,3 +1,7 @@
8 +#######################################################################
9 +# Oracle has modified the originally distributed contents of this file.
10 +#######################################################################
12 # Fact: ipaddress
14 # Purpose: Return the main IP address for a host.
15 @@ -64,7 +68,7 @@
16 end
18 Facter.add(:ipaddress) do
19 - confine :kernel => %w{NetBSD SunOS}
20 + confine :kernel => %w{NetBSD}
21 setcode do
22 ip = nil
23 output = Facter::Util::IP.exec_ifconfig(["-a"])
24 @@ -84,6 +88,41 @@
25 end
27 Facter.add(:ipaddress) do
28 + confine :osfamily => %w{Solaris}
29 + setcode do
30 + ip = nil
31 + output = Facter::Util::IP.exec_ifconfig(["-a"])
33 + output.each_line { |str|
34 + if str =~ /inet ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/
35 + tmp = $1
36 + unless tmp =~ /^127\./ or tmp == "0.0.0.0"
37 + ip = tmp
38 + break
39 + end
40 + end
41 + }
43 + # If we didn't get an IP from ifconfig see if we can get one from
44 + # the hosts database
45 + if ip.nil? && hostname = Facter.value(:hostname)
46 + # we need Hostname to exist for this to work
47 + host = nil
48 + Facter::Core::Execution.execute("getent hosts #{hostname}").each_line {
49 + |l|
50 + _ip = l.chomp.split()[0]
51 + if _ip !~ /^127\./ && _ip =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/
52 + ip = _ip
53 + break
54 + end
55 + }
56 + end
58 + ip
59 + end
60 +end
62 +Facter.add(:ipaddress) do
63 confine :kernel => %w{AIX}
64 setcode do
65 ip = nil
66 @@ -150,8 +189,9 @@
68 Facter.add(:ipaddress, :timeout => 2) do
69 setcode do
70 - if hostname = Facter.value(:hostname)
71 - # we need Hostname to exist for this to work
72 + if hostname = Facter.value(:hostname) &&
73 + Facter::Core::Execution.which('host')
74 + # we need Hostname and `host` to exist for this to work
75 host = nil
76 if host = Facter::Core::Execution.execute("host #{hostname}")
77 list = host.chomp.split(/\s/)