Вы находитесь на странице: 1из 25

PKGNG - FreeBSD.

OS FreeBSD
, .
, ,
90', , , .
,
FreeBSD,
, 10 .
- ,
, ,
FreeBSD , , .
: ,
""
-
PKGNG.
PKGNG:

db (sqlite)

yaml

backup

wiki pkgng
wiki PkgPrimer
FAQ pkgng
BSDCAN Presentation PDF
Youtube Usenix presentationPKGNG

github :
github pkgng

pkgng
" ":

ports-mgmt/portmaster
ports-mgmt/portupgrade-devel
ports-mgmt/portupgrade
ports-mgmt/pkg_cutleaves
ports-mgmt/poudriere
ports-mgmt/poudriere-devel
ports-mgmt/portdowngrade
ports-mgmt/tinderbox-devel
ports-mgmt/portbuilder
sysutils/bsdstats

:
ports-mgmt/portmaster

pkgng:

salt support pkgng (in version 0.10)


cfengine support pkgng
puppet pkgng support
ruby bindings support pkgng
ports-mgmt/packagekit

FreeBSD.
FreeBSD pkg_install, ,
, :
/usr/sbin/pkg_add
/usr/sbin/pkg_create
/usr/sbin/pkg_delete
/usr/sbin/pkg_info
/usr/sbin/pkg_updating
/usr/sbin/pkg_version
sources :
# ls -la /usr/src/usr.sbin/pkg_install

, , PKGNG,
9.1-RELEASE FreeBSD , 9-Stable,
:
# ls -la /usr/sbin/pkg

Bootsrapping - :
/usr/ports/ports-mgmt/pkg

: - PKGNG PacKet management New


Next ( ) Generation.
- pkg.

FreeBSD
, OS FreeBSD :
( /sources);
, ,
.

- .
, FreeBSD , ,
.
:
ports-mgmt/portmaster
ports-mgmt/portupgrade

PKG

,
, .
/ , :
/var/db/pkg -
/var/db/ports -

:
# ls -la /var/db/pkg/perl-5.10.1_1/
total 488
-rw-r--r-1 root wheel
41 7 2010
-rw-r--r-1 root wheel 418192 26 2010
-rw-r--r-1 root wheel
4290 7 2010
-rw-r--r-1 root wheel
254 7 2010
-rwxr-xr-x
1 root wheel
4290 7 2010
-rw-r--r-1 root wheel
17501 7 2010
-rw-r--r-1 root wheel
2401 15 2011
drwxr-xr-x
2 root wheel
512 1 2010
drwxr-xr-x 556 root wheel
15360 25 13:36
#

+COMMENT
+CONTENTS
+DEINSTALL
+DESC
+INSTALL
+MTREE_DIRS
+REQUIRED_BY
.
..

:
# ls -la /var/db/ports/mc/
total 6
drwxr-xr-x
2 root wheel
drwxr-xr-x 25 root wheel
-rw-r--r-1 root wheel
#

512 27
512 17
243 27

2010 .
2012 ..
2010 options

PKGNG, backup /var/db/pkg, , pkgng,


pkg2ng
backup .
PKGNG
FreeBSD , pkgng :
# /usr/ports/ports-mgmt/pkg
# make install clean

,
# ls -la /usr/sbin/pkg

PACKAGESITE,PACKAGEROOT
pkg.
, pkg.conf
/usr/src/usr.sbin/pkg/pkg.c:
#define _LOCALBASE "/usr/local"
#define _PKGS_URL "http://pkgbeta.FreeBSD.org"

:
# echo $PACKAGESITE/Latest/pkg.txz

# echo $PACKAGEROOT/latest/Latest/pkg.txz

pkg.conf:
packagesite: http://pkgbeta.FreeBSD.org/freebsd:9:x86:64/latest

:
# pkg

# /usr/sbin/pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg please wait
Installing pkg-1.0.r5_1... done
If you are upgrading from the old package format, first run:
$ pkg2ng
1.0-rc5
#

, "y"
, :
# pkg2ng ( , )

:
# ls -la /var/db/pkg/
total 84320
drwxr-xr-x 2 root wheel
drwxr-xr-x 8 root wheel
-rw-r--r-- 1 root wheel
-rw-r--r-- 1 root wheel
#

512
512
120832
86149120

Sep
Sep
Sep
Sep

1
1
1
1

21:56
20:16
21:56
20:20

.
..
local.sqlite
repo.sqlite

sqlite,
: local.sqlite
: repo.sqlite

.
:
/var/db/pkg :
# ls -la /var/db/pkg/rsync-3.0.9_1/
total 12
drwxr-xr-x
2 root wheel
512 11 13:04 .
drwxr-xr-x 23 root wheel 1024 11 13:04 ..
-rw-r--r-1 root wheel
134 11 13:04 distfiles
#

pkg,
distfiles.
pkg2ng .
.
pkg,
WITH_PKGNG=yes /etc/make.conf.
.
-------------------------- /etc/make.conf --------------------------------...
WITH_PKGNG=yes

...
---------------------------------------------------------------------------

