1.\" $NetBSD: pkg_admin.1,v 1.7 2021/04/10 19:49:59 nia Exp $ 2.\" 3.\" Copyright (c) 1999-2019 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Hubert Feyrer <hubert@feyrer.de> and 8.\" by Joerg Sonnenberger <joerg@NetBSD.org>. 9.\" 10.\" Redistribution and use in source and binary forms, with or without 11.\" modification, are permitted provided that the following conditions 12.\" are met: 13.\" 1. Redistributions of source code must retain the above copyright 14.\" notice, this list of conditions and the following disclaimer. 15.\" 2. Redistributions in binary form must reproduce the above copyright 16.\" notice, this list of conditions and the following disclaimer in the 17.\" documentation and/or other materials provided with the distribution. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29.\" POSSIBILITY OF SUCH DAMAGE. 30.\" 31.Dd August 22, 2020 32.Dt PKG_ADMIN 1 33.Os 34.Sh NAME 35.Nm pkg_admin 36.Nd perform various administrative tasks to the pkg system 37.Sh SYNOPSIS 38.Nm 39.Op Fl bqSVv 40.Op Fl C Ar config 41.Op Fl d Ar lsdir 42.Op Fl K Ar pkg_dbdir 43.Op Fl s Ar sfx_pattern 44.Ar command Op args ... 45.Sh DESCRIPTION 46This command performs various administrative tasks around the 47.Nx 48Packages System. 49.Sh OPTIONS 50The following command-line options are supported: 51.Bl -tag -width indent 52.It Fl b 53Print only the base names when matching package names for 54.Cm lsall 55and 56.Cm lsbest . 57.It Fl C Ar config 58Read the configuration file from 59.Ar config 60instead of the system default. 61.It Fl d Ar lsdir 62Set 63.Ar lsdir 64as the path to the directory in which to find matching package names for 65.Cm lsall 66and 67.Cm lsbest . 68.It Fl K Ar pkg_dbdir 69Override the value of the 70.Dv PKG_DBDIR 71configuration option with the value 72.Ar pkg_dbdir . 73.It Fl q 74Perform checks in a quiet manner. 75In normal operation, 76.Nm 77prints a 78.Sq \&. 79to standard output to indicate progress. 80This option suppresses this progress indicator. 81.It Fl S 82Set the shell glob pattern for package suffixes when matching package 83names for 84.Cm lsall 85and 86.Cm lsbest 87to be the null suffix. 88.It Fl s Ar sfx_pattern 89Set the shell glob pattern for package suffixes when matching package 90names for 91.Cm lsall 92and 93.Cm lsbest . 94The default pattern is ".t[bg]z". 95.It Fl V 96Print version number and exit. 97.It Fl v 98Be more verbose. 99.El 100.Pp 101The following commands are supported: 102.Bl -tag -width indent 103.It Cm audit Oo Fl eis Oc Oo Fl t Ar type Oc Oo Ar pkg Oc ... 104Check the listed installed packages for vulnerabilities. 105If no package is given, check all installed packages. 106If 107.Fl e 108is given, override the 109.Dv CHECK_END_OF_LIFE 110option from 111.Xr pkg_install.conf 5 112with 113.Qq Li yes . 114If 115.Fl i 116is given, 117any advisory ignored by 118.Dv IGNORE_URL 119in 120.Xr pkg_install.conf 5 121is included but flagged as 122.Qq ignored . 123If 124.Fl s 125is given, check the signature of the pkg-vulnerabilities file before using it. 126.Fl t 127restricts the reported vulnerabilities to type 128.Ar type . 129.It Cm audit-pkg Oo Fl eis Oc Oo Fl t Ar type Oc Oo Ar pkg Oc ... 130Like 131.Cm audit , 132but check only the given package names or patterns. 133.It Cm audit-batch Oo Fl eis Oc Oo Fl t Ar type Oc Oo Ar pkg-list Oc ... 134Like 135.Cm audit-pkg , 136but read the package names or patterns one per line from the given files. 137.It Cm audit-history Oo Fl s Oc Oo Fl t Ar type Oc Oo Ar pkgbase Oc ... 138Print all vulnerabilities for the given base package names. 139.It Cm check Op Ar pkg ... 140Use this command to check the files belonging to some or all of the 141packages installed on the local machine against the checksum 142which was recorded in the 143.Pa +CONTENTS 144files at package installation time. 145Symbolic links also have their integrity checked against the recorded 146value at package installation time. 147If no additional argument is given, the files of all installed packages 148are checked, else only the named packages will be checked (wildcards can 149be used here, see 150.Xr pkg_info 1 ) . 151.Pp 152The packages' 153.Pa +CONTENTS 154files will be parsed and the 155checksum will be checked for every file found. 156A warning message is printed if the expected checksum differs from the 157checksum of the file on disk. 158Symbolic links are also checked, ensuring that the targets on disk are 159the same as the contents recorded at package installation time. 160.It Cm check-license Ar condition 161Check if 162.Ar condition 163can be fulfilled with the currently set of accepted licenses. 164Prints either yes or no to stdout if the condition can be parsed, 165otherwise it exits with error. 166.It Cm check-pkg-vulnerabilities Oo Fl s Oc Ar file 167Check format and hashes in the pkg-vulnerabilities file 168.Ar file . 169If 170.Fl s 171is given, also check the embedded signature. 172.It Cm check-signature Ar file ... 173Reports if 174.Ar file 175is a correctly signed package. 176.It Cm check-single-license Ar license 177Check if 178.Ar license 179is a valid license name and if it is in the set of acceptable licenses. 180Prints either yes or no to stdout if the condition can be parsed, 181otherwise it exits with error. 182.It Cm config-var Ar variable 183Print the current value of 184.Ar variable 185as used after parsing the configuration file. 186.It Cm digest Ar file ... 187Compute a SHA256 message digest of 188.Ar file . 189.It Cm dump 190Dump the contents of the package database, similar to 191.Cm pkg_info -F . 192Columns are printed for the key field used in the pkgdb - the filename -, 193and the data field - the package the file belongs to. 194.It Cm fetch-pkg-vulnerabilities Oo Fl su Oc 195Fetch a new pkg-vulnerabilities file, check the format and if 196.Fl s 197is given the signature. 198If all checks are passed, write it to pkgdb. 199If 200.Fl u 201is given, the fetch is conditional and the file transfer is only done if 202the remote version is newer than the one in pkgdb. 203.It Cm findbest Ar pattern ... 204Search the entries of 205.Dv PKG_PATH 206for packages matching 207.Ar pattern . 208Print the URL of the best matching package to stdout for each pattern. 209If a pattern is not matched, it is skipped and the command will return 210a failure. 211.It Cm gpg-sign-package pkg spkg 212Sign the binary package 213.Ar pkg 214using GPG and write the result to 215.Ar spkg . 216.It Cm lsall Ar /dir/pkgpattern 217.It Cm lsbest Ar /dir/pkgpattern 218List all/best package matching pattern in the given directory 219.Pa /dir . 220If the 221.Fl d 222flag is given, then that directory path overrides 223.Pa /dir . 224Can be used to work around limitations of /bin/sh and other 225filename globbing mechanisms. 226This option implements matching of 227pkg-wildcards against arbitrary files and directories, useful mainly in 228the build system itself. 229See 230.Xr pkg_info 1 231for a description of the pattern. 232.Pp 233Example: 234.Bd -literal 235yui# cd /usr/pkgsrc/packages/i386ELF/All/ 236yui# ls unzip* 237unzip-5.40.tgz unzip-5.41.tgz 238yui# pkg_admin lsall 'unzip*' 239/usr/pkgsrc/packages/i386ELF/All/unzip-5.40.tgz 240/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz 241yui# pkg_admin lsall 'unzip\*[Ge]5.40' 242/usr/pkgsrc/packages/i386ELF/All/unzip-5.40.tgz 243/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz 244yui# pkg_admin lsall 'unzip\*[Ge]5.41' 245/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz 246yui# pkg_admin lsbest 'unzip\*[Ge]5.40' 247/usr/pkgsrc/packages/i386ELF/All/unzip-5.41.tgz 248yui# pkg_admin lsall /usr/pkgsrc/packages/i386ELF/All/'{mit,unproven}-pthread*' 249/usr/pkgsrc/packages/i386ELF/All/mit-pthreads-1.60b6.tgz 250/usr/pkgsrc/packages/i386ELF/All/unproven-pthreads-0.15.tgz 251.Ed 252.It Cm pmatch Ar pattern Ar pkg 253Returns true if 254.Ar pkg 255matches 256.Ar pattern , 257otherwise returns false. 258.It Cm rebuild 259Rebuild the package database mapping from scratch, using the 260.Pa +CONTENTS 261files of the installed packages. 262This option is only intended for recovery after system crashes 263during package installation and removal. 264.It Cm rebuild-tree 265Rebuild the +REQUIRED_BY files from scratch by reresolving all dependencies. 266.Pp 267This option is intended to be used for fixing inconsistencies between 268the records of depending and depended-on packages, such as can arise 269by the use of 270.Cm pkg_delete -f . 271.It Cm set Ar variable=value pkg ... 272Set variable with information about the installed package. 273Use 274.Cm unset 275to remove a variable. 276.Pp 277Packages that are not installed directly by the user but pulled in as 278dependencies are marked by setting 279.Dq automatic=YES . 280.It Cm x509-sign-package pkg spkg key cert 281Sign the binary package 282.Ar pkg 283using the key 284.Ar key 285and the certificate 286.Ar cert , 287using 288.Ar spkg 289as output file. 290.It Cm unset Ar variable pkg ... 291Remove an installation variable. 292.El 293.Sh ENVIRONMENT 294See 295.Xr pkg_install.conf 5 296for options, that can also be specified using the environment. 297.Sh FILES 298.Bl -tag -width @PREFIX@/pkgdb/pkgdb.byfile.db -compact 299.It Pa @PREFIX@/pkgdb/pkgdb.byfile.db 300.It Pa @PREFIX@/pkgdb/\*[Lt]pkg\*[Gt]/+CONTENTS 301.El 302.Sh SEE ALSO 303.Xr pkg_add 1 , 304.Xr pkg_create 1 , 305.Xr pkg_delete 1 , 306.Xr pkg_info 1 , 307.Xr pkg_install.conf 5 , 308.Xr pkgsrc 7 309.Sh HISTORY 310The 311.Nm 312command first appeared in 313.Nx 1.4 . 314.Sh AUTHORS 315The 316.Nm 317command was written by Hubert Feyrer. 318