List optional dependencies with pacman on arch linux

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
19
down vote

favorite
3












I'm using arch linux.



Is there a way to list optional dependencies of all installed packages? And if yes, can I filter this list to see only the missing (not installed) packages?










share|improve this question

















  • 1




    I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
    – jordanm
    Oct 28 '12 at 4:27










  • AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
    – darnir
    Oct 28 '12 at 5:09










  • @jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
    – darnir
    Oct 28 '12 at 5:11














up vote
19
down vote

favorite
3












I'm using arch linux.



Is there a way to list optional dependencies of all installed packages? And if yes, can I filter this list to see only the missing (not installed) packages?










share|improve this question

















  • 1




    I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
    – jordanm
    Oct 28 '12 at 4:27










  • AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
    – darnir
    Oct 28 '12 at 5:09










  • @jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
    – darnir
    Oct 28 '12 at 5:11












up vote
19
down vote

favorite
3









up vote
19
down vote

favorite
3






3





I'm using arch linux.



Is there a way to list optional dependencies of all installed packages? And if yes, can I filter this list to see only the missing (not installed) packages?










share|improve this question













I'm using arch linux.



Is there a way to list optional dependencies of all installed packages? And if yes, can I filter this list to see only the missing (not installed) packages?







arch-linux pacman






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Oct 28 '12 at 0:40









vonPetrushev

3701612




3701612







  • 1




    I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
    – jordanm
    Oct 28 '12 at 4:27










  • AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
    – darnir
    Oct 28 '12 at 5:09










  • @jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
    – darnir
    Oct 28 '12 at 5:11












  • 1




    I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
    – jordanm
    Oct 28 '12 at 4:27










  • AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
    – darnir
    Oct 28 '12 at 5:09










  • @jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
    – darnir
    Oct 28 '12 at 5:11







1




1




I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
– jordanm
Oct 28 '12 at 4:27