pkg
, .
/usr/local/etc/pkg.conf,
:
ASSUME_ALWAYS_YES
PACKAGESITE
PKG_MULTIREPOS

: [NO|YES]
: http://pkg.freebsd.org/${ABI}/latest ( )
: [NO|YES] ( )

:
PKG_DBDIR
= /var/db/pkg
PKG_CACHEDIR = /var/cache/pkg

pkg.conf, :
# Repository definitions
#repos:
# default : http://example.org/pkgng/
# repo1 : http://somewhere.org/pkgng/repo1/
# repo2 : http://somewhere.org/pkgng/repo2/

:
-y - "y [yes]",
-q - " stdout", stdout
( "1"? )
-f - "" ( pkg info)
-L -
-r -
pkg:
-g shell
-x
-X
:
-g
-x
-x
-X

a* -g "[0-z]*" -g "*rar" -g "?c"


"perl-5*" "^deco*$" -x "^mc-*$" -x "^mc-.*$"
".*rar$"
'(pkg)'

manual' ,
pkgng, .
# pkg ( help )
usage: pkg [-v] [-d] [-j |-c ] []
Global options supported:
-d
Increment debug level
-j
Execute pkg(1) inside a jail(8)
-c
Execute pkg(1) inside a chroot(8)
-v
Display pkg(1) version
Commands supported:
add
Registers a package and installs it on the system
...
...
For more information on the different commands see 'pkg help '.

:
# pkg -v
1.0
#

:
# pkg info
pkg-1.0
#

New generation package manager

:
# pkg info -a
pkg-1.0
portmaster-3.13.13
#

New generation package manager


Manage your ports without external databases or languages

:
# pkg info -f portmaster
Name
: portmaster
-
Version
: 3.13.13
-
Origin
: ports-mgmt/portmaster
- _/_
Prefix
: /usr/local
-
Categories
: ports-mgmt
-
Maintainer
: dougb@FreeBSD.org
WWW
: http://dougbarton.us/portmaster.html
Comment
: Manage your ports without external databases or languages
Options
:
BASH: on
-
ZSH: off
-
Flat size
: 133 kB
-
Description
:
This script uses the existing ports infrastructure to track dependencies,
and keep them up to date. It is written in /bin/sh so it has no dependencies.
Portmaster has the following features:
* Updates and repairs (as needed) entries for dependencies in both +CONTENTS
and +REQUIRED_BY files for both the port that is being updated, and any
ports that depend on it
* Runs make config recursively through all ports before starting build
* Downloads distfiles in the background
* Recursively checks and upgrades (or installs) all dependencies
* User can force upgrades of all dependent ports
* Offers the user the opportunity to delete stale distfiles
* Supports ports/MOVED and non-default settings of PORTSDIR and PKG_DBDIR
* Interactive update mode (prompts for each update)
* Option to rebuild port, and ports that depend on it
* Options to make packages out of installed, and new ports
* Option to clean out stale port dependencies
* Options to list installed ports by category, and those with new versions
* Packages can be used for installation either exclusively, if available,
or only for build dependencies
WWW: http://dougbarton.us/portmaster.html
#

,
""/"", :

: 0
: 1
# pkg info -e portmaster ; echo $?
0

# pkg info -e bash ; echo $?


1
#

:
# pkg info -l portmaster
portmaster-3.13.13 owns the following files:
/usr/local/etc/bash_completion.d/portmaster.sh
/usr/local/etc/portmaster.rc.sample
/usr/local/man/man8/portmaster.8.gz
/usr/local/sbin/portmaster
#

depends on ( ):
# pkg info -d apache22-worker-mpm
apache22-worker-mpm-2.2.22_8 depends on:
apr-1.4.6.1.4.1_1
expat-2.0.1_2
libiconv-1.14
pcre-8.31_1
perl-5.14.2_2
#

required by ( ):
# pkg info -r apr
apr-1.4.6.1.4.1_1 is required by:
apache22-worker-mpm-2.2.22_8
subversion-1.7.6
#

: pkg info
==============================< pkg info >=====================================
:
pkg info pkg info -a

:
pkg info name

:
pkg info -f name

:
pkg info -e name ; echo $?

:
pkg info -l name

:
pkg info -d name

:
pkg info -r name
==============================< pkg info >=====================================

?
: rquery,
<query-format>.
( ):
# pkg rquery -a "%n-%v - %c"
# pkg rquery -a "%n-%v - %c" | less
0verkill-0.16_1 - 0verkill is a bloody 2D action Deathmatch-like game in ASCII-art
2ManDVD-1.3.5_2 - Create your own video dvd
2bsd-diff-2.11 - 2.11BSD diff utility
2bsd-vi-050325_1 - The original vi editor, updated to run on modern OSes
2d-rewriter-1.4 - Cellular automata simulator
2dhf-2005.05_4 - A Numerical Hartree-Fock Program for Diatomic Molecules
2ping-1.1 - A bi-directional ping utility
3dc-0.8.1_3 - 3-Dimensional Chess for X Window System
3ddesktop-0.2.9_10 - 3D Virtual Desktop Switcher
...
...
zziplib-0.13.62 - A library to provide transparent read access to zipped files
zzuf-0.13 - Transparent application input fuzzer
#

