Compare commits

..

2 Commits

Author SHA1 Message Date
9a1b34b08d remove excess dependencies leaves 2024-06-12 17:08:46 +03:00
e2efe21a8b build: use requests-unixsocket2 fork
Since requests-2.32.0, the http+unix url scheme is brokek, check
https://github.com/msabramo/requests-unixsocket/issues/73 for more
details
2024-06-12 17:08:28 +03:00
7 changed files with 34 additions and 23 deletions

View File

@ -34,9 +34,9 @@ COPY "docker/install-aur-package.sh" "/usr/local/bin/install-aur-package"
## darcs is not installed by reasons, because it requires a lot haskell packages which dramatically increase image size ## darcs is not installed by reasons, because it requires a lot haskell packages which dramatically increase image size
RUN pacman -Sy --noconfirm --asdeps devtools git pyalpm python-cerberus python-inflection python-passlib python-pyelftools python-requests python-srcinfo && \ RUN pacman -Sy --noconfirm --asdeps devtools git pyalpm python-cerberus python-inflection python-passlib python-pyelftools python-requests python-srcinfo && \
pacman -Sy --noconfirm --asdeps base-devel python-build python-flit python-installer python-wheel && \ pacman -Sy --noconfirm --asdeps base-devel python-build python-flit python-installer python-wheel && \
pacman -Sy --noconfirm --asdeps breezy git mercurial python-aiohttp python-boto3 python-cryptography python-jinja python-requests-unixsocket python-systemd rsync subversion && \ pacman -Sy --noconfirm --asdeps breezy git mercurial python-aiohttp python-boto3 python-cryptography python-jinja python-systemd rsync subversion && \
runuser -u build -- install-aur-package python-aioauth-client python-webargs python-aiohttp-apispec-git python-aiohttp-cors \ runuser -u build -- install-aur-package python-aioauth-client python-webargs python-aiohttp-apispec-git python-aiohttp-cors \
python-aiohttp-jinja2 python-aiohttp-session python-aiohttp-security python-aiohttp-jinja2 python-aiohttp-session python-aiohttp-security python-requests-unixsocket2
## FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container ## FIXME since 1.0.4 devtools requires dbus to be run, which doesn't work now in container
COPY "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn" COPY "docker/systemd-nspawn.sh" "/usr/local/bin/systemd-nspawn"

View File

@ -366,7 +366,7 @@ Web application requires the following python packages to be installed:
* Additional web features also require ``aiohttp-apispec`` (autogenerated documentation), ``aiohttp_cors`` (CORS support, required by documentation). * Additional web features also require ``aiohttp-apispec`` (autogenerated documentation), ``aiohttp_cors`` (CORS support, required by documentation).
* In addition, authorization feature requires ``aiohttp_security``, ``aiohttp_session`` and ``cryptography``. * In addition, authorization feature requires ``aiohttp_security``, ``aiohttp_session`` and ``cryptography``.
* In addition to base authorization dependencies, OAuth2 also requires ``aioauth-client`` library. * In addition to base authorization dependencies, OAuth2 also requires ``aioauth-client`` library.
* In addition if you would like to disable authorization for local access (recommended way in order to run the application itself with reporting support), the ``requests-unixsocket`` library is required. * In addition if you would like to disable authorization for local access (recommended way in order to run the application itself with reporting support), the ``requests-unixsocket2`` library is required.
Middlewares Middlewares
^^^^^^^^^^^ ^^^^^^^^^^^

View File

@ -1313,7 +1313,7 @@ How to enable basic authorization
The ``salt`` parameter is optional, but recommended, and can be set to any (random) string. The ``salt`` parameter is optional, but recommended, and can be set to any (random) string.
#. #.
In order to provide access for reporting from application instances you can (the recommended way) use unix sockets by the following configuration (note, that it requires ``python-requests-unixsocket`` package to be installed): In order to provide access for reporting from application instances you can (the recommended way) use unix sockets by the following configuration (note, that it requires ``python-requests-unixsocket2`` package to be installed):
.. code-block:: ini .. code-block:: ini

View File

