Exemple #1
0
 def get_app_version_only(self):
     return commonutils.get_app_version_only(".")
    def update_version(self, new_version):
        """Updates the version number that is used when generating the .msi.

        Updates the Opticks-Version.wxi file to have the new version number
        and also updates the product and upgrades codes for the 32-bit and
        64-bit version of the .msi package.

        @param new_version: The version in the format of major.minor.
        For the MSI, the version # provided is used for display purposes.  The internal
        MSI version # will always be 1.0.0 since the GUIDs will be updated.
        For the Solaris package, the version # provided will be the actual
        version # of the generated package.
        @type new_version: L{str}

        @rtype: L{int}

        """
        msi_version = "1.0.0"
        if new_version == "current":
            self.require_code_dir()
            sys.path.append(self.opticks_code_dir)
            import commonutils
            new_version = \
                commonutils.get_app_version_only(self.opticks_code_dir)
            if self.verbosity >= 1:
                print "Detected application version as %s" % (new_version)

        if self.verbosity > 1:
            print "Updating MSI version #..."
        if self.verbosity > 1:
            print "Setting MSI Display Version # to %s" % (new_version)
        if self.verbosity > 1:
            print "Setting MSI Internal Version # to %s" % (msi_version)
        version_file = open("Opticks-Version.wxi", "r")
        version_file_contents = version_file.read()
        version_file.close()

        version_file_contents = \
            re.sub(r'(PublicVersionNumber\s*?\=\s*?").*?(")',
            r"\g<1>%s\g<2>" % (new_version), version_file_contents)
        version_file_contents = \
            re.sub(r'(InternalVersionNumber\s*?\=\s*?").*?(")',
            r"\g<1>%s\g<2>" % (msi_version), version_file_contents)
        guid_matcher = \
            re.compile('<\?\s*?define\s*?\S+?Guid\s*?\=\s*?"(?P<guid>.*?)"')
        current_pos = 0
        if self.verbosity > 1:
            print "Updating GUID's..."
        while True:
            match_obj = guid_matcher.search(version_file_contents, current_pos)
            if match_obj:
                new_uuid = str(uuid.uuid4())
                version_file_contents = \
                    version_file_contents[:match_obj.start(1)] + \
                    new_uuid + version_file_contents[match_obj.end(1):]
                current_pos = match_obj.start(1)
            else:
                break
        if self.verbosity > 1:
            print "Done updating GUIDs"

        version_file = open("Opticks-Version.wxi", "w")
        version_file.write(version_file_contents)
        version_file.close()

        if self.verbosity >= 1:
            print "Opticks-Version.wxi has been updated to reference "\
                "the new version. You must re-run this script with "\
                "--32 or --64 to generate a .msi that uses the "\
                "new version number.  Please commit the "\
                "Opticks-Version.wxi change to Subversion."
        if self.verbosity > 1:
            print "Done updating MSI version #"

        if self.verbosity > 1:
            print "Updating pkg version #..."
        pkginfo_file = open("pkginfo", "r")
        pkginfo = pkginfo_file.read()
        pkginfo_file.close()
        pkginfo = re.sub(r"VERSION=.+?\n", "VERSION=%s\n" % (new_version),
            pkginfo)
        pkginfo_file = open("pkginfo", "w")
        pkginfo_file.write(pkginfo)
        pkginfo_file.close()
        if self.verbosity >= 1:
            print "pkginfo has been updated to reference the new version. "\
            "You must re-run this script to generate a Solaris Package "\
            "that uses the new version number.  Please commit the pkginfo "\
            "change to Subversion."
        if self.verbosity > 1:
            print "Done updating pkg version #"
    def generate_installer(self):
        """Generate the Opticks Linux package to the PackageOutput folder.
        @rtype: L{int}

        """
        if self.verbosity > 1:
            print "Cleaning out old PackageOutput temporary directory..."
        self.clean()
        if self.verbosity > 1:
            print "Generating Linux package..."
        if self.opticks_code_dir is None:
            if os.environ.has_key("OPTICKS_CODE_DIR"):
                self.opticks_code_dir = os.environ["OPTICKS_CODE_DIR"]
            else:
                raise ScriptException("The path to the Opticks source "\
                    "code was not provided, see -c or --code-dir")

        if not(os.path.exists(self.opticks_code_dir)):
            raise ScriptException("The path to the Opticks source "\
                "code does not exist %s, see -c or "\
                "--code-dir" % (self.opticks_code_dir))

        if self.opticks_dependencies_dir is None:
            if os.environ.has_key("OPTICKSDEPENDENCIES"):
                self.opticks_dependencies_dir = \
                    os.environ["OPTICKSDEPENDENCIES"]
            else:
                raise ScriptException("The path to the Opticks "\
                    "dependencies was not provided, see -d or "\
                    "--dependencies")

        if not(os.path.exists(self.opticks_dependencies_dir)):
            raise ScriptException("The path to the Opticks "\
                "dependencies does not exist %s, see -d or "\
                "--dependencies" % (self.opticks_dependencies_dir))

        if self.opticks_release_dir is None:
            raise ScriptException("The path to the Opticks release"
                "directory was not provided, see -r or --release-dir")

        if not(os.path.exists(self.opticks_release_dir)):
            raise ScriptException("The path to the Opticks release"\
                "directory does not exist %s, see -r or "\
                "--release-dir" % (self.opticks_release_dir))

        if self.verbosity > 1:
            print "Creating debian format of package"

        sys.path.append(self.opticks_code_dir)
        import commonutils
        version = commonutils.get_app_version_only(self.opticks_code_dir)
        version += "-%i" % self.package_version
        self.get_help() # unpack the Help files
        scons_args = list()
        scons_args.append('scons')
        scons_args.append('CODEDIR=%s' % self.opticks_code_dir)
        scons_args.append('BUILDDIR=%s' % os.path.join(self.opticks_code_dir,"Build"))
        scons_args.append('OPTICKSDEPENDENCIES=%s' % self.opticks_dependencies_dir)
        scons_args.append('VERSION=%s' % version)
        scons_args.append('OUTPUT_DIR=%s' % self.output_dir)

        if self.verbosity > 1:
            print "Execute:"," ".join(scons_args)
        retcode = execute_process(scons_args)
        if retcode != 0:
            raise ScriptException("Running scons failed with "\
                "an error code of %s" % (retcode))
        if self.package_dir is not None:
            try:
                os.mkdir(self.package_dir)
            except OSError: # already exists...ignore the error
                pass
            shutil.copy2(os.path.abspath(os.path.join(self.output_dir,"opticks_%s_amd64.deb" % version)), self.package_dir)
        if self.verbosity > 1:
            print "Done creating debian format of package"

        if self.verbosity > 1:
            print "Creating RPM format of package"
        
        oldpath = os.path.abspath(os.curdir)
        if self.package_dir is not None:
            os.chdir(self.package_dir)
        else:
            os.chdir(self.output_dir)
        alien_args = list()
        alien_args.append('fakeroot')
        alien_args.append('alien')
        alien_args.append('--to-rpm')
        alien_args.append('--scripts')
        alien_args.append('opticks_%s_amd64.deb' % version)

        if self.verbosity > 1:
            print "Execute:"," ".join(alien_args)
        retcode = execute_process(alien_args)
        os.chdir(oldpath)
        if retcode != 0:
            raise ScriptException("Running alien failed with "\
                "an error code of %s" % (retcode))

        if self.verbosity > 1:
            print "Done creating RPM format of package"

        if self.verbosity > 1:
            print "Done generating Linux package"
Exemple #4
0
 def get_app_version_only(self):
     return commonutils.get_app_version_only(".")