{"id":48938,"date":"2025-05-20T14:48:30","date_gmt":"2025-05-20T14:48:30","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=48938"},"modified":"2025-05-20T14:50:05","modified_gmt":"2025-05-20T14:50:05","slug":"apt-3-1-option-exclude-app-repository","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2025\/05\/apt-3-1-option-exclude-app-repository\/","title":{"rendered":"Apt 3.1 Added New Option to Exclude App Packages from A Repository"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-48939\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon-700x700.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/debian-logo-icon.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>apt, the default command line package manager for Debian and Ubuntu based Linux Distributions, released new version 3.1.0 on Monday.<\/p>\n<p>As you may know, apt 3.0 introduced new package dependency resolver with more efficient and clean output. Now, the <b>resolver 3 is enabled by default in the new 3.1 release<\/b>.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-48940\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled-700x298.webp\" alt=\"\" width=\"610\" height=\"260\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled-700x298.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled-300x128.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled-768x327.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-solver-enabled.webp 906w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><!--more--><\/p>\n<p>As you see in the screenshot above, it&#8217;s enabled for both <code>apt<\/code> and <code>apt-get<\/code> by the rules in the <code>01-vendor-ubuntu<\/code> configuration file for Ubuntu, though Ubuntu 25.10 has already enabled this feature for current default apt 3.0.<\/p>\n<h3>why and why-not sub-commands<\/h3>\n<p>Similar to <code>aptitude<\/code>, <code>apt<\/code> now has <b>new <code>why<\/code> and <code>why-not<\/code> sub-commands<\/b>, allowing to find out why a certain package was installed, or why a package is not installable. And, here&#8217;s the description about them in the man page:<\/p>\n<blockquote><p><i>These commands print the reasoning path from the solver. They are similar to the equivalent aptitude commands for many use cases, but are different in that they print the actual reason the solver picked rather than the potential strongest path.<\/i><\/p>\n<p><i>The why command determines why an installed package is installed. This provides reasonable feedback as to why an automatically installed package is installed; for a manually installed package no other reason is given. If the package is not installed, no reason can be determined.<\/i><\/p>\n<p><i>The why-not command determines why a package was determined to not be installable. This may not always yield a result, even if a package is uninstallable.<\/i><\/p>\n<p><i>Both commands take a single argument, the name of a package.<\/i><\/p><\/blockquote>\n<p>For example, run the command below to determine why <code>libheif1<\/code> package was installed in system:<\/p>\n<pre>apt why libheif1<\/pre>\n<p>In my case, it told me user selected to install <code>libm17n-0<\/code>. The package depends <code>libgd3<\/code>, and <code>libgd3<\/code> depends <code>libheif1<\/code>, so it was installed along-with as dependency.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-48941\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1-700x426.webp\" alt=\"\" width=\"610\" height=\"371\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1-700x426.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1-300x183.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1-768x468.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/why-libheif1.webp 816w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<h3>Include and Exclude options<\/h3>\n<p>Besides that, apt 3.1 introduced <b>new <code>Include<\/code> and <code>Exclude<\/code> options<\/b>, allowing to set allow-list or remove packages from a repository.<\/p>\n<p>This is useful when a repository (e.g., Ubuntu PPA) contains many app packages, but you need only one or some of them, and want to block all others. Previously, we can add a rule under <code>\/etc\/apt\/preferences.d<\/code> to set package priority. Now, the new method is way stronger, as it excludes the packages from being parsed into the cache.<\/p>\n<p>For example, assume that you added ppa:ubuntuhandbook1\/apps PPA, but only need the <code>converseen<\/code> package, then you may edit the corresponding .sources file under <code>\/etc\/apt\/sources.list.d<\/code> directory, then add:<\/p>\n<pre>Include: converseen<\/pre>\n<p>After that, save file and run <code>sudo apt update<\/code> to refresh cache. Finally, only <code>converseen<\/code> package from that PPA is available to install, while all others are excluded.<\/p>\n<p><b>NOTE: &#8220;include&#8221; and &#8220;exclude&#8221; do not handle dependencies. You need to add them all if they are also available in the repository. For example, include <code>audacious<\/code> and all its dependencies via:<\/b><\/p>\n<pre>Include: audacious libaudcore5 libaudgui5 libaudqt2 libaudtag3 audacious-plugins audacious-plugins-data<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-48942\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include-700x453.webp\" alt=\"\" width=\"610\" height=\"395\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include-700x453.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include-300x194.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include-768x497.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/apt-sources-include.webp 836w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>For choice, <b>Softare &amp; Updates<\/b> utility offers a graphical way to include\/exclude packages.<\/p>\n<p>Just launch the tool and navigate to &#8220;Other Software&#8221; tab, then highlight and edit the source repository, finally click <b>Add<\/b> button under &#8220;Additional Fields&#8221;, set Key to either <code>Include<\/code> or <code>Exclude<\/code> and input package names as value.<\/p>\n<div id=\"attachment_48943\" style=\"width: 620px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-48943\" class=\"size-large wp-image-48943\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources-700x502.webp\" alt=\"\" width=\"610\" height=\"437\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources-700x502.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources-300x215.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources-768x550.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2025\/05\/edit-sources.webp 956w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><p id=\"caption-attachment-48943\" class=\"wp-caption-text\">Exclude a package for a repository<\/p><\/div>\n<h3>How to Get apt 3.1.0<\/h3>\n<p>apt 3.1.0 has been made into <a href=\"https:\/\/tracker.debian.org\/news\/1646668\/accepted-apt-310-source-into-experimental\/\" target=\"_blank\">Debian experimental<\/a> repository. It will be backported to latest Ubuntu development release once migrated to Debian Unstable (Sid) repository.<\/p>\n<p>If you can&#8217;t wait for the update, then you may grab the <a href=\"https:\/\/salsa.debian.org\/apt-team\/apt\/-\/tags\" target=\"_blank\">source code<\/a> and build it by yourself.<\/p>","protected":false},"excerpt":{"rendered":"<p>apt, the default command line package manager for Debian and Ubuntu based Linux Distributions, released new version 3.1.0 on Monday. As you may know, apt 3.0 introduced new package dependency resolver with more efficient and clean output. Now, the resolver 3 is enabled by default in the new 3.1 release.<\/p>\n","protected":false},"author":1,"featured_media":48939,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[2022,773],"class_list":["post-48938","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-apt","tag-debian"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/48938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=48938"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/48938\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/48939"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=48938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=48938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=48938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}