On Tue 26 Oct 2021 at 13:57:13 -0400, Roberto C. Sánchez wrote: > On Tue, Oct 26, 2021 at 10:31:54AM -0700, Han wrote: > > Hi, > > This might be a dumb question: is dpkg installing (or updating) a > > package > > using a .deb file atomic in the event of power outage? > > By atomic, I meant either the new version of the application is fully > > installed, or not at all. Is this always guaranteed? > > I read the `man dpkg` doc, but couldn't find a clear answer. I might have > > missed it though. > > Thanks, > > Han > > It's not a dumb question. The installation of a package might seem, > from the user perspective, like it could be atomic, but it is really > made up of a variety of steps.
Indeed. > Broadly, the package is downloaded, then unpacked, then any included > pre-installation script is executed, the unpacked contents are placed in > their location on the system, and then any included post-installation > script is executed. A power outage at any point in the process could > leave the package in a state where is it is not fully installed. > Though, generally speaking, a situation like that can almost always be > recovered from by a command like 'apt-get install --reinstall <pkg>'. > However, there might circumstances where more advanced techniques might > be required. Assuming that Ctrl-C while dpkg or apt is running is equivalent to a power outage, I have found that running the specific command afterwards is generally successful. -- Brian.