Skip to main content

Ignore some packages from a repository in apt update

I recently had to pull a package from a community repository, and it has many more packages than I want.

After I pulled the packages I want, apt update (and Webmin) show all the packages available for update. This is undesirable, I only want certain packages.

apt preferences is the answer. Douglas Rumbaugh has a good overview of using apt-pinning to ignore the packages you don't want.

Essentially, using /etc/apt/preferences or a file in /etc/apt/preferences.d you can say what packages from which repository to ignore.

I created a file in /etc/apt/preferences.d with the name of the new repository, and then populated it with enough statements that blocked all the packages I didn't want it to report on.

Package: libpcre*
Pin: release o=(repository)
Pin-Priority: -1

Package: libxml2
Pin: release o=(repository)
Pin-Priority: -1

I put in as many of these as I needed to block the packages I don't want from that repository.  Now apt update doesn't show those packages, and after a "Refresh Available Packages" on Webmin, it doesn't show them either.