, , :
# pkg rquery -a "%n-%v" | wc -l
21952
#

"ru-":
# pkg rquery -x '%n-%v' '^ru-.*$'
ru-MT-5.14
ru-PSCyr-0.4c2_4
ru-artwiz-ru-20041031_2
...
ru-xmms-1.2.11_16
ru-xruskb-1.15.4_2
#

-e query rquery
:
# pkg rquery -e
# pkg query -e

evaluation-condition :
- %n %o %v %m pkg-query(8)
- :
- >[=]
- <[=]
- =[=]
- !=

- ~

: && () , || () ()
- <query-format>
%n
%v
%o
%p
%m
%s[bh]
%M



( / )

maintainer ()
, b - , h -
pkg-message

%?[drCOLB] - , "0" , "1"


d -
r -
B -

:
[0-2]*
# pkg rquery -e '%n ~ [0-2]*' '%n-%v'
0verkill-0.16_1
2ManDVD-1.3.5_2
2bsd-diff-2.11
2bsd-vi-050325_1
2d-rewriter-1.4
2dhf-2005.05_4
2ping-1.1
#

: 500 < < 1000


# pkg rquery -e '(%s>500 && %s<1000)' '%o %sb'
security/crack 512
misc/kde-xdg-env 591

misc/kde4-xdg-env 601
devel/maven-wrapper 693
devel/pear-channel-openpear 824
ports-mgmt/pkg_remove 891
net-mgmt/ssgless 944
#

maintainer == miwi
py2*
# pkg rquery -e "%m ~ miwi* && %n ~py2*" "%n-%v"
py27-apachelog-1.1
py27-apetag-1.2
py27-bcrypt-0.2
py27-django-classy-tags-0.3.4.1
py27-psycopg2-2.4.5
py27-setuptools-git-0.4.2
py27-setuptools_hg-0.4
py27-texttable-0.8.1
#

: pkg rquery
==============================< pkg rquery >===================================

:
pkg rquery -a "%n"
,
:
pkg rquery -a "%n-%v"
glob
regexp

:
:

pkg rquery -g "%n-%v" 'un?r*'


pkg rquery -x "%n-%v" '^un[a-z].*$'

:
:
:

pkg rquery -e '%n ~ [0-2]*' '%n-%v'


pkg rquery -e '(%s>500 && %s<1000)' '%o %sb'
pkg rquery -e "%m ~ miwi* && %n ~py2*" "%n-%v"


:
pkg rquery "pkg depends on %do %dv" misc/mc
:
pkg rquery "pkg %n required by %ro %rv" devel/apr1
==============================< pkg rquery >===================================

/ c .

:
# pkg install rar
Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
The following packages will be installed:
Installing rar: 4.1.1,3
The installation will require 1 MB more space
36 B to be downloaded
Proceed with installing packages [y/N]: y
pkg: cached package rar-4.1.1,3: checksum mismatch, fetching from remote
rar-4.1.1,3.txz
100% 471KB 471.4KB/s 471.4KB/s
00:00
Checking integrity... done
Installing rar-4.1.1,3... done
#

portname:
# pkg search -x "^deco$"
deco-1.6.2_1
deco-3.9_4
#

A program to extract various archive file formats


Demos Commander, a free Norton Commander clone

() : -y , ,
: -L
# pkg install -Ly deco-3.9_4
The following packages will be installed:
Installing deco: 3.9_4
The installation will require 159 kB more space
4 B to be downloaded
pkg: cached package deco-3.9_4: checksum mismatch, fetching from remote
deco-3.9_4.txz
100%
75KB 75.4KB/s 75.4KB/s
00:01
Checking integrity... done
Installing deco-3.9_4... done
#

pkg-origin, category/portname,
:
# pkg install -y net/trafshow
Updating repository catalogue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -L repo
Repository catalogue is up-to-date, no need to fetch fresh copy
The following packages will be installed:
Installing trafshow: 5.2.3_2,1
The installation will require 111 kB more space
51 kB to be downloaded
trafshow-5.2.3_2,1.txz
100%
Checking integrity... done
Installing trafshow-5.2.3_2,1... done
#

51KB

51.0KB/s

51.0KB/s

00:00

, -n:
# pkg install -yn security/nmap
Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
The following packages will be installed:
Downgrading pkgconf: 0.8.9 -> 0.8.7_2
Installing lua: 5.1.5_4
Downgrading pcre: 8.31_1 -> 8.31
Installing nmap: 6.01
The installation will require 17 MB more space
3 MB to be downloaded
#

( ) -f, :
# pkg info -f deco | egrep -i "(version|origin)"
Version
: 3.9_4
Origin
: misc/deco
#

== , :
# pkg install -yfL misc/deco
pkg: misc/deco is already installed and at the latest version
The following packages will be installed:
Reinstalling deco-3.9_4
0 B to be downloaded

Checking integrity... done


Reinstalling deco-3.9_4 done
#

