diff --git a/packaging/arch/mac2ip.install b/packaging/arch/mac2ip.install new file mode 100644 index 0000000..4a31851 --- /dev/null +++ b/packaging/arch/mac2ip.install @@ -0,0 +1,8 @@ +post_install() { + mkdir -p /var/lib/mac2ip + chmod 0777 /var/lib/mac2ip +} + +post_upgrade() { + post_install +} diff --git a/packaging/deb/postinst b/packaging/deb/postinst new file mode 100755 index 0000000..4d8f64f --- /dev/null +++ b/packaging/deb/postinst @@ -0,0 +1,7 @@ +#!/bin/sh +set -e + +mkdir -p /var/lib/mac2ip +chmod 0777 /var/lib/mac2ip + +exit 0 diff --git a/scripts/package-arch.py b/scripts/package-arch.py index d03aeee..2dc3387 100755 --- a/scripts/package-arch.py +++ b/scripts/package-arch.py @@ -87,6 +87,7 @@ def build_package(target_triple=None, target_arch=None, pkgrel=None): depends = arch_meta.get("depends", ["gcc-libs", "glibc"]) optdepends = arch_meta.get("optdepends", []) + install_rel_path = arch_meta.get("install_script") with tempfile.TemporaryDirectory() as build_dir: bin_dir = os.path.join(build_dir, "usr/bin") @@ -102,6 +103,14 @@ def build_package(target_triple=None, target_arch=None, pkgrel=None): if os.path.exists("README.md"): subprocess.run(["install", "-m", "644", "README.md", f"{doc_dir}/README.md"], check=True) + install_scriptlet_name = None + if install_rel_path and os.path.exists(install_rel_path): + install_scriptlet_name = f"{name}.install" + subprocess.run( + ["install", "-m", "644", install_rel_path, os.path.join(build_dir, install_scriptlet_name)], + check=True, + ) + installed_size = subprocess.check_output(["du", "-sb", build_dir]).decode().split()[0] builddate = str(int(time.time())) @@ -117,6 +126,8 @@ def build_package(target_triple=None, target_arch=None, pkgrel=None): f"arch = {arch}", f"license = {license_name}", ] + if install_scriptlet_name: + pkginfo_lines.append(f"install = {install_scriptlet_name}") for dep in depends: pkginfo_lines.append(f"depend = {dep}") for optdep in optdepends: @@ -128,7 +139,11 @@ def build_package(target_triple=None, target_arch=None, pkgrel=None): 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) + tar_members = [".PKGINFO"] + if install_scriptlet_name: + tar_members.append(install_scriptlet_name) + tar_members.append("usr") + subprocess.run(["tar", "--zstd", "-cf", output_file, *tar_members], cwd=build_dir, check=True) print(f"Arch-Paket erfolgreich erstellt: {output_file}")