Skip to content

Commit

Permalink
Problem: building on macOS without --os flag
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
yrashk committed Feb 8, 2025
1 parent ad94115 commit f2289c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions exe/pgpm
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ module Pgpm
exit(1)
end

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

Expand Down
9 changes: 6 additions & 3 deletions lib/pgpm/os.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ def with_scope(&block)
end

def self.auto_detect
return unless RUBY_PLATFORM =~ /linux$/

Pgpm::OS::Linux.auto_detect
if RUBY_PLATFORM =~ /linux$/
Pgpm::OS::Linux.auto_detect
else
RUBY_PLATFORM =~ /darwin/
Pgpm::OS::Darwin.auto_detect
end
end

def self.find(name)
Expand Down
15 changes: 15 additions & 0 deletions lib/pgpm/os/darwin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

module Pgpm
module OS
class Darwin < Pgpm::OS::Unix
def self.name
"darwin"
end

def self.auto_detect
new
end
end
end
end

0 comments on commit f2289c4

Please sign in to comment.