How to list all installed packages from a specific category (component)
up vote
4
down vote
favorite
Is it possible to list all installed packages from a specific official repository component (Main, Restricted, Universe or Multiverse) using utilities like apt, apt-cache, aptitude?
I wrote a simple script for this purpose:
dpkg -l | grep ^ii | cut -f3 -d ' ' | while read -r pkg;
do
status=`apt-cache show $pkg | grep -m1 "Section: multiverse"`
if [ ! -z "$status" ]
then
echo $pkg
fi
done;
It works, but it's really slow cause it's checking all packages one by one. Running the time command for this script will produce:
real 1m16.797s
user 0m57.008s
sys 0m8.260s
I already tried aptitude search patterns, and dpkg-query formating, but it seems they don't have the proper column/schema to create a query for this purpose.
I also had a look at vrms script to find out how it's works, because it's really fast in finding contrib/non-free packages, it's seems that vrms script scans the whole /var/lib/dpkg/status file, looking for things like 'Section: (contrib | non-free | restricted | multiverse | partner )', so it wasn't helpful either, because not all packages have this section.
command-line apt package-management dpkg aptitude
add a comment |
up vote
4
down vote
favorite
Is it possible to list all installed packages from a specific official repository component (Main, Restricted, Universe or Multiverse) using utilities like apt, apt-cache, aptitude?
I wrote a simple script for this purpose:
dpkg -l | grep ^ii | cut -f3 -d ' ' | while read -r pkg;
do
status=`apt-cache show $pkg | grep -m1 "Section: multiverse"`
if [ ! -z "$status" ]
then
echo $pkg
fi
done;
It works, but it's really slow cause it's checking all packages one by one. Running the time command for this script will produce:
real 1m16.797s
user 0m57.008s
sys 0m8.260s
I already tried aptitude search patterns, and dpkg-query formating, but it seems they don't have the proper column/schema to create a query for this purpose.
I also had a look at vrms script to find out how it's works, because it's really fast in finding contrib/non-free packages, it's seems that vrms script scans the whole /var/lib/dpkg/status file, looking for things like 'Section: (contrib | non-free | restricted | multiverse | partner )', so it wasn't helpful either, because not all packages have this section.
command-line apt package-management dpkg aptitude
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
Is it possible to list all installed packages from a specific official repository component (Main, Restricted, Universe or Multiverse) using utilities like apt, apt-cache, aptitude?
I wrote a simple script for this purpose:
dpkg -l | grep ^ii | cut -f3 -d ' ' | while read -r pkg;
do
status=`apt-cache show $pkg | grep -m1 "Section: multiverse"`
if [ ! -z "$status" ]
then
echo $pkg
fi
done;
It works, but it's really slow cause it's checking all packages one by one. Running the time command for this script will produce:
real 1m16.797s
user 0m57.008s
sys 0m8.260s
I already tried aptitude search patterns, and dpkg-query formating, but it seems they don't have the proper column/schema to create a query for this purpose.
I also had a look at vrms script to find out how it's works, because it's really fast in finding contrib/non-free packages, it's seems that vrms script scans the whole /var/lib/dpkg/status file, looking for things like 'Section: (contrib | non-free | restricted | multiverse | partner )', so it wasn't helpful either, because not all packages have this section.
command-line apt package-management dpkg aptitude
Is it possible to list all installed packages from a specific official repository component (Main, Restricted, Universe or Multiverse) using utilities like apt, apt-cache, aptitude?
I wrote a simple script for this purpose:
dpkg -l | grep ^ii | cut -f3 -d ' ' | while read -r pkg;
do
status=`apt-cache show $pkg | grep -m1 "Section: multiverse"`
if [ ! -z "$status" ]
then
echo $pkg
fi
done;
It works, but it's really slow cause it's checking all packages one by one. Running the time command for this script will produce:
real 1m16.797s
user 0m57.008s
sys 0m8.260s
I already tried aptitude search patterns, and dpkg-query formating, but it seems they don't have the proper column/schema to create a query for this purpose.
I also had a look at vrms script to find out how it's works, because it's really fast in finding contrib/non-free packages, it's seems that vrms script scans the whole /var/lib/dpkg/status file, looking for things like 'Section: (contrib | non-free | restricted | multiverse | partner )', so it wasn't helpful either, because not all packages have this section.
command-line apt package-management dpkg aptitude
command-line apt package-management dpkg aptitude
edited Nov 19 at 17:48
Zanna
49.1k13123234
49.1k13123234
asked Mar 31 '17 at 21:25
Ravexina
30.6k1478106
30.6k1478106
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
Okay, I didn't found any solution to do this with standard utilities, however after having a look at vrms I came-up with a pretty better script to search for packages installed from a specific component.
The other script which I mentioned in my question was really time consuming.
However, the new script is available here: pkgs-from.sh
The usage is:
./pkgs-from.sh universe # or main, multiverse, backports
And the time command result for this one is:
real 0m4.367s
user 0m0.980s
sys 0m0.408s
Which is pretty good.
How it works?
The script will create a list of all packages related to the requested component from related files within the /var/lib/apt/lists/ directory, then starts to search throughout them instead of using apt-cache.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
Okay, I didn't found any solution to do this with standard utilities, however after having a look at vrms I came-up with a pretty better script to search for packages installed from a specific component.
The other script which I mentioned in my question was really time consuming.
However, the new script is available here: pkgs-from.sh
The usage is:
./pkgs-from.sh universe # or main, multiverse, backports
And the time command result for this one is:
real 0m4.367s
user 0m0.980s
sys 0m0.408s
Which is pretty good.
How it works?
The script will create a list of all packages related to the requested component from related files within the /var/lib/apt/lists/ directory, then starts to search throughout them instead of using apt-cache.
add a comment |
up vote
1
down vote
Okay, I didn't found any solution to do this with standard utilities, however after having a look at vrms I came-up with a pretty better script to search for packages installed from a specific component.
The other script which I mentioned in my question was really time consuming.
However, the new script is available here: pkgs-from.sh
The usage is:
./pkgs-from.sh universe # or main, multiverse, backports
And the time command result for this one is:
real 0m4.367s
user 0m0.980s
sys 0m0.408s
Which is pretty good.
How it works?
The script will create a list of all packages related to the requested component from related files within the /var/lib/apt/lists/ directory, then starts to search throughout them instead of using apt-cache.
add a comment |
up vote
1
down vote
up vote
1
down vote
Okay, I didn't found any solution to do this with standard utilities, however after having a look at vrms I came-up with a pretty better script to search for packages installed from a specific component.
The other script which I mentioned in my question was really time consuming.
However, the new script is available here: pkgs-from.sh
The usage is:
./pkgs-from.sh universe # or main, multiverse, backports
And the time command result for this one is:
real 0m4.367s
user 0m0.980s
sys 0m0.408s
Which is pretty good.
How it works?
The script will create a list of all packages related to the requested component from related files within the /var/lib/apt/lists/ directory, then starts to search throughout them instead of using apt-cache.
Okay, I didn't found any solution to do this with standard utilities, however after having a look at vrms I came-up with a pretty better script to search for packages installed from a specific component.
The other script which I mentioned in my question was really time consuming.
However, the new script is available here: pkgs-from.sh
The usage is:
./pkgs-from.sh universe # or main, multiverse, backports
And the time command result for this one is:
real 0m4.367s
user 0m0.980s
sys 0m0.408s
Which is pretty good.
How it works?
The script will create a list of all packages related to the requested component from related files within the /var/lib/apt/lists/ directory, then starts to search throughout them instead of using apt-cache.
answered Apr 4 '17 at 13:22
Ravexina
30.6k1478106
30.6k1478106
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f898980%2fhow-to-list-all-installed-packages-from-a-specific-category-component%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown