找到了一种方法。
诀窍是使用两个固定子句。第一个从PPA禁止所有软件包,第二个从中选择所需的软件包。
因此,对于上面的示例,我首先像往常一样添加ppa:
$ sudo add-apt-repository ppa:webapps/preview
...
$ sudo apt-get update
...
现在,如果我运行apt-cache策略,它将告诉我有一个更新版本的铬浏览器可用,并且它将安装升级,因为它的优先级(500)与我当前的铬浏览器相同。
$ sudo apt-cache policy chromium-browser
chromium-browser:
Installed: 18.0.1025.168~r134367-0ubuntu0.12.04.1
Candidate: 20.0.1132.47~r144678-0precise1+webapps3
Version table:
20.0.1132.47~r144678-0precise1+webapps3 0
500 http://ppa.launchpad.net/webapps/preview/ubuntu/ precise/main amd64 Packages
*** 18.0.1025.168~r134367-0ubuntu0.12.04.1 0
500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/universe amd64 Packages
500 http://security.ubuntu.com/ubuntu/ precise-security/universe amd64 Packages
500 http://ppa.launchpad.net/chromium-daily/beta/ubuntu/ precise/main amd64 Packages
100 /var/lib/dpkg/status
18.0.1025.151~r130497-0ubuntu1 0
500 http://us.archive.ubuntu.com/ubuntu/ precise/universe amd64 Packages
E: Unable to parse package file /etc/apt/preferences.d/webapps-preview-pin-400 (1)
$
就该软件包而言,这是很好的,但我不希望安装此ppa中的其他软件包(也具有500优先级)。现在,如果我尝试升级,那么我将从该存储库中获得的不仅仅是铬包:
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages have been kept back:
bamfdaemon gwibber gwibber-service gwibber-service-facebook gwibber-service-twitter indicator-appmenu libbamf0 libbamf3-0 shotwell
The following packages will be upgraded:
chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg gwibber-service-identica indicator-messages indicator-status-provider-mc5
indicator-status-provider-pidgin libindicator-messages-status-provider1
8 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
Need to get 25.3 MB of archives.
After this operation, 5,034 kB of additional disk space will be used.
Do you want to continue [Y/n]?
因此,我能做的就是告诉我,我希望该ppa中的所有软件包(在这种情况下为webapps-preview)具有较低的优先级,但名称中带有“ chromium” 的软件包除外。该机制是固定包
我在/etc/apt/preferences.d/中创建了两个子句的文件。第一个说给webapps-preview ppa中的所有软件包都赋予比常规软件包更低的优先级(这样,即使它们具有更高的版本号,它们也不是首选。第二个子句部分地覆盖了第一个子句,说给这些软件包以该ppa在名称中带有“ chromium”的优先级与其他软件包相同,因此它将被安装(具有更高的版本号)。
$ cat /etc/apt/preferences.d/webapps-preview-pin-400
Package: *
Pin: release o=LP-PPA-webapps-preview
Pin-Priority: 400
Package: *chromium*
Pin: release o=LP-PPA-webapps-preview
Pin-Priority: 500
要为“ Pin:release”选项标识正确的字符串,我们可以再次使用apt-cache策略。
$ apt-cache policy
...
500 http://ppa.launchpad.net/webapps/preview/ubuntu/ precise/main i386 Packages
release v=12.04,o=LP-PPA-webapps-preview,a=precise,n=precise,l=preview,c=main
origin ppa.launchpad.net
...
对于<0.8.14版的apt版本,必须明确指定固定包,因为通配符不起作用:
$ cat /etc/apt/preferences.d/webapps-preview-pin-400
Package: *
Pin: release o=LP-PPA-webapps-preview
Pin-Priority: 400
Package: chromium-browser chromium-codecs-ffmpeg chromium-browser-l10n chromium-codecs-ffmpeg-extra
Pin: release o=LP-PPA-webapps-preview
Pin-Priority: 500
现在,当我尝试升级时,我仅从该PPA中获得了我想要的软件包,而没有其他软件包。所有为我精心挑选的樱桃:
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
chromium-browser chromium-browser-l10n chromium-codecs-ffmpeg
3 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 25.1 MB of archives.
After this operation, 5,026 kB of additional disk space will be used.
Do you want to continue [Y/n]?