Skip to content

Commit

Permalink
Merge setools 4.5.1-2 update
Browse files Browse the repository at this point in the history
  • Loading branch information
fishilico committed Dec 14, 2024
2 parents 9d85bb1 + 6485923 commit 3b4097f
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 7 deletions.
8 changes: 6 additions & 2 deletions setools/.SRCINFO
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pkgbase = setools
pkgdesc = Policy analysis tools for SELinux
pkgver = 4.5.1
pkgrel = 1
pkgrel = 2
url = https://github.com/SELinuxProject/setools/wiki
arch = i686
arch = x86_64
Expand All @@ -10,7 +10,9 @@ pkgbase = setools
license = GPL
license = LGPL
checkdepends = checkpolicy
checkdepends = pyside6
checkdepends = python-pytest
checkdepends = python-pytest-qt
makedepends = cython
makedepends = python-tox
depends = libsepol>=3.2
Expand All @@ -21,9 +23,11 @@ pkgbase = setools
optdepends = python-graphviz: for seinfoflow, sedta, apol
optdepends = python-pyqt6: needed for graphical tools
optdepends = qt6-tools: display apol help with Qt Assistant
provides = selinux-setools=4.5.1-1
provides = selinux-setools=4.5.1-2
conflicts = selinux-setools
source = https://github.com/SELinuxProject/setools/releases/download/4.5.1/setools-4.5.1.tar.bz2
source = 0001-setup.py-Move-static-definitions-to-pyproject.toml.patch
sha256sums = 25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7
sha256sums = 27fd3673709767038fcd5253f13a057dac48b5c6884e07507ff3f1461223cd21

pkgname = setools
222 changes: 222 additions & 0 deletions setools/0001-setup.py-Move-static-definitions-to-pyproject.toml.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
From 2661b1af6d76a5c3c2fd2035b1f86314a1c10470 Mon Sep 17 00:00:00 2001
From: Chris PeBenito <[email protected]>
Date: Mon, 22 Apr 2024 12:07:48 -0400
Subject: [PATCH] setup.py: Move static definitions to pyproject.toml.

Signed-off-by: Chris PeBenito <[email protected]>

Upstream commits
https://github.com/SELinuxProject/setools/commit/2661b1af6d76a5c3c2fd2035b1f86314a1c10470
and
https://github.com/SELinuxProject/setools/commit/5718140bfe41f22bb2a5010168fa4aaa02e759fe
---
pyproject.toml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++-
setup.py | 37 +++-------------------------
2 files changed, 67 insertions(+), 35 deletions(-)

diff --git a/pyproject.toml b/pyproject.toml
index 08e61a330442..37e8226f4609 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,7 +1,70 @@
[build-system]
-requires = ["setuptools", "Cython>=0.27"]
+# setup also requires libsepol and libselinux
+# C libraries and headers to compile.
+requires = ["setuptools", "Cython>=0.29.14"]
build-backend = "setuptools.build_meta"

+[project]
+name = "setools"
+version = "4.6.0.dev"
+description="SELinux policy analysis tools."
+authors = [{name = "Chris PeBenito", email="[email protected]"}]
+readme = {file = "README.md", content-type = "text/markdown"}
+urls.Homepage = "https://github.com/SELinuxProject/setools"
+urls.Repository = "https://github.com/SELinuxProject/setools.git"
+urls."Bug Tracker" = "https://github.com/SELinuxProject/setools/issues"
+
+keywords = ["SELinux",
+ "SETools",
+ "policy",
+ "analysis",
+ "seinfo",
+ "sesearch",
+ "sediff",
+ "sedta",
+ "seinfoflow",
+ "apol"]
+
+# https://pypi.org/classifiers/
+classifiers = ["Development Status :: 5 - Production/Stable",
+ "Environment :: Console",
+ "Environment :: X11 Applications :: Qt",
+ "Intended Audience :: Information Technology",
+ "License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
+ "License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
+ "Programming Language :: Cython",
+ "Topic :: Security",
+ "Topic :: Utilities",
+ "Typing :: Typed"]
+
+requires-python=">=3.10"
+# also requires libsepol.so and libselinux.so.
+dependencies = ["setuptools"]
+
+optional-dependencies.analysis = ["networkx>=2.6",
+ "pygraphviz"]
+optional-dependencies.gui = ["PyQt6"]
+optional-dependencies.test = ["tox"]
+
+[tool.setuptools]
+include-package-data = false
+script-files = ["apol",
+ "sediff",
+ "seinfo",
+ "seinfoflow",
+ "sesearch",
+ "sedta",
+ "sechecker"]
+
+[tool.setuptools.packages.find]
+include = ["setools*"]
+
+[tool.setuptools.package-data]
+"*" = ["*.css", "*.html", "perm_map", "py.typed"]
+
+[tool.setuptools.exclude-package-data]
+"*" = ["*.c", "*.pyi", "*.pyx"]
+

