Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Aug 2002 11:26:23 +0930
From:      Greg 'groggy' Lehey <grog@FreeBSD.org>
To:        "Defryn, Guy" <G.P.Defryn@massey.ac.nz>
Cc:        "'freebsd-questions@FreeBSD.ORG'" <freebsd-questions@freebsd.org>
Subject:   Re: uninstalling software
Message-ID:  <20020815015623.GF36655@wantadilla.lemis.com>
In-Reply-To: <98B01D2717B9D411B38F0008C7840931057F3AF6@its-xchg2.massey.ac.nz>
References:  <98B01D2717B9D411B38F0008C7840931057F3AF6@its-xchg2.massey.ac.nz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday, 15 August 2002 at  8:58:48 +1200, Defryn, Guy wrote:
>
>
> I would like to uninstall some software on my freebsd box.
> I never use the ports or packages so I cannot use PKG_delete
>
> What is the best way of uninstalling programs if you've build them
> From the source code?

That depends on the software.  There's no "one size fits all".  This
is one of the reasons we created the Ports Collection.

I'd recommend you read the information supplied with your packages.
One other possibility is related to a recommendation in my book
"Porting UNIX Software" (starting on page 155):

  More frequently, however, you can't use this approach: the Makefile isn't
  as easy to find, or you have long since discarded the source tree.  In this
  case, we'll have to do it differently.  First, we find the directory where the
  executable gs, the main ghostscript program, is stored:

  $ which gs
  /opt/bin/gs

  Then we look at the last modification timestamp of /opt/bin/gs:

  $ ls -l /opt/bin/gs
  -rwxrwxr-x   1 root     wheel     3168884 Jun 18 14:29 /opt/bin/gs

  This is to help us to know where to look in the next step: we list the directory
  /opt/bin sorted by modification timestamp.  It's a lot easier to find what
  we're looking for if we know the date.  If you don't have which, or
  possibly even if you do, you can use the following script, called wh:

  for j in $*; do
    for i in `echo $PATH|sed 's/:/ /g'`; do
      if [ -f $i/$j ]; then
        ls -l $i/$j
      fi
    done
  done

  wh searches the directories in the current environment variable
  PATH for a specific file and lists all occurrences in the order
  in which they appear in PATH in ls -l format, so you could
  also have entered:

  $ wh gs
  -rwxrwxr-x   1 root     wheel     3168884 Jun 18 14:29 /opt/bin/gs

  Once we know the date we are looking for, it's easy to list the directory, page
  it through more and find the time frame we are looking for.

  $ ls -lt /opt/bin|more
  total 51068
  -rw-------   1 root     bin        294912 Sep  6 15:08 trn.old
  -rwxr-xr-x   1 grog     lemis      106496 Sep  6 15:08 man

  -rw-rw-rw-   1 grog     bin           370 Jun 21 17:24 prab~
  -rw-rw-rw-   1 grog     bin           370 Jun 21 17:22 parb
  -rw-rw-rw-   1 grog     bin           196 Jun 21 17:22 parb~
  -rwxrwxrwx   1 grog     wheel         469 Jun 18 15:19 tep
  -rwxrwxr-x   1 root     wheel          52 Jun 18 14:29 font2c
  -rwxrwxr-x   1 root     wheel         807 Jun 18 14:29 ps2epsi
  -rwxrwxr-x   1 root     wheel          35 Jun 18 14:29 bdftops
  -rwxrwxr-x   1 root     wheel         563 Jun 18 14:29 ps2ascii
  -rwxrwxr-x   1 root     wheel          50 Jun 18 14:29 gslp
  -rwxrwxr-x   1 root     wheel     3168884 Jun 18 14:29 gs
  -rwxrwxr-x   1 root     wheel          53 Jun 18 14:29 gsdj
  -rwxrwxr-x   1 root     wheel          51 Jun 18 14:29 gsbj
  -rwxrwxr-x   1 root     wheel          18 Jun 18 14:29 gsnd
  -rwxrwxr-x   1 root     wheel          54 Jun 18 14:29 gslj
  -rwxr-xr-x   1 root     bin         81165 Jun 18 12:41 faxaddmodem
  -r-xr-xr-x   1 bin      bin        249856 Jun 17 17:18 faxinfo
  -r-xr-xr-x   1 bin      bin        106496 Jun 17 15:50 dialtest
  ...more stuff follows

  It's easy to recognize the programs in this format: they were all installed in
  the same minute, and the next older file (faxaddmodem) is more than 90
  minutes older, the next newer file (tep) is 50 minutes newer.  The files we
  want to remove are, in sequence, font2c, ps2epsi, bdftops,
  ps2ascii, gslp, gs, gsdj, gsbj, gsnd and
  gslj.

  We're not done yet, of course: ghostscript also installs a lot of fonts
  and PostScript files, as we saw in the Makefile.  How do we find and remove
  them? It helps, of course, to have the Makefile, from which we can see
  that the files are installed in the directories /opt/bin,
  /opt/lib/ghostscript and /opt/man/man1.  If you don't have the Makefile, all is
  not lost, but things get a little more complicated.  You can search the complete
  directory tree for files modified between Jun 18 14:00 and Jun 18
  14:59 with:

  $ find  /opt -follow -type f -print|xargs ls -l|grep "Jun 18 14:"
  -rwxrwxr-x   1 root     wheel          35 Jun 18 14:29 /opt/bin/bdftops
  ...etc
  -rw-rw-r--   1 root     wheel         910 Jun 18 14:29 /opt/man/man1/ansi2knr.1
  -rw-rw-r--   1 root     wheel       10005 Jun 18 14:29 /opt/man/man1/gs.1
  -rw-rw-r--   1 root     wheel       11272 Jun 18 14:29 /opt/lib/ghostscript/Fontmap
  -rw-rw-r--   1 root     wheel       22789 Jun 18 14:29 /opt/lib/ghostscript/bdftops.ps
  -rw-rw-r--   1 root     wheel         295 Jun 18 14:29 /opt/lib/ghostscript/decrypt.ps
  -rw-rw-r--   1 root     wheel       74791 Jun 18 14:29 /opt/lib/ghostscript/doc/NEWS
  -rw-rw-r--   1 root     wheel       13974 Jun 18 14:29 /opt/lib/ghostscript/doc/devices.doc
  ...many more files

  There are a couple of points to note here:

  We used GNU find, which uses the -follow option to follow
  symbolic links.  If your /opt hierarchy contains symbolic links,
  find would otherwise not search the subdirectories.  Other versions of
  find may require different options.

  You can't use ls -lR here because ls -lR does not show the full
  pathnames: you would find the files, but the name at the end of the line would
  just be the name of the file, and you wouldn't know the name of the directory.

  If the file is more than six months old, ls -l will list it in the form

  -rwxrwxrwx   1 grog     wheel          22 Feb 10  1994 xyzzy

  This may be enough to differentiate between the files, but it's less certain.
  GNU ls (in the fileutils package) includes a option
  --full-time (note the two leading hyphens).  This will always
  print the full time, regardless of the age of the file.  With this option, the file
  above will list as:

  $ ls --full-time -l xyzzy 
  -rwxrwxrwx   1 grog     wheel          22 Thu Feb 10 16:00:24 1994 xyzzy

Greg
--
When replying to this message, please copy the original recipients.
If you don't, I may ignore the reply.
For more information, see http://www.lemis.com/questions.html
See complete headers for address and phone numbers

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020815015623.GF36655>