Skip to content

Commit

Permalink
Merge pull request #141 from postmodern/openbsd-support
Browse files Browse the repository at this point in the history
Add OpenBSD support
  • Loading branch information
flavorjones authored May 31, 2024
2 parents 250a0d5 + 68f8344 commit 5dd29f8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 31 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,40 @@ jobs:
gem install bundler
bundle install
bundle exec rake ${{ matrix.task }}
openbsd:
strategy:
fail-fast: false
matrix:
task: ["test:unit", "test:examples"]
runs-on: ubuntu-latest
env:
MAKE: gmake
steps:
- uses: actions/checkout@v4
- uses: vmactions/openbsd-vm@v1
with:
envs: MAKE
usesh: true
copyback: false
prepare: |
pkg_add ruby%3.1 gmake cmake git pkgconf security/gnupg
ln -sf /usr/local/bin/ruby31 /usr/local/bin/ruby
ln -sf /usr/local/bin/bundle31 /usr/local/bin/bundle
ln -sf /usr/local/bin/bundler31 /usr/local/bin/bundler
ln -sf /usr/local/bin/erb31 /usr/local/bin/erb
ln -sf /usr/local/bin/gem31 /usr/local/bin/gem
ln -sf /usr/local/bin/irb31 /usr/local/bin/irb
ln -sf /usr/local/bin/racc31 /usr/local/bin/racc
ln -sf /usr/local/bin/rake31 /usr/local/bin/rake
ln -sf /usr/local/bin/rbs31 /usr/local/bin/rbs
ln -sf /usr/local/bin/rdbg31 /usr/local/bin/rdbg
ln -sf /usr/local/bin/rdoc31 /usr/local/bin/rdoc
ln -sf /usr/local/bin/ri31 /usr/local/bin/ri
ln -sf /usr/local/bin/syntax_suggest31 /usr/local/bin/syntax_suggest
ln -sf /usr/local/bin/typeprof31 /usr/local/bin/typeprof
run: |
git config --global --add safe.directory /home/runner/work/mini_portile/mini_portile
gem install bundler
bundle install
bundle exec rake ${{ matrix.task }}
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

#### Added

- When setting the C compiler through the `MiniPortile` constructor, the preferred keyword argument is now `:cc_command`. The original `:gcc_command` is still supported. @flavorjones
- GPG file verification error messages are captured in the raised exception. Previously these errors went to `stderr`. @flavorjones
- When setting the C compiler through the `MiniPortile` constructor, the preferred keyword argument is now `:cc_command`. The original `:gcc_command` is still supported. (#144 by @flavorjones)
- GPG file verification error messages are captured in the raised exception. Previously these errors went to `stderr`. (#145 by @flavorjones)
- Add support for extracting xz-compressed tarballs on OpenBSD. (#141 by @postmodern)
- Add OpenBSD support to the experimental method `MakeMakefile#mkmf_config`. (#141 by @flavorjones)


### 2.8.6 / 2024-04-14
Expand Down
55 changes: 26 additions & 29 deletions lib/mini_portile2/mini_portile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,8 @@ def mkmf_config(pkg: nil, dir: nil, static: nil)
if static
libdir = lib_path
if pcfile
variables = minimal_pkg_config(pcfile, "print-variables").split("\n").map(&:strip)
if variables.include?("libdir")
libdir = minimal_pkg_config(pcfile, "variable=libdir")
end
pcfile_libdir = minimal_pkg_config(pcfile, "variable=libdir").strip
libdir = pcfile_libdir unless pcfile_libdir.empty?
end

#
Expand Down Expand Up @@ -510,30 +508,6 @@ def log_file(action)
}
end

TAR_EXECUTABLES = %w[gtar bsdtar tar basic-bsdtar]
def tar_exe
@@tar_exe ||= begin
TAR_EXECUTABLES.find { |c|
which(c)
} or raise("tar not found - please make sure that one of the following commands is in the PATH: #{TAR_EXECUTABLES.join(", ")}")
end
end

def tar_compression_switch(filename)
case File.extname(filename)
when '.gz', '.tgz'
'z'
when '.bz2', '.tbz2'
'j'
when '.xz'
'J'
when '.Z'
'Z'
else
''
end
end

# From: http://stackoverflow.com/a/5471032/7672
# Thanks, Mislav!
#
Expand Down Expand Up @@ -570,12 +544,35 @@ def detect_host
end
end

TAR_EXECUTABLES = %w[gtar bsdtar tar basic-bsdtar]
def tar_exe
@@tar_exe ||= begin
TAR_EXECUTABLES.find { |c|
which(c)
} or raise("tar not found - please make sure that one of the following commands is in the PATH: #{TAR_EXECUTABLES.join(", ")}")
end
end

def tar_command(file, target)
case File.extname(file)
when '.gz', '.tgz'
[tar_exe, 'xzf', file, '-C', target]
when '.bz2', '.tbz2'
[tar_exe, 'xjf', file, '-C', target]
when '.xz'
# NOTE: OpenBSD's tar command does not support the -J option
"xzcat #{file.shellescape} | #{tar_exe.shellescape} xf - -C #{target.shellescape}"
else
[tar_exe, 'xf', file, '-C', target]
end
end

def extract_file(file, target)
filename = File.basename(file)
FileUtils.mkdir_p target

message "Extracting #{filename} into #{target}... "
execute('extract', [tar_exe, "#{tar_compression_switch(filename)}xf", file, "-C", target], {:cd => Dir.pwd, :initial_message => false})
execute('extract', tar_command(file, target) , {:cd => Dir.pwd, :initial_message => false})
end

# command could be an array of args, or one string containing a command passed to the shell. See
Expand Down

0 comments on commit 5dd29f8

Please sign in to comment.