def _prepare_pkg_base()

in mysqlx-connector-python/cpydist/bdist_solaris.py [0:0]


    def _prepare_pkg_base(self, template_name, data_dir, root=""):
        """Create and populate the src base directory."""
        self.log.info("-> _prepare_pkg_base()")
        self.log.info("  template_name: %s", template_name)
        self.log.info("  data_dir: %s", data_dir)
        self.log.info("  root: %s", root)

        # copy and create necessary files
        sun_dist_name = template_name.format(self.name, self.version)
        self.sun_pkg_name = f"{sun_dist_name}.pkg"
        self.log.info("  sun_pkg_name: %s", self.sun_pkg_name)

        sun_path = os.path.join(root, self.dstroot)
        self.log.info("  sun_path: %s", sun_path)
        cwd = os.path.join(os.getcwd())
        self.log.info("Current directory: %s", cwd)

        copy_file_src_dst = []

        # No special folder for GPL or commercial. Files inside the directory
        # will determine what it is.
        data_path = os.path.join(
            sun_path,
            "usr",
            "share",
            template_name.format(self.name, self.version),
        )
        self.mkpath(data_path)

        lic = "(GPL)"
        sun_pkg_info = os.path.join(sun_path, "pkginfo")
        self.log.info("sun_pkg_info path: %s", sun_pkg_info)
        with open(sun_pkg_info, "w") as f_pkg_info:
            f_pkg_info.write(
                PKGINFO.format(
                    ver=self.version,
                    lic=lic,
                    pkg=self.name,
                    tstamp=time.ctime(),
                )
            )
            f_pkg_info.close()

        data_path = os.path.join(
            sun_path,
            "usr",
            "share",
            template_name.format(self.name, self.version),
        )
        copy_file_src_dst += [
            (
                os.path.join(cwd, "README.txt"),
                os.path.join(data_path, "README.txt"),
            ),
            (
                os.path.join(cwd, "LICENSE.txt"),
                os.path.join(data_path, "LICENSE.txt"),
            ),
            (
                os.path.join(cwd, "CHANGES.txt"),
                os.path.join(data_path, "CHANGES.txt"),
            ),
            (
                os.path.join(cwd, "docs", "INFO_SRC"),
                os.path.join(data_path, "INFO_SRC"),
            ),
            (
                os.path.join(cwd, "docs", "INFO_BIN"),
                os.path.join(data_path, "INFO_BIN"),
            ),
            (
                os.path.join(cwd, "README.rst"),
                os.path.join(data_path, "README.rst"),
            ),
            (
                os.path.join(cwd, "CONTRIBUTING.md"),
                os.path.join(data_path, "CONTRIBUTING.md"),
            ),
            (
                os.path.join(cwd, "SECURITY.md"),
                os.path.join(data_path, "SECURITY.md"),
            ),
        ]

        for src, dst in copy_file_src_dst:
            shutil.copyfile(src, dst)