SBdocs - SlackBuilder Tutorials - pkg-rm

Last updated:

pkg-rm


Description

'pkg-rm' is an interactive command that will remove a package and its recursive dependencies.

  • It will check if a package and its dependencies are free to remove.
  • As long as a dependency is not required by another package it will be scheduled for removal.
  • When the verification process is complete you will be presented a list of packages to remove and prompted if you wish to continue

Examples of use

This example demonstrates what to to when things don't work out as expected. Continuing with the example from 'pkg-get'...

--> time pkg-rm guitarix
 Pkg-rm...
 root /
--------------------------------------------------------------------------------
Dependency-Check => guitarix
Finding recursive dependencies for....guitarix
Done!                              
There are (9) ldeps installed. 
Looking for rdeps......patience is a virtue!
grabbing all dependencies...
now get all installed pkgs list
filtering out installed dependencies 
creating reverse dependencies db file.

time to get all reverse dependencies...
 Done!                                       
there are () rdeps.....now Looking for top level...
 Done!                        


There are (1) to verify ....
--------------------------------------------------------------------------------


--------------------------------------------------------------------------------

There are (9) pkgs to be removed...

guitarix jack-audio-connection-kit ladspa_sdk liblrdf lilv lv2 serd sord sratom
--------------------------------------------------------------------------------
Do you wish to continue? y/N 
real  0m3.762s
user  0m2.626s
sys 0m0.636s


On a system that has been installed using offical slackware repositories the performance of dependency checking isn't too bad. Especially since it has to check the whole system for any reverse upline dependency requirements. But on a Salix installation the process can take up to a minute or more...

Note: 'anyrepo' is just a wrapper script to set the environment for my Salix installation.

--> time anyrepo pkg-rm guitarix


 Pkg-rm...
 root /mnt/Salix64-14.2
--------------------------------------------------------------------------------
Dependency-Check => guitarix
Finding recursive dependencies for....guitarix
Done!                              
There are (36) ldeps installed. 
Looking for rdeps......patience is a virtue!
grabbing all dependencies...
now get all installed pkgs list
filtering out installed dependencies 
creating reverse dependencies db file.
time to get all reverse dependencies...
 Done!                                       
there are (369) rdeps.....now Looking for top level...
 Done!                                


There are (176) to verify ....
--------------------------------------------------------------------------------

Finding recursive dependencies for....BeautifulSoup
Finding recursive dependencies for....ConsoleKit2
Finding recursive dependencies for....ModemManager
Finding recursive dependencies for....PyQt
Finding recursive dependencies for....alsa-oss
Finding recursive dependencies for....alsa-plugins
Finding recursive dependencies for....alsa-utils
Finding recursive dependencies for....bash
Finding recursive dependencies for....bc
Finding recursive dependencies for....bdftopcf
.
.
lots more in here!
.
.
.
Finding recursive dependencies for....xrdb
Finding recursive dependencies for....xsane
Finding recursive dependencies for....xset
Finding recursive dependencies for....xsetroot
Finding recursive dependencies for....xsm
Finding recursive dependencies for....xstdcmap
Finding recursive dependencies for....xterm
Finding recursive dependencies for....xvidtune
Done!                          
--------------------------------------------------------------------------------

There are (10) pkgs to be removed...

celt guitarix jack-audio-connection-kit ladspa_sdk liblrdf lilv lv2 serd sord sratom
--------------------------------------------------------------------------------
Do you wish to continue? y/N 
real  0m57.896s
user  0m47.313s
sys 0m11.484s

What are rdeps

rdeps are, as the name suggests, reverse dependencies. They are not all of them in this case just the top level installed ones, and can be found by using the 'rdeps -i' command.

Arbitrarily, I see above out of the 10 pkgs to be removed that lv2 is listed . If curious as to what its rdeps are do...

--> rdeps -i lv2
guitarix
lilv
sratom

To find all available packages that list lv2 as a dependency...

