Accepting request 949319 from home:cboltz

- add ruby-3.1-build-fix.diff: fix build with ruby 3.1 (boo#1194221,
  MR 827)

OBS-URL: https://build.opensuse.org/request/show/949319
OBS-URL: https://build.opensuse.org/package/show/security:apparmor/apparmor?expand=0&rev=315
This commit is contained in:
Christian Boltz 2022-01-26 18:03:22 +00:00 committed by Git OBS Bridge
parent b6bdf3e03b
commit a53ba0c4c6
4 changed files with 124 additions and 5 deletions

View File

@ -1,9 +1,14 @@
-------------------------------------------------------------------
Wed Jan 26 17:14:58 UTC 2022 - Christian Boltz <suse-beta@cboltz.de>
- add ruby-3.1-build-fix.diff: fix build with ruby 3.1 (boo#1194221,
MR 827)
-------------------------------------------------------------------
Mon Jan 17 10:27:38 UTC 2022 - Samuel Cabrero <scabrero@suse.de>
- add update-samba-abstractions-ldb2.diff: Cater for changes to ldb
packaging to allow parallel installation with libldb;
(bsc#1192684).
packaging to allow parallel installation with libldb (bsc#1192684).
-------------------------------------------------------------------
Mon Dec 20 11:01:50 UTC 2021 - Noel Power <nopower@suse.com>

View File

@ -2,7 +2,7 @@
# spec file for package apparmor
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2011-2021 Christian Boltz
# Copyright (c) 2011-2022 Christian Boltz
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -92,9 +92,12 @@ Patch9: aa-notify-more-arch-mr809.diff
Patch10: openssl-engdef-mr818.diff
# add update-samba-abstractions-ldb2.diff to cater for changes to ldb
# packaging to allow parallel installation with libldb bsc#1192684
# packaging to allow parallel installation with libldb bsc#1192684 (submitted upstream 2022-01-17 - https://gitlab.com/apparmor/apparmor/-/merge_requests/821)
Patch11: update-samba-abstractions-ldb2.diff
# fix build with ruby 3.1 (boo#1194221, from upstream https://gitlab.com/apparmor/apparmor/-/merge_requests/827)
Patch12: ruby-3.1-build-fix.diff
PreReq: sed
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%define apparmor_bin_prefix %{?usrmerged:/usr}/lib/apparmor
@ -362,6 +365,7 @@ mv -v profiles/apparmor.d/usr.lib.apache2.mpm-prefork.apache2 profiles/apparmor/
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build
%define _lto_cflags %{nil}

View File

@ -2,7 +2,7 @@
# spec file for package libapparmor
#
# Copyright (c) 2022 SUSE LLC
# Copyright (c) 2011-2020 Christian Boltz
# Copyright (c) 2011-2022 Christian Boltz
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed

110
ruby-3.1-build-fix.diff Normal file
View File

@ -0,0 +1,110 @@
https://gitlab.com/apparmor/apparmor/-/merge_requests/827
From fde8acf86ddb82f1c10332478daebd3fad1bee45 Mon Sep 17 00:00:00 2001
From: John Johansen <john.johansen@canonical.com>
Date: Wed, 26 Jan 2022 08:04:04 -0800
Subject: [PATCH] libapparmor: Fix ruby 3.1 build for libapparmor
The Hack used to build the libapparmor swig interface for ruby fails
with ruby 3.1. Instead of trying to do black magic in ruby to rename
the generated Makefile to Makefile.new, just save off the Makefile
and restore after ruby's setup has been called.
Fixes: https://gitlab.com/apparmor/apparmor/-/issues/206
Signed-off-by: John Johansen <john.johansen@canonical.com>
---
.gitignore | 2 +-
libraries/libapparmor/swig/ruby/Makefile.am | 4 +++-
libraries/libapparmor/swig/ruby/extconf.rb | 14 +++-----------
3 files changed, 7 insertions(+), 13 deletions(-)
Additionally patch libraries/libapparmor/swig/ruby/Makefile.in which is shipped
in the tarball and based on Makefile.am.
diff --git a/.gitignore b/.gitignore
index 4782a351a..bac706f2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -177,7 +177,7 @@ libraries/libapparmor/swig/ruby/LibAppArmor_wrap.c
libraries/libapparmor/swig/ruby/LibAppArmor_wrap.o
libraries/libapparmor/swig/ruby/Makefile
libraries/libapparmor/swig/ruby/Makefile.in
-libraries/libapparmor/swig/ruby/Makefile.new
+libraries/libapparmor/swig/ruby/Makefile.bak
libraries/libapparmor/swig/ruby/Makefile.ruby
libraries/libapparmor/swig/ruby/mkmf.log
libraries/libapparmor/testsuite/.deps
diff --git a/libraries/libapparmor/swig/ruby/Makefile.am b/libraries/libapparmor/swig/ruby/Makefile.am
index 03ef02fd6..3f4572816 100644
--- a/libraries/libapparmor/swig/ruby/Makefile.am
+++ b/libraries/libapparmor/swig/ruby/Makefile.am
@@ -9,7 +9,9 @@ LibAppArmor_wrap.c : $(srcdir)/../SWIG/libapparmor.i
MOSTLYCLEANFILES=LibAppArmor_wrap.c
Makefile.ruby: extconf.rb
+ mv Makefile Makefile.bak
PREFIX=$(prefix) $(RUBY) $< --with-LibAppArmor-include=$(top_srcdir)/include
+ mv Makefile.bak Makefile
LibAppArmor.so: LibAppArmor_wrap.c Makefile.ruby
$(MAKE) -fMakefile.ruby
@@ -22,7 +24,7 @@ install-exec-local: Makefile.ruby
clean-local:
if test -f Makefile.ruby; then $(MAKE) -fMakefile.ruby clean; fi
- rm -f Makefile.ruby Makefile.new
+ rm -f Makefile.ruby Makefile.new Makefile.bak
rm -f *.o *.so *.log
endif
diff --git a/libraries/libapparmor/swig/ruby/extconf.rb b/libraries/libapparmor/swig/ruby/extconf.rb
index 647d2d831..6a2ef7457 100644
--- a/libraries/libapparmor/swig/ruby/extconf.rb
+++ b/libraries/libapparmor/swig/ruby/extconf.rb
@@ -2,16 +2,8 @@
require 'mkmf'
-# hack 1: ruby black magic to write a Makefile.new instead of a Makefile
-alias open_orig open
-def open(path, mode=nil, perm=nil)
- path = 'Makefile.new' if path == 'Makefile'
- if block_given?
- open_orig(path, mode, perm) { |io| yield(io) }
- else
- open_orig(path, mode, perm)
- end
-end
+# hack 1: Before extconf.rb gets called, Makefile gets backed up, and
+# restored afterwards (see Makefile.am)
if ENV['PREFIX']
prefix = CONFIG['prefix']
@@ -27,7 +19,7 @@ if find_library('apparmor', 'parse_record', '../../src/.libs') and
# hack 2: strip all rpath references
open('Makefile.ruby', 'w') do |out|
- IO.foreach('Makefile.new') do |line|
+ IO.foreach('Makefile') do |line|
l = line.gsub(/-Wl,-R'[^']*'/, '')
# oldincludedir = $(DESTDIR)/usr/include
# -> oldincludedir = /usr/include
Index: apparmor-3.0.3/libraries/libapparmor/swig/ruby/Makefile.in
===================================================================
--- apparmor-3.0.3.orig/libraries/libapparmor/swig/ruby/Makefile.in 2022-01-26 13:13:38.958238926 +0100
+++ apparmor-3.0.3/libraries/libapparmor/swig/ruby/Makefile.in 2022-01-26 13:15:08.206094528 +0100
@@ -469,7 +469,9 @@ uninstall-am:
@HAVE_RUBY_TRUE@ $(SWIG) -ruby -module LibAppArmor -I$(top_srcdir)/include -o $@ $(srcdir)/../SWIG/libapparmor.i
@HAVE_RUBY_TRUE@Makefile.ruby: extconf.rb
+@HAVE_RUBY_TRUE@ mv Makefile Makefile.bak
@HAVE_RUBY_TRUE@ PREFIX=$(prefix) $(RUBY) $< --with-LibAppArmor-include=$(top_srcdir)/include
+@HAVE_RUBY_TRUE@ mv Makefile.bak Makefile
@HAVE_RUBY_TRUE@LibAppArmor.so: LibAppArmor_wrap.c Makefile.ruby
@HAVE_RUBY_TRUE@ $(MAKE) -fMakefile.ruby