diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5532e3..d4faaea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/CHANGELOG.md b/CHANGELOG.md index c0f0e54..76cc7b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/lib/mini_portile2/mini_portile.rb b/lib/mini_portile2/mini_portile.rb index 662a4e4..0607d3f 100644 --- a/lib/mini_portile2/mini_portile.rb +++ b/lib/mini_portile2/mini_portile.rb @@ -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 # @@ -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! # @@ -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