Wiring aptitude test, England, 1930-1940 (vocational test)
, , ,

Lubuntu Linux, MooEdit, and Aptitude

Currently, I use the Lubuntu branch of Ubuntu, which is itself a particular flavour of the Debian distribution of Linux. In my opinion, for keeping track of these easily confused, so-called Linux Distributions, it’s might be least confusing to look upon any O/S bearing the suffix “buntu” (i.e. Ubuntu, Kubuntu, Edubuntu, Xubuntu, Mythbuntu, etc.) as simply a Debian system. Nearly all of the documentation and commands reference Debian, and the ‘buntu group is a direct descendant of Debian, I find it’s least confusing to use Debian nomenclature, regardless of alleged popularity of Ubuntu.

This article assumes the reader is knowledgeable of Package-Management common to most Linux Operating System distributions.

What follows is a brief study of apt-get vs. Aptitude, Debian package management front-end utilities, as a segue into discussion of a find-and-replace regular expression pattern determined to be ideal for extraction of package names as a process of user-specific, custom package installations.

DPKG : The Debian Package Kit

The Debian-based Linux Operating System manages software using “deb” packages, installed by the “apt” package-management system, one of several front-ends to “dpkg”, the Debian Package kit, including the graphical front-end to dpkg, Synaptic. I prefer to use “Aptitude” for my apt front-end to dpkg, as it seems to provide more information, and more options than its successor, “apt-get”, the default package manager of Ubuntu. Since Aptitude however is generally considered as less user-friendly than apt-get, rarely does talk of aptitude surface in the primary Ubuntu communities (i.e. User support / developer communities like Ubuntu.com and Launchpad.net tend to focus discussion on how to perform package-management tasks using “apt-get”).

Why Aptitude Over Apt-Get?

I prefer Aptitude for its incredibly powerful search expression options. Sometimes, a search will return a list of matches so large, yet relevant, that I choose to record the results as a text file for later use that I need to perform the same search in the future, or in the case of unfamiliar packages, to sift through the titles– possibly pulling detailed information from Aptitude– for any I might wish to try later.

Large Package Lists Lazily

On occasion, I might choose to install all of the packages in an Aptitude search results list, at once. The returned results, however, are not necessarily ready to use for input on the command line, to execute a new expression that Aptitude can easily turn and install them. The results I’ve saved require parsing, to extract the actual package names from the list, which appears by default as (1) installed status, (2) package name [the only part I want ], (3) a lot of space ending with a “-” [dash char], (4) a brief description of that package. In order to transform the 4 column list into one containing only the names, I use one of my favourite text editors, mooedit (medit in package manager search terms).

Listen to the Cow

MooEdit, or Medit, is a text-editor with a powerful regular expression engine built-in for search and replace functions. With my Aptitude search-results text file loaded in Mooedit, I use the following regular expression matching pattern to parse the 4-column list into a list containing names only:
^(w )(S+)(s+-s)(.+)
As part of the operation, I need to replace much of what is matched, so the following replacement expression is used, leaving only the package name portion of my Aptitude search results:
2. As shown, the replacement expression simply returns the second atom of the match-expression. There is no need for a slash-N newline character in the replacement, due to use of the “^” character which already forces each new match at every new line.

Another Feat Pulls Udder Teat

From here, I have a list of package names, but I still cant insert it at the command line for apt-get, or aptitude to make productive use of it. I need to transform it into a single-line expression, from the several lines of its initial form. The following, simple match / replacement expression pair accomplishes that task:
Replace:1 (where the second character is a space, replacing the former slash-N, or newline, such that– with each new-line replaced by a space– every package name results on a singular line, which can be appended to an apt-get or aptitude command line expression, as in the following:
..~$ sudo aptitude install -f --with-recommends [shift+insert], where the shift+insert places the clipboard contents at the cursor in the terminal, leaving a final step as the execution of the ultimate, resulting apt expression as compiled from the tasks described, above. Hit enter, and the entire list of packages, as extracted from the text file, will be installed at once.

Damn Dumb Debbie

Of course, apt-get, and aptitude both provide a fail-safe, idiot-proof protection so the system won’t be harmed, should any packages have unmet dependencies, or other issues preventing installation of a long list of packages, a warning will appear at the command prompt. In the case of Aptitude, possible solutions to resolve dependency conflicts are offered. With apt-get, generally the expression is simply returned as a conflict, without suggested fixes– a result more friendly to the less-experienced user– leaving the solution as either to abandan installation of several packages, or to impose perhaps a user-determined method of selectively removing packages from the list, until the dependency problem resolves.

Beating Algorithm of the War Drums

Any reader who is familiar with a Linux distribution using a DEB / APT / DPKG based package-manager as described here, has most likely encountered the package dependency resolution issue described above. If he or she hasn’t tried aptitude, I highly recommend it for both the power of its search expression syntax, and for Aptitude’s suggested dependency resolutions, intelligently selected based on advanced calculations unique to each specific, current configuration, where software installed on that system is considered against available software, including various permutations which might suggest removal of existing packages, or installation of alternate packages. Using Aptitude to configured the Debian-based system, vs apt-get, I believe will ultimately result in a setup most pleasing to the user, as he or she will be most educated about available options, for the information available through Aptitude.

Get Lost!

While this document should be on your system, if you have Aptitude installed, someone has been courteous enough to share it, on the network as well at the following URL:

Here you will find an overview of the powerful, regular-expression empowered options for locating desired packages. I recommend starting with #1, and progressing along, until you get the idea of who Aptitude search works. I find I achieve success by constructing a pattern, such as the following:
aptitude search "?keyword(what i want) ?anotheroption(something else)"
such that the expression portion is enclosed within “quotation marks”.

Assimilate, and use these (relatively simple) keywords! Have fun with your Linux package managers. Explore it; figure it out: aptitude is your key to the road not traveled!
Direct Link to Aptitude’s Specific Search-Patterns Table

Read the latest news about Linux at DistroWatch.org. Discover Linux at Wikipedia. Excluding any associated costs for Internet connectivity, media for storing installation files, and a proper system on which to install and, thereafter, use the software, Linux is typically free to obtain, and requires no payment for licensed usage or the periodic upgrades released regularly to maintain it.

Leave a Reply

Your email address will not be published. Required fields are marked *