Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
List packages with available USE flags for package.use
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
zhak
n00b
n00b


Joined: 04 May 2015
Posts: 21

PostPosted: Thu Sep 24, 2015 5:36 pm    Post subject: List packages with available USE flags for package.use Reply with quote

Hi guys,

I wonder how is it possible to list installed packages in the format to be used in package.use, like

Code:
category/name use use use use use
category/name use use use
. . .


I tried
Code:
eix -I#
and it gives category/name output, but cannot figure out how to append all available use flags to that line

Any advices highly appreciated
Back to top
View user's profile Send private message
kikko
Apprentice
Apprentice


Joined: 29 Apr 2014
Posts: 260
Location: Milan, IT

PostPosted: Thu Sep 24, 2015 5:45 pm    Post subject: Reply with quote

Hi zhak
try with
Code:
qlist -IcU

Let me know if this is satisfying :D
Back to top
View user's profile Send private message
zhak
n00b
n00b


Joined: 04 May 2015
Posts: 21

PostPosted: Thu Sep 24, 2015 8:36 pm    Post subject: Reply with quote

Well, not exactly.

I found quse command which says to list all packages using some flag. So I created a python script which takes output of eix -I# and quse -a and merges together. I'm still learning python, so implementation may be ugly:

Code:

#!/usr/bin/env python

import subprocess

p = subprocess.Popen(["quse", "-aC"], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
out, err = p.communicate()
all_packages = out.split('\n')

p = subprocess.Popen(["eix", "-I#"], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
out, err = p.communicate()
installed_packages = out.split('\n')

for i in range(len(installed_packages)):
    for pkg in all_packages:
        package = installed_packages[i] + '/'
        if package in pkg:
            use_flags_start = pkg.index(' ')
            installed_packages[i] += pkg[use_flags_start:]
            all_packages.remove(pkg)
            break

print('\n'.join(installed_packages))


but this script is yet to be improved: need to check installed package version because quse returns multiple versions of a package.

What is more important, either I'm doing smth. wrong, or quse output is not trustworthy.

for example, from quick overview of its results, quse --all doesn't return sys-devel/gcc package
for many packages use flags set returned by quse differs from what is returned by equery uses {package}
egg: equery uses sys-apps/sed returns acl, nls, static while in quse output there're additional selinux flag listed. and this is only one of many examples
Back to top
View user's profile Send private message
zhak
n00b
n00b


Joined: 04 May 2015
Posts: 21

PostPosted: Fri Sep 25, 2015 3:34 pm    Post subject: Reply with quote

Alright, I found the solution which satisfies me.

The below script outputs all installed packages with all available use flags as returned by equery u in package.use format:
Code:
#
# app-admin
#
app-admin/eselect -doc -emacs -vim-syntax
app-admin/logrotate +acl +cron
app-admin/syslog-ng -ampq -caps -dbi -geoip +ipv6 -json -mongodb -pacct -redis -smtp -spoof-source +ssl -systemd +tcpd
#
# app-arch
#
app-arch/bzip2 -static -static-libs
app-arch/gzip -pic -static
. . .


python 3 script:
Code:

#!/usr/bin/env python

import subprocess
p = subprocess.Popen(["eix", "-I#"], \
    stdout = subprocess.PIPE, stderr = subprocess.PIPE)
out, err = p.communicate()

installed_packages = out.decode("utf8").split("\n")

current_category = ""

i = 0
while i < len(installed_packages) - 1:
    category, name = installed_packages[i].split("/")
    p = subprocess.Popen(["equery", "u", installed_packages[i]], \
        stdout = subprocess.PIPE, stderr = subprocess.PIPE)
    out, err = p.communicate()
    s = out.decode("utf8")
    if len(s) != 0:
        if current_category != category:
            installed_packages.insert(i, "#\n# %s\n#" % category)
            print(installed_packages[i])
            i += 1
            current_category = category
        s = s.replace("+", "").replace("\n", " ").strip()
        installed_packages[i] += ' ' + s
        print(installed_packages[i])
    i += 1


If USE="" in /etc/portage/make.conf, then this script outputs all installed packages with currently installed flags. Otherwise it outputs flags based on global USE setting

The script works slowly and probably it's not the best approach, but it works. The reason I needed it is because I prefer USE="-*" globally and configure per-package use flags. Once minimal system is installed, world needs to be rebuilt and use flags changed for pre-installed packages. it simplifies package.use editing
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum