Score:1

Stop apt from modifying file when upgrading package

kh flag

I got a package containing a program which got patched by me. After an update of the package, my modifications are gone. Can I keep my edits for that specific file?

David avatar
cn flag
There is nothing here that can be used to help you. No Ubuntu version. What does a package containing a program mean?
sudoer avatar
kh flag
@David Take package `chromium` as an example. I edited its desktop file in `/usr/share/applications` - after an update, the desktop file is reverted.
Score:1
cn flag

No: Apt, Snap, Pip, and other package managers will be unaware of any changes made by you, and will overwrite them. Standardization is a feature of packages.

If you don't want your package overwritten and customizations lost, then use apt-pinning or apt-marking to prevent apt from updating the package.

For example, you can run the following command so that the package is not upgraded during the system upgrade.

sudo apt-mark hold packagename

However, since APT does not know about your changes, the files will be overwritten during an upgrade process. If you feel that these changes are important, consider sending a pull request to the upstream source code. However, even if your changes are accepted, it is likely that you will not get the new version as an upgrade in your current version of Ubuntu, but it may be available in future Ubuntu versions.

user535733 avatar
cn flag
@archisman-panigrahi terrific edit. Thank you.
Score:1
in flag

Depending on the nature of your modification, instead of modifying it in place, you can copy the file and put it somewhere else that will override the original file. This may cause other issues, however. For instance, if the original file is updated to fix bugs, your modified copy won't get those updates.

For instance, if you just want to modify the desktop file or the icon, you could copy the desktop file to ~/.local/share/applications/ and then modify that copy, change the icon path in that file, etc.

Many applications install config files in /usr/ or /lib/ and, depending on the application, you may be able to modify a version of the config file in your home directory, or copy it to a parallel path in /etc/ which should not get overwritten.

If the modified file is in the /bin/ directory of the application, you may be able to copy it to ~/bin/ and make sure that directory is before the application's bin directory.

If the file is a core part of the application, there may not be a clean way to make the change in a way that doesn't get overwritten. Your only choice is to either re-patch the file on updates or freeze that application from being updated.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.