Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

13 changes: 8 additions & 5 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ Section: misc
Priority: optional
Maintainer: Stefan Davis <stefan@turnkeylinux.org>
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
Expand All @@ -20,7 +24,6 @@ Depends:
python3-debian,
xorriso,
squashfs-tools,
Recommends:
pool,
Suggests:
dd,
Expand Down
2 changes: 1 addition & 1 deletion debian/copyright
Original file line number Diff line number Diff line change
@@ -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
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions fablib/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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
Expand Down
43 changes: 31 additions & 12 deletions fablib/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -256,13 +260,22 @@ def install(


class PoolInstaller(Installer):

_class = "PoolInstaller"

def __init__(
self,
chroot_path: str,
pool_path: str,
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
Expand All @@ -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()):
Expand All @@ -300,22 +317,24 @@ 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

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...")
Expand Down Expand Up @@ -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 = []

Expand Down
37 changes: 24 additions & 13 deletions share/product.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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; \
Expand Down