Skip to content

Commit 6aa7d2e

Browse files
authored
Merge pull request #620 from joshcooper/swig_selinux_4844
(PA-4844) Patch the autogenerated selinux C extension
2 parents 8affdd8 + 45b4344 commit 6aa7d2e

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

configs/components/_base-ruby-selinux.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# load it with instance_eval. See ruby-x.y-selinux.rb configs.
44
#
55

6+
pkg.add_source("file://resources/patches/ruby-selinux/selinuxswig_ruby_wrap.patch")
7+
68
# These can be overridden by the including component.
79
ruby_version ||= settings[:ruby_version]
810
host_ruby ||= settings[:host_ruby]
@@ -42,16 +44,23 @@
4244
end
4345

4446
pkg.build do
45-
[
47+
steps = [
4648
"export RUBYHDRDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"rubyhdrdir\"]')",
4749
"export VENDORARCHDIR=$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"vendorarchdir\"]')",
4850
"export ARCHDIR=$${RUBYHDRDIR}/$(shell #{ruby} -e 'puts RbConfig::CONFIG[\"arch\"]')",
4951
"export INCLUDESTR=\"-I#{settings[:includedir]} -I$${RUBYHDRDIR} -I$${ARCHDIR}\"",
5052
"cp -pr src/{selinuxswig_ruby.i,selinuxswig.i} .",
51-
"swig -Wall -ruby #{system_include} -o selinuxswig_ruby_wrap.c -outdir ./ selinuxswig_ruby.i",
53+
"swig -Wall -ruby #{system_include} -o selinuxswig_ruby_wrap.c -outdir ./ selinuxswig_ruby.i"
54+
]
55+
56+
if ruby_version =~ /^3/
57+
steps << "#{platform.patch} --strip=0 --fuzz=0 --ignore-whitespace --no-backup-if-mismatch < ../selinuxswig_ruby_wrap.patch"
58+
end
59+
60+
steps.concat([
5261
"#{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",
5362
"#{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",
54-
]
63+
])
5564
end
5665

5766
pkg.install do
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- selinuxswig_ruby_wrap.c.orig 2023-01-18 22:38:21.527547362 -0800
2+
+++ selinuxswig_ruby_wrap.c 2023-01-18 22:38:26.887569066 -0800
3+
@@ -1724,6 +1724,7 @@
4+
{
5+
/* register a new class */
6+
VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
7+
+ rb_undef_alloc_func(cl);
8+
/* create and store the structure pointer to a global variable */
9+
swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
10+
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);

0 commit comments

Comments
 (0)