-Rf:
# pkg install -LRf security/nmap
The following packages will be installed:
Downgrading pkgconf: 0.8.9 -> 0.8.7_2
Downgrading pcre: 8.31_1 -> 8.31
Reinstalling glib-2.28.8_4
Reinstalling gamin-0.1.10_4
Installing lua: 5.1.5_4
Reinstalling sqlite3-3.7.13
Reinstalling gio-fam-backend-2.28.8_1
Installing nmap: 6.01
Reinstalling apache22-worker-mpm-2.2.22_8
Downgrading subversion: 1.7.6 -> 1.7.5
Reinstalling mc-4.8.1.4_1
The installation will require 33 MB more space
12 MB to be downloaded
Proceed with installing packages [y/N]: y
#

() :
# pkg install -yL audio/mpg123 sysutils/coreutils
The following packages will be installed:
Installing mpg123: 1.14.4
Installing coreutils: 8.12
The installation will require 18 MB more space
2 MB to be downloaded
mpg123-1.14.4.txz
coreutils-8.12.txz
Checking integrity... done
Installing mpg123-1.14.4... done
Installing coreutils-8.12... done
#

100% 172KB 172.0KB/s 172.0KB/s


100% 2340KB
2.3MB/s
2.3MB/s

00:00
00:00

, - , orphan
autoremove -A:
# pkg install -Ay security/clamav
Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
The following packages will be installed:
Installing
Installing
Installing
Installing
Installing

arc: 5.21p
arj: 3.10.22_4
lha: 1.14i_6
unzoo: 4.4_2
clamav: 0.97.5_1

The installation will require 15 MB more space


372 B to be downloaded
pkg: cached package arc-5.21p: checksum mismatch, fetching from remote
arc-5.21p.txz
100%
44KB 43.9KB/s 43.9KB/s
00:00
pkg: cached package arj-3.10.22_4: checksum mismatch, fetching from remote
arj-3.10.22_4.txz
100% 214KB 214.1KB/s 214.1KB/s
00:01
pkg: cached package lha-1.14i_6: checksum mismatch, fetching from remote
lha-1.14i_6.txz
100%
34KB 33.9KB/s 33.9KB/s
00:00

pkg: cached package unzoo-4.4_2: checksum mismatch, fetching from remote


unzoo-4.4_2.txz
100%
16KB 15.8KB/s 15.8KB/s
00:00
pkg: cached package clamav-0.97.5_1: checksum mismatch, fetching from remote
clamav-0.97.5_1.txz
100% 4164KB
2.0MB/s
4.0MB/s
00:02
Checking integrity... done
Installing arc-5.21p... done
Installing arj-3.10.22_4... done
Installing lha-1.14i_6... done
Installing unzoo-4.4_2... done
Installing clamav-0.97.5_1... done
#

- :
# pkg autoremove -y
Packages to be autoremoved:
clamav-0.97.5_1
arc-5.21p
arj-3.10.22_4
lha-1.14i_6
unzoo-4.4_2
The autoremoval will free 15 MB
Deleting clamav-0.97.5_1...
====================================================
If you want remove clamav permanently from you system
execute following commands:
#
#
#
#

rm
rm
rm
pw

-rf /var/log/clamav
-rf /var/run/clamav
-rf /var/db/clamav
userdel clamav

====================================================
done
Deleting
Deleting
Deleting
Deleting
#

arc-5.21p... done
arj-3.10.22_4... done
lha-1.14i_6... done
unzoo-4.4_2... done

: pkg install:
===========================< pkg install >=====================================
:
pkg install name[-version]
origin
:
pkg install category1/name1 category2/named2
local cache:
pkg install -yL category/name [category1/name1]

:
pkg install -yn category/name
:
:

pkg install -yLf category/name


pkg install -yLRf category/name

autoremove :
pkg install -Ay category/name
===========================< pkg install >=====================================


,
URL ftp/http:
# pkg info | grep clamav

, :
# ls -la /usr/local/pkgng/packages/All/ | grep clamav
-rw-r--r-1 root wheel
3812776 Sep 23 12:53 clamav-0.97.6.txz

# cd /usr/local/pkgng/packages/All/
# pkg add clamav-0.97.6.txz
Installing clamav-0.97.6...Installing arc-5.21p... done
Installing arj-3.10.22_4... done
Installing lha-1.14i_6... done
Installing unzoo-4.4_2... done
done
# pkg info | grep clamav
clamav-0.97.6
Command line virus scanner written entirely in C
#

# pkg add /usr/local/pkgng/packages/All/clamav-0.97.6.txz


Installing clamav-0.97.6...Installing arc-5.21p... done
Installing arj-3.10.22_4... done
Installing lha-1.14i_6... done
Installing unzoo-4.4_2... done
#

ftp/http:
# pkg add http://unix1.jinr.ru/~lavr/pkgng/lynx-2.8.7.2,1.txz
lynx-2.8.7.2,1.txz
100% 928KB 927.9KB/s 927.9KB/s
Installing lynx-2.8.7.2,1... done
To enable certificate handling for SSL connnections, set
SSL_CERT_DIR and SSL_CERT_FILE in your environment to the
proper values (depending upon which SSL library
/usr/local/bin/lynx uses), as described in:

