コード例 #1
0
ファイル: release.py プロジェクト: Jayuda/nuxeo
    def package(self, old_archive, new_name, failonerror=True):
        """Repackage a ZIP following the rules:
            - have a parent directory with the same name as the archive name
            - set executable bit on scripts in bin/
            - activate the setup wizard

        If 'failonerror', raise an ExitException in case of missing file."""
        if not os.path.isfile(old_archive):
            if failonerror:
                raise ExitException(1, "Could not find %s" % old_archive)
            else:
                log("[WARN] Could not find %s" % old_archive, sys.stderr)
                return
        new_archive = os.path.join(self.archive_dir, new_name + ".zip")
        extract_zip(old_archive, os.path.join(self.tmpdir, new_name))
        log("Packaging %s ..." % new_archive)
        cwd = os.getcwd()
        os.chdir(os.path.join(self.tmpdir, new_name))
        ls = os.listdir(os.curdir)
        if len(ls) == 1:
            if ls[0] != new_name:
                shutil.move(ls[0], new_name)
        else:
            os.mkdir(new_name)
            for file in ls:
                shutil.move(file, os.path.join(new_name, file))

        files = os.listdir(os.path.join(new_name, "bin"))
        for filename in (fnmatch.filter(files, "*ctl") +
                        fnmatch.filter(files, "*.sh") +
                        fnmatch.filter(files, "*.command")):
            os.chmod(os.path.join(new_name, "bin", filename), 0744)
        with open(os.path.join(new_name, "bin", "nuxeo.conf"), "a") as f:
            f.write("nuxeo.wizard.done=false\n")
        make_zip(os.path.join(self.archive_dir, new_name + ".zip"),
                            os.getcwd(), new_name)
        os.chdir(cwd)
        # Cleanup temporary directory
        shutil.rmtree(os.path.join(self.tmpdir, new_name))
コード例 #2
0
ファイル: release.py プロジェクト: papeisdigitais/nuxeo
    def package_all(self, version=None):
        """Repackage files to be uploaded.

        'version': version to package; defaults to the current tag (without the
        'release-' prefix."""
        self.archive_dir = os.path.abspath(os.path.join(self.repo.basedir,
                                                   os.pardir, "archives"))
        if os.path.isdir(self.archive_dir):
            shutil.rmtree(self.archive_dir)
        os.mkdir(self.archive_dir)
        self.tmpdir = tempfile.mkdtemp()

        if version is None:
            version = self.tag

        # Tomcat and JBoss packages
        for old, new in PKG_RENAMINGS.items():
            self.package(old % version, new % version)
        # Tomcat SDK packages
        for old, new in PKG_RENAMINGS_OPTIONALS.items():
            self.package(old % version, new % version, False)

        # Online (aka light) Tomcat package
        offline_name = "nuxeo-cap-%s-tomcat" % version
        extract_zip(os.path.join(self.archive_dir, offline_name + ".zip"),
                    self.tmpdir)
        # Generate online package if packages.xml exists
        if os.path.isfile(os.path.join(self.tmpdir, offline_name,
                        "setupWizardDownloads", "packages.xml")):
            online_name = "nuxeo-cap-%s-tomcat-online" % version
            shutil.move(os.path.join(self.tmpdir, offline_name,
                                       "setupWizardDownloads", "packages.xml"),
                      os.path.join(self.archive_dir, "packages.xml"))
            # Remove Marketplace packages
            shutil.rmtree(os.path.join(self.tmpdir, offline_name,
                                       "setupWizardDownloads"))
            shutil.move(os.path.join(self.tmpdir, offline_name),
                      os.path.join(self.tmpdir, online_name))
            make_zip(os.path.join(self.archive_dir, online_name + ".zip"),
                                os.path.join(self.tmpdir, online_name),
                                online_name)

            # Marketplace packages
            archive_mp_dir = os.path.join(self.archive_dir, "mp")
            if not os.path.isdir(archive_mp_dir):
                os.mkdir(archive_mp_dir)
            # Copy and rename MP to archive directory
            for old, new in MP_RENAMINGS.items():
                shutil.copy2(old % version,
                             os.path.join(archive_mp_dir, new % version))
            log("Checking packages integrity...")
            for package in os.listdir(archive_mp_dir):
                m = hashlib.md5()
                with open(os.path.join(archive_mp_dir, package), "rb") as f:
                    m.update(f.read())
                package_md5 = m.hexdigest()
                found_package = False
                found_package_md5 = False
                for line in open(os.path.join(self.archive_dir, "packages.xml")):
                    if package in line:
                        found_package = True
                    if package_md5 in line:
                        found_package_md5 = True
                    if found_package and found_package_md5:
                        break
                if not found_package:
                    log("[ERROR] Could not find %s in packages.xml" % package,
                    sys.stderr)
                if not found_package_md5:
                    log("[ERROR] %s MD5 did not match packages.xml information"
                        % package, sys.stderr)
            log("Done.")
        self.package_sources(version)
        shutil.rmtree(self.tmpdir)