FreeBSD 的 pkg lock

如果管 server 的人,跟在 server 上面放程式的人是不同人,那難免因為更新的問題吵架,為了避免傷害,有時候例如要把 PHP 維持在指定的版本,這時候 pkg lock 就要用到了。

root@foo:~ # pkg lock -y -x 'php5-.*-5.4.35' 
Locking php5-bcmath-5.4.35
Locking php5-ctype-5.4.35
Locking php5-curl-5.4.35
Locking php5-dom-5.4.35
Locking php5-filter-5.4.35
Locking php5-gettext-5.4.35
Locking php5-hash-5.4.35
Locking php5-iconv-5.4.35
Locking php5-imap-5.4.35
Locking php5-json-5.4.35
Locking php5-mbstring-5.4.35
Locking php5-mcrypt-5.4.35_1
Locking php5-mssql-5.4.35
Locking php5-mysql-5.4.35
Locking php5-mysqli-5.4.35
Locking php5-pcntl-5.4.35
Locking php5-pdo-5.4.35
Locking php5-pdo_sqlite-5.4.35_1
Locking php5-phar-5.4.35
Locking php5-posix-5.4.35
Locking php5-session-5.4.35
Locking php5-simplexml-5.4.35
Locking php5-sockets-5.4.35
Locking php5-sqlite3-5.4.35_1
Locking php5-tokenizer-5.4.35
Locking php5-wddx-5.4.35
Locking php5-xml-5.4.35
Locking php5-xmlreader-5.4.35
Locking php5-xmlrpc-5.4.35
Locking php5-xmlwriter-5.4.35
Locking php5-zlib-5.4.35
root@foo:~ # pkg lock -l
Currently locked packages:
php5-5.4.35
php5-bcmath-5.4.35
php5-ctype-5.4.35
php5-curl-5.4.35
php5-dom-5.4.35
php5-filter-5.4.35
php5-gettext-5.4.35
php5-hash-5.4.35
php5-iconv-5.4.35
php5-imap-5.4.35
php5-json-5.4.35
php5-mbstring-5.4.35
php5-mcrypt-5.4.35_1
php5-mssql-5.4.35
php5-mysql-5.4.35
php5-mysqli-5.4.35
php5-pcntl-5.4.35
php5-pdo-5.4.35
php5-pdo_sqlite-5.4.35_1
php5-phar-5.4.35
php5-posix-5.4.35
php5-session-5.4.35
php5-simplexml-5.4.35
php5-sockets-5.4.35
php5-sqlite3-5.4.35_1
php5-tokenizer-5.4.35
php5-wddx-5.4.35
php5-xml-5.4.35
php5-xmlreader-5.4.35
php5-xmlrpc-5.4.35
php5-xmlwriter-5.4.35
php5-zlib-5.4.35
smarty-2.6.27
root@foo:~ #

這樣下次用 pkg upgrade 的時候,就可以避免全部變新版本了。

root@foo:~ # pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up-to-date.
All repositories are up-to-date.
Checking for upgrades (187 candidates): 100%
Processing candidates (187 candidates):   1%

php5-5.4.35 is locked and may not be modified

php5-session-5.4.35 is locked and may not be modified

php5-xmlwriter-5.4.35 is locked and may not be modified

php5-xmlreader-5.4.35 is locked and may not be modified

php5-dom-5.4.35 is locked and may not be modified

php5-xml-5.4.35 is locked and may not be modified

php5-simplexml-5.4.35 is locked and may not be modified

php5-ctype-5.4.35 is locked and may not be modified

php5-posix-5.4.35 is locked and may not be modified

php5-hash-5.4.35 is locked and may not be modified

php5-phar-5.4.35 is locked and may not be modified

php5-filter-5.4.35 is locked and may not be modified

php5-tokenizer-5.4.35 is locked and may not be modified

php5-json-5.4.35 is locked and may not be modified

php5-sqlite3-5.4.35_1 is locked and may not be modified

php5-pdo_sqlite-5.4.35_1 is locked and may not be modified

php5-pdo-5.4.35 is locked and may not be modified

php5-iconv-5.4.35 is locked and may not be modified