You are not logged in.

#1 2011-08-16 16:16:49

newdave
Member
Registered: 2011-07-06
Posts: 15

[SOLVED] How Pacman Databases Work?

Currently I'm going through the source code of Pacman (for learning purpose) and one thing that utterly confuses me is internal working of Pacman databases. There are two major types of database in my /var/lib/pacman (namely local, sync) which I don't understand their differences. Also, What format is used in sync databases and how can I read them independently from Pacman?

I'd appreciate it if someone could shed some light on the general design of these database or point me to some references ( I was unable to find any).

Last edited by newdave (2011-08-16 18:17:01)

Offline

#2 2011-08-16 16:26:51

Foucault
Member
From: Athens, Greece
Registered: 2010-04-06
Posts: 214

Re: [SOLVED] How Pacman Databases Work?

As far as I know, the local database contains all the metadata (files, dependencies, etc) for the installed packages in your system, whereas the sync databases are a snapshot of the packages available in each repository you have enabled in pacman.conf (I mean the package metadata, not the actual tar.xz packages). The sync databases are updated each time you do pacman -Sy.

Last edited by Foucault (2011-08-16 16:28:04)

Offline

#3 2011-08-16 16:31:23

newdave
Member
Registered: 2011-07-06
Posts: 15

Re: [SOLVED] How Pacman Databases Work?

Foucault wrote:

As far as I know, the local database contains all the metadata (files, dependencies, etc) for the installed packages in your system, whereas the sync databases are a snapshot of the packages available in each repository you have enabled in pacman.conf (I mean the package metadata, not the actual tar.xz packages). The sync databases are updated each time you do pacman -Sy.

Thanks for the reply but I was hoping for a more detailed explanation...

Offline

#4 2011-08-16 16:51:09

Foucault
Member
From: Athens, Greece
Registered: 2010-04-06
Posts: 214

Re: [SOLVED] How Pacman Databases Work?

Well the (sync) databases are basically tar.gzed archives. Copy one in a folder and tar xvfz it to confirm it. There is a great deal of libraries that deal with tarballs; pacman uses libarchive. Regarding the internals, although I have messed around with libalpm a bit, it would be better if someone more involved with the subject replies in order to avoid any confusion. However, you can find the definition and implementation of the database type that is used through pacman and libalpm in the source code of pacman (specifically in the lib/libalpm/db.{c,h} files of the source distribution).

Last edited by Foucault (2011-08-16 16:53:14)

Offline

#5 2011-08-16 16:55:20

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How Pacman Databases Work?

newdave wrote:
Foucault wrote:

As far as I know, the local database contains all the metadata (files, dependencies, etc) for the installed packages in your system, whereas the sync databases are a snapshot of the packages available in each repository you have enabled in pacman.conf (I mean the package metadata, not the actual tar.xz packages). The sync databases are updated each time you do pacman -Sy.

Thanks for the reply but I was hoping for a more detailed explanation...

You mean http://projects.archlinux.org/pacman.gi … ?id=v3.5.0 ?
http://projects.archlinux.org/pacman.gi … 9580a75099

Offline

#6 2011-08-16 17:25:07

newdave
Member
Registered: 2011-07-06
Posts: 15

Re: [SOLVED] How Pacman Databases Work?

Foucault wrote:

Well the (sync) databases are basically tar.gzed archives. Copy one in a folder and tar xvfz it to confirm it. There is a great deal of libraries that deal with tarballs; pacman uses libarchive. Regarding the internals, although I have messed around with libalpm a bit, it would be better if someone more involved with the subject replies in order to avoid any confusion. However, you can find the definition and implementation of the database type that is used through pacman and libalpm in the source code of pacman (specifically in the lib/libalpm/db.{c,h} files of the source distribution).

Now it does make more sense. So basically the database is a tar.gz archive and each package has it's own desc, depends files. But is this really the best design out there? I mean is it the most efficient one?

As to the libalpm, I haven't got to it yet. Pacman is fairly big software ( I think it has more than 20,000 lines of code) and I'm still playing with the frontend part.

Offline

#7 2011-08-16 17:37:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How Pacman Databases Work?

newdave wrote:

Now it does make more sense. So basically the database is a tar.gz archive and each package has it's own desc, depends files. But is this really the best design out there? I mean is it the most efficient one?

No database corruption possible ;P
Define 'efficient' - size, speed, ease of use?

Offline

#8 2011-08-16 17:46:46

newdave
Member
Registered: 2011-07-06
Posts: 15

Re: [SOLVED] How Pacman Databases Work?

karol wrote:
newdave wrote:

Now it does make more sense. So basically the database is a tar.gz archive and each package has it's own desc, depends files. But is this really the best design out there? I mean is it the most efficient one?

No database corruption possible ;P
Define 'efficient' - size, speed, ease of use?

speed and size.

BTW, the links you mentioned didn't provide much insight into what I was looking for.

Offline

#9 2011-08-16 17:55:31

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,648
Website

Re: [SOLVED] How Pacman Databases Work?

As far as speed and size goes, reading directly from the tarball is pretty damn fast (and no-one has show a real database backend to be any more efficient).   The local database format could be improved...

Offline

#10 2011-08-16 18:02:44

newdave
Member
Registered: 2011-07-06
Posts: 15

Re: [SOLVED] How Pacman Databases Work?

Allan wrote:

As far as speed and size goes, reading directly from the tarball is pretty damn fast (and no-one has show a real database backend to be any more efficient).   The local database format could be improved...

I've done some research about other package managers and apparently Redhat uses Berkeley DB for RPM package manager. What do you think of it?

Offline

#11 2011-08-16 18:06:52

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,648
Website

Re: [SOLVED] How Pacman Databases Work?

Overly complex for little gain.

Offline

#12 2011-08-16 18:17:41

Inxsible
Forum Fellow
From: Chicago
Registered: 2008-06-09
Posts: 9,183

Re: [SOLVED] How Pacman Databases Work?

moved to Arch Discussion.


Forum Rules

There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !

Offline

#13 2011-08-16 18:21:31

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How Pacman Databases Work?

I see it's [solved], but there has been some interest in sqlite in the past (from a user, not a dev) https://bugs.archlinux.org/task/8586#comment55711

Offline

#14 2011-08-16 22:09:22

cesura
Package Maintainer (PM)
From: Tallinn, Estonia
Registered: 2010-01-23
Posts: 1,867

Re: [SOLVED] How Pacman Databases Work?

I've just been hacking away at pacman to see if sqlite and a little of my own local db reorganizing will improve efficiency. All without notice of this thread. Weird.

I'll post some patches on pacman-dev if I find anything compelling. wink

Offline

Board footer

Powered by FluxBB