How to check if a virtual package is installed?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
In the following question there is a solution to checking for a package prior to installing it:
How do I check if a package is installed on my server?
However, I have found that this does not work for Virtual Packages.
Is there a way to traverse the package name that apt-get automatically select and check for the correct one?
apt package-management dpkg
add a comment |
In the following question there is a solution to checking for a package prior to installing it:
How do I check if a package is installed on my server?
However, I have found that this does not work for Virtual Packages.
Is there a way to traverse the package name that apt-get automatically select and check for the correct one?
apt package-management dpkg
add a comment |
In the following question there is a solution to checking for a package prior to installing it:
How do I check if a package is installed on my server?
However, I have found that this does not work for Virtual Packages.
Is there a way to traverse the package name that apt-get automatically select and check for the correct one?
apt package-management dpkg
In the following question there is a solution to checking for a package prior to installing it:
How do I check if a package is installed on my server?
However, I have found that this does not work for Virtual Packages.
Is there a way to traverse the package name that apt-get automatically select and check for the correct one?
apt package-management dpkg
apt package-management dpkg
edited Apr 22 '17 at 15:29
Noki
asked Sep 27 '15 at 23:46
NokiNoki
42211025
42211025
add a comment |
add a comment |
4 Answers
4
active
oldest
votes
You can use grep-status (package dctrl-tools
, not installed by default) to find all installed packages providing some virtual package:
$ grep-status -FProvides,Package -sPackage,Provides,Status awk
Package: mawk
Provides: awk
Status: install ok installed
Package: gawk
Provides: awk
Status: install ok installed
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
add a comment |
Apt will not install a virtual package unless there is only one provider for it. If another package depends on a virtual package, it usually also names a real package as an alternative (i.e. build-essential depend on "libc6-dev | libc-dev" - the second being a virtual package).
Virtual packages are not installed, thus you cannot check their status. You can use apt-cache showpkg <pkg-name>
to view which packages provide the virtual package, and then check whether any of these are installed.
add a comment |
@FlorianDiesch'answer looks interesting, but I want something without need for any software not installed by default.
I ended up using this:
function check_packages_and_install_if_absent()
{
for PACKAGENAME
do
if
dpkg -l "$PACKAGENAME" | grep ^ii
then
echo "Package $PACKAGENAME is present"
continue
fi
FOUND=""
while read ACTUALPACKAGENAME
do
echo "$PACKAGENAME is a virtual package, that can be provided by $ACTUALPACKAGENAME"
if
dpkg -l "$ACTUALPACKAGENAME" | grep ^ii
then
echo "Actual package $ACTUALPACKAGENAME is present"
FOUND=true
break;
fi
done < <( apt-cache showpkg "${PACKAGENAME}" | sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | sort | uniq )
# Using sed to print lines after match
# https://stackoverflow.com/questions/32569032/sed-print-all-lines-after-match#answer-32569573
if [[ "$FOUND" == "true" ]]
then
continue
fi
echo "Package $PACKAGENAME is absent, installing"
sudo apt-get install -y "$PACKAGENAME"
done
}
You can call it with a list of normal and/or virtual package names:
function check_packages_and_install_if_absent foo bar baz
add a comment |
You can query the database of installed packages for packagename with
dpkg -l packagename
And you can list all the files in packagename with
dpkg -L packagename
Read man dpkg
for more information, like how to use wildcards.
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2f679137%2fhow-to-check-if-a-virtual-package-is-installed%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can use grep-status (package dctrl-tools
, not installed by default) to find all installed packages providing some virtual package:
$ grep-status -FProvides,Package -sPackage,Provides,Status awk
Package: mawk
Provides: awk
Status: install ok installed
Package: gawk
Provides: awk
Status: install ok installed
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
add a comment |
You can use grep-status (package dctrl-tools
, not installed by default) to find all installed packages providing some virtual package:
$ grep-status -FProvides,Package -sPackage,Provides,Status awk
Package: mawk
Provides: awk
Status: install ok installed
Package: gawk
Provides: awk
Status: install ok installed
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
add a comment |
You can use grep-status (package dctrl-tools
, not installed by default) to find all installed packages providing some virtual package:
$ grep-status -FProvides,Package -sPackage,Provides,Status awk
Package: mawk
Provides: awk
Status: install ok installed
Package: gawk
Provides: awk
Status: install ok installed
You can use grep-status (package dctrl-tools
, not installed by default) to find all installed packages providing some virtual package:
$ grep-status -FProvides,Package -sPackage,Provides,Status awk
Package: mawk
Provides: awk
Status: install ok installed
Package: gawk
Provides: awk
Status: install ok installed
answered Sep 28 '15 at 2:56
Florian DieschFlorian Diesch
66.1k16168183
66.1k16168183
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
add a comment |
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
This sounds perfect, I will try it when I'm free and respond back. Thanks!
– Noki
Sep 30 '15 at 11:24
add a comment |
Apt will not install a virtual package unless there is only one provider for it. If another package depends on a virtual package, it usually also names a real package as an alternative (i.e. build-essential depend on "libc6-dev | libc-dev" - the second being a virtual package).
Virtual packages are not installed, thus you cannot check their status. You can use apt-cache showpkg <pkg-name>
to view which packages provide the virtual package, and then check whether any of these are installed.
add a comment |
Apt will not install a virtual package unless there is only one provider for it. If another package depends on a virtual package, it usually also names a real package as an alternative (i.e. build-essential depend on "libc6-dev | libc-dev" - the second being a virtual package).
Virtual packages are not installed, thus you cannot check their status. You can use apt-cache showpkg <pkg-name>
to view which packages provide the virtual package, and then check whether any of these are installed.
add a comment |
Apt will not install a virtual package unless there is only one provider for it. If another package depends on a virtual package, it usually also names a real package as an alternative (i.e. build-essential depend on "libc6-dev | libc-dev" - the second being a virtual package).
Virtual packages are not installed, thus you cannot check their status. You can use apt-cache showpkg <pkg-name>
to view which packages provide the virtual package, and then check whether any of these are installed.
Apt will not install a virtual package unless there is only one provider for it. If another package depends on a virtual package, it usually also names a real package as an alternative (i.e. build-essential depend on "libc6-dev | libc-dev" - the second being a virtual package).
Virtual packages are not installed, thus you cannot check their status. You can use apt-cache showpkg <pkg-name>
to view which packages provide the virtual package, and then check whether any of these are installed.
edited Sep 28 '15 at 1:29
answered Sep 28 '15 at 0:37
user448115
add a comment |
add a comment |
@FlorianDiesch'answer looks interesting, but I want something without need for any software not installed by default.
I ended up using this:
function check_packages_and_install_if_absent()
{
for PACKAGENAME
do
if
dpkg -l "$PACKAGENAME" | grep ^ii
then
echo "Package $PACKAGENAME is present"
continue
fi
FOUND=""
while read ACTUALPACKAGENAME
do
echo "$PACKAGENAME is a virtual package, that can be provided by $ACTUALPACKAGENAME"
if
dpkg -l "$ACTUALPACKAGENAME" | grep ^ii
then
echo "Actual package $ACTUALPACKAGENAME is present"
FOUND=true
break;
fi
done < <( apt-cache showpkg "${PACKAGENAME}" | sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | sort | uniq )
# Using sed to print lines after match
# https://stackoverflow.com/questions/32569032/sed-print-all-lines-after-match#answer-32569573
if [[ "$FOUND" == "true" ]]
then
continue
fi
echo "Package $PACKAGENAME is absent, installing"
sudo apt-get install -y "$PACKAGENAME"
done
}
You can call it with a list of normal and/or virtual package names:
function check_packages_and_install_if_absent foo bar baz
add a comment |
@FlorianDiesch'answer looks interesting, but I want something without need for any software not installed by default.
I ended up using this:
function check_packages_and_install_if_absent()
{
for PACKAGENAME
do
if
dpkg -l "$PACKAGENAME" | grep ^ii
then
echo "Package $PACKAGENAME is present"
continue
fi
FOUND=""
while read ACTUALPACKAGENAME
do
echo "$PACKAGENAME is a virtual package, that can be provided by $ACTUALPACKAGENAME"
if
dpkg -l "$ACTUALPACKAGENAME" | grep ^ii
then
echo "Actual package $ACTUALPACKAGENAME is present"
FOUND=true
break;
fi
done < <( apt-cache showpkg "${PACKAGENAME}" | sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | sort | uniq )
# Using sed to print lines after match
# https://stackoverflow.com/questions/32569032/sed-print-all-lines-after-match#answer-32569573
if [[ "$FOUND" == "true" ]]
then
continue
fi
echo "Package $PACKAGENAME is absent, installing"
sudo apt-get install -y "$PACKAGENAME"
done
}
You can call it with a list of normal and/or virtual package names:
function check_packages_and_install_if_absent foo bar baz
add a comment |
@FlorianDiesch'answer looks interesting, but I want something without need for any software not installed by default.
I ended up using this:
function check_packages_and_install_if_absent()
{
for PACKAGENAME
do
if
dpkg -l "$PACKAGENAME" | grep ^ii
then
echo "Package $PACKAGENAME is present"
continue
fi
FOUND=""
while read ACTUALPACKAGENAME
do
echo "$PACKAGENAME is a virtual package, that can be provided by $ACTUALPACKAGENAME"
if
dpkg -l "$ACTUALPACKAGENAME" | grep ^ii
then
echo "Actual package $ACTUALPACKAGENAME is present"
FOUND=true
break;
fi
done < <( apt-cache showpkg "${PACKAGENAME}" | sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | sort | uniq )
# Using sed to print lines after match
# https://stackoverflow.com/questions/32569032/sed-print-all-lines-after-match#answer-32569573
if [[ "$FOUND" == "true" ]]
then
continue
fi
echo "Package $PACKAGENAME is absent, installing"
sudo apt-get install -y "$PACKAGENAME"
done
}
You can call it with a list of normal and/or virtual package names:
function check_packages_and_install_if_absent foo bar baz
@FlorianDiesch'answer looks interesting, but I want something without need for any software not installed by default.
I ended up using this:
function check_packages_and_install_if_absent()
{
for PACKAGENAME
do
if
dpkg -l "$PACKAGENAME" | grep ^ii
then
echo "Package $PACKAGENAME is present"
continue
fi
FOUND=""
while read ACTUALPACKAGENAME
do
echo "$PACKAGENAME is a virtual package, that can be provided by $ACTUALPACKAGENAME"
if
dpkg -l "$ACTUALPACKAGENAME" | grep ^ii
then
echo "Actual package $ACTUALPACKAGENAME is present"
FOUND=true
break;
fi
done < <( apt-cache showpkg "${PACKAGENAME}" | sed -e '1,/^Reverse Provides: *$/ d' -e 's/ .*$//' | sort | uniq )
# Using sed to print lines after match
# https://stackoverflow.com/questions/32569032/sed-print-all-lines-after-match#answer-32569573
if [[ "$FOUND" == "true" ]]
then
continue
fi
echo "Package $PACKAGENAME is absent, installing"
sudo apt-get install -y "$PACKAGENAME"
done
}
You can call it with a list of normal and/or virtual package names:
function check_packages_and_install_if_absent foo bar baz
edited Mar 29 at 16:48
answered Mar 29 at 13:09
Stéphane GourichonStéphane Gourichon
1,3571527
1,3571527
add a comment |
add a comment |
You can query the database of installed packages for packagename with
dpkg -l packagename
And you can list all the files in packagename with
dpkg -L packagename
Read man dpkg
for more information, like how to use wildcards.
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
add a comment |
You can query the database of installed packages for packagename with
dpkg -l packagename
And you can list all the files in packagename with
dpkg -L packagename
Read man dpkg
for more information, like how to use wildcards.
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
add a comment |
You can query the database of installed packages for packagename with
dpkg -l packagename
And you can list all the files in packagename with
dpkg -L packagename
Read man dpkg
for more information, like how to use wildcards.
You can query the database of installed packages for packagename with
dpkg -l packagename
And you can list all the files in packagename with
dpkg -L packagename
Read man dpkg
for more information, like how to use wildcards.
answered Sep 28 '15 at 0:42
waltinatorwaltinator
23k74269
23k74269
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
add a comment |
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
As stated in the question this does not work for virtual packages.
– Florian Diesch
Sep 28 '15 at 2:43
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f679137%2fhow-to-check-if-a-virtual-package-is-installed%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