pkg-query.8
1 .\" 2 .\" FreeBSD pkg - a next generation package for the installation and maintenance 3 .\" of non-core utilities. 4 .\" 5 .\" Redistribution and use in source and binary forms, with or without 6 .\" modification, are permitted provided that the following conditions 7 .\" are met: 8 .\" 1. Redistributions of source code must retain the above copyright 9 .\" notice, this list of conditions and the following disclaimer. 10 .\" 2. Redistributions in binary form must reproduce the above copyright 11 .\" notice, this list of conditions and the following disclaimer in the 12 .\" documentation and/or other materials provided with the distribution. 13 .\" 14 .\" 15 .\" @(#)pkg.8 16 .\" 17 .Dd December 13, 2025 18 .Dt PKG-QUERY 8 19 .Os 20 .Sh NAME 21 .Nm "pkg query" 22 .Nd query information for packages 23 .Sh SYNOPSIS 24 .Nm 25 .Ao query-format Ac Ao pkg-name Ac 26 .Pp 27 .Nm 28 .Op Fl a 29 .Ao query-format Ac 30 .Nm 31 .Fl F Ao pkg-file Ac Ao query-format Ac 32 .Nm 33 .Op Fl Cgix 34 .Op Fl e Ao evaluation-condition Ac 35 .Ao query-format Ac Ao pattern Ac Ao ... Ac 36 .Pp 37 .Nm 38 .Op Cm --all 39 .Ao query-format Ac 40 .Nm 41 .Cm --file Ao pkg-file Ac Ao query-format Ac 42 .Nm 43 .Op Cm --{case-sensitive,glob,case-insensitive,regex} 44 .Op Cm --evaluate Ao evaluation-condition Ac 45 .Ao query-format Ac Ao pattern Ac Ao ... Ac 46 .Sh DESCRIPTION 47 .Nm 48 is used for displaying information about packages. 49 .Sh OPTIONS 50 The following options are supported by 51 .Nm : 52 .Bl -tag -width evaluate 53 .It Fl a , Cm --all 54 Match all packages from the database 55 .It Fl C , Cm --case-sensitive 56 Make the standard or the regular expression 57 .Fl ( x ) 58 matching against 59 .Ar pkg-name 60 in pattern case sensitive. 61 .It Fl e , Cm --evaluate 62 Match packages using the given 63 .Ar evaluation-condition . 64 See 65 .Sx EVALUATION FORMAT 66 for details. 67 .It Fl F Ar pkg-file , Cm --file Ar pkg-file 68 Display information only for the package file 69 .Ar pkg-name . 70 .It Fl i , Cm --case-insensitive 71 Make the standard or regular expression 72 .Fl ( x ) 73 matching against 74 .Ar pkg-name 75 in pattern case insensitive. 76 This is the default, unless modified by setting 77 .Ev CASE_SENSITIVE_MATCH 78 to true in 79 .Pa pkg.conf . 80 .It Fl g , Cm --glob 81 Treat 82 .Ao pattern Ac 83 as a glob pattern. 84 .It Fl x , Cm --regex 85 Treat 86 .Ao pattern Ac 87 as a regular expression according to the "modern" or "extended" syntax 88 of 89 .Xr re_format 7 . 90 .El 91 .Sh QUERY FORMAT 92 There are two types of keywords for the query format: the multiline and the 93 normal one. 94 Only one type of multiline pattern is accepted for a given query. 95 .Ss Normal patterns 96 .Bl -tag -width F1 97 .It Cm \&%n 98 Name of the matched package 99 .It Cm \&%v 100 Version of the matched package 101 .It Cm \&%o 102 Origin of the matched package 103 .It Cm \&%p 104 Prefix of the matched package 105 .It Cm \&%m 106 Maintainer of the matched package 107 .It Cm \&%c 108 Comment of the matched package 109 .It Cm \&%e 110 Description of the matched package 111 .It Cm \&%w 112 Home page of the matched package 113 .It Cm \&%V 114 Returns 0 if the package is not marked as 115 .Qq vital , 116 and 1 if the package is marked 117 .Qq vital . 118 .It Cm \&%l 119 License logic of the matched package - nothing for single, & for AND, and | for OR 120 .It Cm \&%s Ns Op bh 121 The flat size of the matched package, where 122 .Cm b 123 is in bytes, and 124 .Cm h 125 is in human readable format. 126 .It Cm \&%a 127 Returns 1 if the matched package was automatically installed 128 as a dependency of another package, 0 otherwise. 129 The package can be automatically removed via 130 .Sq pkg autoremove 131 when this flag is set and no other package depends on it. 132 .It Cm \&%Q 133 Alternative architecture of the matched package 134 .It Cm \&%q 135 Architecture of the matched package 136 .It Cm \&%k 137 Returns 1 if the matched package is locked against modification or deletion, 0 otherwise 138 .It Cm \&%M 139 message contained in the matched package 140 .It Cm \&%t 141 Timestamp that the package was installed 142 .It Cm \&%R 143 The name of the repository from which the package was installed if 144 available, or 145 .Dq unknown-repository 146 otherwise. 147 .It Cm \&%X 148 Internal package checksum 149 .It Cm \&%\&? Ns Op drCFODLUGBbAyY 150 Returns 0 if the list is empty and 1 if the list has information to display. 151 .Bl -tag -width indent 152 .It Cm d 153 for dependencies 154 .It Cm r 155 for reverse dependencies 156 .It Cm C 157 for categories 158 .It Cm F 159 for files 160 .It Cm O 161 for options 162 .It Cm D 163 for directories 164 .It Cm L 165 for licenses 166 .It Cm U 167 for users 168 .It Cm G 169 for groups 170 .It Cm B 171 for required shared libraries 172 .It Cm b 173 for provided shared libraries 174 .It Cm y 175 for provides 176 .It Cm Y 177 for requires 178 .It Cm A 179 for annotations 180 .El 181 .It Cm \&%# Ns Op drCFODLUGBbAyY 182 Returns the number of elements in the list 183 .Bl -tag -width indent 184 .It Cm d 185 for dependencies 186 .It Cm r 187 for reverse dependencies 188 .It Cm C 189 for categories 190 .It Cm F 191 for files 192 .It Cm O 193 for options 194 .It Cm D 195 for directories 196 .It Cm L 197 for licenses 198 .It Cm U 199 for users 200 .It Cm G 201 for groups 202 .It Cm B 203 for required shared libraries 204 .It Cm b 205 for provided shared libraries 206 .It Cm y 207 for provides 208 .It Cm Y 209 for requires 210 .It Cm A 211 for annotations 212 .El 213 .El 214 .Ss Multiline patterns 215 .Bl -tag -width F1 216 .It Cm \&%d Ns Op nov 217 Expands to the list of dependencies for the matched package, where 218 .Cm n 219 stands for the package name, 220 .Cm o 221 for the package origin, and 222 .Cm v 223 for the package version. 224 .It Cm \&%r Ns Op nov 225 Expands to the list of reverse dependencies for the matched package, where 226 .Cm n 227 stands for the package name, 228 .Cm o 229 for the package origin, and 230 .Cm v 231 for the package version. 232 .It Cm \&%C 233 Expands to the list of categories the matched package belongs to. 234 .It Cm \&%F Ns Op psugmftl 235 Expands to the list of files of the matched package, where 236 .Cm p 237 stands for path, 238 .Cm s 239 for checksum, 240 .Cm u 241 for owner, 242 .Cm g 243 for group, 244 .Cm m 245 for mode (permissions), 246 .Cm f 247 for file flags, 248 .Cm l 249 for last modification time, and 250 .Cm t 251 for the symlink target (or empty string if no symlink). 252 .It Cm \&%D 253 Expands to the list of directories of the matched package. 254 .It Cm \&%S Ns Op pugmf 255 Expands to the list of (sub-)directories of the matched package, where 256 .Cm p 257 stands for path, 258 .Cm u 259 for owner, 260 .Cm g 261 for group, 262 .Cm m 263 for mode (permissions), and 264 .Cm f 265 for file flags. Same as 266 .Cm \&%D 267 but allows specifying suboptions. 268 .It Cm \&%O Ns Op kvdD 269 Expands to the list of options of the matched package, where 270 .Cm k 271 stands for option key, 272 .Cm v 273 for option value, 274 .Cm d 275 for option default value and 276 .Cm D 277 for option description. 278 Option default values and descriptions are optional metadata and may 279 be blank for certain packages. 280 .It Cm \&%L 281 Expands to the list of license(s) for the matched package. 282 .It Cm \&%U 283 Expands to the list of users needed by the matched package. 284 .It Cm \&%G 285 Expands to the list of groups needed by the matched package. 286 .It Cm \&%B 287 Expands to the list of shared libraries used by programs from the matched package. 288 .It Cm \&%b 289 Expands to the list of shared libraries provided by the matched package. 290 .It Cm \&%y 291 Expands to the list of provides for the matched package. 292 .It Cm \&%Y 293 Expands to the list of requires for the matched package. 294 .It Cm \&%A Ns Op tv 295 Expands to the list of annotations for the matched package, 296 where 297 .Cm t 298 stands for the annotation tag, and 299 .Cm v 300 stands for the annotation value. 301 .El 302 .Sh EVALUATION FORMAT 303 Packages can be selected by using expressions comparing 304 .Ar Variables 305 (see below) to string or integer values. 306 The mode of comparison is specified by the 307 .Ar Operator 308 (also listed below). 309 Expressions can be combined using && (for and) and || (for or). 310 Parentheses can be used for grouping in the usual manner. 311 .Pp 312 String values are either any text not containing whitespace (possibly 313 followed by but not including whitespace) or any text enclosed in single or 314 double quotes. 315 .Ss Normal Variables 316 .Bl -tag -width F1 317 .It Cm \&%n 318 Name of the package (type string) 319 .It Cm \&%o 320 Origin of the package (type string) 321 .It Cm \&%p 322 Prefix of the package (type string) 323 .It Cm \&%m 324 Maintainer of the package (type string) 325 .It Cm \&%c 326 Comment of the package (type string) 327 .It Cm \&%e 328 Description of the package (type string) 329 .It Cm \&%w 330 WWW address of the package (type string) 331 .It Cm \&%s 332 Flatsize of the package (type integer) 333 .It Cm \&%a 334 Automatic status of the package (type integer) 335 .It Cm \&%q 336 Architecture of the package (type string) 337 .It Cm \&%k 338 Locking status of the package (type integer) 339 .It Cm \&%M 340 Message of the package (type string) 341 .It Cm \&%t 342 Timestamp that the package was installed (type integer) 343 .It Cm \&%i 344 Additional information about the package (type string) 345 .It Cm \&%# Ns Op drCFODLUGBbAyY 346 Number of elements in the list of information (type integer). 347 See 348 .Cm %? 349 above for what information is used. 350 .El 351 .Ss Multiline variables 352 When used in an evaluation, these variables refer to the items in the list. 353 The condition evaluates to true if 354 .Em any 355 element in the list matches. 356 Negative operators are an exception: they check for the 357 .Em absence 358 of any matching element. 359 .Pp 360 For example, 361 .Qq \&%dn != 'curl' 362 means 363 .Qq the package does not depend on curl . 364 .Bl -tag -width F1 365 .It Cm \&%d Ns Op nov 366 Dependency of the package (type string) 367 .It Cm \&%r Ns Op nov 368 Reverse dependency of the package (type string) 369 .It Cm \&%C 370 Category of the package (type string) 371 .It Cm \&%L 372 License of the package (type string) 373 .It Cm \&%B 374 Required shared library of the package (type string) 375 .It Cm \&%b 376 Provided shared library of the package (type string) 377 .It Cm \&%y 378 Provide of the package (type string) 379 .It Cm \&%Y 380 Require of the package (type string) 381 .It Cm \&%A Ns Op tv 382 Annotation of the package (type string) 383 .El 384 .Ss Operators 385 .Bl -tag -width F1 386 .It Va var Cm ~ Ar glob 387 The string value of 388 .Va var 389 matches the given glob pattern. 390 .It Va var Cm !~ Ar glob 391 The string value of 392 .Va var 393 does not match the given glob pattern. 394 .It Va var Cm > Ns Oo = Oc Ar num 395 The numerical value of 396 .Va var 397 is greater than 398 .Op or equal to 399 the given number. 400 .It Va var Cm < Ns Oo = Oc Ar num 401 The numerical value of 402 .Va var 403 is less than 404 .Op or equal to 405 the given number. 406 .It Va var Cm = Ns Oo = Oc Oo Ar num | Ar string Oc 407 The value of 408 .Va var 409 is equal to the given number or string. 410 .It Va var Cm =~ Oo Ar num | Ar string Oc 411 The value of 412 .Va var 413 is equal (case insensitive) to the given number or string. 414 .It Va var Cm != Oo Ar num | Ar string Oc 415 The value of 416 .Va var 417 is not equal to the given number or string. 418 .It Va var Cm !=~ Oo Ar num | Ar string Oc 419 The value of 420 .Va var 421 is not equal case insensitive to the given number or string. 422 .El 423 .Sh ENVIRONMENT 424 The following environment variables affect the execution of 425 .Nm . 426 See 427 .Xr pkg.conf 5 428 for further description. 429 .Bl -tag -width ".Ev NO_DESCRIPTIONS" 430 .It Ev PKG_DBDIR 431 .It Ev CASE_SENSITIVE_MATCH 432 .El 433 .Sh FILES 434 See 435 .Xr pkg.conf 5 . 436 .Sh EXIT STATUS 437 .Ex -std 438 .Sh EXAMPLES 439 List all installed packages by name-version: 440 .Dl $ pkg query %n-%v 441 .Pp 442 List all dependencies for a package by origin: 443 .Dl $ pkg query %do subversion 444 .Pp 445 List all dependencies by package name-version: 446 .Dl $ pkg query %dn-%dv subversion 447 .Pp 448 List all reverse dependencies for a package: 449 .Dl $ pkg query %ro perl 450 .Pp 451 List all files and their known checksums for a package: 452 .Dl $ pkg query '%Fp %Fs' perl 453 .Pp 454 List all files for all packages: 455 .Dl $ pkg query '%o: %Fp' 456 .Pp 457 List all packages with no reverse dependencies: 458 .Dl $ pkg query -e '%#r = 0' %o 459 .Pp 460 List non-automatic packages: 461 .Dl $ pkg query -e '%a = 0' %o 462 .Pp 463 List automatic packages: 464 .Dl $ pkg query -e '%a = 1' %o 465 .Pp 466 List unmaintained packages: 467 .Dl $ pkg query -e '%m = ports@FreeBSD.org' %o 468 .Pp 469 List packages that depend on python312: 470 .Dl $ pkg query -e '%dn = python312' %o 471 .Sh SEE ALSO 472 .Xr pkg_create 3 , 473 .Xr pkg_printf 3 , 474 .Xr pkg_repo_create 3 , 475 .Xr pkg_repos 3 , 476 .Xr pkg-keywords 5 , 477 .Xr pkg-lua-script 5 , 478 .Xr pkg-repository 5 , 479 .Xr pkg-script 5 , 480 .Xr pkg-triggers 5 , 481 .Xr pkg.conf 5 , 482 .Xr pkg 8 , 483 .Xr pkg-add 8 , 484 .Xr pkg-alias 8 , 485 .Xr pkg-annotate 8 , 486 .Xr pkg-audit 8 , 487 .Xr pkg-autoremove 8 , 488 .Xr pkg-check 8 , 489 .Xr pkg-clean 8 , 490 .Xr pkg-config 8 , 491 .Xr pkg-create 8 , 492 .Xr pkg-delete 8 , 493 .Xr pkg-fetch 8 , 494 .Xr pkg-help 8 , 495 .Xr pkg-info 8 , 496 .Xr pkg-install 8 , 497 .Xr pkg-key 8 , 498 .Xr pkg-lock 8 , 499 .Xr pkg-plugins 8 , 500 .Xr pkg-register 8 , 501 .Xr pkg-repo 8 , 502 .Xr pkg-repositories 8 , 503 .Xr pkg-rquery 8 , 504 .Xr pkg-search 8 , 505 .Xr pkg-set 8 , 506 .Xr pkg-shell 8 , 507 .Xr pkg-shlib 8 , 508 .Xr pkg-ssh 8 , 509 .Xr pkg-stats 8 , 510 .Xr pkg-triggers 8 , 511 .Xr pkg-unregister 8 , 512 .Xr pkg-update 8 , 513 .Xr pkg-updating 8 , 514 .Xr pkg-upgrade 8 , 515 .Xr pkg-version 8 , 516 .Xr pkg-which 8