How to "release" a file from pkg(8) control?

I have a maintenance-oriented package that (among other tasks) used to install a specific file, and sometimes overwrite that file with an updated version.

I'm trying to find a way to hang on to that file, but not have the package claim "ownership" of it as seen in pkg list or pkg which /path/myfile.

If I simply remove it from the package, then upon the next pkg upgrade, the file is deleted. This could be prevented with hackery in +PRE_INSTALL (take a backup) and +POST_INSTALL (re-install that backup), but I was hoping to find a more elegant way.

It occurs to me that perhaps, if one were even shifting "responsibility" for a file from package A to package B, a similar situation might arise, so I'm hoping there's a better solution out there.

Any pointers?
 
I have a maintenance-oriented package that (among other tasks) used to install a specific file, and sometimes overwrite that file with an updated version.

If you want relinquish control of dependencies to yourself, I would suggest creating your own repository, and then build that specific package from scratch using ports. Or just build it locally. You can "lock" a package (or it's dependencies) from being touched upon an upgrade or update, but this involves less flexibility.

Use ports.
 
If you want relinquish control of dependencies to yourself, I would suggest creating your own repository, and then build that specific package from scratch using ports. Or just build it locally. You can "lock" a package (or it's dependencies) from being touched upon an upgrade or update, but this involves less flexibility.

Use ports.

I appreciate your reply, but a) that's not the issue, and b) I am installing the package from my own repo. It's not a dependency on another package or port, it's simply one file that should no longer appear in the output of pkg list, but I don't want pkg upgrade to delete it thinking that it is no longer needed.
 
I am not sure if I fully understood the situation. But pkg lock prevents a package to be deleted. May be you have not yet considered that option. Otherwise please excuse the noise :-).
 
You need to patch the port in question to not create this files in the first place, see what is done for configuration files.
Basically, the file in question need to be marked
Code:
@sample myfile.ext-dist myfile.ext
 
Well, while I can't recommend it in general practice, the nerdy, "behind-the-scenes" way is to:

Code:
# cd /var/db/pkg
# cp -vp local.sqlite  local.sqlite.safety
# sqlite3 local.sqlite  
SQLite version 3.46.1 2024-08-13 09:16:08
Enter ".help" for usage hints.
sqlite> select * from files where path='/path/myfile';
/path/myfile|1$hash-of-myfile|246810
sqlite> delete from files where path='/path/myfile';
sqlite> ^D
# pkg upgrade my-package

The more sane method is probably just the original idea of backing up the file, upgrading the port, and re-installing the file:

Code:
# cp -vp /path/myfile /tmp/
# pkg upgrade my-package
# mv /tmp/myfile /path/
 
If the file is mutually (including users other than you) edited/replaced, the file in pkg should be a sample file (i.e., if the filename is /usr/local/some/where/somefile, defined in pkg-plist as @sample some/where/somefile.sample and installed as /usr/local/some/where/somefile.sample) and simply copied or copy-and-edited as /usr/local/some/where/somefile by the admin who installed the pkg. This is often used for configuration files.

If the sample file is fine to be placed in , syntax %%EXAMPLESDIR%%/name-of-the-port/somefile.sample would place it as /usr/local/share/examples/name-of-the-port/somefile.sample by default.
 
Back
Top