IgnorantGuru's Blog

Linux software, news, and tips

Script: blackpac

«Downloads

Download Links: download blackpacview sourceverifyAUR
Description: Blacklists Arch Linux packages so that they may be removed despite dependencies
Recommended For: Arch Linux
Tested On: Arch Linux
Current Version: 1.0.1
Requires:
Related: paccheck
License: GNU GPL v3     * SEE DISCLAIMER *
Bugs/Requests: SourceForge Tracker

Overview

Blackpac maintains a blacklist of packages which is used to create a dummy package, ‘blackpacdummy’, which makes pacman believe it provides the blacklisted packages. This allows you to remove the blacklisted packages from your system despite other packages which depend on them. Blackpac is designed to give the user greater control over what packages are installed, and to override pacman’s dependency checking. Blackpac can also remove and install blacklisted packages, via pacman, as they are listed and unlisted in the blacklist, or you can do this yourself.

WARNING: This script is for advanced users who understand the implications and consequences of removing packages that are required by other packages. It is YOUR responsibility to determine what packages are safe to remove in this manner.

blackpac --help

Usage: blackpac OPTION [...]
Blacklists packages so that they may be removed; packages which depend on them
are satisfied by the dummy package 'blackpacdummy'.  Designed for use on Arch
Linux.
All options except --show require blackpac to be run as root.
One or more options are required:
--blacklist PACKAGE [...]  add PACKAGE(s) to the blacklist
                             (/etc/blackpaclist)
                             and update blackpacdummy
--unlist PACKAGE [...]     install PACKAGE(s), remove them from the blacklist,
                             and update blackpacdummy
--unlistall                install blacklisted packages, clear the blacklist
                             of all entries, and remove blackpacdummy
--update                   add packages in the blacklist to blackpacdummy
                             (use after manually editing blackpaclist)
--remove                   use "pacman -R" to remove all blacklisted packages
                             (updates blackpackdummy first)
--removes                  use "pacman -Rs" to remove all blacklisted packages
                             and their unneeded dependencies
--noinstall                do not automatically install packages before
                             unlisting them (this may prevent successful
                             update or removal of blackpacdummy)
--show                     show list of blacklisted packages currently
                             provided by blackpacdummy and list of
                             packages that currently depend on blackpacdummy
WARNING: Removing packages may break other packages and cause serious system
         malfunction!  It is up to YOU to decide what packages are safe to
         remove from your system.

By default, the blacklist is stored in /etc/blackpaclist. The best way to update the list is to use blackpac to do so. The list may also be edited directly, in which case you will need to run “blackpac ––update” to recreate blackpacdummy.

blackpackdummy is a dummy package, built and installed automatically by blackpac, which installs no files. It simply tells pacman that it provides all of the packages you have blacklisted, giving them a version number of ‘999’, so that you may then remove them without being told other packages depend on them, or on later versions of them. This is similar to using “pacman -Rd packagename” to remove a package regardless of dependencies, except that method does not prevent future updates from reinstalling the package, whereas blackpac’s method should.

Blacklisting a package through blackpac will add the package to the list of what blackpacdummy provides, reinstall blackpacdummy, and update the blacklist. It will not remove the package unless the “––remove” or “––removes” options are also included.

When unlisting a package, blackpac will first run pacman for you to install the package(s) which are being unlisted. If installation is successful, then they are unlisted from the blacklist and removed from blackpackdummy. If you do not want blackpac to attempt installation of the packages being unlisted, include the “––noinstall” option. However, this may create an error when pacman tries to update blackpacdummy. blackpackdummy provides dependencies (as far as pacman is concerned), so you may not be able to remove or update it without installing the packages it provides. (You can see what currently depends on blackpacdummy and what it provides with “blackpac ––show”, which is equivalent to “pacman -Qi blackpacdummy”.)

To illustrate the use and advantages of blackpac, a sample run is below. In this case, installing kmail required the installation of kdelibs and kdepimlibs. However, these in turn had dependencies on akonadi and soprano, which in turn had dependencies on mysql and mysql-clients. It turns out that for most if not all uses, kmail does NOT require akonadi or soprano [Update: As of KDE 4.4, kmail DOES require akonadi]. They may be removed without causing problems on my system – the only barrier was pacman requiring them. The following example shows me removing akonadi and soprano, and their dependencies, using blackpac. (Commands issued are shown in red, output in black.)

# First, I will check what is installed
root:/# pacman -Q akonadi soprano mysql mysql-clients blackpacdummy
akonadi 1.2.1-3
soprano 2.3.1-2
mysql 5.1.42-1
mysql-clients 5.1.42-1
error: package "blackpacdummy" not found

# Next, I will try to remove them without blackpac, which won't work
root:/# pacman -R akonadi soprano
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: kdelibs: requires soprano
:: kdepimlibs: requires akonadi>=1.1.90

