Passing gas. Kicking ass. Walking the roads less traveled. All for positive change.
A Hint From Fate And A Man Page
March 5, 2012Posted by on
First and foremost I apologize for not updating this in a while. An update on what happened on the expedition I said I’d attempt last time is coming. That and an explanation for the delay.
In the mean time a totally non expedition related post. As you folks know I’m a fanatical distrohopper and tinkerer.
Now those of you not completely dumbed down by prolonged windows use know that software/package management is actually a very interesting/complicated/subtle craft that way too many operating systems and package managers completely fuck up. Yes yum, zypper, urpmi, portage, equo, slackpkg, slapt-get, pkg_*, apt-rpm I’m looking at you. As for windows software/package management there if you can even call it that is anarchy. Well okay that’s not strictly true but it’s far from a lie.
There are three package managers that stand out in that they don’t immediately wanna kill myself. APT(which incidentally barely qualifies to be listed here as it’s a hacked together piece of shit, but compared to the competition…), MacPorts, and Pacman. Now Pacman which is arguably the best of them all while awesome had one very big security problem: lack of package signing. Thankfully that’s very very recently changed. However a couple of years ago before that the whole thing didn’t sit too well with a dude named Miklos Vajna who decided for various reasons to make a Slackware fork. Now slackpkg is a disgrace. No dependency resolution whatsoever and kind of slow because it’s a shell script. Vajna needed a good package manager for Frugalware as he called his new distro. Thus he looked to Pacman. He made a fork called Pacman-G2 which had package signing. Also contributed some other patches to help improve Pacman nice guy that he was. Arch unlike Slackware accepted his contributions. Good to see badasses get their due respect once in a while.
Anyway I recently found in APT what is at best poor documentation and at worst a bug depending on how you look at it(long story, if you care look up “aptitude purge <package> recursively removes but does not purge <package>”). Hopefully the devs will implement my suggestions. Back to the point afterwards I started going on one of my geek out sessions looking at how some package managers work and at times even auditing some relevant source code(granted with limited understand as due to their sheer size auditing source archives of modern programs is no easy task).
So the next thing I know I’m playing around with FwLive XFCE Edition, Frugalware’s live CD. Frugalware is a very interesting distro with a nice simple/sane way of doing things and I’m glad I got to play with it. It has a lot of promise and look out for it reaching Debian’s level of popularity. Now pacman-g2 is very similar to pacman but not exactly as I soon found out. I thus go looking for the man page. OK the live CD doesn’t have. I don’t know why. Maybe it’s something to do with conserving space on the live CD but then there were like 250 more megabytes free. At any rate when you don’t have the relavent man page you use Google or DuckDuckGo. You can find the man page to just about anything that way. Anything except pacman-g2. Granted Frugalware is a fringe distro and certainly isn’t as known as say Ubuntu, but you’d think there’d be a man page online somewhere. No luck. Thus in a wild attempt to get the man page I ran “pacman-g2 -Syy && pacman-g2 -Su && pacman-g2 -S pacman-g2”. Finally I hit paydirt. Of course then I was thinking since nobody else posted it online why not I? Perhaps it can help someone. But where to post it? I hardly have write permissions to manpagez.com:/var/www. Thus I temporarily gave up on the idea partly because a good distro maintainer takes a hint from the likes of FreeBSD and has well written colorful man pages on their site.
Now today as usual I was on distrowatch.com(check that thing several times a day). Every Monday the DistroWatch Weekly comes out. Usually the main story is a review of some distribution. Todays featured distro…
Thus I took that as a hint from fate. One “man pacman-g2 | cat -” later I have a nice set of text to copy-paste. Without further ado here is a much needed man page.
pacman-g2 – package manager utility
pacman-g2 <operation> [options] <package> [package] …
pacman-g2 is a package management utility that tracks installed packages on a linux system. It has simple dependency support and the ability to connect to a remote ftp server and
automatically upgrade packages on the local system. pacman-g2 packages are in a bzipped tar format.
Add a package to the system. Package will be uncompressed into the installation root and the database will be updated.
This is like –upgrade except that, unlike –upgrade, this will only upgrade packages that are already installed on your system.
Query the package database. This operation allows you to view installed packages and their files, as well as meta-info about individual packages (dependencies, conflicts,
install date, build date, size). This can be run against the local package database or can be used on individual .fpm packages. See QUERY OPTIONS below.
Remove a package from the system. Files belonging to the specified package will be deleted, and the database will be updated. Most configuration files will be saved with a
.pacsave extension unless the –nosave option was used.
Synchronize packages. With this function you can install packages directly from the ftp servers, complete with all dependencies required to run the packages. For example,
pacman-g2 -S qt will download qt and all the packages it depends on and install them. You could also use pacman-g2 -Su to upgrade all packages that are out of date (see below).
Upgrade a package. This is essentially a “remove-then-add” process. See HANDLING CONFIG FILES for an explanation on how pacman-g2 takes care of config files.
Display processes using deleted files. To empty that list without a restart, you can restart the service (if there is any) of the CGroup. For example if the CGroup is
“name=systemd:/system/sshd.service”, you can run “systemctl restart sshd.service”.
Display version and exit.
Display syntax for the given operation. If no operation was supplied then the general syntax is shown.
Skips all dependency checks. Normally, pacman-g2 will always check a package’s dependency fields to ensure that all dependencies are installed and there are no package
conflicts in the system. This switch disables these checks.
Bypass file conflict checks, overwriting conflicting files. If the package that is about to be installed contains files that are already installed, this option will cause all
those files to be overwritten. This option should be used with care, ideally not at all.
Removes the database entry only. Leaves all files in place.
Bypass the architecture check, so that you can for example install an i686 package on x86_64 if you know what you’re doing.
-r, –root <path>
Specify alternative installation root (default is “/”). This should not be used as a way to install software into e.g. /usr/local instead of /usr. Instead this should be used
if you want to install a package on a temporary mounted partition, which is “owned” by another system. By using this option you not only specify where the software should be
installed, but you also specify which package database to use.
-b, –dbpath: Specify an alternative database path (default is var/lib/pacman).
Output more status and error messages.
Specify an alternate configuration file.
Bypass any and all “Are you sure?” messages. It’s not a good idea to do this unless you want to run pacman-g2 from a script.
Finetune the –noconfirm switch by not answering “yes” to all libpacman questions, but you are able to specify yes/no for all type of them. The types are the followings:
· The given package is in IgnorePkg. (1)
· Replace package foo with bar? (2)
· foo conflicts with bar. Remove bar? (4)
· Do you want to delete the corrupted package? (8)
· Local version is newer. (16)
· Local version is up to date. (32)
Select for what types do you want to answer yes, sum up the values and use the
result as a parameter to this option.
Do not show a progress bar when downloading files. This can be useful for scripts that call pacman-g2 and capture the output.
Do not execute install scriptlets, if any.
Skip the SHA1 integrity check for the downloaded packages.
Treat the target names as regular expressions if no target found.
# pacman-g2 -S –regex ‘perl-.*’
Remove old packages from the cache. When pacman-g2 downloads packages, it saves them in /var/cache/pacman-g2/pkg. If you need to free up diskspace, you can remove these
packages by using the –clean option. Using one –clean (or -c) switch will only remove old packages. Use it twice to remove all packages from the cache.
Don’t install the packages itself, only their dependencies. This can be handy if you want to install the packages themselves with different options or from source.
Display all the members for each package group specified. If no group names are provided, all groups will be listed.
Display dependency information for a given package. This will search through all repositories for a matching package and display the dependencies, conflicts, etc.
List all files in the specified repositories. Multiple repositories can be specified on the command line.
Print out URIs for each package that will be installed, including any dependencies. These can be piped to a file and downloaded at a later time, using a program like wget. If
you need to get the URIs even if they’re downloaded, just use -pp for it.
-s, –search <regexp>
This will search each package in the package list for names or descriptions that contains <regexp>.
Upgrades all packages that are out of date. pacman-g2 will examine every package installed on the system, and if a newer package exists on the server it will upgrade. pacman-g2
will present a report of all packages it wants to upgrade and will not proceed without user confirmation. Dependencies are automatically resolved at this level and will be
installed/upgraded if necessary. Use this twice to downgrade packages that are newer than the ones in the repo.
Retrieve all packages from the server, but do not install/upgrade anything.
Download a fresh copy of the master package list from the ftp server defined in /etc/pacman-g2.conf. This should typically be used each time you use –sysupgrade. If used more
than once, then it forces the re-download of the package database, even in case it’s up to date.
This option functions exactly the same as the IgnorePkg configuration directive. Sometimes it can be handy to skip some package updates without having to edit pacman-g2.conf
Remove all target packages, as well as all packages that depend on one or more target packages. This operation is recursive.
Instructs pacman-g2 to ignore file backup designations. Normally, when a file is about to be removed from the system the database is first checked to see if the file should be
renamed to a .pacsave extension. If –nosave is used, these designations are ignored and the files are removed.
For each target specified, remove it and all its dependencies, provided that (A) they are not required by other packages; and (B) they were not explicitly installed by the
user. This option is analogous to a backwards –sync operation.
View the changelog of a package.
When used with -e, list all packages that were not installed as a dependency and are not required by any other packages.
List all packages that were installed as a dependency (ie, not installed explicitly) and are not required by any other packages.
Check that all files owned by the given package(s) are present on the system. If packages are not specified check all installed packages.
Display all groups that a specified package is part of. If no package names are provided, all groups and members will be listed.
Display information on a given package, use it twice to display also the list of backup files and their modification states. If it is used with the -p option then the .PKGINFO
file will be printed.
-l, –lidbonly List all files owned by <package>. Multiple packages can be specified on the command line.
List all packages that were not found in the sync database(s). Typically these are packages that were downloaded manually and installed with –add.
-o, –owns <path>
Search for the package that owns a given file or directory.
Tells pacman-g2 that the package supplied on the command line is a file, not an entry in the database. Pacman will decompress the file and query it. This is useful with –info
-s, –search <regexp>
This will search each locally-installed package for names or descriptions that contains <regexp>.
Tests the local database, by searching for missing informations. Example:
$ pacman-g2 -Qt
:: zip-2.32-1: file list is missing
The recommended method in this case is to remove the database entry:
# rm -rf /var/lib/pacman-g2/local/zip-2.32-1
and forcing the reinstall of the package:
# pacman-g2 -Sf zip –noconfirm
HANDLING CONFIG FILES
pacman-g2 uses the same logic as rpm to determine action against files that are designated to be backed up. During an upgrade, it uses 3 md5 hashes for each backup file to
determine the required action: one for the original file installed, one for the new file that’s about to be installed, and one for the actual file existing on the filesystem. After
comparing these 3 hashes, the follow scenarios can result:
original=X, current=X, new=X
All three files are the same, so we win either way. Install the new file.
original=X, current=X, new=Y
The current file is un-altered from the original but the new one is different. Since the user did not ever modify the file, and the new one may contain improvements/bugfixes,
we install the new file.
original=X, current=Y, new=X
Both package versions contain the exact same file, but the one on the filesystem has been modified since. In this case, we leave the current file in place.
original=X, current=Y, new=Y
The new one is identical to the current one. Win win. Install the new file.
original=X, current=Y, new=Z
All three files are different, so we install the new file with a .pacnew extension and warn the user, so she can manually move the file into place after making any necessary
pacman-g2 will attempt to read /etc/pacman-g2.conf each time it is invoked. This configuration file is divided into sections or repositories. Each section defines a package
repository that pacman-g2 can use when searching for packages in –sync mode. The exception to this is the options section, which defines global options.
HoldPkg = pacman-g2 glibc bash coreutils
HoldPkg = chkconfig
Include = /etc/pacman-g2/repos/frugalware-current
Server = file:///home/pkgs
DBPath = path/to/db/dir
Overrides the default location of the toplevel database directory. The default is var/lib/pacman-g2.
CacheDir = path/to/cache/dir
Overrides the default location of the package cache directory. The default is var/cache/pacman-g2.
HoldPkg = <package> [package] …
If a user tries to –remove a package that’s listed in HoldPkg, pacman-g2 will ask for confirmation before proceeding.
IgnorePkg = <package> [package] …
Instructs pacman-g2 to ignore any upgrades for this package when performing a –sysupgrade.
UpgradeDelay = <number>
Upgrade only the packages that are at least <number> days old when performing a –sysupgrade.
OldDelay = <number>
Issue a warning when you install a package, but the local sync database (which can be upgraded using -Sy) haven’t been updated for <number> days.
MaxTries = <number>
Try to download packages <number> times. This is useful in case you have a bad internet connection and your packages often get corrupted during the download.
Include = <path>
Include another config file. This config file can include repositories or general configuration options.
ProxyServer = <host|ip>
If set, pacman-g2 will use this proxy server for all ftp/http transfers.
ProxyPort = port
If set, pacman-g2 will use this proxy port for all ftp/http transfers. (Default: 80).
XferCommand = /path/to/command %u
If set, pacman-g2 will use this external program to download all remote files. All instances of %u will be replaced with the URL to be downloaded. If present, instances of %o
will be replaced with the local filename, plus a “.part” extension, which allows programs like wget to do file resumes properly.
This option is useful for users who experience problems with pacman-g2’s built-in http/ftp support, or need the more advanced proxy support that comes with utilities like curl.
In case you want to make the output more user-friendly, there is also %c to mention the number of the currently downloaded file and %t to show the total number of files.
Disables passive ftp connections when downloading packages. (aka Active Mode)
NoUpgrade = <file> [file] …
All files listed with a NoUpgrade directive will never be touched during a package install/upgrade.
NOTE: Do not include the leading slash when specifying files.
NoExtract = <file> [file] …
All files listed with a NoExtract directive will never be extracted from a package into the filesystem. This can be useful when you don’t want part of a package to be
installed. For example, if your httpd root uses an index.php, then you would not want the index.html file to be extracted from the apache package.
Log action messages through syslog(2). This will insert pacman-g2 log entries into your /var/log/messages or equivalent.
LogFile = /path/to/file
Log actions directly to a file, usually /var/log/pacman-g2.log.
Each repository section defines a section name and at least one location where the packages can be found. The section name is defined by the string within square brackets (eg, the
two above are current and custom). Locations are defined with the Server directive and follow a URL naming structure. Currently only ftp is supported for remote servers. If you
want to use a local directory, you can specify the full path with a file:// prefix, as shown above.
USING YOUR OWN REPOSITORY
Let’s say you have a bunch of custom packages in /home/pkgs and their respective FrugalBuild files are all in /var/fst/local. All you need to do is generate a compressed package
database in the /home/pkgs directory so pacman-g2 can find it when run with –refresh.
# gensync /var/fst/local /home/pkgs/custom.fdb
The above command will read all FrugalBuild files in /var/fst/local and generate a compressed database called /home/pkgs/custom.fdb. Note that the the section defined in the
configuration file. That’s it! Now configure your custom section in the configuration file as shown in the config example above. Pacman will now use your package repository. If you
add new packages to the repository, remember to re-generate the database and use pacman-g2’s –refresh option.
pacman-g2 will attempt to execute hooks in the /etc/pacman-g2/hooks directory. The hooks are like package scriptlets: each file can provide functions for a given hook. At the
moment the following hooks are supported:
Executed before upgrading packages (and after the integrity check) during a pacman-g2 -S –sysupgrade.
Executed after a successful pacman-g2 -S –sysupgrade.
The best way to report a bug is to use the form at http://bugs.frugalware.org/. The reason for this is that you will then be able to track progress in fixing the problem. Comments,
patches can be sent to the firstname.lastname@example.org mailing list too. To join the list, visit the following page: http://frugalware.org/mailman/listinfo/frugalware-devel.