I haven't used Arch, but "dependency" doesn't sound optional (it's not in other distros).
– jordanm
Oct 28 '12 at 4:27












AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
– darnir
Oct 28 '12 at 5:09




AFAIK, I don't think you can do that with pacman straight away. But it is very possible to write a small script to do it. Query pacman for list of installed packages. Have Yaourt fetch their PKGBUILDs and read the list of optdeps. The latest version of pacman-git has a commit that states whether the optdeps have already been installed.
– darnir
Oct 28 '12 at 5:09












@jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
– darnir
Oct 28 '12 at 5:11




@jordanm: As has build dependencies and optional dependencies. Optdeps are required only for certain features of a package. So, unless you are using that feature, you don't really need to bloat your system with a load of dependencies.
– darnir
Oct 28 '12 at 5:11










6 Answers
6






active

oldest

votes

















up vote
5
down vote













There is a nice utility in the AUR-Repository (aur/pacdep).



pacdep has a lot of options - just one example - find out optional packages for "thunar-archive-plugin":



> pacdep -oppp thunar-archive-plugin
[...]
Optional dependencies: 6.16 MiB
extra/file-roller 3.89 MiB
extra/kdeutils-ark 1.12 MiB
community/xarchiver 1.16 MiB
[...]


The output above means that none of the optional packages are installed.
After installing "xarchiver" the output looks like



[...]
Optional dependencies: 6.16 MiB
local: 1.16 MiB
xarchiver 1.16 MiB
sync: 5.01 MiB
extra/file-roller 3.89 MiB
extra/kdeutils-ark 1.12 MiB
[...]


I found (the first part of) this answer on
http://mywaytoarch.tumblr.com/post/34979742718/easily-list-package-dependencies






share|improve this answer





























    up vote
    4
    down vote













    You can use expac to query the pacmandatabase.



    Something like:



    awk 'NF>=2' <(expac "%n %O") > optdeps


    will print a list of all the installed packages on your machine and the optdepends for each one (%O)1 to a file called optdeps. You could then sort this against a list of installed optdepends packages.



    See man expac for the complete list of options.




    1. That is an upper case O, not a zero. Because we can't have a font that distinguished between the two...






    share|improve this answer






















    • [poke] We do have such a font now. :)
      – muru
      Dec 8 '14 at 18:35

















    up vote
    2
    down vote













    Though I've had to notice that @DarkHeart's solution doesn't really work, it inspired me to make a working one. (no colours, though)



    I'm using package-query, a similar tool instead of expac which was suggested by @jasonwryan, because I've had it already installed (it's a dependency of yaourt). It should be trivial to change this to use expac instead.



    The listing of all optional dependencies is mostly done by the call to package-query. The first for-loop removes the explanations, so just the package names for the optional dependencies remain; the second for-loop removes the already installed dependencies in its first line before printing the results in the second one.



    #!/usr/bin/perl
    use strict;
    use warnings;

    my %deps;
    for (`package-query -Q -f'%n %O'`)
    $deps (/^(S+)/)[0] = [/(S+):/g];

    my @pkgs = keys %deps;
    for my $pkg (@pkgs)
    my @missing_deps = grep !($_ ~~ @pkgs) @ $deps$pkg ;
    print "$pkg => @missing_depsn" if @missing_deps;






    share|improve this answer





























      up vote
      2
      down vote













      This is not exactly efficient, but will find what you want (in COLOR!):



      pacman -Q > /tmp/paccache
      for pkg in $(awk 'print $1' /tmp/paccache) ; do
      echo -n "$pkg => ";
      for dep in $(pacman -Qi $pkg | awk -F: '/Optional Deps/gsub(/[<>=].*/,"");print $NF;' ) ; do
      grep -q "$dep" /tmp/paccache && COLOR=32 ; echo -en "e[1;$COLOR:-31m$depe[0;m " ; unset COLOR ;
      done
      echo
      done





      share|improve this answer






















      • I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
        – Rörd
        Nov 20 '12 at 21:10










      • And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
        – Rörd
        Nov 20 '12 at 22:28










      • For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
        – i336_
        Mar 2 '16 at 2:18

















      up vote
      2
      down vote













      This should do the trick:



      comm -23 <(expac -l"n" "%o" | sort -u) <(expac -l"n" "%nn%S" | sort -u)


      First input to comm lists all optional dependencies, second input all installed packages and their 'provide' attributes. Both lists are sorted and contain each element only once due to sort -u. Then only lines are shown that are contained in the first but not in the second list.



      (edited to incorporate @Archemar's suggestion)






      share|improve this answer





























        up vote
        0
        down vote













        Sometimes you have to work backwards... first find all non-optional depends, then cross-reference with full list, then use uniq.



        Find all installed



        pacman -Q


        Find all non-optional:



        pacman -Qent


        Unique entries must therefore be optional:



        (pacman -Q; pacman -Qent) | sort | uniq -u 




        share




















          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53080%2flist-optional-dependencies-with-pacman-on-arch-linux%23new-answer', 'question_page');

          );

          Post as a guest






























          6 Answers
          6






          active

          oldest

          votes








          6 Answers
          6






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          5
          down vote













          There is a nice utility in the AUR-Repository (aur/pacdep).



          pacdep has a lot of options - just one example - find out optional packages for "thunar-archive-plugin":



          > pacdep -oppp thunar-archive-plugin
          [...]
          Optional dependencies: 6.16 MiB
          extra/file-roller 3.89 MiB
          extra/kdeutils-ark 1.12 MiB
          community/xarchiver 1.16 MiB
          [...]


          The output above means that none of the optional packages are installed.
          After installing "xarchiver" the output looks like



          [...]
          Optional dependencies: 6.16 MiB
          local: 1.16 MiB
          xarchiver 1.16 MiB
          sync: 5.01 MiB
          extra/file-roller 3.89 MiB
          extra/kdeutils-ark 1.12 MiB
          [...]


          I found (the first part of) this answer on
          http://mywaytoarch.tumblr.com/post/34979742718/easily-list-package-dependencies






          share|improve this answer


























            up vote
            5
            down vote













            There is a nice utility in the AUR-Repository (aur/pacdep).



            pacdep has a lot of options - just one example - find out optional packages for "thunar-archive-plugin":



            > pacdep -oppp thunar-archive-plugin
            [...]
            Optional dependencies: 6.16 MiB
            extra/file-roller 3.89 MiB
            extra/kdeutils-ark 1.12 MiB
            community/xarchiver 1.16 MiB
            [...]


            The output above means that none of the optional packages are installed.
            After installing "xarchiver" the output looks like



            [...]
            Optional dependencies: 6.16 MiB
            local: 1.16 MiB
            xarchiver 1.16 MiB
            sync: 5.01 MiB
            extra/file-roller 3.89 MiB
            extra/kdeutils-ark 1.12 MiB
            [...]


            I found (the first part of) this answer on
            http://mywaytoarch.tumblr.com/post/34979742718/easily-list-package-dependencies






            share|improve this answer
























              up vote
              5
              down vote










              up vote
              5
              down vote









              There is a nice utility in the AUR-Repository (aur/pacdep).



              pacdep has a lot of options - just one example - find out optional packages for "thunar-archive-plugin":



              > pacdep -oppp thunar-archive-plugin
              [...]
              Optional dependencies: 6.16 MiB
              extra/file-roller 3.89 MiB
              extra/kdeutils-ark 1.12 MiB
              community/xarchiver 1.16 MiB
              [...]


              The output above means that none of the optional packages are installed.
              After installing "xarchiver" the output looks like



              [...]
              Optional dependencies: 6.16 MiB
              local: 1.16 MiB
              xarchiver 1.16 MiB
              sync: 5.01 MiB
              extra/file-roller 3.89 MiB
              extra/kdeutils-ark 1.12 MiB
              [...]


              I found (the first part of) this answer on
              http://mywaytoarch.tumblr.com/post/34979742718/easily-list-package-dependencies






              share|improve this answer














              There is a nice utility in the AUR-Repository (aur/pacdep).



              pacdep has a lot of options - just one example - find out optional packages for "thunar-archive-plugin":



              > pacdep -oppp thunar-archive-plugin
              [...]
              Optional dependencies: 6.16 MiB
              extra/file-roller 3.89 MiB
              extra/kdeutils-ark 1.12 MiB
              community/xarchiver 1.16 MiB
              [...]


              The output above means that none of the optional packages are installed.
              After installing "xarchiver" the output looks like



              [...]
              Optional dependencies: 6.16 MiB
              local: 1.16 MiB
              xarchiver 1.16 MiB
              sync: 5.01 MiB
              extra/file-roller 3.89 MiB
              extra/kdeutils-ark 1.12 MiB
              [...]


              I found (the first part of) this answer on
              http://mywaytoarch.tumblr.com/post/34979742718/easily-list-package-dependencies







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Dec 8 '14 at 17:09

























              answered Dec 8 '14 at 17:01









              Martin Schneeweis

              5112




              5112






















                  up vote
                  4
                  down vote













                  You can use expac to query the pacmandatabase.



                  Something like:



                  awk 'NF>=2' <(expac "%n %O") > optdeps


                  will print a list of all the installed packages on your machine and the optdepends for each one (%O)1 to a file called optdeps. You could then sort this against a list of installed optdepends packages.



                  See man expac for the complete list of options.




                  1. That is an upper case O, not a zero. Because we can't have a font that distinguished between the two...






                  share|improve this answer






















                  • [poke] We do have such a font now. :)
                    – muru
                    Dec 8 '14 at 18:35














                  up vote
                  4
                  down vote













                  You can use expac to query the pacmandatabase.



                  Something like:



                  awk 'NF>=2' <(expac "%n %O") > optdeps


                  will print a list of all the installed packages on your machine and the optdepends for each one (%O)1 to a file called optdeps. You could then sort this against a list of installed optdepends packages.



                  See man expac for the complete list of options.




                  1. That is an upper case O, not a zero. Because we can't have a font that distinguished between the two...






                  share|improve this answer






















                  • [poke] We do have such a font now. :)
                    – muru
                    Dec 8 '14 at 18:35












                  up vote
                  4
                  down vote










                  up vote
                  4
                  down vote









                  You can use expac to query the pacmandatabase.



                  Something like:



                  awk 'NF>=2' <(expac "%n %O") > optdeps


                  will print a list of all the installed packages on your machine and the optdepends for each one (%O)1 to a file called optdeps. You could then sort this against a list of installed optdepends packages.



                  See man expac for the complete list of options.




                  1. That is an upper case O, not a zero. Because we can't have a font that distinguished between the two...






                  share|improve this answer














                  You can use expac to query the pacmandatabase.



                  Something like:



                  awk 'NF>=2' <(expac "%n %O") > optdeps


                  will print a list of all the installed packages on your machine and the optdepends for each one (%O)1 to a file called optdeps. You could then sort this against a list of installed optdepends packages.



                  See man expac for the complete list of options.




                  1. That is an upper case O, not a zero. Because we can't have a font that distinguished between the two...







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 16 '17 at 15:45









                  Community♦

                  1




                  1










                  answered Oct 28 '12 at 6:43









                  jasonwryan

                  47.7k14131180




                  47.7k14131180











                  • [poke] We do have such a font now. :)
                    – muru
                    Dec 8 '14 at 18:35
















                  • [poke] We do have such a font now. :)
                    – muru
                    Dec 8 '14 at 18:35















                  [poke] We do have such a font now. :)
                  – muru
                  Dec 8 '14 at 18:35




                  [poke] We do have such a font now. :)
                  – muru
                  Dec 8 '14 at 18:35










                  up vote
                  2
                  down vote













                  Though I've had to notice that @DarkHeart's solution doesn't really work, it inspired me to make a working one. (no colours, though)



                  I'm using package-query, a similar tool instead of expac which was suggested by @jasonwryan, because I've had it already installed (it's a dependency of yaourt). It should be trivial to change this to use expac instead.



                  The listing of all optional dependencies is mostly done by the call to package-query. The first for-loop removes the explanations, so just the package names for the optional dependencies remain; the second for-loop removes the already installed dependencies in its first line before printing the results in the second one.



                  #!/usr/bin/perl
                  use strict;
                  use warnings;

                  my %deps;
                  for (`package-query -Q -f'%n %O'`)
                  $deps (/^(S+)/)[0] = [/(S+):/g];

                  my @pkgs = keys %deps;
                  for my $pkg (@pkgs)
                  my @missing_deps = grep !($_ ~~ @pkgs) @ $deps$pkg ;
                  print "$pkg => @missing_depsn" if @missing_deps;






                  share|improve this answer


























                    up vote
                    2
                    down vote













                    Though I've had to notice that @DarkHeart's solution doesn't really work, it inspired me to make a working one. (no colours, though)



                    I'm using package-query, a similar tool instead of expac which was suggested by @jasonwryan, because I've had it already installed (it's a dependency of yaourt). It should be trivial to change this to use expac instead.



                    The listing of all optional dependencies is mostly done by the call to package-query. The first for-loop removes the explanations, so just the package names for the optional dependencies remain; the second for-loop removes the already installed dependencies in its first line before printing the results in the second one.



                    #!/usr/bin/perl
                    use strict;
                    use warnings;

                    my %deps;
                    for (`package-query -Q -f'%n %O'`)
                    $deps (/^(S+)/)[0] = [/(S+):/g];

                    my @pkgs = keys %deps;
                    for my $pkg (@pkgs)
                    my @missing_deps = grep !($_ ~~ @pkgs) @ $deps$pkg ;
                    print "$pkg => @missing_depsn" if @missing_deps;






                    share|improve this answer
























                      up vote
                      2
                      down vote










                      up vote
                      2
                      down vote









                      Though I've had to notice that @DarkHeart's solution doesn't really work, it inspired me to make a working one. (no colours, though)



                      I'm using package-query, a similar tool instead of expac which was suggested by @jasonwryan, because I've had it already installed (it's a dependency of yaourt). It should be trivial to change this to use expac instead.



                      The listing of all optional dependencies is mostly done by the call to package-query. The first for-loop removes the explanations, so just the package names for the optional dependencies remain; the second for-loop removes the already installed dependencies in its first line before printing the results in the second one.



                      #!/usr/bin/perl
                      use strict;
                      use warnings;

                      my %deps;
                      for (`package-query -Q -f'%n %O'`)
                      $deps (/^(S+)/)[0] = [/(S+):/g];

                      my @pkgs = keys %deps;
                      for my $pkg (@pkgs)
                      my @missing_deps = grep !($_ ~~ @pkgs) @ $deps$pkg ;
                      print "$pkg => @missing_depsn" if @missing_deps;






                      share|improve this answer














                      Though I've had to notice that @DarkHeart's solution doesn't really work, it inspired me to make a working one. (no colours, though)



                      I'm using package-query, a similar tool instead of expac which was suggested by @jasonwryan, because I've had it already installed (it's a dependency of yaourt). It should be trivial to change this to use expac instead.



                      The listing of all optional dependencies is mostly done by the call to package-query. The first for-loop removes the explanations, so just the package names for the optional dependencies remain; the second for-loop removes the already installed dependencies in its first line before printing the results in the second one.



                      #!/usr/bin/perl
                      use strict;
                      use warnings;

                      my %deps;
                      for (`package-query -Q -f'%n %O'`)
                      $deps (/^(S+)/)[0] = [/(S+):/g];

                      my @pkgs = keys %deps;
                      for my $pkg (@pkgs)
                      my @missing_deps = grep !($_ ~~ @pkgs) @ $deps$pkg ;
                      print "$pkg => @missing_depsn" if @missing_deps;







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Nov 21 '12 at 0:29

























                      answered Nov 20 '12 at 23:56









                      Rörd

                      1213




                      1213




















                          up vote
                          2
                          down vote













                          This is not exactly efficient, but will find what you want (in COLOR!):



                          pacman -Q > /tmp/paccache
                          for pkg in $(awk 'print $1' /tmp/paccache) ; do
                          echo -n "$pkg => ";
                          for dep in $(pacman -Qi $pkg | awk -F: '/Optional Deps/gsub(/[<>=].*/,"");print $NF;' ) ; do
                          grep -q "$dep" /tmp/paccache && COLOR=32 ; echo -en "e[1;$COLOR:-31m$depe[0;m " ; unset COLOR ;
                          done
                          echo
                          done





                          share|improve this answer






















                          • I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                            – Rörd
                            Nov 20 '12 at 21:10










                          • And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                            – Rörd
                            Nov 20 '12 at 22:28










                          • For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                            – i336_
                            Mar 2 '16 at 2:18














                          up vote
                          2
                          down vote













                          This is not exactly efficient, but will find what you want (in COLOR!):



                          pacman -Q > /tmp/paccache
                          for pkg in $(awk 'print $1' /tmp/paccache) ; do
                          echo -n "$pkg => ";
                          for dep in $(pacman -Qi $pkg | awk -F: '/Optional Deps/gsub(/[<>=].*/,"");print $NF;' ) ; do
                          grep -q "$dep" /tmp/paccache && COLOR=32 ; echo -en "e[1;$COLOR:-31m$depe[0;m " ; unset COLOR ;
                          done
                          echo
                          done





                          share|improve this answer






















                          • I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                            – Rörd
                            Nov 20 '12 at 21:10










                          • And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                            – Rörd
                            Nov 20 '12 at 22:28










                          • For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                            – i336_
                            Mar 2 '16 at 2:18












                          up vote
                          2
                          down vote










                          up vote
                          2
                          down vote









                          This is not exactly efficient, but will find what you want (in COLOR!):



                          pacman -Q > /tmp/paccache
                          for pkg in $(awk 'print $1' /tmp/paccache) ; do
                          echo -n "$pkg => ";
                          for dep in $(pacman -Qi $pkg | awk -F: '/Optional Deps/gsub(/[<>=].*/,"");print $NF;' ) ; do
                          grep -q "$dep" /tmp/paccache && COLOR=32 ; echo -en "e[1;$COLOR:-31m$depe[0;m " ; unset COLOR ;
                          done
                          echo
                          done





                          share|improve this answer














                          This is not exactly efficient, but will find what you want (in COLOR!):



                          pacman -Q > /tmp/paccache
                          for pkg in $(awk 'print $1' /tmp/paccache) ; do
                          echo -n "$pkg => ";
                          for dep in $(pacman -Qi $pkg | awk -F: '/Optional Deps/gsub(/[<>=].*/,"");print $NF;' ) ; do
                          grep -q "$dep" /tmp/paccache && COLOR=32 ; echo -en "e[1;$COLOR:-31m$depe[0;m " ; unset COLOR ;
                          done
                          echo
                          done






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Nov 30 '12 at 14:09

























                          answered Oct 28 '12 at 8:28









                          DarkHeart

                          3,38822137




                          3,38822137











                          • I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                            – Rörd
                            Nov 20 '12 at 21:10










                          • And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                            – Rörd
                            Nov 20 '12 at 22:28










                          • For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                            – i336_
                            Mar 2 '16 at 2:18
















                          • I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                            – Rörd
                            Nov 20 '12 at 21:10










                          • And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                            – Rörd
                            Nov 20 '12 at 22:28










                          • For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                            – i336_
                            Mar 2 '16 at 2:18















                          I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                          – Rörd
                          Nov 20 '12 at 21:10




                          I'm not perfectly sure, but shouldn't that be || instead of && after the grep, and then parentheses around the rest of the line?
                          – Rörd
                          Nov 20 '12 at 21:10












                          And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                          – Rörd
                          Nov 20 '12 at 22:28




                          And more importantly, this should probably use the "Optional Deps" section instead of the "Depends On" section of the pacman output.
                          – Rörd
                          Nov 20 '12 at 22:28












                          For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                          – i336_
                          Mar 2 '16 at 2:18




                          For example with xmms2: pacman -Qi xmms2 | sed -n '/^Optional/,$p' | sed '/^Required/q' | head -n -1 | cut -c19- | cut -d: -f1
                          – i336_
                          Mar 2 '16 at 2:18










                          up vote
                          2
                          down vote













                          This should do the trick:



                          comm -23 <(expac -l"n" "%o" | sort -u) <(expac -l"n" "%nn%S" | sort -u)


                          First input to comm lists all optional dependencies, second input all installed packages and their 'provide' attributes. Both lists are sorted and contain each element only once due to sort -u. Then only lines are shown that are contained in the first but not in the second list.



                          (edited to incorporate @Archemar's suggestion)






                          share|improve this answer


























                            up vote
                            2
                            down vote













                            This should do the trick:



                            comm -23 <(expac -l"n" "%o" | sort -u) <(expac -l"n" "%nn%S" | sort -u)


                            First input to comm lists all optional dependencies, second input all installed packages and their 'provide' attributes. Both lists are sorted and contain each element only once due to sort -u. Then only lines are shown that are contained in the first but not in the second list.



                            (edited to incorporate @Archemar's suggestion)






                            share|improve this answer
























                              up vote
                              2
                              down vote










                              up vote
                              2
                              down vote









                              This should do the trick:



                              comm -23 <(expac -l"n" "%o" | sort -u) <(expac -l"n" "%nn%S" | sort -u)


                              First input to comm lists all optional dependencies, second input all installed packages and their 'provide' attributes. Both lists are sorted and contain each element only once due to sort -u. Then only lines are shown that are contained in the first but not in the second list.



                              (edited to incorporate @Archemar's suggestion)






                              share|improve this answer














                              This should do the trick:



                              comm -23 <(expac -l"n" "%o" | sort -u) <(expac -l"n" "%nn%S" | sort -u)


                              First input to comm lists all optional dependencies, second input all installed packages and their 'provide' attributes. Both lists are sorted and contain each element only once due to sort -u. Then only lines are shown that are contained in the first but not in the second list.



                              (edited to incorporate @Archemar's suggestion)







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 2 '17 at 12:38

























                              answered Jul 29 '15 at 8:02









                              Sunday

                              1365




                              1365




















                                  up vote
                                  0
                                  down vote













                                  Sometimes you have to work backwards... first find all non-optional depends, then cross-reference with full list, then use uniq.



                                  Find all installed



                                  pacman -Q


                                  Find all non-optional:



                                  pacman -Qent


                                  Unique entries must therefore be optional:



                                  (pacman -Q; pacman -Qent) | sort | uniq -u 




                                  share
























                                    up vote
                                    0
                                    down vote













                                    Sometimes you have to work backwards... first find all non-optional depends, then cross-reference with full list, then use uniq.



                                    Find all installed



                                    pacman -Q


                                    Find all non-optional:



                                    pacman -Qent


                                    Unique entries must therefore be optional:



                                    (pacman -Q; pacman -Qent) | sort | uniq -u 




                                    share






















                                      up vote
                                      0
                                      down vote










                                      up vote
                                      0
                                      down vote









                                      Sometimes you have to work backwards... first find all non-optional depends, then cross-reference with full list, then use uniq.



                                      Find all installed



                                      pacman -Q


                                      Find all non-optional:



                                      pacman -Qent


                                      Unique entries must therefore be optional:



                                      (pacman -Q; pacman -Qent) | sort | uniq -u 




                                      share












                                      Sometimes you have to work backwards... first find all non-optional depends, then cross-reference with full list, then use uniq.



                                      Find all installed



                                      pacman -Q


                                      Find all non-optional:



                                      pacman -Qent


                                      Unique entries must therefore be optional:



                                      (pacman -Q; pacman -Qent) | sort | uniq -u 





                                      share











                                      share


                                      share










                                      answered 2 mins ago









                                      kevinf

                                      27527




                                      27527



























                                           

                                          draft saved


                                          draft discarded















































                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f53080%2flist-optional-dependencies-with-pacman-on-arch-linux%23new-answer', 'question_page');

                                          );

                                          Post as a guest













































































                                          Popular posts from this blog

                                          How to check contact read email or not when send email to Individual?

                                          Displaying single band from multi-band raster using QGIS

                                          How many registers does an x86_64 CPU actually have?