🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.uu.comp.os.linux.questions
Article #192

Re: OK, how do I UNinstall programs?

#192
From: Cameron Hutchison
Date: Tue, 30 Mar 1999 00:00
123 lines
4026 bytes
Nix <$}xin{$@esperi.demon.co.uk> writes:

>Gareth Owen <gowen+usenet@ma.man.ac.uk> writes:

>[`how do I uninstall?']
>> Well, sadly, you usually have to find the programs/libraries/directores
>> that have been installed and manually delete them.  This can be
>> problematic in the case of libraries, since other stuff may be dependent
>> on them.  It's not difficult to write a shell script which uses ldd to
>> check for dependent apps in your PATH.  Mail me if you want mine...

>This is *exactly* what GNU stow is for.

Maybe I did something wrong, but when I used stow to remove a package, it
was *really slow*. I have a few shell functions that I wrote to make
removing packages easier.

It is similar to stow in that all packages are installed in
/usr/local/pkg/<pkgname> and then symlinked into the /usr/local hierarchy.
It also supports multiple package repositories for multiple hierarchies.

The functions are quite basic but do the job quite well. I've had no
problems with them yet on my single user machine. There are 4 functions
below - you only use the instpkg and rmpkg, the other two are internal.

-------------cut here------------

function instpkg()
{
  if [ $# != 1 ] ; then
    echo "Usage: instpkg package_name" >&2
    return 1
  fi
 
  for dstdir in $(echo $PKGDIRS | tr : " ") ; do
    local pkgdir=${dstdir}/pkg/$1
  
    if [ -d ${pkgdir} ] ; then
      pkg_installdir $pkgdir $dstdir
      return 0
    fi
  done
 
  echo -n "instpkg: $1 is not a package name in \"" >&2
  echo -n $PKGDIRS | tr : " " >&2
  echo "\""
  return 1
}

function rmpkg()
{
  if [ $# != 1 ] ; then
    echo "Usage: rmpkg package_name" >&2
    return 1
  fi
 
  for dstdir in $(echo $PKGDIRS | tr : " ") ; do
    local pkgdir=${dstdir}/pkg/$1
  
    if [ -d ${pkgdir} ] ; then
      pkg_removedir $pkgdir $dstdir
      return 0
    fi
  done
 
  echo -n "rmpkg: $1 is not a package name in \"" >&2
  echo -n $PKGDIRS | tr : " " >&2
  echo "\""
  return 1
}

function pkg_installdir()
{
  if [ $# != 2 ] ; then
    echo "Usage: pkg_installdir srcdir dstdir" >&2
    return 1
  fi
 
  for i in $1/* ; do
    local dir=`basename $i`
    if [ -d $i ] ; then
      if [ ! -e $2/$dir ] ; then
        mkdir $2/$dir
      fi
 
      if [ -d $2/$dir ] ; then
        pkg_installdir $i $2/$dir
      else
        echo "Cannot install to $2/$dir: Not a directory" >&2
      fi
    else
      ln -s $i $2/$dir
    fi
  done
}

function pkg_removedir()
{
  if [ $# != 2 ] ; then
    echo "Usage: pgk_removedir srcdir dstdir" >&2
    return 1
  fi
 
  for i in $1/* ; do
    local base=`basename $i`
    if [ -d $2/$base ] ; then
      pkg_removedir $i $2/$base
      rmdir $2/$base 2>/dev/null
    else
      if [ -L $2/$base ] ; then
        rm -f $2/$base
      else
        echo "Will not remove non-link file $2/$base" >&2
      fi
    fi
  done
}

-------------cut here------------

-- 
Cameron Hutchison (camh@zip.net.au) | Onward To Mars
GCS d--@ -p+ c++(++++) l++ u+ e+ m+(-) s n- h++ f? !g w+ t r+
Technical Details
Message-ID: <7drmqj$1aj$1@the-fly.zip.com.au>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36fd699c.214862@news.bart.nl> <e2hfr41mpi.fsf@ma.man.ac.uk> <87lngebujq.fsf@loki.wkstn.nix>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: faa64,654ee553763ffe89
X-Google-Attributes: gidfaa64,public
X-Google-Thread: 102983,654ee553763ffe89
X-Google-Attributes: gid102983,public
X-Google-Thread: 10a997,654ee553763ffe89
X-Google-Attributes: gid10a997,public
X-Google-Thread: 10d8ad,654ee553763ffe89
X-Google-Attributes: gid10d8ad,public
X-Google-Thread: f9b51,654ee553763ffe89
X-Google-Attributes: gidf9b51,public
From: Cameron Hutchison <camh@zip.net.au>
Subject: Re: OK, how do I UNinstall programs?
Date: 1999/03/30
Message-ID: <7drmqj$1aj$1@the-fly.zip.com.au>
X-Deja-AN: 460944583
References: <36fd699c.214862@news.bart.nl> <e2hfr41mpi.fsf@ma.man.ac.uk> <87lngebujq.fsf@loki.wkstn.nix>
Organization: The Zipsters
Newsgroups: alt.uu.comp.os.linux.questions,alt.os.linux,aus.computers.linux,comp.os.linux.setup,uk.comp.os.linux
Originator: camh@zipper.zip.com.au