BTW, if you want to put on hold all packages from a specific repository, you may consider following. Each repository puts its package index under /var/lib/apt/lists/. The files there are named after deb strings in /etc/apt/sources.list and/or /etc/apt/sources.list.d/*.list. So, say if you have enabled the Medibuntu repository and /etc/apt/sources.list.d/medibuntu.list contains a string starting with
Code:
deb http://packages.medibuntu.org/...
there will be a corresponding package index for medibuntu under
Code:
/var/lib/apt/lists/packages.medibuntu.org_..._Packages
That means you can put all packages from Medibuntu on hold with
Code:
sudo apt-mark hold `sed -n s/^Package://p /var/lib/apt/lists/*.medibuntu.*Packages`
As long as you aren't mixing packages for different architectures (say amd64 and i386), the command above will work as expected. However, in a multiarch environment it will lock only packages for the native architecture. Setting on hold packages for a foreign architecture will require something like the following (provided that the foreign architecture is i386)
Code:
sudo apt-mark hold `sed -nr 's/^Package:\s*(\S+)/\1 \1:i386/p' /var/lib/apt/lists/*.medibuntu.*Packages`
Trying to put on hold only actually installed packages from a 3rd part repository further complicates the matter:
Code:
awk -F':[ \t]*' '/^Package:/,/^$/{
if(/^Package:/){p=$2;a=""}
if(/^Architecture:/&&$2!="all")a=":"$2
if(/^$/)print p""a" hold"
}' /var/lib/apt/lists/*.medibuntu.*Packages|sort -uk1,1|
join - <(dpkg -l|awk '/^ii/{print$2}'|sort)|sudo dpkg --set-selections
sudo dpkg -Pa
Using combine provided by package moreutils together with dctrl-tools simplifies this task a bit:
Code:
sudo apt-get install moreutils dctrl-tools
alias _=combine
_ <(grep-dctrl -sPackage,Architecture '' /var/lib/apt/lists/*.medibuntu.*Packages|tbl-dctrl -Hd:) and <(grep-status -FStatus -sPackage,Architecture 'ok installed'|tbl-dctrl -Hd:) _|
sed 's/$/ hold/'
The method used by ppa-purge to select all packages installed from a PPA is also worth mentioning:
Code:
sed -n s/^Package://p /var/lib/apt/lists/*.medibuntu.*Packages|sort -u|xargs -r dpkg -l 2>/dev/null|awk '/^ii/,$0=$2" hold"'
Using aptitude makes the task look quite straightforward. Unfortunately, aptitude's hold state has nothing to do with dpkg's hold state and won't be honored by any other package management tool. Still, if you manage your packages exclusively through aptitude, it may be convenient:
Code:
sudo aptitude hold ~i~OMedibuntu
Otherwise, the best available option is to feed the output of aptitude search either to apt-mark hold or directly to dpkg:
Code:
sudo apt-mark hold `aptitude --disable-columns -F%p search ~i~OMedibuntu`
or
Code:
aptitude --disable-columns -F'%p hold' search ~i~OMedibuntu|sudo dpkg --set-selections
sudo dpkg -Pa
Bookmarks