Feedback

type to search

Replacing non interactively a Required Package

Asked by [ Editor ] , Edited by Marco Amadori [ Editor ]

Although my use case is installing upstart in a debian live build system (with a script/hook for live-build package), I wonder if there is a Debian-purest-way to install a package that would end replacing an essential (those with priority: required) package without passing ‘Yes, do as I say!’ in some hackish way.



or Cancel

2 answers

1

rhonda [ Editor ]

I think you might want to take a look at the equivs package which allows you to install an empty package with the name with the only purpose to fulfill dependencies.

Please be aware that you will have to make sure with that approach that you also fulfill all the expectations of other packages from the one you replace, like offering the binaries (if only symlinked to /bin/true or similar) so that they don’t fail on installation or upgrade.

NN comments
marco.amadori
-

Better that I asked directly about the use case, I'm confused. What could I do with equivs that I cannot do with by writing a debian package?

Let's take the upstart package, how can I install it in an unattended way (by a script for example) providing another package (equivs generated or properly built with e.g. dh) ?

sysvinit is required, thus removing it will make it ask for a interactive prompt.

I suspect I'm missing something that could be both deep and easy there, like what I initially thought it would work:

apt-get --option Dpkg::Options::=--force-remove-essential install upstart

But it still ask for typing in the phrase 'Yes, do as I say!' :-(

rhonda
-

With equivs you create an empty sysvinit package with which you replace the one installed in the system. You just need to make sure that at the same time you install your upstart package, otherwise you might run short of /sbin/init and can’t boot into the system anymore.

Installing the (equivs) created sysvinit package gets you rid of its priority and essential hooks, and after you’ve done so you can even remove it. Both of these steps don’t require any interactivity:

echo -e 'Package: sysvinit\nVersion: 2.87' > sysvinit.equivs
equivs-build sysvinit.equivs
sudo dpkg -i sysvinit_ 2.87_all.deb
sudo dpkg --purge sysvinit

And you are done. (space in package name because of otherwise the version would get turned into italics). The version is needed because dpkg has a versioned conflicts on older sysvinit packages.

CAUTION! Doing that will make your system unbootable because of lack of /sbin/init if you don’t do anything else after that! You are warned!

marco.amadori
-
Now I got your, point, really interesting and more general than my solution, which is enough for debian live at build time but not for a real system.

Many thanks!

marco.amadori
-

Do you know why apt-get does not let me to remove this fake package but dpkg it does?

Without the ability of using apt-get my "dpkg --force-remove-essential remove sysvinit" is like your solution but without the need for equivs package.

How apt-get is supposed to retrieve the information about which packages are essential? Not /var/lib/dpkg/available ?

echo -e 'Package: sysvinit\nVersion: 2.90' > sysvinit.equivs

equivs-build sysvinit.equivs

sudo dpkg -i sysvinit_ 2.90_all.deb

sudo apt-get install upstart
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libnih-dbus1 libnih1
The following packages will be REMOVED:
  sysvinit
The following NEW packages will be installed:
  libnih-dbus1 libnih1 upstart
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  sysvinit
0 upgraded, 3 newly installed, 1 to remove and 0 not upgraded.
Need to get 486 kB of archives.
After this operation, 1012 kB of additional disk space will be used.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?]
rhonda
-

I would suspect that apt looks into the package lists it has available and merges the information from there with the dpkg status file content, thus resulting in that behavior.

or Cancel
0

marco.amadori [ Editor ]

What I have found working is doing this in a script:


dpkg --force-remove-essential remove sysvinit
apt-get install upstart

But I miss why apt-get with "Dpkg::Options::=--force-remove-essential" fails in doing it.

NN comments
matteoc
-

Have you tried with force-remove-essential inside /etc/dpkg/dpkg.cfg ?

marco.amadori
-
Does not work either, it permits a direct dpkg -i /path/to/upstart*deb (or dpkg -r), but does not permit apt-get to remove/replace sysvinit. Maybe it is a bug for apt.

or Cancel

Your answer

You need to join Debian to complete this action, click here to do so.