[FreeBSD] PKGNG

FreeBSD 開始廢棄原本的 pkg,改用 PKGNG

安裝方式:

  • Ports
# portsnap fetch update
# cd /usr/ports/ports-mgmt/pkg
# make install clean
  • Package
# pkg_add -r pkg
Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-current/Latest/pkg.tbz... Done.

設定:

  • 設定檔一:
# cat /usr/local/etc/pkg/repos/FreeBSD.conf
FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
  mirror_type: "srv",
  enabled: yes
}
  • 設定檔二:
# cat /etc/make.conf
WITH_PKGNG=yes

使用方式:

  • 先執行 pkg2ng
# pkg2ng
  • 更新 database
# pkg update
Updating FreeBSD repository catalogue...
Fetching meta.txz: 100%    968 B   1.0kB/s    00:01
Fetching packagesite.txz: 100%     5 iB   5.5MB/s    00:01
Processing entries: 100%
FreeBSD repository update completed. 24360 packages processed.
  • 尋找 Package(含有字串)
# pkg search rrd
irrd-2.3.10_2
jrrd-1.0.8
p5-Catalyst-View-RRDGraph-0.10_1
p5-POE-Component-RRDTool-0.18_5
p5-RRD-Simple-1.44_6
p5-RRDTool-OO-0.36
pecl-rrd-1.1.3_1
py27-python-rrdtool-1.4.7
py27-rrdtool_lgpl-1.0b1_5
rrdbot-0.9.7_3
rrdman-1.0.1_4
rrdmerge-0.0.1
rrdtool-1.4.8_9
rrdtool10-1.0.50_6
rrdtool12-1.2.30_7
rubygem-rrd-ffi-0.2.14
  • 安裝 Package (從 database)
# pkg install rrdtool-1.4.8_9
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
...............略
  • 安裝 Package (檔案)
# pkg add http://pkgbeta.freebsd.org/freebsd-10-amd64/latest/misc/hello-2.8.txz
不過這個方法,如果有依存的 package,就都需要自己一個個安裝
  • 顯示所有 Package 資訊
# pkg info
mysql-client-5.5.15: Multithreaded SQL database (client)
mysql-server-5.5.15: Multithreaded SQL database (server)
  • 顯示某個 Package 的依存
# pkg info -d mysql-server-5.5.19
mysql-server-5.5.19 depends on:
mysql-client-5.5.19
  • 顯示某個 Package 安裝的檔案
# pkg info -l perl5-5.20.2_6
perl5-5.20.2_6:
        /usr/local/man/man1/perlxstypemap.1.gz
        /usr/local/man/man1/piconv.1.gz
        /usr/local/man/man1/pl2pm.1.gz
        ....略
  • 顯示 Package 的資訊
顯示所有的 Package
# pkg query -a "Package name = %n, Version = %v, Size = %sh"
Package name = pecl-intl, Version = 3.0.0, Size = 489kB
Package name = pecl-pdflib, Version = 2.1.9, Size = 192kB
Package name = perl5, Version = 5.20.2_6, Size = 51.2MB
只顯示指定的 Package
# pkg query "Package name = %n, Version = %v, Size = %sh" perl5-5.20.2_6
Package name = perl5, Version = 5.20.2_6, Size = 51.2MB
顯示比較詳細的資訊
# pkg query "package[%n]\nversion[%v]\norigin[%o]\nprefix[%p]\nmaintainer[%m]\ncomment[%c]\nwww[%w]\nlicenselogic[%l]\nflatsize[%sh]\norphan[%a]\nmessage[%M]\n" perl5
package[perl5]
version[5.20.2_6]
origin[lang/perl5.20]
prefix[/usr/local]
maintainer[perl@FreeBSD.org]
comment[Practical Extraction and Report Language]
www[http://www.perl.org/]
licenselogic[or]
flatsize[51.2MB]
orphan[0]
message[The /usr/bin/perl symlink has been removed starting with Perl 5.20.
For shebangs, you should either use:
#!/usr/local/bin/perl
or
#!/usr/bin/env perl
The first one will only work if you have a /usr/local/bin/perl,
the second will work as long as perl is in PATH.
]
  • 搜尋檔案是由哪個 Package 新增的
# pkg which /usr/local/lib/mysql/libmysqlclient.a
/usr/local/lib/mysql/libmysqlclient.a was installed by package mysql-client-5.5.15
  • 備份 Package Database
# pkg backup -d /TOSHIBA_5T/pkg_backup_20150910
Dumping database:
Backing up: 100%
# file /TOSHIBA_5T/pkg_backup_20150910
/TOSHIBA_5T/pkg_backup_20150910: SQLite 3.x database, user version 31
還原 Database
# pkg backup -r /TOSHIBA_5T/pkg_backup_20150910
Restoring database...done
  • 創造 Package(製作出來的 Package 檔案可以到其他電腦用 pkg add 安裝)
# pkg create -a
Creating package for mysql-client-5.5.15
Creating package for mysql-server-5.5.15
Creating package for nInvaders-0.1.1
# ls
mysql-client-5.5.15.txz
mysql-server-5.5.15.txz
nInvaders-0.1.1.txz
Please follow and like us:

2 comments on “[FreeBSD] PKGNG

  1. 最近用 PKG install 會出現下列錯誤訊息:

    pkg: sqlite error while executing iterator in file pkgdb_iterator.c:1033: database disk image is malformed
    

    解決方法很簡單,砍掉 /var/db/pkg/repo*.sqlite 就好囉!

  2. 有些 Package 如果在安裝的過程中,不想被 REMOVED 或是 UPGRADED 的話,可以考慮 lock 起來:

    #pkg lock php5-extensions-1.3

    這樣在安裝過程中,會出現錯誤訊息,但是就不會被影響到。
    錯誤訊息如下:

    php5-extensions-1.3 is locked and may not be modified

    要 unlock 就輸入:

    #pkg unlock php5-extensions-1.3

發表迴響

你的電子郵件位址並不會被公開。 必要欄位標記為 *