Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 121 lines (98 sloc) 3.84 KB
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of unmaskit
# Copyright (c) 2010 - Fabiano Francesconi
# encomiabile.it (c) 2010 - www.encomiabile.it
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.0.1'
import sys
import os
import portage
from optparse import OptionParser
import commands
import libs.eutils as eutils
warn = sys.stderr
basename = "unmaskit-"
portage_path = "/etc/portage"
config = {
'package_keywords_fname' : None,
'package_use_fname' : None,
'package_unmask_fname' : None,
'package_to_unmask' : None,
'source_file' : None,
'destination_file' : None,
'verbose' : False,
'ask' : False
}
def _is_entry_a_dir(entry):
return os.path.isdir(entry)
def get_portage_conf_file():
"""
This gather informations regarding portage configuration files stored in
/etc/portage as they can be files or directories.
Example:
If package.keywords is a directory, None is left in the config dict;
if it's a file, then the package_keywords_fname is the file itself
"""
if not _is_entry_a_dir("%s/package.keywords" % portage_path):
config['package_keywords_fname'] = "%s/package.keywords" % portage_path
if not _is_entry_a_dir("%s/package.use" % portage_path):
config['package_use_fname'] = "%s/package.use" % portage_path
if not _is_entry_a_dir("%s/package.unmask" % portage_path):
config['package_unmask_fname'] = "%s/package.unmask" % portage_path
def main():
usage = "usage: %prog [options] package-name "
version = "%%prog %s" % __version__
parser = OptionParser(
usage=usage,
version=version,
description="unmaskit unmasks dependencies for you")
# parser options
parser.add_option("-n", "--no-version", action="store_true",
dest="no_version", default=False,
help="unmask always the latest version")
parser.add_option("-p", "--pretend", action="store_true",
dest="pretend", default=False,
help="print what would be done")
parser.add_option("-q", "--quiet", action="store_true",
dest="quiet", default=False,
help="suppress all the output")
parser.add_option("-a", "--ask", action="store_true",
dest="ask", default=False,
help="ask whether to proceed with the action or abort")
(options, args) = parser.parse_args()
config['no_version'] = options.no_version
config['pretend'] = options.pretend
config['quiet'] = options.quiet
config['ask'] = options.ask
# print "Using repositories: %s %s" % (portage.settings['PORTDIR'], portage.settings['PORTDIR_OVERLAY'])
get_portage_conf_file()
# check args and store their values
if (len(args)!=1):
parser.error("incorrect number of arguments. See -h for usage help.")
else:
pname = config['package_to_unmask'] = args[0]
# os.execve('/bin/sh', ["/bin/sh", '-c', "emerge -pe %s" % config['package_to_unmask']], {})
# x = commands.getoutput('emerge -pe %s' % config['package_to_unmask'])
try:
aname = eutils.expand_package_name(pname)
except:
print >> warn, "Invalid package name '%s'" % pname
sys.exit(1)
print aname
print eutils.get_version_from_atom(aname)
# print eutils.get_package_name_from_atom(aname)
# print eutils.get_atom_deps(aname)
print "status : ", eutils.get_package_status(aname)
# print eutils.is_package_keyworded(aname)
if __name__ == '__main__':
sys.exit(main())
Something went wrong with that request. Please try again.