00:00

/docs/README.sslcerts
and:
/docs/README.rootcerts.
You may also need to generate keys and certificates as
described in the latter document and your SSL documentation.
#

: pkg add
===============================< pkg add >=====================================
FS
:
pkg add filename.txz
FTP/HTTPS:
pkg add [http/ftp]://host.domain/path/filename.txz
===============================< pkg add >=====================================


pkg info, rquery, install, add -
, :
pkg query - rquery, rquery
, rquery query
, pkg-query(8).
:
# pkg query -F /var/cache/pkg/All/portmaster-3.13.13.txz "%n-%v origin: %o size: %sh"
portmaster-3.13.13 origin: ports-mgmt/portmaster size: 123 kB
#

# cd /var/cache/pkg/All
# pkg query -F trafshow-5.2.3_2,1.txz "%n-%v origin: %o files %Fp"
trafshow-5.2.3_2,1 origin: net/trafshow files /usr/local/bin/trafshow
trafshow-5.2.3_2,1 origin: net/trafshow files /usr/local/etc/trafshow.dist

trafshow-5.2.3_2,1 origin: net/trafshow files /usr/local/man/man1/trafshow.1.gz


#

tar :
# tar ztf /var/cache/pkg/All/ru-xcode-4.1.txz
+MANIFEST
+MTREE_DIRS
/usr/local/bin/xcode
# tar ztf /var/cache/pkg/All/pkgconf-0.8.7_2.txz
+MANIFEST
+MTREE_DIRS
/usr/local/bin/pkg-config
/usr/local/bin/pkgconf
/usr/local/share/aclocal/pkg.m4
/usr/local/share/licenses/pkgconf-0.8.7_2/BSD
/usr/local/share/licenses/pkgconf-0.8.7_2/LICENSE
/usr/local/share/licenses/pkgconf-0.8.7_2/catalog.mk
/usr/local/share/licenses/pkgconf-0.8.7_2/
/usr/local/share/licenses/
#

:
/ autoremove:
# pkg query -e '%a == 0' 'packages %n-%v without autoremove'
packages clamav-0.97.6 without autoremove
packages pkg-1.0 without autoremove
packages portmaster-3.13.13 without autoremove

# pkg query -e '%a == 1' 'packages %n-%v with autoremove'


packages arc-5.21p with autoremove
packages arj-3.10.22_4 with autoremove
packages lha-1.14i_6 with autoremove
packages libiconv-1.14 with autoremove
packages libltdl-2.4.2 with autoremove
packages unzoo-4.4_2 with autoremove
#

, :
# pkg query "%o version %v : %c " clamav
security/clamav version 0.97.6 : Command line virus scanner written entirely in C
# pkg query "%C" clamav ( )
security
# pkg query "%Fp" clamav ( )
# pkg query "%D" clamav ( )
/var/run/clamav/
/var/log/clamav/
/var/db/clamav/
/usr/local/share/licenses/clamav-0.97.6/
/usr/local/share/licenses/
# pkg query "%Ok %Ov" clamav ( )
ARC on
ARJ on
DOCS off
EXPERIMENTAL off
ICONV on
LDAP off
LHA on
LLVM on
MILTER on
STDERR off
TESTS off
UNRAR on
UNZOO on

#
# pkg query "%n-%v use user: %U" apache22-worker-mpm
( UID)
apache22-worker-mpm-2.2.22_8 use user: www
# pkg query "%n-%v use user: %G" apache22-worker-mpm
( GID)
apache22-worker-mpm-2.2.22_8 use user: www
# pkg query "%n-%v use shared libs %B"
( - libs)

:
# pkg query
pkg depends
pkg depends
pkg depends
pkg depends
pkg depends
pkg depends
#

"pkg depends on %do %dv" clamav


on archivers/arc 5.21p
on archivers/arj 3.10.22_4
on archivers/lha 1.14i_6
on converters/libiconv 1.14
on devel/libltdl 2.4.2
on archivers/unzoo 4.4_2

:
# pkg query "pkg %n required by %ro %rv" apr
pkg apr required by www/apache22-worker-mpm 2.2.22_8
#

query rquery,
.
query:
# pkg query -e '%a == 0' '%n-%v'
# pkg query -e '%a == 1' '%n-%v'
# pkg query -e '%a == 0 && %#d==0 ' %o
ports-mgmt/pkg
ports-mgmt/portmaster
# pkg query -e '%a == 0 && %#r==0 ' %o
www/apache22-worker-mpm
security/clamav
ports-mgmt/pkg
ports-mgmt/portmaster
#

portmaster' root,trunk,branch leaf :


root ( ):
# pkg query -e "%#d = 0 && %#r = 0" "%n-%v"

trunk ( , ):
# pkg query -e "%#d = 0 && %#r > 0" "%n-%v"

branch ( ):
# pkg query -e "%#d > 0 && %#r > 0" "%n-%v"

