Example #1
0
    def create_file_repo(self, repo_props=EmptyDict, create_repo=False):

        if self.transport.publish_cache_contains(self.publisher):
            return

        if create_repo:
            try:
                # For compatibility reasons, assume that
                # repositories created using pkgsend
                # should be in version 3 format (single
                # publisher only).
                sr.repository_create(self.path, version=3)
            except sr.RepositoryExistsError:
                # Already exists, nothing to do.
                pass
            except (apx.ApiException, sr.RepositoryError) as e:
                raise TransactionOperationError(None, msg=str(e))

        try:
            repo = sr.Repository(properties=repo_props, root=self.path)
        except EnvironmentError as e:
            raise TransactionOperationError(
                None,
                msg=_("An error occurred while trying to "
                      "initialize the repository directory "
                      "structures:\n{0}").format(e))
        except cfg.ConfigError as e:
            raise TransactionRepositoryConfigError(str(e))
        except sr.RepositoryInvalidError as e:
            raise TransactionRepositoryInvalidError(str(e))
        except sr.RepositoryError as e:
            raise TransactionOperationError(None, msg=str(e))

        self.transport.publish_cache_repository(self.publisher, repo)
Example #2
0
    def setUp(self):
        """ Start two depots.
                    depot 1 gets foo and moo, depot 2 gets foo and bar
                    depot1 is mapped to publisher test1 (preferred)
                    depot2 is mapped to publisher test2 """

        # This test suite needs an actual depot.
        pkg5unittest.ManyDepotTestCase.setUp(self, ["os.org", "os.org"],
                                             start_depots=True)
        self.make_misc_files(self.misc_files)

        # Publish a set of packages to one repository.
        self.dpath1 = self.dcs[1].get_repodir()
        self.durl1 = self.dcs[1].get_depot_url()
        self.published = self.pkgsend_bulk(
            self.durl1, (self.amber10, self.amber20, self.bronze10,
                         self.bronze20, self.tree10, self.scheme10))

        # Ensure timestamps of all successive publications are greater.
        time.sleep(1)

        # Publish the same set to another repository (minus the tree
        # and scheme packages).
        self.dpath2 = self.dcs[2].get_repodir()
        self.durl2 = self.dcs[2].get_depot_url()
        self.published += self.pkgsend_bulk(
            self.durl2,
            (self.amber10, self.amber20, self.bronze10, self.bronze20))

        self.merge_dir = tempfile.mkdtemp(dir=self.test_root)
        repo.repository_create(self.merge_dir)
Example #3
0
        def setUp(self):
                """ Start two depots.
                    depot 1 gets foo and moo, depot 2 gets foo and bar
                    depot1 is mapped to publisher test1 (preferred)
                    depot2 is mapped to publisher test2 """

                # This test suite needs an actual depot.
                pkg5unittest.ManyDepotTestCase.setUp(self, ["os.org", "os.org"],
                    start_depots=True)
                self.make_misc_files(self.misc_files)

                # Publish a set of packages to one repository.
                self.dpath1 = self.dcs[1].get_repodir()
                self.durl1 = self.dcs[1].get_depot_url()
                self.published = self.pkgsend_bulk(self.durl1, (self.amber10,
                    self.amber20, self.bronze10, self.bronze20, self.tree10,
                    self.scheme10))

                # Ensure timestamps of all successive publications are greater.
                time.sleep(1)

                # Publish the same set to another repository (minus the tree
                # and scheme packages).
                self.dpath2 = self.dcs[2].get_repodir()
                self.durl2 = self.dcs[2].get_depot_url()
                self.published += self.pkgsend_bulk(self.durl2, (self.amber10,
                    self.amber20, self.bronze10, self.bronze20))

                self.merge_dir = tempfile.mkdtemp(dir=self.test_root)
                repo.repository_create(self.merge_dir)
Example #4
0
 def get_repo(self, auto_create=False):
         if auto_create:
                 try:
                         sr.repository_create(self.__dir)
                 except sr.RepositoryExistsError:
                         # Already exists, nothing to do.
                         pass
         return sr.Repository(cfgpathname=self.__cfg_file,
             root=self.__dir, writable_root=self.__writable_root)
Example #5
0
 def get_repo(self, auto_create=False):
         if auto_create:
                 try:
                         sr.repository_create(self.__dir)
                 except sr.RepositoryExistsError:
                         # Already exists, nothing to do.
                         pass
         return sr.Repository(cfgpathname=self.__cfg_file,
             root=self.__dir, writable_root=self.__writable_root)
Example #6
0
        def create_file_repo(self, repo_props=EmptyDict, create_repo=False):

                if self.transport.publish_cache_contains(self.publisher):
                        return

                if create_repo:
                        try:
                                # For compatibility reasons, assume that
                                # repositories created using pkgsend
                                # should be in version 3 format (single
                                # publisher only).
                                sr.repository_create(self.path, version=3)
                        except sr.RepositoryExistsError:
                                # Already exists, nothing to do.
                                pass
                        except (apx.ApiException, sr.RepositoryError), e:
                                raise TransactionOperationError(None,
                                    msg=str(e))
Example #7
0
                        dest = ""
                elif dest:
                        if not os.path.isabs(dest):
                                dest = os.path.join(pkg_root, dest)
                gconf[log_type_map[log_type]["param"]] = dest

        cherrypy.config.update(gconf)

        # Now that our logging, etc. has been setup, it's safe to perform any
        # remaining preparation.

        # Initialize repository state.
        if not readonly:
                # Not readonly, so assume a new repository should be created.
                try:
                        sr.repository_create(inst_root, properties=repo_props)
                except sr.RepositoryExistsError:
                        # Already exists, nothing to do.
                        pass
                except (api_errors.ApiException, sr.RepositoryError) as _e:
                        emsg("pkg.depotd: {0}".format(_e))
                        sys.exit(1)

        try:
                sort_file_max_size = dconf.get_property("pkg",
                    "sort_file_max_size")

                repo = sr.Repository(cfgpathname=repo_config_file,
                    log_obj=cherrypy, mirror=mirror, properties=repo_props,
                    read_only=readonly, root=inst_root,
                    sort_file_max_size=sort_file_max_size,
Example #8
0
                        dest = ""
                elif dest:
                        if not os.path.isabs(dest):
                                dest = os.path.join(pkg_root, dest)
                gconf[log_type_map[log_type]["param"]] = dest

        cherrypy.config.update(gconf)

        # Now that our logging, etc. has been setup, it's safe to perform any
        # remaining preparation.

        # Initialize repository state.
        if not readonly:
                # Not readonly, so assume a new repository should be created.
                try:
                        sr.repository_create(inst_root, properties=repo_props)
                except sr.RepositoryExistsError:
                        # Already exists, nothing to do.
                        pass
                except (api_errors.ApiException, sr.RepositoryError), _e:
                        emsg("pkg.depotd: %s" % _e)
                        sys.exit(1)

        try:
                sort_file_max_size = dconf.get_property("pkg",
                    "sort_file_max_size")

                repo = sr.Repository(cfgpathname=repo_config_file,
                    log_obj=cherrypy, mirror=mirror, properties=repo_props,
                    read_only=readonly, root=inst_root,
                    sort_file_max_size=sort_file_max_size,