diff --git a/configs/components/_base-ruby-selinux.rb b/configs/components/_base-ruby-selinux.rb index 82d314471..e13753d74 100644 --- a/configs/components/_base-ruby-selinux.rb +++ b/configs/components/_base-ruby-selinux.rb @@ -3,6 +3,8 @@ # load it with instance_eval. See ruby-x.y-selinux.rb configs. # +pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch") + # These can be overridden by the including component. ruby_version ||= settings[:ruby_version] host_ruby ||= settings[:host_ruby] @@ -42,16 +44,23 @@ end pkg.build do - [ + steps = [ "export RUBYHDRDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"rubyhdrdir\"]')", "export VENDORARCHDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"vendorarchdir\"]')", "export ARCHDIR=$${RUBYHDRDIR}/$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"arch\"]')", "export INCLUDESTR=\"-I#{settings[:includedir]} -I$${RUBYHDRDIR} -I$${ARCHDIR}\"", "cp -pr src/{selinuxswig_ruby.i,selinuxswig.i} .", - "swig -Wall -ruby #{system_include} -o selinuxswig_ruby_wrap.c -outdir ./ selinuxswig_ruby.i", + "swig -Wall -ruby #{system_include} -o selinuxswig_ruby_wrap.c -outdir ./ selinuxswig_ruby.i" + ] + + if ruby_version =~ /^3/ + steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_wrap.patch" + end + + steps.concat([ "#{cc} $${INCLUDESTR} #{system_include} #{cflags} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -DSHARED -c -o selinuxswig_ruby_wrap.lo selinuxswig_ruby_wrap.c", "#{cc} $${INCLUDESTR} #{system_include} -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -shared -o _rubyselinux.so selinuxswig_ruby_wrap.lo -lselinux -Wl,-z,relro,-z,now,-soname,_rubyselinux.so", - ] + ]) end pkg.install do diff --git a/resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch b/resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch new file mode 100644 index 000000000..28b7999a5 --- /dev/null +++ b/resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch @@ -0,0 +1,10 @@ +--- selinuxswig_ruby_wrap.c.orig 2023-01-18 22:38:21.527547362 -0800 ++++ selinuxswig_ruby_wrap.c 2023-01-18 22:38:26.887569066 -0800 +@@ -1724,6 +1724,7 @@ + { + /* register a new class */ + VALUE cl = rb_define_class("swig_runtime_data", rb_cObject); ++ rb_undef_alloc_func(cl); + /* create and store the structure pointer to a global variable */ + swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer); + rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);