2017-10-02 07:01:46 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import re;
|
|
|
|
from os import system as ossystem;
|
|
|
|
from os import path as ospath;
|
2017-10-06 12:29:09 +00:00
|
|
|
import sys;
|
|
|
|
|
|
|
|
from parser import Manifest, Package;
|
2017-10-02 07:01:46 +00:00
|
|
|
|
|
|
|
# [1] get absolute path
|
|
|
|
path = ospath.dirname(ospath.dirname(ospath.realpath(__file__)));
|
|
|
|
|
2017-10-06 12:29:09 +00:00
|
|
|
# [2] get group option (if set)
|
|
|
|
OPTGROUP = None;
|
|
|
|
if( len(sys.argv) > 2 and ( sys.argv[1] == "-g" or sys.argv[1] == "--group" ) ):
|
|
|
|
OPTGROUP = sys.argv[2];
|
2017-10-02 07:01:46 +00:00
|
|
|
|
2017-10-06 12:29:09 +00:00
|
|
|
# [3] search for manifest file
|
|
|
|
man = Manifest.Manifest();
|
|
|
|
|
|
|
|
# [4] If group selected
|
|
|
|
if( OPTGROUP != None ):
|
|
|
|
|
|
|
|
if( not man.hasGroup(OPTGROUP) ):
|
|
|
|
print "Unknown group";
|
|
|
|
exit(1);
|
|
|
|
|
|
|
|
print "[%s]" % OPTGROUP;
|
|
|
|
for pkg_name in man._pkg[OPTGROUP]:
|
|
|
|
pkg = man._pkg[OPTGROUP][pkg_name];
|
|
|
|
if( pkg.isInstalled() ):
|
|
|
|
print "\033[38;5;78m",;
|
|
|
|
elif( pkg.isRemoved() ):
|
|
|
|
print "\033[38;5;208m",;
|
|
|
|
elif( pkg.isPurged() ):
|
|
|
|
print "\033[38;5;161m",;
|
|
|
|
|
|
|
|
print "%s\033[0m" % pkg.serialize();
|
|
|
|
|
|
|
|
# [4] List all
|
|
|
|
else:
|
|
|
|
for group in man._pkg:
|
|
|
|
print "[%s]" % group;
|
|
|
|
for pkg_name in man._pkg[group]:
|
|
|
|
pkg = man._pkg[group][pkg_name];
|
|
|
|
if( pkg.isInstalled() ):
|
|
|
|
print "\033[38;5;78m",;
|
|
|
|
elif( pkg.isRemoved() ):
|
|
|
|
print "\033[38;5;208m",;
|
|
|
|
elif( pkg.isPurged() ):
|
|
|
|
print "\033[38;5;161m",;
|
|
|
|
|
|
|
|
print "%s\033[0m" % pkg.serialize();
|