Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/archinstall/lib/packages.py
diff options
context:
space:
mode:
authorAnton Hvornum <anton@hvornum.se>2022-02-02 14:22:52 +0100
committerGitHub <noreply@github.com>2022-02-02 14:22:52 +0100
commitc08520f9902aeb1b4ce22e1159060792081b0327 (patch)
tree934ac279ac0e6d675b409d7936c97ce73d721a6a /archinstall/lib/packages.py
parentdfd064a57f6a0006e9fc614ea229fd9883722085 (diff)
SysCommand() to remove ANSII VT100 Esc codes & archlinux-keyring fix (#933)
* Fixed SysCommandWorker() so that it removes ANSII VT100 escape codes. I also moved package.py into it's own folder, as that's something I want to expand on a lot, so package related stuff should go in there. I created a installed_package() function which gets information about the locally installed package. I changed so that find_packages() and find_package() returns a data-model instead for the package information. This should unify and make sure we detect issues down the line. * Working on structuring .version constructor that works with BaseModel * Added version contructors to VersionDef(). Also added __eq__ and __lt__ to LocalPackage() and PackageSearchResult(). * removed debug and added a TODO * Removed whitespace * Removed mirror-database function from myrepo
Diffstat (limited to 'archinstall/lib/packages.py')
-rw-r--r--archinstall/lib/packages.py66
1 files changed, 0 insertions, 66 deletions
diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py
deleted file mode 100644
index 1d46ef5e..00000000
--- a/archinstall/lib/packages.py
+++ /dev/null
@@ -1,66 +0,0 @@
-import json
-import ssl
-import urllib.error
-import urllib.parse
-import urllib.request
-from typing import Dict, Any
-
-from .exceptions import RequirementError
-
-BASE_URL = 'https://archlinux.org/packages/search/json/?name={package}'
-BASE_GROUP_URL = 'https://archlinux.org/groups/x86_64/{group}/'
-
-
-def find_group(name :str) -> bool:
- ssl_context = ssl.create_default_context()
- ssl_context.check_hostname = False
- ssl_context.verify_mode = ssl.CERT_NONE
- try:
- response = urllib.request.urlopen(BASE_GROUP_URL.format(group=name), context=ssl_context)
- except urllib.error.HTTPError as err:
- if err.code == 404:
- return False
- else:
- raise err
-
- # Just to be sure some code didn't slip through the exception
- if response.code == 200:
- return True
-
-
-def find_package(name :str) -> Any:
- """
- Finds a specific package via the package database.
- It makes a simple web-request, which might be a bit slow.
- """
- ssl_context = ssl.create_default_context()
- ssl_context.check_hostname = False
- ssl_context.verify_mode = ssl.CERT_NONE
- response = urllib.request.urlopen(BASE_URL.format(package=name), context=ssl_context)
- data = response.read().decode('UTF-8')
- return json.loads(data)
-
-
-def find_packages(*names :str) -> Dict[str, Any]:
- """
- This function returns the search results for many packages.
- The function itself is rather slow, so consider not sending to
- many packages to the search query.
- """
- return {package: find_package(package) for package in names}
-
-
-def validate_package_list(packages: list) -> bool:
- """
- Validates a list of given packages.
- Raises `RequirementError` if one or more packages are not found.
- """
- invalid_packages = [
- package
- for package in packages
- if not find_package(package)['results'] and not find_group(package)
- ]
- if invalid_packages:
- raise RequirementError(f"Invalid package names: {invalid_packages}")
-
- return True