bulk pkg_delete (FreeBSD)


 
Thread Tools Search this Thread
Operating Systems BSD bulk pkg_delete (FreeBSD)
# 1  
Old 08-30-2004
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mailx bulk operations

Greeting. How to download messages in bulk in mailx? e.g. how to download all the message received on mar-23-2017 and save as a file or download individual mailx message that received on mar-23-2017 as individual file and as a loop? We are on HP-UX centstdb B.11.31 U ia64 3294693583... (1 Reply)
Discussion started by: moneric
1 Replies

2. Shell Programming and Scripting

Bulk changes using sed

Hallo Team, I would like to change everything on field 24 that starts with 10.0.108.* to be 10.0.108.11 -bash-3.2$ cat pax1.csv|cut -f24 -d","|sort -u 10.0.108.11 10.0.108.11100 10.0.108.11102 10.0.108.11104 10.0.108.11105 10.0.108.11106 10.0.108.11108 10.0.108.11110... (6 Replies)
Discussion started by: kekanap
6 Replies

3. Shell Programming and Scripting

Parsing Bulk Data

Hi All, :D Actullay I am looking for a smart way :b: to parse files in a directory whose count is around 2000000 :eek: in a single day. Find is working with me but taking a lot of times :confused:, sometimes even a day which is not helping me.:wall: So anyone can help me know a smart... (5 Replies)
Discussion started by: jojo123
5 Replies

4. Shell Programming and Scripting

Renaming files in bulk.

Hi, I have a bunch of files which are named something like: Company Name~1234~X1234~X1-123.pdf I need to get them renamed something like: Company Name~1234(X1234)X1-123.pdf Once I have the X1234 inside () I have a piece of software which can use the X1234 bit. I will be receiving... (7 Replies)
Discussion started by: jcborland
7 Replies

5. Shell Programming and Scripting

Bulk Find and Replace

Hi Friends, I have a directory with a ton of .html files, like this ls -m1 dir 1.html 2.html 3.html 4.html Somewhere in the files, there is a pattern like this 1.html http://unix.com/cgi-bin/task?taskid=12010&task.out 2.html http://unix.com/cgi-bin/task?taskid=11110&task.out... (1 Reply)
Discussion started by: jacobs.smith
1 Replies

6. Shell Programming and Scripting

Bulk rename

hi, my directory has the following files I want to rename or mv them as file 1 corresponds to new_1.bed, file2 to new_2.bed and so on. How do I do it using awk or bash? TIA (4 Replies)
Discussion started by: jacobs.smith
4 Replies

7. AIX

Bulk Fixes Selection

Under smit, one has to manually select each fix with F7. there 9000 fixes left to be marked. How Can I manually install/Mark all of these without SMIT. ---------- Post updated at 02:29 PM ---------- Previous update was at 01:15 PM ---------- From the command line instfix -T -d... (4 Replies)
Discussion started by: mrmurdock
4 Replies

8. Programming

Application crashes in FreeBSD 7.1 while working ok in FreeBSD 6.3

Hello there, My mulithreaded application (which is too large to represent the source code here) is crashing after installing FreeBSD 7.1-RELEASE/amd64. It worked properly on others machines (Dual Cores with 4GB of RAM - FreeBSD 6.2-RELEASE/i386). The current machine has 2x Core 2 Duo... (1 Reply)
Discussion started by: Seenquev
1 Replies

9. Shell Programming and Scripting

Need help renaming bulk file extentions

Hello, I am trying to rename bulk files however i dont think the rename/mv command is giong to help me here. here is a quick snapshot of the files I need to rename: 75008040 -rw-r----- 1 root root 8716 May 8 05:00 10.9.144.2 75008041 -rw-r----- 1 root root 11700 May 8 05:00 10.9.160.2... (10 Replies)
Discussion started by: jallan
10 Replies

10. Shell Programming and Scripting

outcomment bulk

Hello chiefs, So i wanna outcomment several lines, but i dont want to start each line with #-sign. Once i saw it in use, but dont remember the syntax. It should work with sh or ksh. regards congo (3 Replies)
Discussion started by: congo
3 Replies
Login or Register to Ask a Question