Skip to content

Commit

Permalink
sys-libs/libselinux: bump to 2.6-rc1
Browse files Browse the repository at this point in the history
Package-Manager: portage-2.3.0
  • Loading branch information
perfinion committed Oct 3, 2016
1 parent 335085f commit d2e6a08
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 22 deletions.
1 change: 1 addition & 0 deletions sys-libs/libselinux/Manifest
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
DIST libselinux-2.5.tar.gz 189019 SHA256 94c9e97706280bedcc288f784f67f2b9d3d6136c192b2c9f812115edba58514f SHA512 1c6718aa6fa05c8635427cd6f5a89ce47fb6bb9bd2fec417293122826695d1ebb0e0b86e83711abb5c4fe71c67dce6f2e18745592833d1711f0ab2d01246b8c7 WHIRLPOOL 96192b856d32a82b9b4413137085e69ad52cbf2e0d274603a90d904e9a318a80c83f337aef26f54c685a689972432955f0f9de67949e0bb4f844611df22d3589
DIST libselinux-2.6-rc1.tar.gz 203034 SHA256 4ef2bbb1bdb1d0c43ed14b237066364b07bd1d2ae0a16dcd475bbf7793723928 SHA512 72a8a1d244fea3902cecff69fda48c1bc8d7ce1789902126565272782105bd43205e517af8a4cac5cc5cab47c48f0cd3b287c42a408ae3889b51b19b0b38632b WHIRLPOOL b9012b74a3f073e25b63d83003194f23f7177cdd0e33443de87ff7491e0ecffa72eea07be04247cafd3045773427dbf98f592e02346c8fa32bc161be624cc2b4
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
From 024a8628e698e8c90f7876a35c820f30c6957031 Mon Sep 17 00:00:00 2001
From: Jason Zaman <[email protected]>
Date: Sun, 2 Oct 2016 02:06:35 +0800
Subject: [PATCH] libselinux: versioned ruby pkg-config and query vendorarchdir
properly

Gentoo and Arch have pkg-config entries for "ruby-$(RUBYLIBVER)" but not
for "ruby". Check if that exists first then fall back to plain ruby if
it does not.

The ruby install paths were incorrect. Fedora 20 installed to
/usr/lib64/ruby/vendor_ruby/, Arch needs it to be vendor_ruby as well,
site_ruby does not work. Thanks to Nicolas Iooss for the correct way to
query for the path.

Signed-off-by: Jason Zaman <[email protected]>
---
libselinux/src/Makefile | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 7169230..f9e3de1 100644
--- libselinux/src/Makefile
+++ libselinux/src/Makefile
@@ -16,9 +16,8 @@ PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_i
PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
PYLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
RUBYLIBVER ?= $(shell $(RUBY) -e 'print RUBY_VERSION.split(".")[0..1].join(".")')
-RUBYPLATFORM ?= $(shell $(RUBY) -e 'print RUBY_PLATFORM')
-RUBYINC ?= $(shell $(PKG_CONFIG) --cflags ruby)
-RUBYINSTALL ?= $(LIBDIR)/ruby/site_ruby/$(RUBYLIBVER)/$(RUBYPLATFORM)
+RUBYINC ?= $(shell $(PKG_CONFIG) --exists ruby-$(RUBYLIBVER) && $(PKG_CONFIG) --cflags ruby-$(RUBYLIBVER) || $(PKG_CONFIG) --cflags ruby)
+RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
LIBBASE ?= $(shell basename $(LIBDIR))

VERSION = $(shell cat ../VERSION)
--
2.7.3

Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
https://bugs.gentoo.org/500674

random fixes:
- make sure PCRE_CFLAGS get used
- use PCRE_LIBS via pkg-config
- move LDFLAGS to before objects, not after
- do not hardcode -L$(LIBDIR) (let the toolchain handle it)
- do not hardcode -I$(INCLUDEDIR) (let the toolchain handle it)

diff --git a/libselinux/Makefile b/libselinux/Makefile
index baa0db3..4dc5aa0 100644
--- libselinux/Makefile
+++ libselinux/Makefile
@@ -1,5 +1,6 @@
SUBDIRS = src include utils man

