type="choice", choices=("y", "n"))
parser.add_option("--debug", help="show debug output",
action="store_true", dest="debug")
+parser.add_option("--version", help="show version and exit",
+ action="store_true", dest="version")
parser.add_option("--ignore-default-opts",
action="store_true",
help="do not use the EBUILD_DEFAULT_OPTS environment variable")
opts, pargs = parser.parse_args(args=sys.argv[1:])
-if len(pargs) < 2:
- parser.error("missing required args")
-
os.environ["PORTAGE_CALLER"]="ebuild"
try:
import portage
from _emerge.Package import Package
from _emerge.RootConfig import RootConfig
+if opts.version:
+ print("Portage", portage.VERSION)
+ sys.exit(os.EX_OK)
+
+if len(pargs) < 2:
+ parser.error("missing required args")
+
if not opts.ignore_default_opts:
default_opts = portage.settings.get("EBUILD_DEFAULT_OPTS", "").split()
opts, pargs = parser.parse_args(default_opts + sys.argv[1:])