How to tell FreeBSD to stop producing pkgsave files.

Really, just file a PR for it. Then it can be changed in the OS and everyone benefits from it. You have good arguments to get this added. And, it'll be your contribution to the FreeBSD OS, how does that sound?
 
On a properly maintained system those files shouldn't get created in the first place. I've never had a single one in all the years I've been using pkg(8) (I originally started using it on 9.x when the old pkg_* tools were still the default).

I trust in you. If you say that this particular behavior is not a real problem for a lot of very well maintained systems,I will not file any PR. It means that I've tried to fix my previous broken system using my imagination (and it worked),but this creates not expected situations,that no one else will find in the future. If you want to file a PR,you can do it. For me is enough if you would like to complete the script that I have asked,adding the filter for detecting the pkgsave executable files to the command line that you have already wrote :

Code:
find /usr/local -type f -name '*.pkgsave' -filter executable files only
 
For me is enough if you would like to complete the script that I have asked,adding the filter for detecting the pkgsave executable files to the command line that you have already wrote :
Well, this shows I'm not that experienced with find(1) and I need to try and test whatever I come up with. I always get royally confused with the -perm option.

I think this might do it: find /usr/local/ -type f -name '*.pkgsave' -perm +a+x

Code:
     -perm [-|+]mode
             The mode may be either symbolic (see chmod(1)) or an octal
             number.  If the mode is symbolic, a starting value of zero is
             assumed and the mode sets or clears permissions without regard to
             the process' file mode creation mask.  If the mode is octal, only
             bits 07777 (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG |
             S_IRWXO) of the file's mode bits participate in the comparison.
             If the mode is preceded by a dash (“-”), this primary evaluates
             to true if at least all of the bits in the mode are set in the
             file's mode bits.  If the mode is preceded by a plus (“+”), this
             primary evaluates to true if any of the bits in the mode are set
             in the file's mode bits.  Otherwise, this primary evaluates to
             true if the bits in the mode exactly match the file's mode bits.
             Note, the first character of a symbolic mode may not be a dash
             (“-”).
 
I have a LOT of pkgsave's executable files on /usr/local,but I see that none of them is executed when FreeBSD starts. So,the directories to scan are only /usr/local/etc/rc.d/ and /etc/rc.d ?

This list seems to contains exactly the files that I should remove :

Code:
# find /usr/local/etc/rc.d -type f -name '*.pkgsave' -perm +a+x

/usr/local/etc/rc.d/openvpn.pkgsave
/usr/local/etc/rc.d/avahi-dnsconfd.pkgsave
/usr/local/etc/rc.d/avahi-daemon.pkgsave
/usr/local/etc/rc.d/cupsd.pkgsave
/usr/local/etc/rc.d/uuidd.pkgsave
/usr/local/etc/rc.d/cbsdd.pkgsave
/usr/local/etc/rc.d/cbsd-statsd-jail.pkgsave
/usr/local/etc/rc.d/cbsdrsyncd.pkgsave
/usr/local/etc/rc.d/cbsd-statsd-hoster.pkgsave
/usr/local/etc/rc.d/dbus.pkgsave
/usr/local/etc/rc.d/cbsd-statsd-bhyve.pkgsave

Instead,I have no files on /etc/rc.d
 
I have a LOT of pkgsave's executable files on /usr/local,but I see that none of them is executed when FreeBSD starts.
You still want to remove those, it just clutters the system, taking up space for absolutely no reason.

So,the directories to scan are only /usr/local/etc/rc.d/ and /etc/rc.d ?
Those are the only two directories where services are started from during boot. Technically speaking you need to look at /etc/rc.d and whatever directories have been set in local_startup (see /etc/defaults/rc.conf). But most people simply use the default and have this set to /usr/local/etc/rc.d.
 
Now I'm thinking to remove every *.pkgsave file from the system. So,the command that I will issue is the following :

Code:
# find / -type f -name '*.pkgsave' -delete

Will this operation mess up the system ?
 
