Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #241691 > unrolled thread

is dpkg install atomic?

Started byHan <keepsimple@gmail.com>
First post2021-10-26 20:00 +0200
Last post2021-10-26 22:10 +0200
Articles 5 — 5 participants

Back to article view | Back to linux.debian.user


Contents

  is dpkg install atomic? Han <keepsimple@gmail.com> - 2021-10-26 20:00 +0200
    Re: is dpkg install atomic? Greg Wooledge <greg@wooledge.org> - 2021-10-26 20:00 +0200
    Re: is dpkg install atomic? Roberto C. Sánchez <roberto@debian.org> - 2021-10-26 20:00 +0200
      Re: is dpkg install atomic? Brian <ad44@cityscape.co.uk> - 2021-10-26 20:20 +0200
        Re: is dpkg install atomic? David Wright <deblis@lionunicorn.co.uk> - 2021-10-26 22:10 +0200

#241691 — is dpkg install atomic?

FromHan <keepsimple@gmail.com>
Date2021-10-26 20:00 +0200
Subjectis dpkg install atomic?
Message-ID<DcyKd-6RI-1@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [next] | [standalone]


#241692

FromGreg Wooledge <greg@wooledge.org>
Date2021-10-26 20:00 +0200
Message-ID<DcyTT-6Vg-5@gated-at.bofh.it>
In reply to#241691
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?

No.  A package can be in a "half-installed" state.

unicorn:~$ dpkg -l | head -n3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)

See where it says "Half-inst" in the middle?  If an "H" is shown in
that column, the package is half-installed.

Also, the post-install scripts that most packages use are shell scripts,
so you already know a priori that the script could be interrupted
partway through.

[toc] | [prev] | [next] | [standalone]


#241693

FromRoberto C. Sánchez <roberto@debian.org>
Date2021-10-26 20:00 +0200
Message-ID<DcyTU-6Vg-13@gated-at.bofh.it>
In reply to#241691
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.

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.

Regards,

-Roberto
-- 
Roberto C. Sánchez

[toc] | [prev] | [next] | [standalone]


#241694

FromBrian <ad44@cityscape.co.uk>
Date2021-10-26 20:20 +0200
Message-ID<Dczdf-7hX-1@gated-at.bofh.it>
In reply to#241693
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.

[toc] | [prev] | [next] | [standalone]


#241700

FromDavid Wright <deblis@lionunicorn.co.uk>
Date2021-10-26 22:10 +0200
Message-ID<DcAVH-8nw-7@gated-at.bofh.it>
In reply to#241694
On Tue 26 Oct 2021 at 19:11:50 (+0100), Brian wrote:

> 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.

And it might be worth adding that if apt is downloading a large
package when interrupted, it will continue the download from
wherever it got to, without wasting bandwidth.

Cheers,
David.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web