Monday, January 03, 2011

pkg(1) and local caching of downloads

When installing packages, the pkg(1) command, by default, caches the downloaded files under the /var/pkg directory.

If you're using IPS to install packages from local repositories (either over the network or from the filesystem) you probably don't want to store an additional copy of files you could easily obtain again.

The caching behaviour is controlled by the local image property "flush-content-cache-on-success". Setting it to "true" will cause the cache to be emptied when packages are installed successfully:

boyd@sol11:~$ pkg property flush-content-cache-on-success
PROPERTY VALUE
flush-content-cache-on-success False
boyd@sol11:~$ sudo pkg set-property flush-content-cache-on-success true
boyd@sol11:~$ pkg property flush-content-cache-on-success
PROPERTY VALUE
flush-content-cache-on-success True

Now, after a successful package install, the cached files that were kept around from older installs are removed:

boyd@sol11:~$ sudo pkg install desktop/synergy
Packages to install: 1
Create boot environment: No
DOWNLOAD PKGS FILES XFER (MB)
Completed 1/1 27/27 6.7/6.7

PHASE ACTIONS
Install Phase 56/56

PHASE ITEMS
Package State Update Phase 1/1
Image State Update Phase 2/2

PHASE ITEMS
Reading Existing Index 8/8
Indexing Packages 1/1
Deleting content cache

No comments: