Score:0

An apt-get command to install libgdbm5 OR libgdbm6

ng flag

I wrote some install instructions involving the command

apt-get install libgdbm5

...but newer ubuntu versions only have libgdbm6 (focal onwards I think)

Clearly I could write out different instructions for different versions, but is there easy way to write this command so that it would run on either ubuntu version and install whichever of the two packages is available?

I wondered if apt-get install libgdbm might be provided as some sort of useful alias, but no. Doesn't exist.

I wondered if apt-get install libgdbm* would do something useful. That sort of works, but installs various other packages with the same prefix.

I saw this question but that's not asking about packages with number suffixes in the name.

Knud Larsen avatar
by flag
`$ wget http://de.archive.ubuntu.com/ubuntu/pool/main/g/gdbm/libgdbm5_1.14.1-6_amd64.deb` ... and install with `sudo dpkg -i libgdbm5_1.14.1-6_amd64.deb` (No dependencies / no conflicts.)
nobody avatar
gh flag
libgdm* will be installed over metapackage ubuntu-standart as dependence
Score:1
in flag

...but newer ubuntu versions only have libgdbm6

Indeed: according to https://packages.ubuntu.com/search?keywords=libgdbm5 , libgdm5 is only available in Bionic (18.04LTS), whereas libgdm6 (See https://packages.ubuntu.com/search?keywords=libgdbm6) is available in Focal (20.04LTS), Groovy (20.10) and Hirsuite (21.04).

Consequently, the Focal/Groovy/Hirsuite package repositorios shouldn't have any package that depends on libgdbm5 (or on any non-available package, for that matter).

If you do not have the Bionic repositories configured in your APT instance, there's no way you can install libgdm5, no matter package aliases or virtual (provided) packages.

An approach here would be to add a Bionic repository to yor APT configuration. I suggest you do that by creating a /etc/apt/sources.list.d/bionic.list file and having the relevant deb repo configuration there. The one-liner to achieve this would be

sudo echo "deb http://in.archive.ubuntu.com/ubuntu/ bionic main restricted universe" > /etc/apt/sources.list.d/bionic.list

...followed by apt-get update and apt-get install libgdbm6.

Also remember that, by default, the repositories for your release should have priority over any other repositories defined in /etc/apt/sources.list.d. Do read https://wiki.debian.org/AptConfiguration to have a better idea of how repository priorities work.

Score:1
cn flag

"[I]s there easy way to write this command so that it would run on either ubuntu version and install whichever of the two packages is available?"

You should not be explicitly installing libs anyway. You should be installing the applications, and letting apt figure out the dependencies. That's what apt is for.

NO:  sudo apt install python3-gdbm libgdbm6
YES: sudo apt install python3-gdbm
  • Specifying libs will apt-mark them as "manual", which may break future release-upgrades...or leave old, unused libs dangling around on your system needlessly.

If you still really want specify libs, you must test for the available version first in your script.

$ apt list libgdbm6
Listing... Done
libgdbm6/hirsute,now 1.19-2 amd64 [installed,automatic]

$ dpkg -l | grep libgdbm6
ii  libgdbm6:amd64                             1.19-2                                                              
amd64        GNU dbm database routines (runtime version) 

$ apt list libgdbm5
Listing... Done
$ 

$ dpkg -l | grep libgdbm5
$ 
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.