Compare commits
1 Commits
feat/world
...
feat/7zz-c
| Author | SHA1 | Date | |
|---|---|---|---|
| 9d2404d8f6 |
@@ -79,6 +79,39 @@ PYEOF
|
|||||||
COPY --chmod=0755 himalaya-ro.sh /usr/local/bin/himalaya-ro
|
COPY --chmod=0755 himalaya-ro.sh /usr/local/bin/himalaya-ro
|
||||||
|
|
||||||
|
|
||||||
|
# ---------- Install 7-Zip (7zz) for CHM extraction ----------
|
||||||
|
RUN /opt/hermes/.venv/bin/python3 /dev/stdin << 'PYEOF'
|
||||||
|
import urllib.request, tarfile, os, shutil, re, subprocess
|
||||||
|
|
||||||
|
# Scrape 7-zip.org for latest Linux x64 binary link
|
||||||
|
url = 'https://7-zip.org/download.html'
|
||||||
|
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||||
|
r = urllib.request.urlopen(req, timeout=15)
|
||||||
|
html = r.read().decode()
|
||||||
|
match = re.search(r'href="(a/7z[\d]+-linux-x64\.tar\.xz)"', html)
|
||||||
|
if not match:
|
||||||
|
raise RuntimeError('Could not find 7z Linux x64 download link on 7-zip.org')
|
||||||
|
dl_url = f'https://7-zip.org/{match.group(1)}'
|
||||||
|
|
||||||
|
# Follow Himalaya pattern: download, extract, install, verify
|
||||||
|
xz = '/tmp/7z.tar.xz'
|
||||||
|
urllib.request.urlretrieve(dl_url, xz)
|
||||||
|
os.makedirs('/tmp/7z', exist_ok=True)
|
||||||
|
with tarfile.open(xz, 'r:xz') as t:
|
||||||
|
t.extractall('/tmp/7z')
|
||||||
|
shutil.move('/tmp/7z/7zz', '/usr/local/bin/7zz')
|
||||||
|
os.chmod('/usr/local/bin/7zz', 0o755)
|
||||||
|
shutil.rmtree('/tmp/7z', ignore_errors=True)
|
||||||
|
os.remove(xz)
|
||||||
|
|
||||||
|
# Verify
|
||||||
|
result = subprocess.run(['/usr/local/bin/7zz'], capture_output=True, text=True)
|
||||||
|
assert result.returncode == 0, f'7zz verify failed: {result.stderr}'
|
||||||
|
version = result.stdout.split()[2] if result.stdout else 'unknown'
|
||||||
|
print(f'7-Zip {version} installed successfully')
|
||||||
|
PYEOF
|
||||||
|
|
||||||
|
|
||||||
# ---------- Runtime ----------
|
# ---------- Runtime ----------
|
||||||
USER hermes
|
USER hermes
|
||||||
ENV HERMES_HOME=/opt/data
|
ENV HERMES_HOME=/opt/data
|
||||||
|
|||||||
Reference in New Issue
Block a user