bulk pkg_delete (FreeBSD) | Unix Linux Forums | BSD

  Go Back    


BSD BSD, sometimes called Berkeley Unix, is a Unix operating system developed by the Computer Systems Research Group of the UC Berkeley.

bulk pkg_delete (FreeBSD)

BSD


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 08-30-2004
erebus47 erebus47 is offline
Registered User
 
Join Date: Aug 2004
Last Activity: 29 October 2004, 10:49 AM EDT
Location: /dev/null
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
bulk pkg_delete (FreeBSD)

I have been toying with this all night now and cannot seem to get it to work, so I came to you for some aid. I recently discovered the wonders of the AWK programming language and how it can be useful of UNIX system administratioin, especially directly from and interacitive interpreter (ala sh).

The FreeBSD development team made it very easy to install pre-compiled binary packages remotely via the pkg_add -r directive which gives you functionality and facility very similiar to that of Debian's famed APT. When issuing a fetch, you do not have to give a specific version number along with the package name in the string, so something such as this will work fine:


Code:
# pkg_add -r <package>

One little incovinience that I did come across is, of course, having to look for specific version numbers each time I want to remove a package via the pkg system. This process was tedious and involved looking through pkg_info output for your program and maybe piping it to 'more' or 'less' to scroll through a long list of packages:


Code:
# pkg_info | less

... 
long list of packages here
...

# pkg_delete <package_version>

This might not seem like a lot to the naked eye, and indeed, it takes but a minute to accomplish, but it does get rather boring and is a minute that could have been well spent elsewhere. I was thinking about how I might accomplish this more time effective.

I needed pkg_info's output to accomplish the bulk of this, so that goes first. I would then have to pipe it to some pattern matching utility and search for my program, which, of course, would not have to be specific. Their is two options here, and my first was the less efficient, but the first to come to mind. The second saves a process. The third will eliminate the need for yet another process. The problem with this and what I need help with will unfold:


Code:
# pkg_info | grep xchat | awk '{ print $1 }' | xargs pkg_delete

# pkg_delete `pkg_info | grep xchat | awk '{ print $1 }'`

# pkg_delete `pkg_info | awk '/xchat/ { print $1 }'`

This little timeline was how I wrote this in the exact order. The last one is what I stuck with, though. The basic operation of this script is as follows: output package information, look for records with the string "xchat", extract only the first field from the output, and delete the package.

Here is my problem. I have a gnome installation that I would like to get rid of via package managment for the sake of cleanliness. I could do this manually, though it would take me ages to go through every single package with the method above. I tried the following to delete the bulk of the gnome packages:


Code:
# pkg_info | awk '/gnome/ { print $1 }'              
glibwww-0.2_1
gnome-icon-theme-1.0.3
gnomeapplets-1.4.1
gnomeaudio-1.4.0
gnomecanvas-0.22.0
gnomecontrolcenter-1.4.0.5_1
gnomecore-1.4.2
gnomedb-0.2.96_1
gnomegames-1.4.0.4_1
gnomehier-1.0_8
gnomelibs-1.4.2_1
gnomemedia-1.2.3_1
gnomemimedata-2.2.0_1
gnomemm-1.2.4
gnomepilot-0.1.71
gnomepilot-conduits-0.9
gnomepim-1.4.9
gnomeprint-0.37
gnomeuserdocs-1.4.1.1
gnomevfs-1.0.5_4
gnomevfs2-2.2.5
libgnome-2.2.0.1
libgnomecanvas-2.2.1
libgnomeui-2.2.0.1_1
py-gnome-1.4.4_1
rep-gtk-gnome-0.15_1

For all of the above package, I got the a message similar to the following for each:


Code:
 
pkg_delete: file '/usr/X11R6/share/gnome/help/charpick_applet/it/figures/charpick_applet.png' doesn't really exist

After a minute or two, I ran this and got the same message as above:


Code:
# pkg_info | awk '/gnome/ { print $1; system("pkg_delete" $1); }'

This is the end of the road, and I hope someone might have a solution to this. I was thinking it was going to be something recursive, but i'm studying up on awk a bit more. Thanks in advance...

EDIT:

I just did "man pkg_delete" and came across the -x switch. Here's what it does, which is what the above does too:

Code:
     -x      Treat the pkg-name as a regular expression and delete all pack-
             ages whose names match that regular expression.  Multiple regular
             expressions could be provided, in that case pkg_delete deletes
             all packages that match at least one regular expression from the
             list.

I ran "pkg_delete -x gnome" and got the same errors i got early, plus a new one:


Code:
pkg_delete: couldn't entirely delete package (perhaps the packing list is
incorrectly specified?)

And that's the update.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Bulk Fixes Selection mrmurdock AIX 4 06-21-2010 01:19 PM
Bulk move in ssh command Deei Shell Programming and Scripting 0 05-28-2010 11:19 AM
outcomment bulk congo Shell Programming and Scripting 3 08-01-2007 12:29 AM
bulk mail as a background job HungryH UNIX for Dummies Questions & Answers 2 01-01-2002 10:15 AM



All times are GMT -4. The time now is 10:12 AM.