How to tell FreeBSD to stop producing pkgsave files.

Hello.

From the boot messages I see that tor starts two times. So,I'm investigating the reason and I've found that it could be because the system creates a lot of pkgsave files,even with the executables,as you can see below.

Code:
# find /usr -name "tor*.pkgsave" -print

/usr/local/bin/tor.pkgsave
/usr/local/etc/rc.d/tor.pkgsave

# find /usr -name "tor" -print

/usr/local/bin/tor
/usr/local/etc/tor
/usr/local/etc/rc.d/tor

is there a method to tell the system to don't produce them ? otherwise I have a lot of duplicated services that tries to start and a lot of errors happens.
 
Thanks. Not useful for me. I have a lot of troubles to understand what's the pourpose of pkgsaves. The thread is too much technical for me. The fastest method for me could be to disable them,but on the thread I didn't find how to do it.
 
I have have no previous knowledge either, but this:
.pkgsave file only exists when a file wasn't part of a package and now is.
The old files are kept as pkg doesn't want to be the one to rm them.
Indicates that if preexisting files not installed by pkg is overwritten by pkg, then pkg saves the previous file as a pkgsave file.
Could it be that you installed tor manually and then installed it again from ports/packages?
 
I am far from a technical guy but as I used Linux system before I already encountered rpm.save and pac.save which I guess work the way as pkgsave files do.
Simple explanation (the only way I can do it anyway :) ):
Let's say you have already configured your sshd_config and changed the default port 22 to 5226.
Then a SSH update comes, a new sshd_config file is put in place and your old file is now called sshd_config.kpgsave.
The new config file has port 22 but the pkgsave file has port 5226.
In order to keep everything in line you have to make a diff between sshd_config and sshd_config.pkgsave to bring your own modification into the new config file.

Well sorry I can't explain it better ...
 
Thanks. Now I understand better. What I still does not understand is why a pkgsave file is executable. I think this is the real problem. Infact,when I have deleted the "/usr/local/bin/tor.pkgsave" and the "/usr/local/etc/rc.d/tor.pkgsave" files and I've rebooted,I started to see what I wanted,one only tor process hearing on one only port. So,I think that the tecnique explained is useful for the configuration files,but not for the executables. At this point,until I don't understand why I should have more executable files hearing on different ports,I'll keep thinking that I need to write a script to detect and remove every pkgsave / executable file that is created.
 
It makes no sense for me. I don't see the utility of having duplicated executable files,rather it creates troubles to me. So,I would like to disable the pkgsave feature for the executable files. Instead,I see that this feature is ok for the config. files.
 
Still you didn't answer the question which would probably help people in the same case ... did you installed it manually yes or no ?
It makes no sense for me. I don't see the utility of having duplicated executable files,rather it creates troubles to me.
It doesn't make sense to you in this situation may be, but it did may be at the time when the developers coded it like this, I guess there is a reason.
So,I would like to disable the pkgsave feature for the executable files. Instead,I see that this feature is ok for the config. files.
It's a strange behavior I get that but it's not that difficult to solve either, write a simple script that find all the executable files with an extension ".pkgsave" and delete them if it's more convenient for you.
It looks like not an easy task to find documentation on "pkgsave" so unless someone gives you a better alternative I am afraid that's your best option.

EDIT:
grammar ... sorry
 
At this point,until I don't understand why I should have more executable files hearing on different ports,I'll keep thinking that I need to write a script to detect and remove every pkgsave / executable file that is created.
From the links people have sent:

1) The files are created when pkg doesn't know what to do with older files that it doesn't think are needed any more.
2) It can't guess what you want to do with them, so renames them for you to deal with.
3) It doesn't care what sort of file they are - config, executable, whatever.
4) So yes, it looks like you will need to use a find command with an rm on it to delete these files. Test it carefully first.

But if you answered gotnull's question people might be able to help more.
 
It makes no sense for me. I don't see the utility of having duplicated executable files,rather it creates troubles to me. So,I would like to disable the pkgsave feature for the executable files. Instead,I see that this feature is ok for the config. files.

Again, it should not be creating these, except for files it did not expect to see that it now needs to replace when installing. If the files were from a prior package, it would not create these (since it would be deleting the prior ones first). Hence the question above of if these files were somehow installed manually previously.
 
Again, it should not be creating these, except for files it did not expect to see that it now needs to replace when installing. If the files were from a prior package, it would not create these (since it would be deleting the prior ones first). Hence the question above of if these files were somehow installed manually previously.