ok. So,at the moment I'm / we are without a satisfactory solution.

Did you really not see my post #34 where I offered an alternative final clause for SirDice's find command, that instead of deleting the *.pkgsave files, just cleared their executable flags?

That would leave them in place (as you said you want) but prevent them from being run by the rc system (which you found was a problem)?
 
Sure man,I seen your command on post #34,this one :

find /usr/local -type f -name '*.pkgsave' -exec chmod a-x {} \;

but :

1) the annoying executable files are located only on /usr/local/etc/rc.d and I have already removed them,copying them on another directory

2) actually my goal is to free space from the whole disk. If you tell to me that my system will continue to work great if I remove every *.pkgsave file stored on the disk,I will do it.
 
"Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for a lifetime”
-- Lao Tzu
 
"Give a man a fish and you feed him for a day. Teach him how to fish and you feed him for a lifetime”
-- Lao Tzu

"Tell a fisher to read the man page and you hurt him for a day. Ask him how to fish and you have found a new friend for the lifetime". Mario Zio.
 
I would ask you a suggestion. Since my main FreeBSD system is not working well,'cause the problem that I have explained here :


I suspect that the problem is tied to the massive presence of the *.pkgsave files located everywhere between the regular FreeBSD system files. In particular,I suspect that some *.pkgsave files that are connected to some regular configuration files interfere with them. For example,it / they could interfere with the regular working of the /boot/loader.conf. Is that possible ?
 
Mutual exclusivity at its finest.
Not really. If you maintain a system properly and don't muck around with the package database then you won't get those files. That said, people make mistakes and screw up, this thread is testament of that. It's a relatively simple change that would prevent some potential disastrous consequences if you do happen to screw up your system this way.
 
Sure man,I seen your command on post #34,this one :

find /usr/local -type f -name '*.pkgsave' -exec chmod a-x {} \;

Right. So I've just re-read the whole thread, trying to figure out why that didn't help to satisfy your requirements.

And I suspect - tell me if I'm wrong, how I'm wrong - that it's the -exec clause that you didn't follow? Another fish:

In find(1) / -exec and read until absorbed. I'm not being facetious or condescending; it's a very important and powerful 'primary' in find-speak. So:

On each file *.pkgsave found, run chmod a-x {} \;
i.e. clear all executable bits, where {} is each filename.

That's all, hopefully enough?

but:
1) the annoying executable files are located only on /usr/local/etc/rc.d and I have already removed them,copying them on another directory

Ok, but are we not seeking long-term general solutions and learnings, rather than just one-off fixes?

2) actually my goal is to free space from the whole disk. If you tell to me that my system will continue to work great if I remove every *.pkgsave file stored on the disk,I will do it.

Apart from disabling the executable scripts called *.pkgsave, as above, and apart from consuming a tiny amount of diskspace, no, your system won't work any better, or worse, if you leave all that messiness in place.

Peace.
 
Ok, but are we not seeking long-term general solutions and learnings, rather than just one-off fixes?

Not exactly. To remove the only executable files I have,I used this command line :

Code:
# find /usr/local/etc/rc.d -type f -name '*.pkgsave' -delete

even if the executables files are only on that dir,using that command help to save a little bit of time than removing those files "manually" :D. For sure I could have used your script,but if those files are not useful,why keep them ? I can remove them. And now that you told me that I can remove every pkgsave file without creating issues to the system,I will do it. I prefer to remove the unuseful files if it doesn't create issues,than leaving them there and/or changing them to -x.
 
No. I'm again stuck with this problem. I was trying to start kde wayland and I found that a lot of libraries are missing. I have these libraries on my PC,but they aren't detected by find because their extension is...pkgsave...so,now I would need a script that can rename a lot of *.pkgsave files to the original names :

Screenshot from 2023-02-02 15-16-39.png


I think it's enough to remove the pkgsave word at the end of the name. Someone can help me to do this ? One more time. The tecnique to rename the files adding the pkgsave extension is causing to me more troubles than advantages.
 
Back
Top