--> pkg-info -R lv2
ardour-4.7.0-x86_64-1_slonly.txz
calf-0.0.60-x86_64-1_slonly.txz
clam-r15456-x86_64-1_slonly.txz
distrho-mini-series-20140826-x86_64-1_slonly.txz
distrho-ports-20140826-x86_64-1_slonly.txz
fabla-1.3.1-x86_64-1_slonly.txz
foo-yc20-1.3.0-x86_64-1_slonly.txz
invada_studio_plugins_lv2-1.2.0_0-x86_64-1_slonly.txz
lv2dynparam1-2-x86_64-1_slonly.txz
mda-lv2-1.2.2-x86_64-1_slonly.txz
swh-plugins-lv2-1.0.15-x86_64-1_slonly.txz
yoshimi-1.3.2-x86_64-1_slonly.txz
zynjacku-6-x86_64-1_slonly.txz
lvtk-1.2.0-x86_64-1_slonly.txz
slv2-0.6.6-x86_64-2_slonly.txz
sratom-0.4.6-x86_64-1_slonly.txz
suil-0.8.2-x86_64-1_slonly.txz
linuxsampler-1.0.0-x86_64-2_slonly.txz

When dependencies aren't removed

Just for grins I want to install clam to demonstrate what happens when running 'pkg-rm' to remove guitarix. First lets see what its dependencies are...

--> ldeps -v clam
clam -- 6 => id3lib jack-audio-connection-kit ladspa_sdk lv2 portaudio xerces-c

It shows 3 shared dependencies with guitarix. So when attempting to remove guitarix -- jack-audio-connection-kit, ladspa_sdk & lv2 -- should remain installed.

I can use 'pkg-get clam' to install clam...

Alternatively in the 'getpkg' tutorial I demonstrated building a script that I called 'pkg-getd' ( since then I went ahead and included it in the package-manager )

I feel like using it here ...

 --> pkg-getd clam
Checking for dependencies...
xerces-c will be installed
portaudio will be installed
lv2 is up-to-date
ladspa_sdk is up-to-date
jack-audio-connection-kit is up-to-date
id3lib will be installed
clam will be installed
root /
%%%%%%%%%%% xerces-c install
at the location /var/pkgcache/14.2-x86_64
  1150K ..........                                            100% 1.80M=0.7s
Verifying package xerces-c-3.1.4-x86_64-1_slonly.txz.
Installing package xerces-c-3.1.4-x86_64-1_slonly.txz:
PACKAGE DESCRIPTION:
# xerces-c (XML Parser)
#
# Xerces-C++ is a validating XML parser written in a
# portable subset of C++. Xerces-C++ makes it easy to
# give your application the ability to read and write XML
# data. A shared library is provided for parsing, generating,
# manipulating, and validating XML documents.
#
# Homepage: http://xerces.apache.org/xerces-c/
#
Executing install script for xerces-c-3.1.4-x86_64-1_slonly.txz.
Package xerces-c-3.1.4-x86_64-1_slonly.txz installed.
.
.
.
.
%%%%%%%%%%% clam install
at the location /var/pkgcache/14.2-x86_64
  1850K .....                                                 100% 5.22M=0.9s
Verifying package clam-r15456-x86_64-3_slonly.txz.
Installing package clam-r15456-x86_64-3_slonly.txz:
PACKAGE DESCRIPTION:
# clam (C++ Library for Audio and Music)
#
# CLAM is a software framework for research and application development
# on the audio and music domain. It provides means to perform complex
# audio signal analysis, transformations and synthesis. It also provides
# a uniform interface to common tasks on audio applications such as
# accessing audio devices and audio files, thread safe communication
# with the user interface and DSP algorithms recombination and scaling.
#
Executing install script for clam-r15456-x86_64-3_slonly.txz.
Package clam-r15456-x86_64-3_slonly.txz installed. 

Now lets see what happens when trying to remove guitarix...

--> time pkg-rm guitarix
 Pkg-rm...
 root /
--------------------------------------------------------------------------------
Dependency-Check => guitarix
Finding recursive dependencies for....guitarix
Done!                              
There are (9) ldeps installed. 
Looking for rdeps......patience is a virtue!
grabbing all dependencies...
now get all installed pkgs list
filtering out installed dependencies 
creating reverse dependencies db file.

time to get all reverse dependencies...
 Done!                                       
there are (1) rdeps.....now Looking for top level...
 Done!                        


There are (2) to verify ....
--------------------------------------------------------------------------------

Finding recursive dependencies for....clam
Done!                              
--------------------------------------------------------------------------------

There are (6) pkgs to be removed...

guitarix liblrdf lilv serd sord sratom
--------------------------------------------------------------------------------
Do you wish to continue? y/N 
real  0m4.693s
user  0m2.827s
sys 0m0.737s

As you can see the 3 shared dependencies are now not scheduled for removal.