leaf ( , ):
# pkg query -e "%#d > 0 && %#r = 0" "%n-%v"

help man
,
# pkg help
# pkg help

- man pkg-command

# man pkg-command

: ,
.
PKG SEARCH
:
pkg search pkg-name
pkg search [-fDsqop] pkg-name
pkg search [-gexXcdfDsqop] pattern

:
#
#
#
#

pkg
pkg
pkg
pkg

search
search
search
search

www/apache22
misc/mc
-x "^mc-*$" (-x regexp)
-x "^mc-*"

#
#
#
#

pkg
pkg
pkg
pkg

search
search
search
search

-g
-g
-g
-g

"?c"
(-g shell global match)
"l?m*"
"[0-z]*" (-g shell global match - )
"[0-z]*" | sort -k 1,1 ( )

PKG RQUERY
:
pkg
pkg
pkg
pkg

rquery
rquery [-a] [-r reponame]
rquery -e [-r reponame]
rquery [-gxX] [-r reponame] <query-format> <pattern> <...>

:
# pkg rquery "" pkgname

:
%d
%r
%?d
%?r

/
/
0/1 /
0/1 /

:
# pkg rquery -a "package: %n-%v"
# pkg rquery -a "package: %n-%v - %c" ( )
# pkg rquery -a "package: %n-%v size: %sh - %c" ( + )

gtar mc:
# pkg rquery "tar depends %?d" gtar (0 - , 1 - )
# pkg rquery "rar depends %?d" archivers/rar
#
#
#
#

pkg
pkg
pkg
pkg

rquery
rquery
rquery
rquery

"rar depends %do %dv" archivers/rar


"rar depends %do %dv" rar
"gtar depends %do %dv" gtar
"gtar depends %do %dv" archivers/gtar

# pkg rquery "mc depends %do %dv" misc/mc


# pkg rquery "pkg %n-%v require next deps: %dn-%dv" bash-4.2.37

gtar mc:
# pkg rquery "tar depends %?r" gtar (0 - , 1 - )
# pkg rquery "tar depends %?r" archivers/rar
# pkg rquery "tar depends %ro %rv" misc/mc

# pkg rquery "pkg %n-%v needs for next packages: %rn-%rv" bash-4.2.37

() PKG ADD
:
pkg add <pkg-name>
pkg add <protocol>:/path/pkg-name

, pkg install, , http


ftp .
# pkg add /path/to/packages/foo-1.2.3.txz ( foo...)
# pkg add http://example.org/pkgng-repo/foo-1.2.3.txz
# pkg add ftp://example.org/pkgng-repo/foo-1.2.3.txz
( foo-1.2.3.txz ftp/http )

() PKG INSTALL
:
pkg install [-AfgLnqRXxy] [-r reponame] <pkg-origin> ...

, , pkg-origin:
category/portname, -y.
#
#
#
#

pkg
pkg
pkg
pkg

install
install
install
install

www/apach22
archivers/rar
mc
-y misc/mc

( -y == pkg.conf: ASSUME_ALWAYS_YES )
# pkg install -y -r repo1 audio/mpg123

: -f
# pkg install -f
# pkg install -fy archivers/rar ( )

,
( ) :
pkg set -o [oldorigin:neworigin]
pkg install -fR category/name - name
(-R - )
# pkg set -o graphics/libglut:graphics/freeglut ( libglut freeglut)
# pkg install -Rf graphics/freeglut ( freeglut )

emacs, editors/emacs
editors/emacs23, , editors/emacs, :
# pkg set -o editors/emacs:editors/emacs23

, -L
# pkg install -yL rar-4.1.1,3 unrar-4.20,5


, orphan() -A
# pkg install -yAfL mc-4.8.1.1_1

- autoremove:
# pkg autoremove -y

autoremove:
# pkg query -a "installed package %o %v has autoremove flag = %a"

# pkg query -a "installed package %n-%v has autoremove flag = %a"

PKG QUIERY
:
pkg
pkg
pkg
pkg
pkg

query
query
query
query
query

<query-format> <pkg-name>
[-a] <query-format>
-F <pkg-name> <query-format>
-e <evaluation-condition> <query-format>
[-gxX] <query-format> <pattern> <...>

pkg query - <query-format>!


# pkg query "%Fp %Fs %sh" portmaster-3.13.13
# pkg query " %n-%v \n ports: %o\n desc: %c\n home: %w\n pkg size: %sh" portmaster-3.13.13

:
# pkg query %Fp _ | grep -E '/lib[^/]+\.so\.[0-9]+$'

: ,
!
C autoremove :
# pkg query -e '%a == 0' '%n-%v'

# pkg query -e '%a == 1' '%o'

50MB:
# pkg query -e "%s > 50000000" "%n-%v is bigger than 50MB: %sh"
python27-2.7.3_3 is bigger than 50MB: 67 MB
#

50MB :
# pkg query -e "%s > 50000000 && %a == 1" "%n-%v is bigger than 50MB: %sh and has been
automatically installed"

PKG AUDIT,

:
pkg audit [-Fq]

