From d028819b5cc958f3322e26ba75f7ae3b90067868 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 11:36:35 +0900 Subject: [PATCH 1/7] Use rb_io_descriptor() API to fix deprecated message Since Ruby 3.4, it marks as deprecated that it use `fptr->fd` directly. Ref. https://github.com/ruby/ruby/commit/b4d73e9f80aa5fe72c39f42a88727fed0abb261b ```sh $ gem install capng_c --verbose ...(snip)... capng.c: In function 'rb_capng_get_caps_file': capng.c:511:3: warning: 'fd' is deprecated: rb_io_descriptor [-Wdeprecated-declarations] 511 | fd = fptr->fd; | ^~ In file included from ./capng.h:19, from capng.c:14: /home/watson/.rbenv/versions/3.4.1/include/ruby-3.4.0/ruby/io.h:154:9: note: declared here 154 | int fd; | ^~ capng.c: In function 'rb_capng_apply_caps_file': capng.c:541:3: warning: 'fd' is deprecated: rb_io_descriptor [-Wdeprecated-declarations] 541 | fd = fptr->fd; | ^~ /home/watson/.rbenv/versions/3.4.1/include/ruby-3.4.0/ruby/io.h:154:9: note: declared here 154 | int fd; | ^~ At top level: ...(snip)... ``` So, this patch will use `rb_io_descriptor()` instead of `fptr->fd` if available. Signed-off-by: Shizuo Fujita --- ext/capng/capng.c | 21 +++++++++++++++------ ext/capng/extconf.rb | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/ext/capng/capng.c b/ext/capng/capng.c index cdc73a5..235f1be 100644 --- a/ext/capng/capng.c +++ b/ext/capng/capng.c @@ -67,6 +67,19 @@ rb_capng_alloc(VALUE klass) return obj; } +static int +capng_get_file_descriptor(VALUE rb_file) +{ +#ifdef HAVE_RB_IO_DESCRIPTOR + return rb_io_descriptor(rb_file); +#else + rb_io_t* fptr = NULL; + + fptr = RFILE(rb_file)->fptr; + return fptr->fd; +#endif +} + /* * Initalize CapNG class. * @@ -500,15 +513,13 @@ static VALUE rb_capng_get_caps_file(VALUE self, VALUE rb_file) { int result = 0, fd = 0; - rb_io_t* fptr = NULL; Check_Type(rb_file, T_FILE); if (NIL_P(rb_file)) { return Qfalse; } - fptr = RFILE(rb_file)->fptr; - fd = fptr->fd; + fd = capng_get_file_descriptor(rb_file); result = capng_get_caps_fd(fd); if (result == 0) @@ -529,7 +540,6 @@ static VALUE rb_capng_apply_caps_file(VALUE self, VALUE rb_file) { int result = 0, fd = 0; - rb_io_t* fptr = NULL; Check_Type(rb_file, T_FILE); @@ -537,8 +547,7 @@ rb_capng_apply_caps_file(VALUE self, VALUE rb_file) return Qfalse; } - fptr = RFILE(rb_file)->fptr; - fd = fptr->fd; + fd = capng_get_file_descriptor(rb_file); result = capng_apply_caps_fd(fd); if (result == 0) diff --git a/ext/capng/extconf.rb b/ext/capng/extconf.rb index 28d0082..0469847 100644 --- a/ext/capng/extconf.rb +++ b/ext/capng/extconf.rb @@ -29,5 +29,6 @@ have_const("CAPNG_AMBIENT", "cap-ng.h") have_const("CAPNG_INIT_SUPP_GRP", "cap-ng.h") have_func("rb_sym2str", "ruby.h") +have_func("rb_io_descriptor", "ruby.h") have_func("capng_get_caps_fd", "cap-ng.h") create_makefile("capng/capng") From c7a1fb008a381251b297494bf940bcf7b4b2af9c Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 11:42:44 +0900 Subject: [PATCH 2/7] CI: Add Ruby 3.1 ~ 3.4 Signed-off-by: Shizuo Fujita --- .github/workflows/linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 998955a..58a38cb 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -8,7 +8,7 @@ jobs: strategy: fail-fast: false matrix: - ruby: [ '2.5', '2.6' , '2.7', '3.0' ] + ruby: [ '2.5', '2.6' , '2.7', '3.0', '3.1', '3.2', '3.3', '3.4' ] os: - ubuntu-latest name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} From 8f0c3ac1da76d02f86c8186cbc08085d6de607d4 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 12:21:50 +0900 Subject: [PATCH 3/7] Remove installing bundler Signed-off-by: Shizuo Fujita --- .github/workflows/linux.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 58a38cb..a3db33c 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,6 +25,5 @@ jobs: env: CI: true run: | - gem install bundler rake bundle install --jobs 4 --retry 3 bundle exec rake From c43b919bb1528563e086578714e708e461cfd1c7 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 12:28:22 +0900 Subject: [PATCH 4/7] Fix to work rake task for Ruby 3.3+ Signed-off-by: Shizuo Fujita --- Rakefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Rakefile b/Rakefile index ffca570..6877099 100644 --- a/Rakefile +++ b/Rakefile @@ -12,9 +12,7 @@ end require "rake/extensiontask" -spec = eval File.read("capng_c.gemspec") - -Rake::ExtensionTask.new("capng", spec) do |ext| +Rake::ExtensionTask.new("capng") do |ext| ext.lib_dir = "lib/capng" end From da3c2ddd77f044515d1b4ab070756fda03257588 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 12:33:25 +0900 Subject: [PATCH 5/7] Install proper version of bundler Signed-off-by: Shizuo Fujita --- ci/apt-test.sh | 2 +- ci/yum-test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/apt-test.sh b/ci/apt-test.sh index 788d9a9..daadece 100755 --- a/ci/apt-test.sh +++ b/ci/apt-test.sh @@ -10,6 +10,6 @@ apt install -V -y lsb-release apt install -V -y ruby-dev git build-essential pkg-config apt install -V -y libcap-ng-dev cd /capng && \ - gem install bundler --no-document && \ + gem install bundler -v 2.3.27 --no-document && \ bundle install && \ bundle exec rake diff --git a/ci/yum-test.sh b/ci/yum-test.sh index 39e19cc..069dd52 100755 --- a/ci/yum-test.sh +++ b/ci/yum-test.sh @@ -60,5 +60,5 @@ if [ $USE_SCL -eq 1 ]; then export MANPATH= cd /capng && source /opt/rh/rh-ruby26/enable && gem install bundler --no-document && bundle install && bundle exec rake else - cd /capng && gem install bundler --no-document && bundle install && bundle exec rake + cd /capng && gem install bundler -v 2.3.27 --no-document && bundle install && bundle exec rake fi From a898aadd23474ea45a5e2284093a0f38be7d6f56 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Mon, 13 Jan 2025 12:40:38 +0900 Subject: [PATCH 6/7] Install libyaml for psych gem Signed-off-by: Shizuo Fujita --- ci/apt-test.sh | 2 +- ci/yum-test.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/apt-test.sh b/ci/apt-test.sh index daadece..6c1f92a 100755 --- a/ci/apt-test.sh +++ b/ci/apt-test.sh @@ -7,7 +7,7 @@ export DEBIAN_FRONTEND=noninteractive apt update apt install -V -y lsb-release -apt install -V -y ruby-dev git build-essential pkg-config +apt install -V -y ruby-dev git build-essential pkg-config libyaml-dev apt install -V -y libcap-ng-dev cd /capng && \ gem install bundler -v 2.3.27 --no-document && \ diff --git a/ci/yum-test.sh b/ci/yum-test.sh index 069dd52..fa1f791 100755 --- a/ci/yum-test.sh +++ b/ci/yum-test.sh @@ -53,6 +53,7 @@ else rubygems \ rpm-build fi +${DNF} install -y libyaml-devel ${DNF} install -y libcap-ng-devel if [ $USE_SCL -eq 1 ]; then From 7928bf1853478ef6dfd0429611d734eb64efb6d4 Mon Sep 17 00:00:00 2001 From: Shizuo Fujita Date: Tue, 14 Jan 2025 09:38:23 +0900 Subject: [PATCH 7/7] Use AlmaLinux and RockyLinux Signed-off-by: Shizuo Fujita --- .github/workflows/yum.yml | 14 +++++++------- ci/yum-test.sh | 6 ++++++ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/yum.yml b/.github/workflows/yum.yml index 2da8dad..53326c2 100644 --- a/.github/workflows/yum.yml +++ b/.github/workflows/yum.yml @@ -9,16 +9,16 @@ jobs: fail-fast: false matrix: label: - - CentOS 7 x86_64 - - CentOS 8 x86_64 + - RockyLinux 8 x86_64 + - AlmaLinux 9 x86_64 - Fedora 33 x86_64 - AmazonLinux 2 x86_64 include: - - label: CentOS 7 x86_64 - test-docker-image: centos:7 + - label: RockyLinux 8 x86_64 + test-docker-image: rockylinux:8 test-script: ci/yum-test.sh - - label: CentOS 8 x86_64 - test-docker-image: centos:8 + - label: AlmaLinux 9 x86_64 + test-docker-image: almalinux:9 test-script: ci/yum-test.sh - label: Fedora 33 x86_64 test-docker-image: fedora:33 @@ -36,4 +36,4 @@ jobs: --tty \ --volume ${PWD}:/capng \ ${{ matrix.test-docker-image }} \ - /capng/${{ matrix.test-script }} \ No newline at end of file + /capng/${{ matrix.test-script }} diff --git a/ci/yum-test.sh b/ci/yum-test.sh index fa1f791..c7caafe 100755 --- a/ci/yum-test.sh +++ b/ci/yum-test.sh @@ -34,6 +34,12 @@ case ${distribution} in ;; esac ;; + rocky) + DNF="dnf --enablerepo=powertools" + ;; + almalinux) + DNF="dnf --enablerepo=crb" + ;; esac ${DNF} groupinstall -y "Development Tools"