2017-05-18 13:15:44 +00:00
|
|
|
#!/usr/bin/env python
|
2017-01-01 18:17:29 +00:00
|
|
|
|
|
|
|
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-01-01 18:17:29 +00:00
|
|
|
|
|
|
|
# [1] get absolute path
|
2017-05-18 13:15:44 +00:00
|
|
|
path = ospath.dirname(ospath.dirname(ospath.realpath(__file__)));
|
2017-01-01 18:17:29 +00:00
|
|
|
|
2017-10-06 12:29:09 +00:00
|
|
|
|
|
|
|
# [2] get group option (if set)
|
|
|
|
OPTGROUP = None;
|
|
|
|
ARGS = sys.argv;
|
|
|
|
if( len(sys.argv) > 2 and ( sys.argv[1] == "-g" or sys.argv[1] == "--group" ) ):
|
|
|
|
OPTGROUP = sys.argv[2];
|
|
|
|
ARGS = ARGS[0:1] + ARGS[3:];
|
|
|
|
|
|
|
|
# [3] get packages
|
|
|
|
packages = ARGS[1:];
|
2017-01-01 18:17:29 +00:00
|
|
|
|
|
|
|
# [3] search for manifest file
|
2017-10-06 12:29:09 +00:00
|
|
|
man = Manifest.Manifest();
|
|
|
|
|
2017-01-01 18:17:29 +00:00
|
|
|
|
|
|
|
# [5] Install packages
|
|
|
|
installed = [];
|
|
|
|
for pkg in packages:
|
|
|
|
print "\033[38;5;208m[install](%d/%d) %s\033[0m" % (packages.index(pkg)+1, len(packages), pkg);
|
|
|
|
exitcode = ossystem("sudo apt-get install %s" % pkg);
|
2017-05-18 13:15:44 +00:00
|
|
|
|
2017-01-01 18:17:29 +00:00
|
|
|
# if all ran successfully
|
|
|
|
if ( exitcode == 0 ):
|
|
|
|
print "\033[38;5;78msuccess\033[0m";
|
|
|
|
installed.append( pkg );
|
|
|
|
else:
|
|
|
|
print "\033[38;5;161merror\033[0m";
|
|
|
|
|
|
|
|
|
|
|
|
# [6] update manifest
|
|
|
|
for pkg in installed:
|
|
|
|
print "\033[38;5;39m[notifying](%d/%d) %s\033[0m" % (installed.index(pkg)+1, len(installed), pkg);
|
|
|
|
|
2017-10-06 12:29:09 +00:00
|
|
|
# if existing package update it
|
|
|
|
if( man.hasPackage(pkg) ):
|
|
|
|
pkgReg = man.getPackage(pkg);
|
|
|
|
pkgReg.install();
|
|
|
|
if( OPTGROUP != None ):
|
|
|
|
man.mvPackage(pkg, OPTGROUP);
|
|
|
|
|
|
|
|
# else create package
|
2017-01-01 18:17:29 +00:00
|
|
|
else:
|
2017-10-06 12:29:09 +00:00
|
|
|
pkgNew = Package.Package(pkg, 'x');
|
|
|
|
if( OPTGROUP != None ):
|
|
|
|
man.addPackage(pkgNew, OPTGROUP);
|
|
|
|
else:
|
|
|
|
man.addPackage(pkgNew);
|
2017-01-01 18:17:29 +00:00
|
|
|
|
2017-10-06 12:29:09 +00:00
|
|
|
man.save();
|