, -,
PORTAUDIT_SITE,
:
# pkg audit perl-5.14.2_2
# pkg audit -F perl-5.14.2_2 ( )

, FreeBSD
http://portaudit.FreeBSD.org/
PORTAUDIT_SITE URL: http://portaudit.FreeBSD.org/auditfile.tbz

PKG SET
:
pkg set [-a] [-A [01]] [-o <oldorigin>:<neworigin>] [-y] [-xXg] <pkg-name>

: !
# pkg set -o devel/pkg-config:devel/pkgconf
# pkg set -o graphics/libglut:graphics/freeglut

autoremove :
# pkg set -A 1 mc-4.8.1.1_1

autoremove:
# pkg set -A 0 mc-4.8.1.1_1

PKG INFO
:
pkg
pkg
pkg
pkg

info
info
info
info

<pkg-name>
-a
[-eDgxXEdrlsqopOfRF] <pkg-name>
[-drlsq] -F <pkg-name>

.
# pkg info
deco-3.9_4
pkg-1.0
portmaster-3.13.13

Demos Commander, a free Norton Commander clone


New generation package manager
Manage your ports without external databases or languages

-a -
# pkg info -a
deco-3.9_4
pkg-1.0
portmaster-3.13.13
#

Demos Commander, a free Norton Commander clone


New generation package manager
Manage your ports without external databases or languages

:
# pkg info deco
deco-3.9_4
#

Demos Commander, a free Norton Commander clone


# pkg info -f deco
Name
: deco
Version
: 3.9_4
Origin
: misc/deco
Prefix
: /usr/local
Categories
: misc
Maintainer
: ports@FreeBSD.org
WWW
: http://deco.sourceforge.net/
Comment
: Demos Commander, a free Norton Commander clone
Flat size
: 159 kB
Description
:
A clone of Norton Commander for Unix. Text-based,
full featured file manager intuitive interface.
WWW: http://deco.sourceforge.net/
#

pkg-message - -D

# pkg info -D pkg


If you are upgrading from the old package format, first run:
# pkg2ng
# pkg info -d png-1.5.12
png-1.5.12 depends on:
#


# pkg info -d mc (pkg info -d mc-4.8.1.1_1)
mc-4.8.1.1_1 depends on:
gamin-0.1.10_4
gettext-0.18.1.1
gio-fam-backend-2.28.8_1
glib-2.28.8_4
libiconv-1.14
libslang2-2.2.4_3
pcre-8.31
perl-5.14.2_2
pkgconf-0.8.5
png-1.5.12
python27-2.7.3_3
#


# pkg info -r perl-5.14.2_2
perl-5.14.2_2 is required by:
glib-2.28.8_4
gamin-0.1.10_4
gio-fam-backend-2.28.8_1
mc-4.8.1.1_1
# pkg info -r python27-2.7.3_3
python27-2.7.3_3 is required by:
glib-2.28.8_4
gamin-0.1.10_4
gio-fam-backend-2.28.8_1
mc-4.8.1.1_1
#

:
# pkg info -B pkg

: ,
!
, , ,
SHLIBS : YES pkg.conf
. off,
.
PKG DELETE
:
pkg delete [-fgnqRXxy] <pkg-name> ...
pkg delete [-nqy] -a

:
-a
-f
-n
-R
-q


/
, ,

,

-n

:
# pkg delete rar
# pkg delete -y rar
# pkg delete -y rar unrar
# pkg delete -x ".*rar$" ( regexp)

PKG VERSION
:
pkg version [-IPR] [-hoqv] [-l limchar] [-L limchar] [-Xxge pattern]
[-r reponame] [-O origin] [index]
pkg version -t version1 version2
pkg version -T <pkgname> <pattern>

,
pkg version
# pkg version -P
deco-3.9_4
pkg-1.0
portmaster-3.13.13
#

( )
=
=
=

# pkg version -R
deco-3.9_4
pkg-1.0
portmaster-3.13.13
#

( out of date pkg)


=
>
=

# pkg version -vRL=


pkg-1.0
# pkg version -vRL\<
deco-3.9_4
pkg-1.0
portmaster-3.13.13
# pkg version -vRL\>
deco-3.9_4
portmaster-3.13.13
#

>

succeeds remote (remote has 1.0.r5_1)

=
>
=

up-to-date with remote


succeeds remote (remote has 1.0.r5_1)
up-to-date with remote

=
=

up-to-date with remote


up-to-date with remote

PKG CHECK
:
pkg check [-Bdsr] [-vy] [-a | -gxX <pkg-name>]

, :
-B
-d
-r
-s
-v
-a

SHLIBS

checksums
checksums
verbose ( )

-v ! :
# pkg check -sv cvsup-mirror
Checking checksums: cvsup-mirror
cvsup-mirror-1.3_8: checksum mismatch for /usr/local/etc/cvsup/update.sh
# pkg check -sv trafshow
Checking checksums: trafshow
# pkg check -dv apache22-worker-mpm
Checking dependencies: apache22-worker-mpm

:
PKG WHICH
:
pkg which [-qo] <file>

