How to upgrade a local pkg or create an upgradable pkg?

I compiled the scroll application from source and created a package (scroll-1.12.4.pkg) using pkg create. I then installed it with: pkg install ./scroll-1.12.4.pkg and everything worked fine.
Recently, a new version of scroll was released, so I built the new version and packaged it as scroll-1.12.5.pkg. I tried to install it using the same method:
pkg install ./scroll-1.12.5.pkg
However, instead of performing an upgrade, pkg treated it as a fresh install. As a result, my configuration files were overwritten with the package defaults.
I was expecting pkg to recognise that scroll-1.12.5.pkg is a newer version of the already installed package and perform an upgrade, similar to what happens when you run pkg upgrade from a repository. But apparently installing a local package always seems to do a fresh install.
Is there a way to install a local package file (.pkg) in "upgrade mode" so that it respects existing configuration files and only updates the binaries? Perhaps some flag or alternative command?
Any help would be greatly appreciated. Thanks in advance!
 
Create a port for it, and let the port create the package. Rename the configuration file to *.sample and in your pkg-plist you define it as a "sample" file.

This is from security/sudo/pkg-plist for example:
Code:
@sample etc/sudo.conf.sample

This gets treated differently, if there is no existing config file the sample is copied as the 'default' configuration. If there's an existing config file it will not get overwritten.

I was expecting pkg to recognise that scroll-1.12.5.pkg is a newer version of the already installed package and perform an upgrade, similar to what happens when you run pkg upgrade from a repository.
If you watch a pkg upgrade closely you'll notice its actually a pkg-delete(8) of the old package followed by a pkg-install(8) of the new. It doesn't matter if it's a package from a remote repository or a local one. The behavior is exactly the same.
 
Back
Top