Skip to content

Commit

Permalink
ref: make arch stuff sustainable
Browse files Browse the repository at this point in the history
  • Loading branch information
ook37 committed Jan 10, 2025
1 parent 8c61af2 commit 2c45562
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,31 @@ class LiteralString(str): pass

def adjust_architectures(architectures):
if "any" in architectures:
return ["amd64", "arm64"]
return [arch for arch in valid_architectures if arch not in {"all", "any"}]
return architectures

def get_api_data(pkg_name):
response = requests.get(f"https://pacstall.dev/api/packages/{pkg_name}")
if response.status_code != 200:
print(f"Error: Failed to fetch data for package '{pkg_name}'")
return

api_data = response.json()
last_updated = api_data.get("lastUpdatedAt")
archopts = api_data.get("architectures")

archarr = []
if "arm64" in archopts or "aarch64" in archopts:
archarr.append("arm64")
if "amd64" in archopts or "x86_64" in archopts:
archarr.append("amd64")
if "all" in archopts:
archarr = ["all"]
elif "any" in archopts:
archarr = ["any"] + adjust_architectures(archopts)

return last_updated, archarr

def load_database():
if os.path.exists(DATABASE_FILE):
with open(DATABASE_FILE, "r") as f:
Expand Down Expand Up @@ -166,27 +188,6 @@ def gen_workflows():
for package_name, package_data in packages.items():
gen_workflow(package_name, package_data)

def get_api_data(pkg_name):
response = requests.get(f"https://pacstall.dev/api/packages/{pkg_name}")
if response.status_code != 200:
raise ValueError(f"Failed to fetch data for package '{pkg_name}'")

api_data = response.json()
last_updated = api_data.get("lastUpdatedAt")
archopts = api_data.get("architectures")

archarr = []
if "arm64" in archopts or "aarch64" in archopts:
archarr.append("arm64")
if "amd64" in archopts or "x86_64" in archopts:
archarr.append("amd64")
if "all" in archopts:
archarr = ["all"]
elif "any" in archopts:
archarr = ["any"] + adjust_architectures(archopts)

return last_updated, archarr

def alter_package(name, distros, architectures, overflow=5):
data = load_database()
package_exists = name in data
Expand Down

0 comments on commit 2c45562

Please sign in to comment.