예제 #1
0
        def __init__(self, image_directory, application_path, check_all,
            check_cache):
                global_settings.client_name = nongui_misc.get_um_name()
                self.api_lock = nrlock.NRLock()
                self.image_dir_arg = image_directory
                self.exact_match = True
                if self.image_dir_arg == None:
                        self.image_dir_arg, self.exact_match =  \
                            api.get_default_image_root()
                if not self.exact_match:
                        logger.debug("Unable to get image directory")
                        sys.exit(enumerations.UPDATES_UNDETERMINED)
                        
                self.application_path = application_path
                self.check_all = check_all
                self.check_cache_only = check_cache
                self.application_dir = \
                    os.environ.get("PACKAGE_MANAGER_ROOT", "/")
                misc.setlocale(locale.LC_ALL, "")

                if global_settings.verbose:
                        pe = printengine.LoggingPrintEngine(
                            logger, logging.DEBUG)
                        self.progress_tracker = \
                            progress.CommandLineProgressTracker(print_engine=pe)
                else:
                        self.progress_tracker = progress.NullProgressTracker()
                self.api_obj = None
                self.return_status = enumerations.UPDATES_UNDETERMINED
                self.pylintstub = None

                # Check Updates - by default check all
                self.api_obj = self.__get_api_obj()
                if self.api_obj == None:
                        self.return_status = enumerations.UPDATES_UNDETERMINED
                        return

                if self.check_all:
                        self.__check_for_updates()
                elif self.check_cache_only:
                        self.__check_for_updates_cache_only()
예제 #2
0
    def __init__(self, image_directory, application_path):
        global_settings.client_name = gui_misc.get_um_name()
        self.api_lock = nrlock.NRLock()
        self.image_dir_arg = image_directory
        self.exact_match = True
        if self.image_dir_arg == None:
            self.image_dir_arg, self.exact_match = api.get_default_image_root()
        if not self.exact_match:
            if debug:
                print >>sys.stderr, ("Unable to get the image directory")
            sys.exit(enumerations.UPDATES_UNDETERMINED)
        self.application_path = application_path
        self.gconf = pmgconf.PMGConf()
        try:
            self.application_dir = os.environ["PACKAGE_MANAGER_ROOT"]
        except KeyError:
            self.application_dir = "/"
        misc.setlocale(locale.LC_ALL, "")
        for module in (gettext, gtk.glade):
            module.bindtextdomain("pkg", os.path.join(self.application_dir, "usr/share/locale"))
            module.textdomain("pkg")
        gui_misc.init_for_help(self.application_dir)

        self.icon_theme = gtk.icon_theme_get_default()
        pkg_icon_location = os.path.join(self.application_dir, PKG_ICON_LOCATION)
        self.icon_theme.append_search_path(pkg_icon_location)
        icon_location = os.path.join(self.application_dir, ICON_LOCATION)
        self.icon_theme.append_search_path(icon_location)
        self.progress_tracker = progress.NullProgressTracker()
        self.api_obj = None
        self.installupdate = None
        self.return_status = enumerations.UPDATES_UNDETERMINED
        self.pylintstub = None

        gui_misc.setup_logging()
        gobject.idle_add(self.__do_image_update)
