teacup remove

This is a teacup subcommand.

The teacup remove subcommand is used to remove packages from the local repository.


The teacup remove option has been extended so that invoking it without arguments proceeds to delete all items in the local repository.

If you provide the name of a package, all versions of that package that reside in the local repository are deleted.

If you provide the name of a package and a version, then all variations of that package and version are deleted.


  Removing old packages

MHo: A way to remove all packages (outdated) older than a given version would be nice. Or is it possible another way?


AK: Looking at my own local repository I saw that I had a lot of sqlite packages installed:

% teacup list --at-default|grep sqlite3
package sqlite3 3.6.17  linux-glibc2.3-ix86
package sqlite3 3.6.18  linux-glibc2.3-ix86
package sqlite3 3.6.19  linux-glibc2.3-ix86
package sqlite3 3.6.20  linux-glibc2.3-ix86
package sqlite3 3.6.21  linux-glibc2.3-ix86
package sqlite3 3.6.22  linux-glibc2.3-ix86
package sqlite3 3.6.23  linux-glibc2.3-ix86
package sqlite3 3.7.2   linux-glibc2.3-ix86
package sqlite3 3.7.3   linux-glibc2.3-ix86
package sqlite3 3.7.4   linux-glibc2.3-ix86
package sqlite3 3.7.5   linux-glibc2.3-ix86
package sqlite3 3.7.6.3 linux-glibc2.3-ix86

I decided to drop everything below version 3.7. First, just locate them, to make sure that I got the right ones

% teacup search --at-default eq name sqlite3 and lt version 3.7
entity  name    version platform
------- ------- ------- -------------------
package sqlite3 3.6.17  linux-glibc2.3-ix86
package sqlite3 3.6.18  linux-glibc2.3-ix86
package sqlite3 3.6.19  linux-glibc2.3-ix86
package sqlite3 3.6.20  linux-glibc2.3-ix86
package sqlite3 3.6.21  linux-glibc2.3-ix86
package sqlite3 3.6.22  linux-glibc2.3-ix86
package sqlite3 3.6.23  linux-glibc2.3-ix86
------- ------- ------- -------------------
7 entities found

Convert the output of the search into a script, which, when run, removes the unwanted packages...

% teacup search --at-default eq name sqlite3 and lt version 3.7|grep pack|sed -e 's|^|teacup remove --is |'
teacup remove --is package sqlite3 3.6.17  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.18  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.19  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.20  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.21  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.22  linux-glibc2.3-ix86
teacup remove --is package sqlite3 3.6.23  linux-glibc2.3-ix86

Now this can be either saved to a file and then run via sh or bash, or directly piped into it, like

% teacup search --at-default eq name sqlite3 and lt version 3.7|grep pack|sed -e 's|^|teacup remove --is |' | sh
 Removing instance package sqlite3 3.6.17 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.18 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.19 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.20 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.21 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.22 linux-glibc2.3-ix86
 Removing instance package sqlite3 3.6.23 linux-glibc2.3-ix86

MHo Yes, I overlooked the capabilties of search... I'll have to modify this a bit so it works on MS Windows, but it should be possible anyway. I have to walk through all packages in such a way...

MHo 2012-11-03: If I remove old packages, how to prevent teacup update from reinstalling them? Here's my try for ms windows:

@echo off
rem Removing old objects from local repository
rem see https://wiki.tcl-lang.org/20572
if %3.==. (
   echo %%1 = type ^(like package or application^)
   echo %%2 = name
   echo %%3 = versions below and including this are subject of removal
   goto :EOF
)
for /f "usebackq tokens=1-3" %%i in (`teacup search --at-default eq name %2 and le version %3^|find "%1"`) do echo teacup remove --is %%i %%j %%k
echo Um abzubrechen, ^^C druecken
pause
for /f "usebackq tokens=1-3" %%i in (`teacup search --at-default eq name %2 and le version %3^|find "%1"`) do teacup remove --is %%i %%j %%k