diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control index b4273a2..695dbaf 100644 --- a/debian/control +++ b/debian/control @@ -3,11 +3,15 @@ Section: misc Priority: optional Maintainer: Stefan Davis Build-Depends: - debhelper (>= 10), - python3-all (>= 3.7~), + debhelper-compat (= 13), + python3 (>= 3.13), + pybuild-plugin-pyproject, + dh-python, python3-debian, - dh-python -Standards-Version: 4.0.0 +Standards-Version: 4.7.2 +Vcs-Git: https://github.com/turnkeylinux/fab.git +Vcs-Browser: https://github.com/turnkeylinux/fab +Rules-Requires-Root: no Package: fab Architecture: all @@ -20,7 +24,6 @@ Depends: python3-debian, xorriso, squashfs-tools, -Recommends: pool, Suggests: dd, diff --git a/debian/copyright b/debian/copyright index 3cdc320..5159429 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,5 +1,5 @@ Copyright (c) 2011-2014 TurnKey GNU/Linux - https://www.turnkeylinux.org -Copyright (c) 2020-2021 TurnKey GNU/Linux - https://www.turnkeylinux.org +Copyright (c) 2020-2026 TurnKey GNU/Linux - https://www.turnkeylinux.org Fab is free software; you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the diff --git a/debian/install b/debian/fab.install similarity index 100% rename from debian/install rename to debian/fab.install diff --git a/fablib/annotate.py b/fablib/annotate.py index 74ec89e..93eb637 100644 --- a/fablib/annotate.py +++ b/fablib/annotate.py @@ -4,7 +4,7 @@ from re import Match from tempfile import TemporaryDirectory -from debian import deb822 +from debian import debfile def parse_plan(plan: str) -> set[str]: @@ -54,7 +54,9 @@ def plan_lint(plan_path: str, pool_path: str) -> str: plan = fob.read().strip() packages = parse_plan(plan) - packages_info: dict[str, str] = get_packages_info(list(packages), pool_path) + packages_info: dict[str, str] = get_packages_info( + list(packages), pool_path, + ) if not packages: column_len = 0 diff --git a/fablib/installer.py b/fablib/installer.py index e0041db..245d4b2 100644 --- a/fablib/installer.py +++ b/fablib/installer.py @@ -16,7 +16,7 @@ from typing import TextIO, cast from chroot import Chroot -from debian import deb822, debfile +from debian import debfile from fablib import common @@ -28,8 +28,10 @@ class Error(Exception): class RevertibleFile: - """File that automatically reverts to previous state on destruction - or if the revert method is invoked""" + """File that automatically reverts to previous state. + + Reverts on destruction or if the revert method is invoked. + """ @staticmethod def _get_orig_path(path: str) -> str: @@ -51,7 +53,7 @@ def __init__(self, path: str) -> None: self._inner = open(path, "w") def revert(self) -> None: - """revert file to original state""" + """Revert file to original state.""" if self.orig_path is not None: assert self.path is not None shutil.move(self.orig_path, self.path) @@ -73,7 +75,7 @@ def __del__(self) -> None: class RevertibleScript(RevertibleFile): - """RevertibleFile that ensures file is executable""" + """RevertibleFile that ensures file is executable.""" def __init__(self, path: str, lines: Iterable[str]) -> None: super().__init__(path) @@ -103,8 +105,10 @@ def __init__( def _get_packages_priority( packages: list[str], ) -> tuple[list[str], list[str]]: - """high priority packages must be installed before regular packages - APT should handle this, but in some circumstances it chokes... + """Sort list of packages into 2 lists of high & regular priority. + + High priority packages must be installed before regular packages, APT + should handle this, but in some circumstances it chokes... """ HIGH_PRIORITY = "linux-image" @@ -256,6 +260,9 @@ def install( class PoolInstaller(Installer): + + _class = "PoolInstaller" + def __init__( self, chroot_path: str, @@ -263,6 +270,12 @@ def __init__( arch: str, environ: dict[str, str] | None = None, ) -> None: + + logging.debug( + f"{self._class}(\n {chroot_path=},\n {pool_path=},\n {arch=}," + f" {environ=}\n)", + ) + super().__init__(chroot_path, environ) from pool_lib import Pool @@ -285,12 +298,16 @@ def sha256sum(path: str) -> str: with open(path, "rb") as fob: return str(hashlib.sha256(fob.read()).hexdigest()) + def sha512sum(path: str) -> str: + with open(path, "rb") as fob: + return str(hashlib.sha512(fob.read()).hexdigest()) + index = [] for package in os.listdir(packagedir): - path = os.path.join(packagedir, package) + path = join(packagedir, package) # dl_path would best be calculated; but we don't # have access to chroot_path here... - dl_path = os.path.join("var/cache/apt/archives", package) + dl_path = join("var/cache/apt/archives", package) if path.endswith(".deb"): control = debfile.DebFile(path).debcontrol() for field in list(control.keys()): @@ -300,6 +317,7 @@ def sha256sum(path: str) -> str: index.append("Size: " + filesize(path)) index.append("MD5sum: " + md5sum(path)) index.append("SHA256: " + sha256sum(path)) + index.append("SHA512: " + sha512sum(path)) index.append("") return index @@ -307,15 +325,16 @@ def sha256sum(path: str) -> str: def install( self, packages: list[str], ignore_errors: list[str] | None = None ) -> None: - """install packages into chroot via pool""" + """Install packages into chroot via pool.""" if ignore_errors is None: ignore_errors = [] + logging.debug(f"{self._class}.install({packages=}, {ignore_errors=})") + print("getting packages...") packagedir = join(self.chroot.path, "var/cache/apt/archives") logger.debug(f"{packagedir=}") - logger.debug(f"{packages=}") self.pool.get(packagedir, packages, strict=True) print("generating package index...") @@ -353,7 +372,7 @@ def __init__( def install( self, packages: list[str], ignore_errors: list[str] | None = None ) -> None: - """install packages into chroot via live apt""" + """Install packages into chroot via live apt.""" if ignore_errors is None: ignore_errors = [] diff --git a/share/product.mk b/share/product.mk index b760843..555c0bc 100755 --- a/share/product.mk +++ b/share/product.mk @@ -13,6 +13,14 @@ $(shell /usr/share/fab/load_env) include /tmp/.build_env +# check if root is overlayfs and warn user +IS_OVERLAY := $(shell [ "$$(findmnt -n -o FSTYPE /)" = "overlay" ] && echo yes) +ifeq ($(IS_OVERLAY),yes) + FREE_RAM := $(shell free -mh | awk '/^Mem:/ {print $$4}') + $(info '/' is overlayfs. Build will fail unless "proper" filesystem is mounted) + $(info [free RAM: $(FREE_RAM)]) +endif + COMMON_PATCHES := turnkey.d $(COMMON_PATCHES) CONF_VARS_BUILTIN ?= FAB_ARCH HOST_ARCH FAB_HTTP_PROXY AMD64 ARM64 RELEASE DISTRO CODENAME DEBIAN UBUNTU KERNEL DEBUG CHROOT_ONLY DI_LIVE_DEBUG @@ -34,10 +42,10 @@ FAB_INSTALL_ENV = $(FAB_CHROOT_ENV) FAB_SHARE_PATH ?= /usr/share/fab BOOTSTRAP ?= $(FAB_PATH)/bootstraps/$(CODENAME)-$(FAB_ARCH) ifneq ("$(wildcard $(FAB_PATH)/altstraps/$(CODENAME)-$(FAB_ARCH).core)", "") -BOOTSTRAP := $(FAB_PATH)/altstraps/$(CODENAME)-$(FAB_ARCH).core + BOOTSTRAP := $(FAB_PATH)/altstraps/$(CODENAME)-$(FAB_ARCH).core endif -ifeq (,"$(wildcard $(BOOTSTRAP)")) -$(error bootstrap $(BOOTSTRAP) not found - download or build it first) +ifeq (,$(wildcard $(BOOTSTRAP))) + $(error bootstrap $(BOOTSTRAP) not found - download or build it first) endif CDROOTS_PATH ?= $(FAB_PATH)/cdroots @@ -49,9 +57,9 @@ MKSQUASHFS_OPTS ?= -no-sparse # we set _CDROOT with eval to improve the readability of $(value _CDROOT) # in help target ifeq ($(shell echo $(CDROOT) | grep ^/), ) -$(eval _CDROOT = $$(CDROOTS_PATH)/$(CDROOT)) + $(eval _CDROOT = $$(CDROOTS_PATH)/$(CDROOT)) else -$(eval _CDROOT = $(CDROOT)) + $(eval _CDROOT = $(CDROOT)) endif COMMON_OVERLAYS_PATH ?= $(FAB_PATH)/common/overlays @@ -80,7 +88,7 @@ CDROOT_OVERLAY ?= cdroot.overlay REMOVELIST ?= removelist # unset REMOVELIST if the file doesn't exist ifeq ($(wildcard $(REMOVELIST)),) -REMOVELIST = + REMOVELIST = endif UNIT_DIRS ?= unit.d @@ -103,19 +111,22 @@ define remove-deck exit 1; \ fi; \ fuser -k $1; \ + for m in run dev/pts dev proc sys; do \ + umount "$1/$m" || true ; \ + done ; \ echo deck -D $1; \ deck -D $1; \ fi endef ifdef CHROOT_ONLY -all: root.sandbox + all: root.sandbox else -ifeq ($(FAB_ARCH_FAMILY),arm) -all: root.sandbox -else -all: $O/product.iso -endif + ifeq ($(FAB_ARCH_FAMILY),arm) + all: root.sandbox + else + all: $O/product.iso + endif endif define mount-deck @@ -222,7 +233,7 @@ define help/body endef ifndef CHROOT_ONLY -help/body += ;\ + help/body += ;\ echo ' cdroot \# created by squashing root.patched into cdroot template + overlay'; \ echo ' product.iso \# product ISO created from the cdroot'; \ echo; \