From f2289c4223b0887f50b8e5acd3df9228c0fec1eb Mon Sep 17 00:00:00 2001 From: Yurii Rashkovskii Date: Fri, 7 Feb 2025 17:14:47 -0800 Subject: [PATCH] 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) --- exe/pgpm | 4 ++++ lib/pgpm/os.rb | 9 ++++++--- lib/pgpm/os/darwin.rb | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 lib/pgpm/os/darwin.rb diff --git a/exe/pgpm b/exe/pgpm index ca78955..c026060 100755 --- a/exe/pgpm +++ b/exe/pgpm @@ -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) diff --git a/lib/pgpm/os.rb b/lib/pgpm/os.rb index 949f2bb..8d00fc7 100644 --- a/lib/pgpm/os.rb +++ b/lib/pgpm/os.rb @@ -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) diff --git a/lib/pgpm/os/darwin.rb b/lib/pgpm/os/darwin.rb new file mode 100644 index 0000000..cf0f10b --- /dev/null +++ b/lib/pgpm/os/darwin.rb @@ -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