← Back to team overview

curtin-dev team mailing list archive

Re: [Merge] ~ogayot/curtin:systemd-offline into curtin:master

 


Diff comments:

> diff --git a/curtin/distro.py b/curtin/distro.py
> index 3284b69..18912e2 100644
> --- a/curtin/distro.py
> +++ b/curtin/distro.py
> @@ -280,6 +281,25 @@ def apt_install(mode, packages=None, opts=None, env=None, target=None,
>      if opts is None:
>          opts = []
>  
> +    if systemd_force_offline:
> +        env = env.copy() if env is not None else os.environ.copy()
> +        # To determine if we are running in a chroot, systemd checks if
> +        # /proc/1/root (corresponding to the init process) and / are the same
> +        # inode. If they are different, systemd assumes we are in a chroot.
> +        # However, we are running apt-get in a new PID namespace (with /proc
> +        # properly mounted). This means that in the new namespace, apt-get gets
> +        # assigned PID 1 and is therefore the "init" process.
> +        # When systemd compares /proc/1/root and /, it sees they are identical
> +        # because the init process is actually running in the chroot.
> +        #
> +        # Before we started passing the --mount-proc option to unshare, it was
> +        # working because /proc/1 in the chroot would still refer to the
> +        # systemd init process (running outside the chroot).
> +        #
> +        # With the SYSTEMD_OFFLINE variable, one can "force" systemd to assume
> +        # it is running in a chroot. Let's use it.
> +        env['SYSTEMD_OFFLINE'] = 'true'

> if systemd_force_offline is None and SYSTEMD_OFFLINE set in the environment respect that

I think for consistency if SYSTEMD_OFFLINE is set then we should respect that regardless of the value of systemd_force_offline. What do you think?

fwiw the env parsing happens here https://github.com/systemd/systemd/blob/d3d880e558e608de351c0b518c10953cba2ed0b3/src/basic/parse-util.c#L22 and I think `true` is safe enough.

> +
>      if mode not in ['install', 'upgrade', 'dist-upgrade']:
>          raise ValueError(
>              'Unsupported mode "%s" for apt package install/upgrade' % mode)


-- 
https://code.launchpad.net/~ogayot/curtin/+git/curtin/+merge/462140
Your team curtin developers is subscribed to branch curtin:master.



References