@ -21,7 +21,7 @@ optdepends=('breezy: -bzr packages support'
'python-aiohttp-session: web server with authorization' 'python-aiohttp-session: web server with authorization'
'python-boto3: sync to s3' 'python-boto3: sync to s3'
'python-cryptography: web server with authorization' 'python-cryptography: web server with authorization'
'python-requests-unixsocket: client report to web server by unix socket' 'python-requests-unixsocket2: client report to web server by unix socket'
'python-jinja: html report generation' 'python-jinja: html report generation'
'python-systemd: journal support' 'python-systemd: journal support'
'rsync: sync by using rsync' 'rsync: sync by using rsync'

View File

@ -81,7 +81,7 @@ web = [
"aiohttp_session", "aiohttp_session",
"aiohttp_security", "aiohttp_security",
"cryptography", "cryptography",
"requests-unixsocket", # required by unix socket support "requests-unixsocket2", # required by unix socket support
"setuptools", # required by aiohttp-apispec "setuptools", # required by aiohttp-apispec
] ]

View File

@ -27,16 +27,16 @@ class FilesystemPackage:
class representing a simplified model for the package installed to filesystem class representing a simplified model for the package installed to filesystem
Attributes: Attributes:
base(str): package base name package_name(str): package name
dependencies(list[str]): list of package dependencies dependencies(list[str]): list of package dependencies
directories(list[Path]): list of directories this package contains directories(list[Path]): list of directories this package contains
files(list[Path]): list of files this package contains files(list[Path]): list of files this package contains
groups(list[str]): list of groups of the package groups(list[str]): list of groups of the package
""" """
base: str package_name: str
groups: list[str] groups: set[str]
dependencies: list[str] dependencies: set[str]
directories: list[Path] = field(default_factory=list) directories: list[Path] = field(default_factory=list)
files: list[Path] = field(default_factory=list) files: list[Path] = field(default_factory=list)
@ -50,3 +50,6 @@ class FilesystemPackage:
bool: True in case if this package must be used for the dependencies calculation or False otherwise bool: True in case if this package must be used for the dependencies calculation or False otherwise
""" """
return "base" not in self.groups return "base" not in self.groups
def __repr__(self):
return f'FilesystemPackage(package_name="{self.package_name}", dependencies={self.dependencies})'

View File

@ -105,16 +105,16 @@ class PackageArchive:
Returns: Returns:
FilesystemPackage: generated pacman package model with empty paths FilesystemPackage: generated pacman package model with empty paths
""" """
package_base, *_ = path.parent.name.rsplit("-", 2) package_name, *_ = path.parent.name.rsplit("-", 2)
try: try:
pacman_package = OfficialSyncdb.info(package_base, pacman=self.pacman) pacman_package = OfficialSyncdb.info(package_name, pacman=self.pacman)
return FilesystemPackage( return FilesystemPackage(
base=package_base, package_name=package_name,
groups=pacman_package.groups, groups=set(pacman_package.groups),
dependencies=pacman_package.depends, dependencies=set(pacman_package.depends),
) )
except UnknownPackageError: except UnknownPackageError:
return FilesystemPackage(base=package_base, groups=[], dependencies=[]) return FilesystemPackage(package_name=package_name, groups=set(), dependencies=set())
def depends_on(self) -> Dependencies: def depends_on(self) -> Dependencies:
""" """
@ -126,7 +126,7 @@ class PackageArchive:
dependencies, roots = self.depends_on_paths() dependencies, roots = self.depends_on_paths()
installed_packages = self.installed_packages() installed_packages = self.installed_packages()
result: dict[str, list[FilesystemPackage]] = {} dependencies_per_path: dict[Path, list[FilesystemPackage]] = {}
for package_base, package in installed_packages.items(): for package_base, package in installed_packages.items():
if package_base in self.package.packages: if package_base in self.package.packages:
continue # skip package itself continue # skip package itself
@ -135,16 +135,24 @@ class PackageArchive:
required_by.extend(library for library in package.files if library.name in dependencies) required_by.extend(library for library in package.files if library.name in dependencies)
for path in required_by: for path in required_by:
result.setdefault(str(path), []).append(package) dependencies_per_path.setdefault(path, []).append(package)
# reduce trees # reduce trees
for path, packages in result.items(): result = {}
root_packages = [ for path, packages in dependencies_per_path.items():
package package_names = [package.package_name for package in packages]
result[str(path)] = [
package.package_name
for package in packages for package in packages
if not any(package.base in other.dependencies for other in packages) # if there is any package which is dependency of this package, we can skip it here
# also skip packages which didn't pass validation
if not package.dependencies.intersection(package_names) and package.is_valid
] ]
if str(path) == 'usr/lib/python3.12/site-packages':
print(package_names)
print(packages)
print(result[str(path)])
return Dependencies(result) return Dependencies(result)
@ -195,6 +203,6 @@ class PackageArchive:
else: else:
package.files.append(entry) package.files.append(entry)
result[package.base] = package result[package.package_name] = package
return result return result