82 lines
2.2 KiB
Plaintext
82 lines
2.2 KiB
Plaintext
|
#!/bin/py
|
||
|
|
||
|
|
||
|
###########
|
||
|
# IMPORTS #
|
||
|
###########
|
||
|
from os import path as ospath;
|
||
|
from os import system as ossystem;
|
||
|
import sys;
|
||
|
|
||
|
|
||
|
# get absolute path
|
||
|
path = ospath.dirname(ospath.realpath(__file__));
|
||
|
|
||
|
# help function
|
||
|
def showhelp():
|
||
|
print "apt-plus 1.0.0 (amd64)";
|
||
|
print "Usage: apt-plus command arguments";
|
||
|
print "Usage: apt-plus install|remove|purge pkg1 [pkg2 ...]";
|
||
|
print "Usage: apt-plus manifest /path/to/manifest.txt";
|
||
|
print;
|
||
|
print "apt-plus is a set of shell aliases using apt-get";
|
||
|
print "in order to automate basic routines";
|
||
|
print "installed packages are notices in the manifest file";
|
||
|
print "(default is ~/.x-migration)";
|
||
|
print;
|
||
|
print "List of commands:";
|
||
|
print " update - Upgrades packages and kernel and cleans after";
|
||
|
print " install - Installs packages and notice it in the manifest";
|
||
|
print " remove - Removes packages and notice it in the manifest";
|
||
|
print " purge - Purges packages and notice it in the manifest";
|
||
|
print " manifest - To set the manifest file";
|
||
|
print;
|
||
|
|
||
|
|
||
|
# If at least 1 arg given
|
||
|
if ( len(sys.argv) > 1 ):
|
||
|
|
||
|
command=sys.argv[1];
|
||
|
|
||
|
# if "updated"
|
||
|
if ( command == "update" ):
|
||
|
ossystem("sh %s/update;" % path);
|
||
|
elif ( command == "install" ):
|
||
|
# if package/s given
|
||
|
if ( len(sys.argv) < 3 ):
|
||
|
sys.exit("Missing argument : package names");
|
||
|
|
||
|
packages = " ".join(sys.argv[2:]);
|
||
|
|
||
|
ossystem( "python %s/install %s" % (path, packages) );
|
||
|
elif ( command == "remove" ):
|
||
|
# if package/s given
|
||
|
if ( len(sys.argv) < 3 ):
|
||
|
sys.exit("Missing argument : package names");
|
||
|
|
||
|
packages = " ".join(sys.argv[2:]);
|
||
|
ossystem( "python %s/remove %s" % (path, packages) );
|
||
|
elif ( command == "purge" ):
|
||
|
# if package/s given
|
||
|
if ( len(sys.argv) < 3 ):
|
||
|
sys.exit("Missing argument : package names");
|
||
|
|
||
|
packages = " ".join(sys.argv[2:]);
|
||
|
ossystem( "python %s/purge %s" % (path, packages) );
|
||
|
|
||
|
elif ( command == "manifest" ):
|
||
|
# if package/s given
|
||
|
if ( len(sys.argv) < 3 ):
|
||
|
sys.exit("Missing argument : manifest file");
|
||
|
elif ( not ospath.isfile(sys.argv[2]) ):
|
||
|
sys.exit("Given path isn't a file");
|
||
|
|
||
|
file = ospath.realpath(sys.argv[2]);
|
||
|
with open( ("%s/manifest" % path), "w") as f:
|
||
|
f.write(file);
|
||
|
else:
|
||
|
showhelp();
|
||
|
# if missing 1 arg
|
||
|
else:
|
||
|
showhelp();
|