Skip to content

Commit 94b8f4f

Browse files
committed
Switch Docker to UV-bookworm-slim image
1 parent 1109e32 commit 94b8f4f

File tree

4 files changed

+112
-6
lines changed

4 files changed

+112
-6
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ dist/
1010
downloads/
1111
eggs/
1212
.eggs/
13-
lib/
1413
lib64/
1514
parts/
1615
sdist/

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM python:3.13-slim
1+
FROM ghcr.io/astral-sh/uv:python3.13-bookworm-slim
22

33
WORKDIR /app
44

55
# Install Python dependencies
66
COPY requirements.txt .
7-
RUN pip install --no-cache-dir -r requirements.txt \
8-
&& pip install gunicorn # Explicitly ensure gunicorn is installed
7+
RUN uv pip install --system --no-cache-dir -r requirements.txt \
8+
&& uv pip install --system --no-cache-dir gunicorn
99

1010
# Copy application files
1111
COPY app.py .
@@ -17,8 +17,8 @@ COPY templates ./templates
1717
RUN touch lib/__init__.py
1818

1919
# Set environment variables
20-
ENV PYTHONPATH=/app:/app/lib
21-
ENV PORT=5000
20+
ENV PYTHONPATH=/app:/app/lib \
21+
PORT=5000
2222

2323
# Expose the port
2424
EXPOSE 5000

lib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# This file makes the lib directory a Python package

lib/apt_parser.py

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
"""
2+
Core APT repository parsing functionality
3+
"""
4+
5+
class AptParser:
6+
"""
7+
Class for parsing APT repository files
8+
"""
9+
10+
@staticmethod
11+
def parse_release_file(content):
12+
"""
13+
Parse a Release file content into structured data
14+
"""
15+
info = {}
16+
lines = content.split('\n')
17+
current_key = None
18+
current_value = []
19+
20+
for line in lines:
21+
if not line.strip():
22+
continue
23+
24+
if line.startswith(' '):
25+
# Continuation of previous field
26+
if current_key:
27+
current_value.append(line.strip())
28+
else:
29+
# Save previous field if exists
30+
if current_key:
31+
info[current_key] = current_value[0] if len(current_value) == 1 else current_value
32+
current_value = []
33+
34+
# Parse new field
35+
parts = line.split(': ', 1)
36+
if len(parts) == 2:
37+
key, value = parts
38+
current_key = key
39+
current_value = [value.strip()]
40+
41+
# Save last field
42+
if current_key:
43+
info[current_key] = current_value[0] if len(current_value) == 1 else current_value
44+
45+
# Parse special fields into arrays
46+
if 'Architectures' in info:
47+
info['Architectures'] = info['Architectures'].split(' ')
48+
info['Architectures'] = [arch for arch in info['Architectures'] if arch]
49+
50+
if 'Components' in info:
51+
info['Components'] = info['Components'].split(' ')
52+
info['Components'] = [comp for comp in info['Components'] if comp]
53+
54+
return info
55+
56+
@staticmethod
57+
def parse_packages(content):
58+
"""
59+
Parse a Packages file content into structured data
60+
"""
61+
packages = []
62+
blocks = content.split('\n\n')
63+
64+
for block in blocks:
65+
if not block.strip():
66+
continue
67+
68+
pkg = {}
69+
lines = block.split('\n')
70+
71+
for line in lines:
72+
parts = line.split(': ', 1)
73+
if len(parts) != 2:
74+
continue
75+
76+
key, value = parts
77+
value = value.strip()
78+
79+
if key == 'Package':
80+
pkg['name'] = value
81+
elif key == 'Version':
82+
pkg['version'] = value
83+
elif key == 'Filename':
84+
pkg['filename'] = value
85+
86+
if all(k in pkg for k in ['name', 'version', 'filename']):
87+
packages.append(pkg)
88+
89+
return packages
90+
91+
@staticmethod
92+
def build_packages_url(base_url, codename, component, arch):
93+
"""
94+
Build a Packages URL from components
95+
"""
96+
clean_base_url = base_url.rstrip('/')
97+
# Check if the base URL already includes the dists directory
98+
if '/dists/' in clean_base_url:
99+
# Extract the base part before /dists/
100+
base_part = clean_base_url.split('/dists/')[0]
101+
# Check if codename is already in the URL
102+
if f"/dists/{codename}" in clean_base_url:
103+
return f"{clean_base_url}/{component}/binary-{arch}/Packages"
104+
else:
105+
return f"{base_part}/dists/{codename}/{component}/binary-{arch}/Packages"
106+
return f"{clean_base_url}/dists/{codename}/{component}/binary-{arch}/Packages"

0 commit comments

Comments
 (0)