#
# Coverage config
diff --git a/setup.py b/setup.py
index b2245ac7f33f..0b8e3e96d89e 100644
--- a/setup.py
+++ b/setup.py
@@ -1,37 +1,34 @@
#!/usr/bin/env python3

-import glob
-from setuptools import Extension, setup
import sys
import os
-from os.path import join
-from contextlib import suppress
+import glob
+from pathlib import Path
+
+from setuptools import Extension, setup
from Cython.Build import cythonize
-import os.path


# Library linkage
-lib_dirs = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
-include_dirs = []
+lib_dirs: list[str] = ['.', '/usr/lib64', '/usr/lib', '/usr/local/lib']
+include_dirs: list[str] = []

-with suppress(KeyError):
- userspace_src = os.environ["USERSPACE_SRC"]
- include_dirs.insert(0, userspace_src + "/libsepol/include")
- include_dirs.insert(1, userspace_src + "/libselinux/include")
- lib_dirs.insert(0, userspace_src + "/libsepol/src")
- lib_dirs.insert(1, userspace_src + "/libselinux/src")
+userspace_src = os.getenv("USERSPACE_SRC", "")
+if userspace_src:
+ userspace_path = Path(userspace_src)
+ include_dirs.insert(0, str(userspace_path / "libsepol/include"))
+ include_dirs.insert(1, str(userspace_path / "libselinux/include"))
+ lib_dirs.insert(0, str(userspace_path / "libsepol/src"))
+ lib_dirs.insert(1, str(userspace_path / "libselinux/src"))

-if sys.platform.startswith('darwin'):
- macros=[('DARWIN',1)]
-else:
- macros=[]
+macros: list[tuple[str, str | int]] = [('DARWIN',1)] if sys.platform.startswith('darwin') else []

# Code coverage. Enable this to get coverage in the cython code.
-enable_coverage = bool(os.environ.get("SETOOLS_COVERAGE", False))
+enable_coverage = bool(os.getenv("SETOOLS_COVERAGE", ""))
if enable_coverage:
macros.append(("CYTHON_TRACE", 1))

-cython_annotate = bool(os.environ.get("SETOOLS_ANNOTATE", False))
+cython_annotate = bool(os.getenv("SETOOLS_ANNOTATE", ""))

