The current `package-upgrade' from package.el delete old package before installing the new one. This can be problematic if the user interrupt the process or if there is some network problems. Since `package-install' allow the same package to be installed if the argument is of `package-desc' type. We can use this to make package upgrade atomic by deferring `package-delete'. Related thread: https://lists.gnu.org/archive/html/emacs-devel/2023-07/msg00887.html ================================ In GNU Emacs 29.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38,  cairo version 1.16.0) of 2023-07-25 built on sid Repository revision: 906ecf442c43da98e6b8c7488f549691901690e9 Repository branch: emacs-29 Windowing system distributor 'The X.Org Foundation', version 11.0.12101007 System Description: Debian GNU/Linux trixie/sid Configured using:  'configure --prefix=/usr/local --program-suffix=29  --build=amd64-linux-gnu --enable-gtk-deprecation-warnings  --enable-check-lisp-object-type --with-json --with-x-toolkit=gtk3  --with-xwidgets --with-x --with-mailutils --with-imagemagick  --with-native-compilation --with-file-notification=inotify  --with-tree-sitter'