# Now I will blacklist them with blackpac, and will include the
# --removes option to tell blackpac to run pacman and remove them and their
# dependencies (use with caution)
root:/# blackpac --removes --blacklist akonadi soprano
Blacklisting akonadi...
Blacklisting soprano...
Building blackpacdummy...
Installing blackpacdummy...
>>> pacman --noconfirm -U "/tmp/blackpac.tmp/blackpacdummy-1.0.0-1-any.pkg.tar.gz"
loading package data...
checking dependencies...
(1/1) checking for file conflicts                   [###################] 100%
(1/1) installing blackpacdummy                      [###################] 100%
Removing blacklisted packages...
>>> pacman -Rs  akonadi soprano
checking dependencies...
Remove (4): akonadi-1.2.1-3  mysql-5.1.42-1  mysql-clients-5.1.42-1
            soprano-2.3.1-2
Total Removed Size:   67.83 MB
Do you want to remove these packages? [Y/n]
(1/4) removing akonadi                              [###################] 100%
(2/4) removing mysql                                [###################] 100%
(3/4) removing mysql-clients                        [###################] 100%
(4/4) removing soprano                              [###################] 100%

# Now I will look at what blackpacdummy is providing, and what
# depends on it
root:/# blackpac --show
Showing dependencies...
(see the 'Provides:' and 'Required By:' lines below)

>>> pacman -Qi blackpacdummy
Name           : blackpacdummy
Version        : 1.0.0-1
URL            : https://igurublog.wordpress.com/downloads/script-blackpac/
Licenses       : unknown
Groups         : None
Provides       : akonadi=999  soprano=999
Depends On     : None
Optional Deps  : None
Required By    : kdelibs  kdepimlibs
Conflicts With : None
Replaces       : None
Installed Size :   4.00 K
Packager       : IgnorantGuru
                 [https://igurublog.wordpress.com/contact-ignorantguru/]
Architecture   : any
Build Date     : Fri 15 Jan 2010 05:37:57 PM MST
Install Date   : Fri 15 Jan 2010 05:37:57 PM MST
Install Reason : Explicitly installed
Install Script : No
Description    : Dummy package created by blackpac to provide blacklisted
                 packages

# Now I will attempt to remove blackpacdummy, which won't
# work because kdelibs and kdepimlibs require it
root:/# pacman -R blackpacdummy
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: kdelibs: requires soprano
:: kdepimlibs: requires akonadi>=1.1.90

# Now I will tell blackpac to unlist everything in the blacklist
# (akonadi and soprano), which will cause it to first run pacman so I can install
# them
root:/# blackpac --unlistall                                                  
Installing blacklisted packages...                                            
>>> pacman --needed -S  akonadi soprano                                       
resolving dependencies...                                                     
looking for inter-conflicts...                                                                                                                             
Targets (4): mysql-clients-5.1.42-1  mysql-5.1.42-1  soprano-2.3.1-2          
             akonadi-1.2.1-3                                                  
Total Download Size:    0.00 MB                                               
Total Installed Size:   67.83 MB                                              
Proceed with installation? [Y/n]
checking package integrity...
(4/4) checking for file conflicts                   [###################] 100%
(1/4) installing mysql-clients                      [###################] 100%
(2/4) installing mysql                              [###################] 100%
(3/4) installing soprano                            [###################] 100%
(4/4) installing akonadi                            [###################] 100%
Unlisting akonadi...
Unlisting soprano...
Building blackpacdummy...
Removing blackpacdummy (blacklist is empty)...
>>> pacman --noconfirm -R blackpacdummy
checking dependencies...
(1/1) removing blackpacdummy                        [###################] 100%

# Now let's see what's installed - we're back to where we started
root:/# pacman -Q akonadi soprano mysql mysql-clients blackpacdummy
akonadi 1.2.1-3
soprano 2.3.1-2
mysql 5.1.42-1
mysql-clients 5.1.42-1
error: package "blackpacdummy" not found

In just this one example, blackpac allowed me to remove 68MB of packages from my system, not to mention packages I simply don’t want installed, without breaking anything I use. And it allowed me to un-blacklist them and reinstall them with one command.

As demonstrated above, unlisting a package and installing it will generally undo any changes. Nevertheless, remove blacklisted packages with caution as removing the wrong packages can cause system failure. In all events, it never hurts to be prepared with a recent system backup.

Related Arch Forums Thread: blackpac – blacklist and remove packages

Installation Instructions

You may use the AUR or “yaourt -S blackpac”. (The PKGBUILD will always download and build the latest version.)

Or, follow the standard Script Installation Instructions.

2 Comments

  1. This seems quite an interesting script. However, if packages actually run fine without their given dependencies, it may be possible to get them listed as optdepends instead. If that seems reasonable, open a feature request on the bug tracker.

    Comment by Allan | January 16, 2010

    • Thanks – I’ll look that over. In this case it’s tricky because kmail does require kdelibs, and in some situations kdelibs does require akonadi and soprano (probably), which in turn requires mysql. But kmail may indeed not require the dependencies of kdelibs. So this chain of dependencies is the problem. OTOH it’s also possible that kmail does require akonadi when used in an integrated way with KDE’s Contact, etc. But in general I think the KDE packages overdo the dependencies – they would have you install all of KDE. So I may take your suggestion. I also may look at the kde-mod situation to see if that handles it differently.

      Comment by igurublog | January 16, 2010