ext_py_mods = [Extension('setools.policyrep', ['setools/policyrep.pyx'],
include_dirs=include_dirs,
@@ -53,53 +50,26 @@ ext_py_mods = [Extension('setools.policyrep', ['setools/policyrep.pyx'],
'-Wwrite-strings',
'-fno-exceptions'])]

-installed_data = [('share/man/man1', glob.glob("man/*.1"))]
-
-linguas = ["ru"]
-
-with suppress(KeyError):
- linguas = os.environ["LINGUAS"].split(" ")
+linguas: set[Path] = set(Path(p) for p in os.getenv("LINGUAS", "").split(" ") if p)
+if not linguas:
+ linguas.add(Path("ru"))
+linguas.add(Path("."))

+base_source_path = Path("man") # below source root
+base_target_path = Path("share/man") # below prefixdir, usually /usr or /usr/local
+installed_data = list[tuple]()
for lang in linguas:
- if lang and os.path.exists(join("man", lang)):
- installed_data.append((join('share/man', lang, 'man1'), glob.glob(join("man", lang, "*.1"))))
+ source_path = base_source_path / lang
+ if source_path.exists():
+ for i in range(1, 9):
+ installed_data.append((base_target_path / lang / f"man{i}",
+ glob.glob(str(source_path / f"*.{i}"))))

-setup(name='setools',
- version='4.5.1',
- description='SELinux policy analysis tools.',
- author='Chris PeBenito',
- author_email='[email protected]',
- url='https://github.com/SELinuxProject/setools',
- packages=['setools', 'setools.checker', 'setools.diff', 'setoolsgui', 'setoolsgui.widgets',
- 'setoolsgui.widgets.criteria', 'setoolsgui.widgets.details',
- 'setoolsgui.widgets.models', 'setoolsgui.widgets.views'],
- scripts=['apol', 'sediff', 'seinfo', 'seinfoflow', 'sesearch', 'sedta', 'sechecker'],
- data_files=installed_data,
- package_data={'': ['*.css', '*.html'],
- 'setools': ['perm_map', 'policyrep.pyi', 'py.typed']},
+# see pyproject.toml for most package options.
+setup(data_files=installed_data,
ext_modules=cythonize(ext_py_mods, include_path=['setools/policyrep'],
annotate=cython_annotate,
compiler_directives={"language_level": 3,
"c_string_type": "str",
"c_string_encoding": "ascii",
- "linetrace": enable_coverage}),
- test_suite='tests',
- license='GPLv2+, LGPLv2.1+',
- classifiers=[
- 'Environment :: Console',
- 'Environment :: X11 Applications :: Qt',
- 'Intended Audience :: Information Technology',
- 'Topic :: Security',
- 'Topic :: Utilities',
- ],
- keywords='SELinux SETools policy analysis tools seinfo sesearch sediff sedta seinfoflow apol',
- python_requires='>=3.10',
- # setup also requires libsepol and libselinux
- # C libraries and headers to compile.
- setup_requires=['setuptools', 'Cython>=0.29.14'],
- install_requires=['setuptools'],
- extras_require={
- "analysis": ["networkx>=2.6", "pygraphviz"],
- "test": "tox"
- }
- )
+ "linetrace": enable_coverage}))
--
2.46.0

20 changes: 15 additions & 5 deletions setools/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

pkgname=setools
pkgver=4.5.1
pkgrel=1
pkgrel=2
pkgdesc="Policy analysis tools for SELinux"
groups=('selinux')
arch=('i686' 'x86_64' 'aarch64')
Expand All @@ -30,11 +30,19 @@ optdepends=('python-graphviz: for seinfoflow, sedta, apol'
'python-pyqt6: needed for graphical tools'
'qt6-tools: display apol help with Qt Assistant')
makedepends=('cython' 'python-tox')
checkdepends=('checkpolicy' 'python-pytest')
checkdepends=('checkpolicy' 'pyside6' 'python-pytest' 'python-pytest-qt')
conflicts=("selinux-${pkgname}")
provides=("selinux-${pkgname}=${pkgver}-${pkgrel}")
source=("https://github.com/SELinuxProject/setools/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2")
sha256sums=('25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7')
source=("https://github.com/SELinuxProject/setools/releases/download/${pkgver}/${pkgname}-${pkgver}.tar.bz2"
0001-setup.py-Move-static-definitions-to-pyproject.toml.patch
)
sha256sums=('25e47d00bbffd6046f55409c9ba3b08d9b1d5788cc159ea247d9e0ced8e482e7'
'27fd3673709767038fcd5253f13a057dac48b5c6884e07507ff3f1461223cd21')

prepare() {
cd "${pkgname}"
patch -Np1 -i "../0001-setup.py-Move-static-definitions-to-pyproject.toml.patch"
}

build() {
cd "${pkgname}"
Expand All @@ -44,7 +52,9 @@ build() {

check() {
cd "${pkgname}"
python setup.py test
# Instructions from https://github.com/SELinuxProject/setools/blob/4.5.1/README.md#unit-tests
python setup.py build_ext -i
pytest tests
}

package() {
Expand Down

0 comments on commit 3b4097f

Please sign in to comment.