예제 #3
0
파일: pkgdep.py 프로젝트: sunsparc64/pkg5
def resolve(args, img_dir):
    """Take a list of manifests and resolve any file dependencies, first
        against the other published manifests and then against what is installed
        on the machine."""
    out_dir = None
    echo_manifest = False
    output_to_screen = False
    suffix = None
    verbose = False
    use_system_to_resolve = True
    constraint_files = []
    extra_external_info = False
    try:
        opts, pargs = getopt.getopt(args, "d:e:Emos:Sv")
    except getopt.GetoptError as e:
        usage(_("illegal global option -- {0}").format(e.opt))
    for opt, arg in opts:
        if opt == "-d":
            out_dir = arg
        elif opt == "-e":
            constraint_files.append(arg)
        elif opt == "-E":
            extra_external_info = True
        elif opt == "-m":
            echo_manifest = True
        elif opt == "-o":
            output_to_screen = True
        elif opt == "-s":
            suffix = arg
        elif opt == "-S":
            use_system_to_resolve = False
        elif opt == "-v":
            verbose = True

    if (out_dir or suffix) and output_to_screen:
        usage(_("-o cannot be used with -d or -s"))

    manifest_paths = [os.path.abspath(fp) for fp in pargs]

    for manifest in manifest_paths:
        if not os.path.isfile(manifest):
            usage(_("The manifest file {0} could not be found.").format(
                manifest),
                  retcode=2)

    if out_dir:
        out_dir = os.path.abspath(out_dir)
        if not os.path.isdir(out_dir):
            usage(_("The output directory {0} is not a directory.").format(
                out_dir),
                  retcode=2)

    provided_image_dir = True
    pkg_image_used = False
    if img_dir == None:
        orig_cwd = None
        try:
            orig_cwd = os.getcwd()
        except OSError:
            # May be unreadable by user or have other problem.
            pass

        img_dir, provided_image_dir = api.get_default_image_root(
            orig_cwd=orig_cwd)
        if os.environ.get("PKG_IMAGE"):
            # It's assumed that this has been checked by the above
            # function call and hasn't been removed from the
            # environment.
            pkg_image_used = True

    if not img_dir:
        error(
            _("Could not find image.  Use the -R option or set "
              "$PKG_IMAGE to the\nlocation of an image."))
        return 1

    system_patterns = misc.EmptyI
    if constraint_files:
        system_patterns = []
        for f in constraint_files:
            try:
                with open(f, "rb") as fh:
                    for l in fh:
                        l = l.strip()
                        if l and not l.startswith("#"):
                            system_patterns.append(l)
            except EnvironmentError as e:
                if e.errno == errno.ENOENT:
                    error("{0}: '{1}'".format(e.args[1], e.filename),
                          cmd="resolve")
                    return 1
                raise api_errors._convert_error(e)
        if not system_patterns:
            error(
                _("External package list files were provided but "
                  "did not contain any fmri patterns."))
            return 1
    elif use_system_to_resolve:
        system_patterns = ["*"]

    # Becuase building an ImageInterface permanently changes the cwd for
    # python, it's necessary to do this step after resolving the paths to
    # the manifests.
    try:
        api_inst = api.ImageInterface(img_dir,
                                      CLIENT_API_VERSION,
                                      progress.QuietProgressTracker(),
                                      None,
                                      PKG_CLIENT_NAME,
                                      exact_match=provided_image_dir)
    except api_errors.ImageNotFoundException as e:
        if e.user_specified:
            if pkg_image_used:
                error(
                    _("No image rooted at '{0}' "
                      "(set by $PKG_IMAGE)").format(e.user_dir))
            else:
                error(_("No image rooted at '{0}'").format(e.user_dir))
        else:
            error(_("No image found."))
        return 1
    except api_errors.PermissionsException as e:
        error(e)
        return 1
    except api_errors.ImageFormatUpdateNeeded as e:
        # This should be a very rare error case.
        format_update_error(e)
        return 1

    try:
        pkg_deps, errs, unused_fmris, external_deps = \
            dependencies.resolve_deps(manifest_paths, api_inst,
                system_patterns, prune_attrs=not verbose)
    except (actions.MalformedActionError, actions.UnknownActionError) as e:
        error(
            _("Could not parse one or more manifests because of "
              "the following line:\n{0}").format(e.actionstr))
        return 1
    except dependencies.DependencyError as e:
        error(e)
        return 1
    except api_errors.ApiException as e:
        error(e)
        return 1
    ret_code = 0

    if output_to_screen:
        ret_code = pkgdeps_to_screen(pkg_deps, manifest_paths, echo_manifest)
    elif out_dir:
        ret_code = pkgdeps_to_dir(pkg_deps, manifest_paths, out_dir, suffix,
                                  echo_manifest)
    else:
        ret_code = pkgdeps_in_place(pkg_deps, manifest_paths, suffix,
                                    echo_manifest)

    if extra_external_info:
        if constraint_files and unused_fmris:
            msg(
                _("\nThe following fmris matched a pattern in a "
                  "constraint file but were not used in\ndependency "
                  "resolution:"))
            for pfmri in sorted(unused_fmris):
                msg("\t{0}".format(pfmri))
        if not constraint_files and external_deps:
            msg(_("\nThe following fmris had dependencies resolve "
                  "to them:"))
            for pfmri in sorted(external_deps):
                msg("\t{0}".format(pfmri))

    for e in errs:
        if ret_code == 0:
            ret_code = 1
        emsg(e)
    return ret_code
예제 #4
0
파일: pkgdep.py 프로젝트: aszeszo/test
                out_dir = os.path.abspath(out_dir)
                if not os.path.isdir(out_dir):
                        usage(_("The output directory %s is not a directory.") %
                            out_dir, retcode=2)

        provided_image_dir = True
        pkg_image_used = False
        if img_dir == None:
                orig_cwd = None
                try:
                        orig_cwd = os.getcwd()
                except OSError:
                        # May be unreadable by user or have other problem.
                        pass

                img_dir, provided_image_dir = api.get_default_image_root(
                    orig_cwd=orig_cwd)
                if os.environ.get("PKG_IMAGE"):
                        # It's assumed that this has been checked by the above
                        # function call and hasn't been removed from the
                        # environment.
                        pkg_image_used = True

        if not img_dir:
                error(_("Could not find image.  Use the -R option or set "
                    "$PKG_IMAGE to the\nlocation of an image."))
                return 1

        system_patterns = misc.EmptyI
        if constraint_files:
                system_patterns = []
                for f in constraint_files: