Ref: Arch-Paketierung in separates Skript auslagern und Workflows aktualisieren

This commit is contained in:
2026-08-23 18:52:38 +02:00
parent 24955f75b5
commit 8ef3ad28a0
5 changed files with 81 additions and 187 deletions
+1 -62
View File
@@ -44,68 +44,7 @@ jobs:
- name: Build Arch Linux Package (.pkg.tar.zst)
run: |
python3 - <<'EOF'
import json, os, subprocess, tempfile, time
metadata = json.loads(subprocess.check_output(["cargo", "metadata", "--format-version", "1", "--no-deps"]))
pkg = metadata["packages"][0]
name = pkg["name"]
version = pkg["version"]
description = pkg.get("description", "")
license = pkg.get("license", "")
repository = pkg.get("repository", "")
authors = pkg.get("authors", [])
author = authors[0] if authors else "Unknown"
arch_meta = pkg.get("metadata", {}).get("arch", {})
pkgrel = arch_meta.get("pkgrel", "1")
arch = arch_meta.get("arch", "x86_64")
depends = arch_meta.get("depends", ["gcc-libs", "glibc", "sudo", "docker"])
optdepends = arch_meta.get("optdepends", ["docker-compose: Unterstützung für Docker Compose v1"])
with tempfile.TemporaryDirectory() as build_dir:
bin_dir = os.path.join(build_dir, "usr/bin")
doc_dir = os.path.join(build_dir, f"usr/share/doc/{name}")
lic_dir = os.path.join(build_dir, f"usr/share/licenses/{name}")
os.makedirs(bin_dir, exist_ok=True)
os.makedirs(doc_dir, exist_ok=True)
os.makedirs(lic_dir, exist_ok=True)
subprocess.run(["install", "-m", "755", f"target/release/{name}", f"{bin_dir}/{name}"], check=True)
if os.path.exists("LICENSE"):
subprocess.run(["install", "-m", "644", "LICENSE", f"{lic_dir}/LICENSE"], check=True)
if os.path.exists("README.md"):
subprocess.run(["install", "-m", "644", "README.md", f"{doc_dir}/README.md"], check=True)
installed_size = subprocess.check_output(["du", "-sb", build_dir]).decode().split()[0]
builddate = str(int(time.time()))
pkginfo_lines = [
f"pkgname = {name}",
f"pkgbase = {name}",
f"pkgver = {version}-{pkgrel}",
f"pkgdesc = {description}",
f"url = {repository}",
f"builddate = {builddate}",
f"packager = {author}",
f"size = {installed_size}",
f"arch = {arch}",
f"license = {license}",
]
for dep in depends:
pkginfo_lines.append(f"depend = {dep}")
for optdep in optdepends:
pkginfo_lines.append(f"optdepend = {optdep}")
pkginfo_lines.append("makepkgopt = strip\n")
with open(os.path.join(build_dir, ".PKGINFO"), "w") as f:
f.write("\n".join(pkginfo_lines))
os.makedirs("target/arch", exist_ok=True)
output_file = os.path.abspath(f"target/arch/{name}-{version}-{pkgrel}-{arch}.pkg.tar.zst")
subprocess.run(["tar", "--zstd", "-cf", output_file, ".PKGINFO", "usr"], cwd=build_dir, check=True)
print(f"Arch-Paket erfolgreich erstellt: {output_file}")
EOF
python3 scripts/package-arch.py
- name: Publish Packages to Gitea Package Registry
env:
+1 -62
View File
@@ -44,68 +44,7 @@ jobs:
- name: Build Arch Linux Package (.pkg.tar.zst)
run: |
python3 - <<'EOF'
import json, os, subprocess, tempfile, time
metadata = json.loads(subprocess.check_output(["cargo", "metadata", "--format-version", "1", "--no-deps"]))
pkg = metadata["packages"][0]
name = pkg["name"]
version = pkg["version"]
description = pkg.get("description", "")
license = pkg.get("license", "")
repository = pkg.get("repository", "")
authors = pkg.get("authors", [])
author = authors[0] if authors else "Unknown"
arch_meta = pkg.get("metadata", {}).get("arch", {})
pkgrel = arch_meta.get("pkgrel", "1")
arch = arch_meta.get("arch", "x86_64")
depends = arch_meta.get("depends", ["gcc-libs", "glibc", "sudo", "docker"])
optdepends = arch_meta.get("optdepends", ["docker-compose: Unterstützung für Docker Compose v1"])
with tempfile.TemporaryDirectory() as build_dir:
bin_dir = os.path.join(build_dir, "usr/bin")
doc_dir = os.path.join(build_dir, f"usr/share/doc/{name}")
lic_dir = os.path.join(build_dir, f"usr/share/licenses/{name}")
os.makedirs(bin_dir, exist_ok=True)
os.makedirs(doc_dir, exist_ok=True)
os.makedirs(lic_dir, exist_ok=True)
subprocess.run(["install", "-m", "755", f"target/release/{name}", f"{bin_dir}/{name}"], check=True)
if os.path.exists("LICENSE"):
subprocess.run(["install", "-m", "644", "LICENSE", f"{lic_dir}/LICENSE"], check=True)
if os.path.exists("README.md"):
subprocess.run(["install", "-m", "644", "README.md", f"{doc_dir}/README.md"], check=True)
installed_size = subprocess.check_output(["du", "-sb", build_dir]).decode().split()[0]
builddate = str(int(time.time()))
pkginfo_lines = [
f"pkgname = {name}",
f"pkgbase = {name}",
f"pkgver = {version}-{pkgrel}",
f"pkgdesc = {description}",
f"url = {repository}",
f"builddate = {builddate}",
f"packager = {author}",
f"size = {installed_size}",
f"arch = {arch}",
f"license = {license}",
]
for dep in depends:
pkginfo_lines.append(f"depend = {dep}")
for optdep in optdepends:
pkginfo_lines.append(f"optdepend = {optdep}")
pkginfo_lines.append("makepkgopt = strip\n")
with open(os.path.join(build_dir, ".PKGINFO"), "w") as f:
f.write("\n".join(pkginfo_lines))
os.makedirs("target/arch", exist_ok=True)
output_file = os.path.abspath(f"target/arch/{name}-{version}-{pkgrel}-{arch}.pkg.tar.zst")
subprocess.run(["tar", "--zstd", "-cf", output_file, ".PKGINFO", "usr"], cwd=build_dir, check=True)
print(f"Arch-Paket erfolgreich erstellt: {output_file}")
EOF
python3 scripts/package-arch.py
- name: Publish Packages to Gitea Package Registry
env:
+5
View File
@@ -31,6 +31,8 @@ DockerUpdate/
│ └── workflows/
│ ├── testing.yaml # CI/CD für testing-Branch (Tests, Testing-Packages & Preview-Release)
│ └── main.yaml # CI/CD für main-Branch (Tests, Stable-Packages & Release)
├── scripts/
│ └── package-arch.py # Hilfsskript zur Arch-Linux-Paketerstellung (.pkg.tar.zst)
├── Cargo.toml # Rust-Manifest, Abhängigkeiten und Metadaten für deb / generate-rpm / arch
├── Cargo.lock
├── LICENSE # GPL-3.0 Lizenztext
@@ -103,6 +105,9 @@ cargo deb
# Fedora / RPM-Paket (.rpm) erstellen (benötigt cargo-generate-rpm)
cargo generate-rpm
# Arch Linux-Paket (.pkg.tar.zst) erstellen
python3 scripts/package-arch.py
```
---
+3 -63
View File
@@ -245,7 +245,8 @@ Die Paketkonfiguration und Abhängigkeiten (`sudo`, `docker.io | docker-ce`) sin
### 2. Arch Linux (`.pkg.tar.zst`)
Die Paketmetadaten und Abhängigkeiten für Arch Linux sind direkt in `Cargo.toml` unter `[package.metadata.arch]`
hinterlegt. Das Paket kann nach dem Kompilieren des Release-Builds über das folgende Skript (analog zu CI/CD) erzeugt
hinterlegt. Das Paket kann nach dem Kompilieren des Release-Builds über das Skript `scripts/package-arch.py` (analog zu
CI/CD) erzeugt
werden:
```bash
@@ -253,68 +254,7 @@ werden:
cargo build --release
# Arch Linux-Paket (.pkg.tar.zst) erstellen
python3 - <<'EOF'
import json, os, subprocess, tempfile, time
metadata = json.loads(subprocess.check_output(["cargo", "metadata", "--format-version", "1", "--no-deps"]))
pkg = metadata["packages"][0]
name = pkg["name"]
version = pkg["version"]
description = pkg.get("description", "")
license = pkg.get("license", "")
repository = pkg.get("repository", "")
authors = pkg.get("authors", [])
author = authors[0] if authors else "Unknown"
arch_meta = pkg.get("metadata", {}).get("arch", {})
pkgrel = arch_meta.get("pkgrel", "1")
arch = arch_meta.get("arch", "x86_64")
depends = arch_meta.get("depends", ["gcc-libs", "glibc", "sudo", "docker"])
optdepends = arch_meta.get("optdepends", ["docker-compose: Unterstützung für Docker Compose v1"])
with tempfile.TemporaryDirectory() as build_dir:
bin_dir = os.path.join(build_dir, "usr/bin")
doc_dir = os.path.join(build_dir, f"usr/share/doc/{name}")
lic_dir = os.path.join(build_dir, f"usr/share/licenses/{name}")
os.makedirs(bin_dir, exist_ok=True)
os.makedirs(doc_dir, exist_ok=True)
os.makedirs(lic_dir, exist_ok=True)
subprocess.run(["install", "-m", "755", f"target/release/{name}", f"{bin_dir}/{name}"], check=True)
if os.path.exists("LICENSE"):
subprocess.run(["install", "-m", "644", "LICENSE", f"{lic_dir}/LICENSE"], check=True)
if os.path.exists("README.md"):
subprocess.run(["install", "-m", "644", "README.md", f"{doc_dir}/README.md"], check=True)
installed_size = subprocess.check_output(["du", "-sb", build_dir]).decode().split()[0]
builddate = str(int(time.time()))
pkginfo_lines = [
f"pkgname = {name}",
f"pkgbase = {name}",
f"pkgver = {version}-{pkgrel}",
f"pkgdesc = {description}",
f"url = {repository}",
f"builddate = {builddate}",
f"packager = {author}",
f"size = {installed_size}",
f"arch = {arch}",
f"license = {license}",
]
for dep in depends:
pkginfo_lines.append(f"depend = {dep}")
for optdep in optdepends:
pkginfo_lines.append(f"optdepend = {optdep}")
pkginfo_lines.append("makepkgopt = strip\n")
with open(os.path.join(build_dir, ".PKGINFO"), "w") as f:
f.write("\n".join(pkginfo_lines))
os.makedirs("target/arch", exist_ok=True)
output_file = os.path.abspath(f"target/arch/{name}-{version}-{pkgrel}-{arch}.pkg.tar.zst")
subprocess.run(["tar", "--zstd", "-cf", output_file, ".PKGINFO", "usr"], cwd=build_dir, check=True)
print(f"Arch-Paket erfolgreich erstellt: {output_file}")
EOF
python3 scripts/package-arch.py
# Installation des erstellten Pakets
sudo pacman -U target/arch/docker-update-*.pkg.tar.zst
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
import json
import os
import subprocess
import tempfile
import time
def main():
metadata = json.loads(subprocess.check_output(["cargo", "metadata", "--format-version", "1", "--no-deps"]))
pkg = metadata["packages"][0]
name = pkg["name"]
version = pkg["version"]
description = pkg.get("description", "")
license_name = pkg.get("license", "")
repository = pkg.get("repository", "")
authors = pkg.get("authors", [])
author = authors[0] if authors else "Unknown"
arch_meta = pkg.get("metadata", {}).get("arch", {})
pkgrel = arch_meta.get("pkgrel", "1")
arch = arch_meta.get("arch", "x86_64")
depends = arch_meta.get("depends", ["gcc-libs", "glibc", "sudo", "docker"])
optdepends = arch_meta.get("optdepends", ["docker-compose: Unterstützung für Docker Compose v1"])
with tempfile.TemporaryDirectory() as build_dir:
bin_dir = os.path.join(build_dir, "usr/bin")
doc_dir = os.path.join(build_dir, f"usr/share/doc/{name}")
lic_dir = os.path.join(build_dir, f"usr/share/licenses/{name}")
os.makedirs(bin_dir, exist_ok=True)
os.makedirs(doc_dir, exist_ok=True)
os.makedirs(lic_dir, exist_ok=True)
subprocess.run(["install", "-m", "755", f"target/release/{name}", f"{bin_dir}/{name}"], check=True)
if os.path.exists("LICENSE"):
subprocess.run(["install", "-m", "644", "LICENSE", f"{lic_dir}/LICENSE"], check=True)
if os.path.exists("README.md"):
subprocess.run(["install", "-m", "644", "README.md", f"{doc_dir}/README.md"], check=True)
installed_size = subprocess.check_output(["du", "-sb", build_dir]).decode().split()[0]
builddate = str(int(time.time()))
pkginfo_lines = [
f"pkgname = {name}",
f"pkgbase = {name}",
f"pkgver = {version}-{pkgrel}",
f"pkgdesc = {description}",
f"url = {repository}",
f"builddate = {builddate}",
f"packager = {author}",
f"size = {installed_size}",
f"arch = {arch}",
f"license = {license_name}",
]
for dep in depends:
pkginfo_lines.append(f"depend = {dep}")
for optdep in optdepends:
pkginfo_lines.append(f"optdepend = {optdep}")
pkginfo_lines.append("makepkgopt = strip\n")
with open(os.path.join(build_dir, ".PKGINFO"), "w") as f:
f.write("\n".join(pkginfo_lines))
os.makedirs("target/arch", exist_ok=True)
output_file = os.path.abspath(f"target/arch/{name}-{version}-{pkgrel}-{arch}.pkg.tar.zst")
subprocess.run(["tar", "--zstd", "-cf", output_file, ".PKGINFO", "usr"], cwd=build_dir, check=True)
print(f"Arch-Paket erfolgreich erstellt: {output_file}")
if __name__ == "__main__":
main()