:
-q -
-o - origin name-version

, ,
.
# pkg which /usr/local/bin/gdbus
/usr/local/bin/gdbus was installed by package glib-2.28.8_4
# pkg which /usr/local/bin/idle
/usr/local/bin/idle was installed by package python27-2.7.3_3
# pkg which -o /usr/local/bin/idle
/usr/local/bin/idle was installed by package lang/python27
#

PKG UPDATE
:
pkg update [-fq]

.
, ,
pkg, -L ( ).
# pkg update
Updating repository catalogue
repo.txz
100%
13MB
4.3MB/s
3.9MB/s
00:03
#
# pkg update -f (
)

PKG UPGRADE
:
pkg upgrade [-fLnqy] [-r reponame]

: -y, !

.
# pkg upgrade -f
( )
# pkg upgrade -yf
# pkg upgrade -yfL ( )

pkg upgrade (pkg update),


.
# pkg upgrade -n

( )

: , :
# pkg install -yfR mc-4.8.1.1_1
# pkg install -yfRL mc-4.8.1.1_1

PKG STATS
:
pkg stats [-qlr]

:
# pkg stats
Local package database:
Installed packages: 3
Disk space occupied: 6932 kB
Remote package database(s):
Number of repositories: 1
Packages available: 22212
Unique packages: 22212
Total size of packages: 96 GB
# pkg stats -l ( )
# pkg stats -r ( )

PKG FETCH
:
pkg fetch [-r reponame] [-yqgxXadL] <pkg-name> [...]

.
# pkg fetch -a
( )
# pkg fetch -yL bash-4.2.37
# pkg fetch -yd clamav-0.97.5_1 ( clamav )

PKG_CACHEDIR: /var/cache/pkg/All/
PKG CREATE
:
pkg create [-n] [-f format] [-o outdir] [-p plist] [-r rootdir] -m
manifestdir
pkg create [-gnxX] [-f format] [-o outdir] [-r rootdir] pkg-name ...
pkg create [-n] [-f format] [-o outdir] [-r rootdir] -a

pkgng
/usr/ports/packages/All:
# pkg create -a -o /usr/ports/packages/All

packagename pkgng :
# pkg create -o /usr/ports/packages/All packagename

out-of-date
PKG CLEAN
, .
# pkg clean

.
PKG REPO
:
pkg repo [-fq]

[rsa-key]

# cd /scratch/huge_free_space
# pkg create -a
# pkg repo .

: pkg add/install
PKG REGISTER
:
pkg register [-ld] -f <plist-file> -m <metadatadir> -i <input-path>
-l - ,

-d - orphan
-f plist-file -
-m metadatadir -
-i input-path -

pkg2ng, :
pkg register -l -m ${MDIR} -f ${PLIST} ${CMD_ARGS}

shared library PKG SHLIB


:
pkg shlib <library>

: pkg info -B
, ,
SHLIBS : YES pkg.conf
# pkg shlib libpkg.so.0
libpkg.so.0 is linked to by the folowing packages:
pkg-1.0
#

ABI,
.
:
# pkg shlib libapr-1.so.4
libapr-1.so.4 is linked to by the folowing packages:
apache22-worker-mpm-2.2.22_8
apr-1.4.6.1.4.1_1
#
# pkg info -B mc
mc-4.8.1.4_1 uses the following shared libraries:
libslang.so.2
libpcre.so.1
libintl.so.9
libiconv.so.3
libglib-2.0.so.0
#

Backup PKG BACKUP


:
pkg backup -d
pkg backup -r

:
# pkg backup -d /var/tmp/pkgng_db.dump
# pkg backup -r /var/tmp/pkgng_db.dump

PKG SHELL
:
pkg shell

pkg shell - sqlite, :


# echo 'select * from packages;' | pkg shell
# echo 'select origin,name,version,comment from packages;' | pkg shell

:
# echo '.databases' |
seq name
--- --------------0
main

pkg shell
file
---------------------------------------------------------/var/db/pkg/local.sqlite

:
# echo '.tables'
categories
deps
directories
files
groups

| pkg shell
licenses
mtree
options
packages
pkg_categories

pkg_directories
pkg_groups
pkg_licenses
pkg_shlibs
pkg_users

scripts
shlibs
users

:
# echo '.schema packages' | pkg shell
CREATE TABLE packages (id INTEGER PRIMARY KEY,origin TEXT UNIQUE NOT NULL,name TEXT NOT
NULL,version TEXT NOT NULL,comment TEXT NOT NULL,desc TEXT NOT NULL,mtree_id INTEGER
REFERENCES mtree(id) ON DELETE RESTRICT ON UPDATE CASCADE,message TEXT,arch TEXT NOT
NULL,maintainer TEXT NOT NULL, www TEXT,prefix TEXT NOT NULL,flatsize INTEGER NOT
NULL,automatic INTEGER NOT NULL,licenselogic INTEGER NOT NULL,infos TEXT, time INTEGER,
pkg_format_version INTEGER);
#

: , , , ,
, - ,
- .
lavr@unix1.jinr.ru