+PKG_CONFIG ?= pkg-config
DISABLE_SETRANS ?= n
DISABLE_RPM ?= n
ANDROID_HOST ?= n
@@ -20,10 +21,11 @@ export DISABLE_SETRANS DISABLE_RPM DISABLE_FLAGS ANDROID_HOST

USE_PCRE2 ?= n
ifeq ($(USE_PCRE2),y)
- PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8
- PCRE_LDFLAGS := -lpcre2-8
+ PCRE_CFLAGS := -DUSE_PCRE2 -DPCRE2_CODE_UNIT_WIDTH=8 $(shell $(PKG_CONFIG) --cflags libpcre2-8)
+ PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre2-8)
else
- PCRE_LDFLAGS := -lpcre
+ PCRE_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcre)
+ PCRE_LDFLAGS := $(shell $(PKG_CONFIG) --libs libpcre)
endif
export PCRE_CFLAGS PCRE_LDFLAGS

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 13501cd..42cb2f6 100644
--- libselinux/src/Makefile
+++ libselinux/src/Makefile
@@ -67,7 +67,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi

PCRE_LDFLAGS ?= -lpcre

-override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
+override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)

SWIG_CFLAGS += -Wno-error -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-parameter \
-Wno-shadow -Wno-uninitialized -Wno-missing-prototypes -Wno-missing-declarations
@@ -107,17 +107,17 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<

