NAK/cmnt: [PATCH 1/2][kteam-tools] cranky: chroot: add subcommand to update chroots.
Kleber Souza
kleber.souza at canonical.com
Fri Feb 11 12:53:09 UTC 2022
Hi Zack,
On 1/10/22 15:56, Zachary Tahenakos wrote:
> Convenience command for what create-base and create-session already do if the chroot/session already exists.
>
> Signed-off-by: Zachary Tahenakos <zachary.tahenakos at canonical.com>
> ---
> cranky/cmds.d/chroot | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/cranky/cmds.d/chroot b/cranky/cmds.d/chroot
> index 7cf5d9f1..dfea331e 100755
> --- a/cranky/cmds.d/chroot
> +++ b/cranky/cmds.d/chroot
> @@ -163,6 +163,8 @@ commands:
> Create a base sbuilder chroot for the series of the handle package.
> create-session configs|sources [<handle>]
> Create a session for the requested purpose.
> + update [<handle>]
> + Updates the requested handle's packages.
> map-session configs|sources [<handle>]
> Emit the name of the required session if available.
> run [<handle>] -- command
> @@ -202,7 +204,7 @@ EOF
> cmd="$1"
> shift
> case "$cmd" in
> -create-base)
> +create-base|update)
> if [ "$#" -eq 0 ]; then
> set - "$@" "$PWD"
> elif [ "$#" -ne 1 ]; then
> @@ -290,6 +292,15 @@ create-session)
> session_chroot_create "$series" "amd64" "$src" "$session"
> fi
> ;;
> +update)
> + if base_chroot_available "$series" "amd64"; then
> + chroot_update "$RET"
> + else
> + echo "$P: Chroot does not exist to update" 1>&2
> + echo "Use \"$p create-base\" to create it" 1>&2
> + exit 1
> + fi
> + ;;
All the cranky commands that are run on the chroots they
actually use the session chroot and not the base one.
So the update part above needs to be done in a similar way that
is done when 'create-session' is run, which checks for
'session_chroot_available' instead of 'base_chroot_available'.
The parameters check which is done up above also needs to be
done like the session-related commands, accepting a mandatory
'<sources|configs>' parameter. Currently the value provided
to this parameter doesn't really matter as we map everything
to a "sources" session, but this should be consistent with the
other commands.
Also, I just realized that the way the chroot update is done here
when we run 'cranky chroot create-base' and the base already exists
doesn't really work. Running any command on a base chroot will
create a temporary session which gets destroyed at the end. So this
option is kind of useless :).
Thanks,
Kleber
More information about the kernel-team
mailing list