1.\" $NetBSD: pkg_delete.1,v 1.1.1.8 2010/04/23 20:54:08 joerg Exp $ 2.\" 3.\" FreeBSD install - a package for the installation and maintenance 4.\" of non-core utilities. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 15.\" Jordan K. Hubbard 16.\" 17.\" 18.\" from FreeBSD: @(#)pkg_delete.1 19.\" 20.Dd January 20, 2010 21.Dt PKG_DELETE 1 22.Os 23.Sh NAME 24.Nm pkg_delete 25.Nd a utility for deleting previously installed software package distributions 26.Sh SYNOPSIS 27.Nm 28.Op Fl ADFfkNnORrVv 29.Op Fl K Ar pkg_dbdir 30.Op Fl P Ar destdir 31.Op Fl p Ar prefix 32.Ar pkg-name ... 33.Sh DESCRIPTION 34The 35.Nm 36command is used to delete packages that have been previously installed 37with the 38.Xr pkg_add 1 39command. 40The given packages are sorted, so that the dependencies needed by a 41package are deleted after the package. 42Before any action is executed, 43.Nm 44checks for packages that are marked as 45.Cm preserved 46or have depending packages left. 47If the 48.Fl k 49flag is given, preserved packages are skipped and not removed. 50Unless the 51.Fl f 52flag is given, 53.Nm 54stops on the first error. 55.Sh WARNING 56.Bf -emphasis 57Since the 58.Nm 59command may execute scripts or programs provided by a package file, 60your system may be susceptible to 61.Dq Trojan horses 62or other subtle 63attacks from miscreants who create dangerous package files. 64.Pp 65You are advised to verify the competence and identity of those who 66provide installable package files. 67For extra protection, examine all the package control files in the 68package record directory 69.Pa \*[Lt]PKG_DBDIR\*[Gt]/\*[Lt]pkg-name\*[Gt]/ ) . 70Pay particular 71attention to any 72.Pa +INSTALL 73or 74.Pa +DEINSTALL 75files, and inspect the 76.Pa +CONTENTS 77file for 78.Cm @cwd , 79.Cm @mode 80(check for setuid), 81.Cm @dirrm , 82.Cm @exec , 83and 84.Cm @unexec 85directives, and/or use the 86.Xr pkg_info 1 87command to examine the installed package control files. 88.Ef 89.Sh OPTIONS 90The following command line options are supported: 91.Bl -tag -width indent 92.It Ar pkg-name ... 93The named packages are deinstalled, wildcards can be used, see 94.Xr pkg_info 1 . 95If no version is given, the one currently installed 96will be removed. 97If the 98.Fl F 99flag is given, one or more (absolute) filenames may be specified and 100the package database will be consulted for the package to which the 101given file belongs. 102These packages are then deinstalled. 103.It Fl A 104Recursively remove all automatically installed packages that were needed 105by the given packages and are no longer required. 106Does not remove manually installed packages; see also the 107.Fl R 108flag. 109.It Fl D 110If a deinstallation script exists for a given package, do not execute it. 111.It Fl F 112Any 113.Ar pkg-name 114given will be interpreted as pathname which is 115subsequently transformed in a (real) package name via the package 116database. 117That way, packages can be deleted by giving a filename 118instead of the package-name. 119.It Fl f 120Force removal of the package, even if a dependency is recorded or the 121deinstall script fails. 122This might break the package database; see 123.Xr pkg_admin 1 124on how to repair it. 125.It Fl ff 126Force removal of the package, even if the package is marked as a 127.Cm preserved 128package. 129Note that this is a dangerous operation. 130See also the 131.Fl k 132option. 133.It Fl K Ar pkg_dbdir 134Override the value of the 135.Dv PKG_DBDIR 136configuration option with the value 137.Ar pkg_dbdir . 138.It Fl k 139Silently skip all packages that are marked as 140.Cm preserved . 141.It Fl N 142Remove the package's registration and its entries from the package database, 143but leave the files installed. 144Don't run any deinstall scripts or 145.Cm @unexec 146lines either. 147.It Fl n 148Don't actually deinstall a package, just report the steps that 149would be taken. 150.It Fl O 151Only delete the package's entries from the package database; do not 152touch the package or its files itself. 153.It Fl P Ar destdir 154Prefix all file and directory names with 155.Ar destdir . 156For packages without install scripts this has the same behavior as 157using 158.Xr chroot 8 . 159.It Fl p Ar prefix 160Set 161.Ar prefix 162as the directory in which to delete files from any installed packages 163which do not explicitly set theirs. 164For most packages, the prefix will 165be set automatically to the installed location by 166.Xr pkg_add 1 . 167.It Fl R 168Recursively remove all packages that were needed by the given packages 169and are no longer required. 170This option overrides the 171.Fl A 172flag. 173.It Fl r 174Recursively remove all packages that require one of the packages given. 175.It Fl V 176Print version number and exit. 177.It Fl v 178Turn on verbose output. 179.El 180.Sh TECHNICAL DETAILS 181.Nm 182does pretty much what it says. 183It examines installed package records in 184.Pa \*[Lt]PKG_DBDIR\*[Gt]/\*[Lt]pkg-name\*[Gt] , 185deletes the package contents, and finally removes the package records. 186.Pp 187If a package is required by other installed packages, 188.Nm 189will list those dependent packages and refuse to delete the package 190(unless the 191.Fl f 192option is given). 193.Pp 194If a package has been marked as a 195.Cm preserved 196package, it will not be able to be deleted 197(unless more than one occurrence of the 198.Fl f 199option is given). 200.Pp 201If a filename is given instead of a package name, the package of which 202the given file belongs to can be deleted if the 203.Fl F 204flag is given. 205The filename needs to be absolute, see the output produced by the 206.Xr pkg_info 1 207.Fl aF 208command. 209.Pp 210If a 211.Cm deinstall 212script exists for the package, it is executed before and after 213any files are removed. 214It is this script's responsibility to clean up any additional messy details 215around the package's installation, since all 216.Nm 217knows how to do is delete the files created in the original distribution. 218The 219.Ic deinstall 220script is called as: 221.Bd -filled -offset indent -compact 222.Cm deinstall 223.Aq Ar pkg-name 224.Ar VIEW-DEINSTALL 225.Ed 226before removing the package from a view, and as: 227.Bd -filled -offset indent -compact 228.Cm deinstall 229.Aq Ar pkg-name 230.Ar DEINSTALL 231.Ed 232before deleting all files and as: 233.Bd -filled -offset indent -compact 234.Cm deinstall 235.Aq Ar pkg-name 236.Ar POST-DEINSTALL 237.Ed 238after deleting them. 239Passing the keywords 240.Ar VIEW-DEINSTALL , 241.Ar DEINSTALL , 242and 243.Ar POST-DEINSTALL 244lets you potentially write only one program/script that handles all 245aspects of installation and deletion. 246.Pp 247All scripts are called with the environment variable 248.Ev PKG_PREFIX 249set to the installation prefix (see the 250.Fl p 251option above). 252This allows a package author to write a script 253that reliably performs some action on the directory where the package 254is installed, even if the user might have changed it by specifying the 255.Fl p 256option when running 257.Nm 258or 259.Xr pkg_add 1 . 260The scripts are also called with the 261.Ev PKG_METADATA_DIR 262environment variable set to the location of the 263.Pa +* 264meta-data files, and with the 265.Ev PKG_REFCOUNT_DBDIR 266environment variable set to the location of the package reference counts 267database directory. 268If the 269.Fl P 270flag was given to 271.Nm , 272.Ev PKG_DESTDIR 273will be set to 274.Ar destdir . 275.Sh ENVIRONMENT 276See 277.Xr pkg_install.conf 5 278for options, that can also be specified using the environment. 279.Sh SEE ALSO 280.Xr pkg_add 1 , 281.Xr pkg_admin 1 , 282.Xr pkg_create 1 , 283.Xr pkg_info 1 , 284.Xr pkg_install.conf 5 285.Xr pkgsrc 7 286.Sh AUTHORS 287.Bl -tag -width indent -compact 288.It "Jordan Hubbard" 289most of the work 290.It "John Kohl" 291refined it for 292.Nx 293.It "Hubert Feyrer" 294.Nx 295wildcard dependency processing, pkgdb, recursive "down" 296delete, etc. 297.It Joerg Sonnenberger 298Rewrote most of the code to compute correct order of deinstallation 299and to improve error handling. 300.El 301