what it means "installed manually" ? Concerning tor,I have configured it following some stray tutorial found here. Anyway tor is not the only executable file that's executed two times. Some time ago the same is happened with different executables,even with apache. If this happens sometime ok,I can remove the duplicated file easily,if it produces a lot of duplicated executables it should be stopped now,because the system will not work at all anymore. It could even complicated understand which pkgsave file is connected to a configuration file and which is connected to an executable.
 
When you are installing a program using "pkg" during the extract of the pkg if there's a file conflict the pkg will rename the old file to .pkgsave and will not overwrite it (delete it).
At some point if you are manually installed a software let's say apache24 from it's source code and then manually created /usr/local/etc/rc.d/apache24 to start it as a service and then if you install again apache24 via pkg it will not replace already configured by you the apache24 file instead it will rename it as apache24.pkgsave and will retain it's file attributes aka will keep it as 755 (rwxr-xr-x) therefor you will end up with two files in /usr/local/etc/rc.d one is the apache24 extracted from the pkg and apache24.pkgsave which was your original file created by you. Same may happen if your pkg database is deleted (which is very bad thing) and then pkg will not know what pkg are installed previously by itself and will preserve all files that are already installed as pkgsave.
 
---> you will end up with two files in /usr/local/etc/rc.d one is the apache24 extracted from the pkg and apache24.pkgsave which was your original file created by you.

that's what I don't want to happen. I prefer that the new executable overwrite the older one or that the new executable is copied as pkgsave,but it should not be +x. It's ok if it makes a backup of the configuration files connected to that executable.
 
It's up to you to delete those .pkgsave files. You can use "find" to search for all files which end on .pkgsave
 
Concerning tor,I have configured it following some stray tutorial found here. Anyway tor is not the only executable file that's executed two times. Some time ago the same is happened with different executables,even with apache. If this happens sometime ok,I can remove the duplicated file easily,if it produces a lot of duplicated executables it should be stopped now,because the system will not work at all anymore.
Something else is going on. I can make 10 copies of /usr/local/bin/ntpd (for example) named ntpd.1, ntpd.2, etc. and leave all of them executable. That still won't spawn 10 copies of ntpd when I start the service. It doesn't matter how many copies you have of some executable, they're not going to get executed when you boot the system. That's not how things work, at all. Executables aren't spontaneously started if nothing calls them.
 
VladiBG,why don't you get the habit to read some older messages ? It's annoying that I should repeat again again concepts that I have already told before (comment #17). And its easy to catch you that you didn't do that :D. Anyway. It happened that the executables created were a lot,so my system messed up totally. Even if I wrote a script to remove every pkgsave,it should understand which one is executable from which one isn't. It's not an easy task for me.
 
It happened that the executables created were a lot,so my system messed up totally.
I'm not doubting your system is screwed up, but the .pkgsave files have nothing to do with that. They are NOT the cause of your problems.
 
Something else is going on. I can make 10 copies of /usr/local/bin/ntpd (for example) named ntpd.1, ntpd.2, etc. and leave all of them executable. That still won't spawn 10 copies of ntpd when I start the service. It doesn't matter how many copies you have of some executable, they're not going to get executed when you boot the system. That's not how things work, at all. Executables aren't spontaneously started if nothing calls them.

Carefully look at this example :

Code:
# find /usr -name "tor*.pkgsave" -print

/usr/local/bin/tor.pkgsave
/usr/local/etc/rc.d/tor.pkgsave

# find /usr -name "tor" -print

/usr/local/bin/tor
/usr/local/etc/rc.d/tor

I had 4 legit executable which ran. I think this could happen because the system thinks that tor.pkgsave file is the same as the tor executable and it allowed to run it. If it does not work like this,I don't know.
 
I had 4 legit executable which ran.
You have two rc(8) scripts. That's causing it to get started twice.

I think this could happen because the system thinks that tor.pkgsave file is the same as the tor executable and it allowed to run it.
No, that has nothing to do with it. It's the /usr/local/etc/rc.d/tor.pkgsave that caused it to get started twice. And that script will simply execute /usr/local/bin/tor, not /usr/local/bin/tor.pkgsave. The rc(8) file itself has been renamed, its contents aren't modified.

Simple solution: find / -type f -name '*.pkgsave' -delete
 
Back
Top