Skip to content

Commit f2289c4

Browse files
committed
Problem: building on macOS without --os flag
It'll fail because we can't autodetect the OS. Solution: make macOS detectable but fail on anything but RedHat-based (because that's the only systems we support right this moment)
1 parent ad94115 commit f2289c4

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

exe/pgpm

+4
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ module Pgpm
8585
exit(1)
8686
end
8787

88+
unless os.is_a?(Pgpm::OS::RedHat)
89+
puts "#{os.name} is not a supported OS at this moment"
90+
exit(1)
91+
end
8892
puts "Building #{pkgs.map { |p| "#{p.name}@#{p.version}" }.join(", ")} for Postgres #{matching_pgver}"
8993
selected_pgdist = Postgres::RedhatBasedPgdg.new(matching_pgver.to_s)
9094

lib/pgpm/os.rb

+6-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ def with_scope(&block)
3737
end
3838

3939
def self.auto_detect
40-
return unless RUBY_PLATFORM =~ /linux$/
41-
42-
Pgpm::OS::Linux.auto_detect
40+
if RUBY_PLATFORM =~ /linux$/
41+
Pgpm::OS::Linux.auto_detect
42+
else
43+
RUBY_PLATFORM =~ /darwin/
44+
Pgpm::OS::Darwin.auto_detect
45+
end
4346
end
4447

4548
def self.find(name)

lib/pgpm/os/darwin.rb

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# frozen_string_literal: true
2+
3+
module Pgpm
4+
module OS
5+
class Darwin < Pgpm::OS::Unix
6+
def self.name
7+
"darwin"
8+
end
9+
10+
def self.auto_detect
11+
new
12+
end
13+
end
14+
end
15+
end

0 commit comments

Comments
 (0)