diff --git a/.gitignore b/.gitignore index 12cdd16..2b6343d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,7 @@ tmp *.pyo *.tar.bz2 .mypy_cache +.ruff_cache __pycache__ tags +fab.egg-info/ diff --git a/contrib/fab-rewind b/contrib/fab-rewind index adcbe0a..834f36c 100755 --- a/contrib/fab-rewind +++ b/contrib/fab-rewind @@ -68,7 +68,6 @@ undeck() { stop_services "$targ" if [[ "$targ" == "cdroot" ]]; then rm -rf build/product.iso - rm -rf "build/$targ" else deck -D "build/$targ" fi @@ -93,6 +92,7 @@ mount_if_not_mounted() { fi } +# cdroot is not a deck - but 'undeck' handles it anyway undeck cdroot undeck root.sandbox diff --git a/debian/control b/debian/control index 8b0c6aa..b4273a2 100644 --- a/debian/control +++ b/debian/control @@ -18,10 +18,10 @@ Depends: ${shlibs:Depends}, turnkey-chroot, python3-debian, - pool -Recommends: xorriso, - squashfs-tools + squashfs-tools, +Recommends: + pool, Suggests: dd, wodim, diff --git a/fab b/fab index a0e30b6..e5a5ae8 100755 --- a/fab +++ b/fab @@ -197,6 +197,19 @@ def cmd_chroot( environ["USER"] = "root" environ["UID"] = "0" environ["EUID"] = "0" + + os_environ_debug = "\n".join( + sorted([f" {k}: {v}" for k, v in os.environ.items()]) + ) + chr_environ_debug = "\n".join( + sorted([f" {k}: {v}" for k, v in environ.items()]) + ) + logger.debug( + "cmd_chroot()" + f"\nchroot = Chroot({chroot_path}, {environ=})" + f"\n\nfull env:\n---------\n{os_environ_debug}" + f"\n\nchroot env:\n-----------\n{chr_environ_debug}" + ) chroot = Chroot(chroot_path, environ=environ) if not script_args and not script_path_raw: diff --git a/fablib/annotate.py b/fablib/annotate.py index 19ac143..74ec89e 100644 --- a/fablib/annotate.py +++ b/fablib/annotate.py @@ -4,7 +4,7 @@ from re import Match from tempfile import TemporaryDirectory -from debian import debfile +from debian import deb822 def parse_plan(plan: str) -> set[str]: diff --git a/fablib/installer.py b/fablib/installer.py index d1c3743..e0041db 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 debfile +from debian import deb822, debfile from fablib import common diff --git a/share/load_env b/share/load_env new file mode 100755 index 0000000..7b9b425 --- /dev/null +++ b/share/load_env @@ -0,0 +1,103 @@ +#!/bin/bash +# This script is called by /usr/share/fab/product.mk. +# It sets the needed environment variables once, so make doesn't need to keep +# recalculating them + + +_echo() { + # Because we call this script directly from the top of the make file/s, + # make will expect anything sent to stdout to be valid make commands. + # However stderr is ignored by make, so ALL output to users needs to be + # sent to stderr. + echo "$*" >&2 +} +fatal() { _echo "Fatal: $*"; exit 1; } + +[[ -n "$FAB_PATH" ]] || fatal "FAB_PATH not set - required for default paths" + +if [[ -z "$RELEASE" ]]; then + _distro="$(lsb_release -si)" + DISTRO="${_distro,,}" + CODENAME="$(lsb_release -sc)" + RELEASE="$DISTRO/$CODENAME" + _echo "RELEASE not set - falling back to system: $RELEASE" +else + DISTRO="$(dirname "$RELEASE")" + CODENAME="$(basename "$RELEASE")" +fi + +DEBIAN= +UBUNTU= +case $DISTRO in + debian) + DEBIAN=y;; + ubuntu) + UBUNTU=y;; + *) + fatal "Distro '$DISTRO' not supported" +esac + +AMD64= +ARM64= +FAB_ARCH_FAMILY= +if [[ -z "$FAB_ARCH" ]]; then + FAB_ARCH="$(dpkg --print-architecture)" + _echo "FAB_ARCH not set - falling back to system: $FAB_ARCH" +fi +case $FAB_ARCH in + amd64) + AMD64=y + FAB_ARCH_FAMILY=x86 + ;; + arm64) + ARM64=y + FAB_ARCH_FAMILY=arm + ;; + *) + fatal "Architecture '$FAB_ARCH' not supported" + ;; +esac + +if [[ -n "$FAB_POOL" ]]; then + FAB_POOL_PATH="$FAB_PATH/pools/$CODENAME" + FAB_INSTALL_OPTS="$FAB_INSTALL_OPTS --no-deps" +fi + +if [[ "${NO_PROXY,,}" == "true" ]]; then + _echo "NO_PROXY set - disabling caching proxies" + FAB_HTTP_PROXY= + FAB_HTTPS_PROXY= +else + [[ -n "$FAB_HTTP_PROXY" ]] || _echo "Warning - FAB_HTTP_PROXY not set" + [[ -n "$FAB_HTTPS_PROXY" ]] || _echo "Warning - FAB_HTTPS_PROXY not set" +fi + +cat > /tmp/.build_env <