$(SWIGSO): $(SWIGLOBJ)
- $(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lselinux

$(SWIGRUBYSO): $(SWIGRUBYLOBJ)
- $(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lselinux

$(LIBA): $(OBJS)
$(AR) rcs $@ $^
$(RANLIB) $@

$(LIBSO): $(LOBJS)
- $(CC) $(CFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl $(LDFLAGS) -L$(LIBDIR) -Wl,-soname,$(LIBSO),-z,defs,-z,relro
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ $(PCRE_LDFLAGS) -ldl -Wl,-soname,$(LIBSO),-z,defs,-z,relro
ln -sf $@ $(TARGET)

$(LIBPC): $(LIBPC).in ../VERSION
@@ -130,7 +130,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<

$(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
- $(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBDIR)/libsepol.a -L$(LIBDIR)
+ $(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lselinux $(LIBDIR)/libsepol.a

%.o: %.c policy.h
$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
diff --git a/libselinux/utils/Makefile b/libselinux/utils/Makefile
index e56a953..6fd205a 100644
--- libselinux/utils/Makefile
+++ libselinux/utils/Makefile
@@ -25,7 +25,7 @@ CFLAGS ?= -O -Wall -W -Wundef -Wformat-y2k -Wformat-security -Winit-self -Wmissi
-fipa-pure-const -Wno-suggest-attribute=pure -Wno-suggest-attribute=const \
-Werror -Wno-aggregate-return -Wno-redundant-decls
override CFLAGS += -I../include -I$(INCLUDEDIR) -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS)
-LDLIBS += -L../src -lselinux -L$(LIBDIR)
+LDLIBS += -L../src -lselinux
PCRE_LDFLAGS ?= -lpcre

ifeq ($(ANDROID_HOST),y)
157 changes: 157 additions & 0 deletions sys-libs/libselinux/libselinux-2.6_rc1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI="6"
PYTHON_COMPAT=( python2_7 python3_4 python3_5 )
USE_RUBY="ruby21 ruby22 ruby23"

# No, I am not calling ruby-ng
inherit multilib python-r1 toolchain-funcs multilib-minimal

MY_P="${P//_/-}"
SEPOL_VER="${PV}"
MY_RELEASEDATE="20160930"

DESCRIPTION="SELinux userland library"
HOMEPAGE="https://github.com/SELinuxProject/selinux/wiki"

if [[ ${PV} == 9999 ]] ; then
inherit git-r3
EGIT_REPO_URI="https://github.com/SELinuxProject/selinux.git"
S="${WORKDIR}/${MY_P}/${PN}"
else
SRC_URI="https://raw.githubusercontent.com/wiki/SELinuxProject/selinux/files/releases/${MY_RELEASEDATE}/${MY_P}.tar.gz"
KEYWORDS="~amd64 ~arm ~arm64 ~mips ~x86"
S="${WORKDIR}/${MY_P}"
fi

LICENSE="public-domain"
SLOT="0"

IUSE="pcre2 python ruby static-libs ruby_targets_ruby21 ruby_targets_ruby22 ruby_targets_ruby23"

RDEPEND=">=sys-libs/libsepol-${SEPOL_VER}:=[${MULTILIB_USEDEP}]
!pcre2? ( >=dev-libs/libpcre-8.33-r1:=[static-libs?,${MULTILIB_USEDEP}] )
pcre2? ( dev-libs/libpcre2:=[static-libs?,${MULTILIB_USEDEP}] )
python? ( ${PYTHON_DEPS} )
ruby? (
ruby_targets_ruby21? ( dev-lang/ruby:2.1 )
ruby_targets_ruby22? ( dev-lang/ruby:2.2 )
ruby_targets_ruby23? ( dev-lang/ruby:2.3 )
)"
DEPEND="${RDEPEND}
virtual/pkgconfig
python? ( >=dev-lang/swig-2.0.9 )"

src_prepare() {
if [[ ${PV} != 9999 ]] ; then
# If needed for live builds, place them in /etc/portage/patches
eapply "${FILESDIR}/libselinux-2.6-0005-use-ruby-include-with-rubylibver.patch"
eapply "${FILESDIR}/libselinux-2.6-0007-build-related-fixes-bug-500674.patch"
fi

eapply_user

multilib_copy_sources
}

multilib_src_compile() {
tc-export AR CC PKG_CONFIG RANLIB

emake \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
LDFLAGS="-fPIC ${LDFLAGS} -pthread" \
USE_PCRE2="$(usex pcre2 y n)" \
all

if multilib_is_native_abi && use python; then
building() {
python_export PYTHON_INCLUDEDIR PYTHON_LIBPATH
emake \
PYINC="-I${PYTHON_INCLUDEDIR}" \
LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
USE_PCRE2="$(usex pcre2 y n)" \
pywrap
}
python_foreach_impl building
fi

if multilib_is_native_abi && use ruby; then
building() {
einfo "Calling rubywrap for ${1}"
# Clean up .lo file to force rebuild
rm -f src/selinuxswig_ruby_wrap.lo || die
emake \
RUBY=${1} \
LDFLAGS="-fPIC ${LDFLAGS} -lpthread" \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
USE_PCRE2="$(usex pcre2 y n)" \
rubywrap
}
for RUBYTARGET in ${USE_RUBY}; do
use ruby_targets_${RUBYTARGET} || continue

building ${RUBYTARGET}
done
fi
}

multilib_src_install() {
emake DESTDIR="${D}" \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
SHLIBDIR="\$(DESTDIR)/$(get_libdir)" \
USE_PCRE2="$(usex pcre2 y n)" \
install

if multilib_is_native_abi && use python; then
installation() {
emake DESTDIR="${D}" \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
USE_PCRE2="$(usex pcre2 y n)" \
install-pywrap
python_optimize # bug 531638
}
python_foreach_impl installation
fi

if multilib_is_native_abi && use ruby; then
installation() {
einfo "Calling install-rubywrap for ${1}"
# Forcing (re)build here as otherwise the resulting SO file is used for all ruby versions
rm src/selinuxswig_ruby_wrap.lo
emake DESTDIR="${D}" \
LIBDIR="\$(PREFIX)/$(get_libdir)" \
RUBY=${1} \
USE_PCRE2="$(usex pcre2 y n)" \
install-rubywrap
}
for RUBYTARGET in ${USE_RUBY}; do
use ruby_targets_${RUBYTARGET} || continue

installation ${RUBYTARGET}
done
fi

use static-libs || rm "${D}"/usr/lib*/*.a || die
}

pkg_postinst() {
# Fix bug 473502
for POLTYPE in ${POLICY_TYPES};
do
mkdir -p /etc/selinux/${POLTYPE}/contexts/files || die
touch /etc/selinux/${POLTYPE}/contexts/files/file_contexts.local || die
# Fix bug 516608
for EXPRFILE in file_contexts file_contexts.homedirs file_contexts.local ; do
if [[ -f "/etc/selinux/${POLTYPE}/contexts/files/${EXPRFILE}" ]]; then
sefcontext_compile /etc/selinux/${POLTYPE}/contexts/files/${EXPRFILE} \
|| die "Failed to recompile contexts"
fi
done
done
}
Loading

0 comments on commit d2e6a08

Please sign in to comment.