Score:4

apt-get - select the oldest google-chrome file in sources.list.d

it flag

In the folder /etc/apt/sources.list.d I have the file:

google-chrome-repo.list:

deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main
deb-src [arch=amd64 signed-by=/usr/share/keyrings/google-chrome-keyring.gpg] https://dl.google.com/linux/chrome/deb/ stable main

and in the folder /usr/share/keyrings i have a file named google-chrome-keyring.gpg

If I install google-chrome:

sudo apt-get install google-chrome-stable

That annoying second file is created in /etc/apt/sources.list.d with the name google-chrome.list, with content:

### THIS FILE IS AUTOMATICALLY CONFIGURED ###
# You may comment out this entry, but any other modifications may be lost.
deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main

and the file in the /etc/apt/trusted.gpg.d folder named google-chrome.gpg

If I don't delete the annoying autogenerated file /etc/apt/sources.list.d/google-chrome.list, then the command:

sudo apt-get purge google-chrome-stable

will give the following error:

E: Conflicting values set for option Signed-By regarding source https://dl.google.com/linux/chrome/deb/ stable: /usr/share/keyrings/google-chrome-keyring.gpg != 
E: The list of sources could not be read.

My goal instead is to be able to do apt-get install and apt-get purge of google-chrome as many times as I want, without first having to delete the autogenerated file each time.

How can i get this? Is there a way to make apt-get ignore that file?

The solutions proposed in other topics like delete that file are not really functional.

I want to be able to use apt-get directly as written above and not scripts or substitute functions.

It would be nice if there were some Dpkg::Options::= like:

Of multiple coincident files in "sources.list.d", only consider the oldest one (the one created first).

Score:4
vn flag

I don't think what you explicitly asks is possible (to use only the oldest source file).

But instead, you can make a DPkg::Post-Invoke command that runs after using apt/dpkg to remove the file you don't want.

Create the file /etc/apt/apt.conf.d/100post-invoke (you can call it anything you like) with the contents:

# This is a list of shell commands to run after invoking dpkg/apt-get #
DPkg::Post-Invoke { "rm -f /etc/apt/sources.list.d/google-chrome.list"; };

Now, after running any apt install or apt purge command, the file /etc/apt/sources.list.d/google-chrome.list will be deleted (or ignored if it doesn't exist).

You can of course add any number of commands to the /etc/apt/apt.conf.d/100post-invoke file to customize the behavior of apt/dpkg.

it flag
Ok, is an acceptable answer
Artur Meinild avatar
vn flag
Sounds good - I believe this is closest to what you want to do.
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.