diff mbox series

[meta-selinux,13/17] selinux-python: upgrade 3.4 -> 3.5

Message ID 20230311131308.1337339-13-yi.zhao@windriver.com
State New
Headers show
Series [meta-selinux,01/17] gitignore: add it | expand

Commit Message

Yi Zhao March 11, 2023, 1:13 p.m. UTC
License-Update: Rename COPYING to LICENSE. No content changes.

* Refresh patch.
* Drop backport patch.
* Add dependency python3-setuptools-scm-native to fix build error.

Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
 ...andle-unsupported-languages-properly.patch | 173 ------------------
 .../fix-sepolicy-install-path.patch           |   8 +-
 ...ux-python_3.4.bb => selinux-python_3.5.bb} |  24 ++-
 3 files changed, 19 insertions(+), 186 deletions(-)
 delete mode 100644 recipes-security/selinux/selinux-python/0001-gettext-handle-unsupported-languages-properly.patch
 rename recipes-security/selinux/{selinux-python_3.4.bb => selinux-python_3.5.bb} (79%)
diff mbox series

Patch

diff --git a/recipes-security/selinux/selinux-python/0001-gettext-handle-unsupported-languages-properly.patch b/recipes-security/selinux/selinux-python/0001-gettext-handle-unsupported-languages-properly.patch
deleted file mode 100644
index b83300d..0000000
--- a/recipes-security/selinux/selinux-python/0001-gettext-handle-unsupported-languages-properly.patch
+++ /dev/null
@@ -1,173 +0,0 @@ 
-From 4693794ff8c52f87a4abdb68fe9dae6618023c03 Mon Sep 17 00:00:00 2001
-From: Vit Mojzis <vmojzis@redhat.com>
-Date: Fri, 24 Jun 2022 16:24:25 +0200
-Subject: [PATCH] gettext: handle unsupported languages properly
-
-With "fallback=True" gettext.translation behaves the same as
-gettext.install and uses NullTranslations in case the
-translation file for given language was not found (as opposed to
-throwing an exception).
-
-Fixes:
-  # LANG is set to any "unsupported" language, e.g. en_US.UTF-8
-  $ chcat --help
-  Traceback (most recent call last):
-  File "/usr/bin/chcat", line 39, in <module>
-    t = gettext.translation(PROGNAME,
-  File "/usr/lib64/python3.9/gettext.py", line 592, in translation
-    raise FileNotFoundError(ENOENT,
-  FileNotFoundError: [Errno 2] No translation file found for domain: 'selinux-python'
-
-Signed-off-by: Vit Mojzis <vmojzis@redhat.com>
-Reviewed-by: Daniel Burgener <dburgener@linux.microsoft.com>
-Acked-by: Petr Lautrbach <plautrba@redhat.com>
-
-Upstream-Status: Backport
-[https://github.com/SELinuxProject/selinux/commit/344463076b2a91e1d2c7f5cc3835dc1a53a05e88]
-
-Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
----
- chcat/chcat                           | 5 +++--
- semanage/semanage                     | 3 ++-
- semanage/seobject.py                  | 3 ++-
- sepolgen/src/sepolgen/sepolgeni18n.py | 4 +++-
- sepolicy/sepolicy.py                  | 3 ++-
- sepolicy/sepolicy/__init__.py         | 3 ++-
- sepolicy/sepolicy/generate.py         | 3 ++-
- sepolicy/sepolicy/gui.py              | 3 ++-
- sepolicy/sepolicy/interface.py        | 3 ++-
- 9 files changed, 20 insertions(+), 10 deletions(-)
-
-diff --git a/chcat/chcat b/chcat/chcat
-index e779fcc..952cb81 100755
---- a/chcat/chcat
-+++ b/chcat/chcat
-@@ -38,9 +38,10 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
--except ImportError:
-+except:
-     try:
-         import builtins
-         builtins.__dict__['_'] = str
-diff --git a/semanage/semanage b/semanage/semanage
-index 8f4e44a..f45061a 100644
---- a/semanage/semanage
-+++ b/semanage/semanage
-@@ -38,7 +38,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/semanage/seobject.py b/semanage/seobject.py
-index ff8f4e9..0782c08 100644
---- a/semanage/seobject.py
-+++ b/semanage/seobject.py
-@@ -42,7 +42,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/sepolgen/src/sepolgen/sepolgeni18n.py b/sepolgen/src/sepolgen/sepolgeni18n.py
-index 56ebd80..1ff307d 100644
---- a/sepolgen/src/sepolgen/sepolgeni18n.py
-+++ b/sepolgen/src/sepolgen/sepolgeni18n.py
-@@ -19,7 +19,9 @@
- 
- try: 
-     import gettext
--    t = gettext.translation( 'selinux-python' )
-+    t = gettext.translation("selinux-python",
-+                        localedir="/usr/share/locale",
-+                        fallback=True)
-     _ = t.gettext
- except:
-     def _(str):
-diff --git a/sepolicy/sepolicy.py b/sepolicy/sepolicy.py
-index 7ebe0ef..c7a70e0 100755
---- a/sepolicy/sepolicy.py
-+++ b/sepolicy/sepolicy.py
-@@ -36,7 +36,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/sepolicy/sepolicy/__init__.py b/sepolicy/sepolicy/__init__.py
-index 7208234..9c3caa0 100644
---- a/sepolicy/sepolicy/__init__.py
-+++ b/sepolicy/sepolicy/__init__.py
-@@ -31,7 +31,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/sepolicy/sepolicy/generate.py b/sepolicy/sepolicy/generate.py
-index 67189fc..3717d5d 100644
---- a/sepolicy/sepolicy/generate.py
-+++ b/sepolicy/sepolicy/generate.py
-@@ -56,7 +56,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/sepolicy/sepolicy/gui.py b/sepolicy/sepolicy/gui.py
-index b026374..5bdbfeb 100644
---- a/sepolicy/sepolicy/gui.py
-+++ b/sepolicy/sepolicy/gui.py
-@@ -49,7 +49,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
-diff --git a/sepolicy/sepolicy/interface.py b/sepolicy/sepolicy/interface.py
-index 599f97f..43f8644 100644
---- a/sepolicy/sepolicy/interface.py
-+++ b/sepolicy/sepolicy/interface.py
-@@ -38,7 +38,8 @@ try:
-         kwargs['unicode'] = True
-     t = gettext.translation(PROGNAME,
-                     localedir="/usr/share/locale",
--                    **kwargs)
-+                    **kwargs,
-+                    fallback=True)
-     _ = t.gettext
- except:
-     try:
--- 
-2.25.1
-
diff --git a/recipes-security/selinux/selinux-python/fix-sepolicy-install-path.patch b/recipes-security/selinux/selinux-python/fix-sepolicy-install-path.patch
index bd14450..5eb2e54 100644
--- a/recipes-security/selinux/selinux-python/fix-sepolicy-install-path.patch
+++ b/recipes-security/selinux/selinux-python/fix-sepolicy-install-path.patch
@@ -1,4 +1,4 @@ 
-From d43220e336edf8ccaaa7bd3eb9c13874ed34d468 Mon Sep 17 00:00:00 2001
+From 2a0c2489e9d245502e7a9dc5878da01f9d64db2a Mon Sep 17 00:00:00 2001
 From: Xin Ouyang <Xin.Ouyang@windriver.com>
 Date: Mon, 23 Sep 2013 21:17:59 +0800
 Subject: [PATCH] sepolicy: fix install path for new pymodule sepolicy
@@ -13,15 +13,15 @@  Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/sepolicy/Makefile b/sepolicy/Makefile
-index 3361be4..5842321 100644
+index 4e9e93d..512aab5 100644
 --- a/sepolicy/Makefile
 +++ b/sepolicy/Makefile
 @@ -27,7 +27,7 @@ test:
  	@$(PYTHON) test_sepolicy.py -v
  
  install:
--	$(PYTHON) setup.py install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR)` $(PYTHON_SETUP_ARGS)
-+	$(PYTHON) setup.py install --prefix=$(PREFIX) --root=$(DESTDIR) --install-lib=$(PYTHONLIBDIR) --no-compile $(PYTHON_SETUP_ARGS)
+-	$(PYTHON) -m pip install --prefix=$(PREFIX) `test -n "$(DESTDIR)" && echo --root $(DESTDIR) --ignore-installed --no-deps` $(PYTHON_SETUP_ARGS) .
++	$(PYTHON) -m pip install --prefix=$(PREFIX) --root $(DESTDIR) --ignore-installed --no-deps $(PYTHON_SETUP_ARGS) .
  	[ -d $(DESTDIR)$(BINDIR) ] || mkdir -p $(DESTDIR)$(BINDIR)
  	install -m 755 sepolicy.py $(DESTDIR)$(BINDIR)/sepolicy
  	(cd $(DESTDIR)$(BINDIR); ln -sf sepolicy sepolgen)
diff --git a/recipes-security/selinux/selinux-python_3.4.bb b/recipes-security/selinux/selinux-python_3.5.bb
similarity index 79%
rename from recipes-security/selinux/selinux-python_3.4.bb
rename to recipes-security/selinux/selinux-python_3.5.bb
index cc279f2..9ff63db 100644
--- a/recipes-security/selinux/selinux-python_3.4.bb
+++ b/recipes-security/selinux/selinux-python_3.5.bb
@@ -4,19 +4,18 @@  This package contains Python modules sepolgen, sepolicy; And the \
 SELinux utilities audit2allow, chcat, semanage ..."
 SECTION = "base"
 LICENSE = "GPL-2.0-or-later"
-LIC_FILES_CHKSUM = "file://${S}/COPYING;md5=393a5ca445f6965873eca0259a17f833"
+LIC_FILES_CHKSUM = "file://${S}/LICENSE;md5=393a5ca445f6965873eca0259a17f833"
 
 require selinux_common.inc
 
-inherit python3native
+inherit python3targetconfig
 
 SRC_URI += "file://fix-sepolicy-install-path.patch \
-            file://0001-gettext-handle-unsupported-languages-properly.patch \
            "
 
 S = "${WORKDIR}/git/python"
 
-DEPENDS = "libsepol libselinux gettext-native"
+DEPENDS = "libsepol libselinux gettext-native python3-setuptools-scm-native"
 
 RDEPENDS:${PN} = "\
         python3-core \
@@ -96,19 +95,26 @@  FILES:${PN}-sepolgen-ifgen = "\
         ${bindir}/sepolgen-ifgen-attr-helper \
 "
 FILES:${PN}-sepolgen = "\
-        ${libdir}/python${PYTHON_BASEVERSION}/site-packages/sepolgen* \
+        ${PYTHON_SITEPACKAGES_DIR}/sepolgen* \
         ${localstatedir}/lib/sepolgen/perm_map \
 "
 
 FILES:${PN} += "\
-        ${libdir}/python${PYTHON_BASEVERSION}/site-packages/seobject.py* \
-        ${libdir}/python${PYTHON_BASEVERSION}/site-packages/sepolicy*.egg-info \
-        ${libdir}/python${PYTHON_BASEVERSION}/site-packages/sepolicy/* \
+        ${PYTHON_SITEPACKAGES_DIR}/seobject.py* \
+        ${PYTHON_SITEPACKAGES_DIR}/sepolicy*.dist-info \
+        ${PYTHON_SITEPACKAGES_DIR}/sepolicy/* \
 "
 
 do_install() {
     oe_runmake DESTDIR="${D}" \
         PYLIBVER='python${PYTHON_BASEVERSION}' \
-        PYTHONLIBDIR='${libdir}/python${PYTHON_BASEVERSION}/site-packages' \
+        PYTHONLIBDIR='${PYTHON_SITEPACKAGES_DIR}' \
         install
+
+    # Remove .pyc files
+    find ${D} -name *.pyc -delete
+
+    # Fix buildpaths issue
+    sed -i -e 's,${WORKDIR},,g' \
+        ${D}${PYTHON_SITEPACKAGES_DIR}/sepolicy-${PV}.dist-info/direct_url.json
 }