After removing 'guitarix' and its deps I now want to remove 'clam' and its deps.

Oops!

Something went wrong and jack-audio-connection-kit was not removed. What gives? It turns out to be an issue with slackware's removepkg command. Normally, calling removepkg with just the package name is sufficient. But for some reason it doesn't work with certain packages. ie:

--> removepkg jack-audio-connection-kit

No such package: /var/log/packages/jack-audio-connection-kit. Can't remove.

However, I know for a fact it is intalled.

--> comparepkg  jack-audio-connection-kit
Available
--------------------------------------------------------------------------------
jack-audio-connection-kit-0.124.1-x86_64-1_Skn.txz
jack-audio-connection-kit-0.124.1-x86_64-2_slonly.txz

Installed
--------------------------------------------------------------------------------
jack-audio-connection-kit-0.124.1-x86_64-1_Skn.txz

Just for confirmation...

--> ls /var/log/packages/jack-audio-connection*                         
/var/log/packages/jack-audio-connection-kit-0.124.1-x86_64-1_Skn

* This bug occures wheather I use a slackonly package or my own built from Slackbuilds.org. I'm not sure exacly what the problem is, but i suspect it is due to the version number beginning with a 0(zero). In any case, this command is not whithin my jurisdiction to fiddle with.

removepkg does however remove the program by feeding it the full name of the package minus the suffix (.txz, etc...). ie:

removepkg jack-audio-connection-kit-0.124.1-x86_64-1_Skn

This is a real bother everytime this bug presents itself. So I wrote an alternative removal command 'rmpkg'.

rmpkg

This is just a little wrapper script for 'removepkg'. The content are ....

--> cat /etc/pkg-tools/sbin/rmpkg
#!/bin/bash

# pkgbase is from installpkg...nice voodoo
pkgbase() {
  # basename + strip extensions .tbz, .tgz, .tlz and .txz
  echo "$1" | sed 's?.*/??;s/\.t[bglx]z$//'
}

for p in $@; do
  pkg=$(
    pkf=$(pkg-j $p)
    [[ $pkf ]] && {
      pkgbase $pkf
    }
  );
  
  [[ $pkg ]] && {
    echo "removepkg $pkg"
    removepkg $pkg
  }
done

pkg-populate_db

pkg-j is part of the pkg-tools and returns the full installed package for the name given as an argument...

 --> pkg-j jack-audio-connection-kit
jack-audio-connection-kit-0.124.1-x86_64-1_Skn.txz

After finding the package and removing the suffix (.txz) it calls removepkg. Then it updates the packages database for pkg-info.

--> rmpkg jack-audio-connection-kit

Removing package /var/log/packages/jack-audio-connection-kit-0.124.1-x86_64-1_Skn...
Removing files:
  --> Deleting symlink /usr/lib64/libjack.so
  --> Deleting symlink /usr/lib64/libjack.so.0
  --> Deleting symlink /usr/lib64/libjackserver.so
  --> Deleting symlink /usr/lib64/libjackserver.so.0
  --> Deleting /usr/bin/alsa_in
  --.1/reference/
  .
  .
  lots more here!
  .
  --> Deleting empty directory /usr/doc/jack-audio-connection-kit-0.124.1/

Note: If you happen to run into this bug or just want to remove packages without dependency checking you can use 'rmpkg' pkgname and all will be well.

Removing slackware packages

Any offical slackware package is of course not even considered for removal using pkg-rm. You have to remove them manually either with 'removepkg' or better 'rmpkg'.
From the 'pkg-get'' installation example I had to install the raptor2 slackware package for 'guitarix' to work. I would now have to remove it manually.

--> rmpkg raptor2

Removing package /var/log/packages/raptor2-2.0.15-x86_64-2...
Removing files:
  --> Deleting symlink /usr/doc/raptor2-2.0.15/html
  --> Deleting symlink /usr/lib64/libraptor2.so
  --> Deleting symlink /usr/lib64/libraptor2.so.0
  --> Deleting /usr/bin/rapper
  --> Deleting /usr/doc/raptor2-2.0.15/AUTHORS
  --> Deleting /usr/doc/raptor2-2.0.15/COPYING
bla bla bla....
  --> Deleting empty directory /usr/doc/raptor2-2.0.15/

Comment in the Forum.

© 2015 - 2018  -   SlackBuilder  -   All Rights Reserved.

By: Lance Peterson -- Slackerson