I found that whenever I connected to the Internet, my plasma desktop would refresh the package repositories through PackageKit. But sometimes I use the hot spots of mobile phones to access the Internet, and my available traffic is very limited. So I don’t want to refresh the package repositories when I connect to the network through the mobile phone hotspot. How to do that?
Welcome to ask.edora @jackylau
dnf and PackageKit do have independent database/cache for software. It also creates always a cache if you run the apps with different user (sudo/root or normal user).
In other words, if you use just always sudo for example, you will have always an up to date cache and the repository not has to been updated/refreshed.
To achieve sudo always for dnf you can do the following:
Use maximum possible dnf and you will have less this issue with refreshing it.
If you are on a fast internet you can also do a
sudo dnf upgrade --refresh
Please check also the
man dnf.conf command.
There you have an option of a
cacheonly command you can set.
If set to True DNF will run entirely from system cache, will not update the cache and will use it even in case it is expired. Default is False. API Notes: Must be set before repository objects are created. Plugins must set this in the pre_config hook. Later changes are ignored.
In properties of that particular wireless connection in the “Details” tab there ought to be a “metered connection” option. Its description matches your use case. I did not verify it.
This is not suitable for me.
- I set up a special account for system management. I usually use ordinary accounts. So I have no way to run command like “dnf search foobar”.
- Even if the /etc/profile.d/custom.sh file is added, whenever I connect to the Internet, PackageKit will still refresh the software package repositories.
Which package or configure file control this behavior? I want to disable it.
And how can the users not in the wheel group run command “dnf search foobar" successful?
As @sobek said if you may want to try setting the connection to metered.
You could look at masking packagekit while you’re on the hotspot. Fedora 31 Disable Autoupdate - #2 by davidva should be a good start.
After using dbus-monitor and dbus-send for some tracking work, I found that the refresh repositories request was issued by DiscoverNotifier. So I quit DiscoverNotifier from the system tray, and PackageKit will not refresh repositories when I connect to the network.
I haven’t had time to check the code of DiscoverNotifier. I think DiscoverNotifier can decide whether to refresh repositories according to the current network type, because PackageKit has provided NetworkState property.
This post gives me the important help of my tracking work.
If you don’t want to use dbus-monitor and dbus-send, it is also possible to use bustle and d-feet.