Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Hvornum <anton.feeds+github@gmail.com>2020-09-15 11:14:58 +0000
committerAnton Hvornum <anton.feeds+github@gmail.com>2020-09-15 11:14:58 +0000
commitd44c671661707282e6ec06dc4a0c0cafb8ba19aa (patch)
tree147d0e3fd267580f32705c3fb3b74827e73940d1
parenteb4b0f09efb066974f23a5c702c9ed461f329604 (diff)
Adding package search via upstream package database and JSON.
-rw-r--r--archinstall/lib/packages.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/archinstall/lib/packages.py b/archinstall/lib/packages.py
new file mode 100644
index 00000000..3a671784
--- /dev/null
+++ b/archinstall/lib/packages.py
@@ -0,0 +1,27 @@
+import urllib.request, urllib.parse
+import ssl, json
+
+BASE_URL = 'https://www.archlinux.org/packages/search/json/?name={package}'
+
+def find_package(name):
+ """
+ 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):
+ """
+ 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.
+ """
+ result = {}
+ for package in names:
+ result[package] = find_package(package)
+ return result \ No newline at end of file