Example #1
0
    def add_files(self):
        db = self.db
        cab = msilib.CAB("distfiles")
        f = Feature(db,
                    "default",
                    "Default Feature",
                    "Everything",
                    1,
                    directory="TARGETDIR")
        f.set_current()
        rootdir = os.path.abspath(self.bdist_dir)
        root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
        db.Commit()
        todo = [root]
        while todo:
            dir = todo.pop()
            for file in os.listdir(dir.absolute):
                afile = os.path.join(dir.absolute, file)
                if os.path.isdir(afile):
                    newdir = Directory(db, cab, dir, file, file,
                                       "%s|%s" % (dir.make_short(file), file))
                    todo.append(newdir)
                else:
                    key = dir.add_file(file)
                    if file == self.install_script:
                        if self.install_script_key:
                            raise DistutilsOptionError, "Multiple files with name %s" % file
                        self.install_script_key = '[#%s]' % key

        cab.commit(db)
 def add_files(self):
     db = self.db
     cab = msilib.CAB("distfiles")
     f = msilib.Feature(db,
                        "default",
                        "Default Feature",
                        "Everything",
                        1,
                        directory="TARGETDIR")
     f.set_current()
     rootdir = os.path.abspath(self.bdist_dir)
     root = msilib.Directory(db, cab, None, rootdir, "TARGETDIR",
                             "SourceDir")
     db.Commit()
     todo = [root]
     while todo:
         dir = todo.pop()
         for file in os.listdir(dir.absolute):
             if os.path.isdir(os.path.join(dir.absolute, file)):
                 newDir = msilib.Directory(
                     db, cab, dir, file, file,
                     "%s|%s" % (dir.make_short(file), file))
                 todo.append(newDir)
             else:
                 dir.add_file(file)
     cab.commit(db)
    def add_files(self):
        db = self.db
        cab = msilib.CAB('distfiles')
        rootdir = os.path.abspath(self.bdist_dir)
        root = Directory(db, cab, None, rootdir, 'TARGETDIR', 'SourceDir')
        f = Feature(db,
                    'Python',
                    'Python',
                    'Everything',
                    0,
                    1,
                    directory='TARGETDIR')
        items = [(f, root, '')]
        for version in self.versions + [self.other_version]:
            target = 'TARGETDIR' + version
            name = default = 'Python' + version
            desc = 'Everything'
            if version is self.other_version:
                title = 'Python from another location'
                level = 2
            else:
                title = 'Python %s from registry' % version
                level = 1
            f = Feature(db, name, title, desc, 1, level, directory=target)
            dir = Directory(db, cab, root, rootdir, target, default)
            items.append((f, dir, version))

        db.Commit()
        seen = {}
        for feature, dir, version in items:
            todo = [dir]
            while todo:
                dir = todo.pop()
                for file in os.listdir(dir.absolute):
                    afile = os.path.join(dir.absolute, file)
                    if os.path.isdir(afile):
                        short = '%s|%s' % (dir.make_short(file), file)
                        default = file + version
                        newdir = Directory(db, cab, dir, file, default, short)
                        todo.append(newdir)
                    else:
                        if not dir.component:
                            dir.start_component(dir.logical, feature, 0)
                        if afile not in seen:
                            key = seen[afile] = dir.add_file(file)
                            if file == self.install_script:
                                if self.install_script_key:
                                    raise DistutilsOptionError(
                                        'Multiple files with name %s' % file)
                                self.install_script_key = '[#%s]' % key
                        else:
                            key = seen[afile]
                            add_data(self.db, 'DuplicateFile',
                                     [(key + version, dir.component, key, None,
                                       dir.logical)])

            db.Commit()

        cab.commit(db)
        return
Example #4
0
 def add_files(self):
     db = self.db
     cab = msilib.CAB("distfiles")
     f = msilib.Feature(
         db,
         "default",
         "Default Feature",
         "Everything",
         1,
         directory="TARGETDIR",
     )
     f.set_current()
     rootdir = os.path.abspath(self.bdist_dir)
     root = msilib.Directory(db, cab, None, rootdir, "TARGETDIR",
                             "SourceDir")
     db.Commit()
     todo = [root]
     while todo:
         dir = todo.pop()
         for file in os.listdir(dir.absolute):
             sep_comp = self.separate_components.get(
                 os.path.relpath(
                     os.path.join(dir.absolute, file),
                     self.bdist_dir,
                 ))
             if sep_comp is not None:
                 restore_component = dir.component
                 dir.start_component(
                     component=sep_comp,
                     flags=0,
                     feature=f,
                     keyfile=file,
                 )
                 dir.add_file(file)
                 dir.component = restore_component
             elif os.path.isdir(os.path.join(dir.absolute, file)):
                 newDir = msilib.Directory(
                     db,
                     cab,
                     dir,
                     file,
                     file,
                     "{}|{}".format(dir.make_short(file), file),
                 )
                 todo.append(newDir)
             else:
                 dir.add_file(file)
     cab.commit(db)
Example #5
0
 def generate_msi(self, document, dstroot):
     """
     generate msi from a document, using systescanmerge and registryscanmerge 
     """
     self.database = msilib.OpenDatabase(self.msiFile.path, msilib.MSIDBOPEN_DIRECT)
     self.document = document
     
     propertyRecords = self.collectPropertyRecords() 
     table = "Property"
     msilib.add_data(self.database, table, propertyRecords)
     
     promptText = self.productName + " " + self.productVersion + " [1]"
     diskPrompt = [ ("DiskPrompt", promptText ) ]
     msilib.add_data(self.database, table, diskPrompt) 
     
     self.cabFile = msilib.CAB("files.cab")
     f = msilib.Feature(self.database, "defaultFeature", "Default Feature", "Everything", 0, directory="TARGETDIR")
     f.set_current()
     
     home =  dstroot[:3] # example home = "C:\"
     
     # this is the root directory object, a parent of all subdirs in the installation
     root = msilib.Directory(self.database, self.cabFile, None, home , "TARGETDIR", "SourceDir")
     
     self.__buildMSIHiarchy(dstroot, root)
     
     # create a component in "Component" table responsible for installing the registry keys
     root.start_component(component = self.RegsitryComponent, flags = 0)
     # RegsitryComponent is set to current component by default, we don't need that right now,
     root.component = None
     
     # Create and add registry records:
     self.createRegistryRecords()
     if len(self.registryRecords) != 0:
         # there are registry changes, enable and then add them to the installer
         actionsRecords = self.enableRegistryActions()
         table = "InstallExecuteSequence"
         msilib.add_data(self.database, table, actionsRecords)
         
         # now add self.registryRecords found by calling createRegistryRecords, to the msi. a list of tuples is the format.
         table = "Registry"
         msilib.add_data(self.database, table, self.registryRecords) 
         
     self.database.Commit()
     self.cabFile.commit(self.database)
Example #6
0
    def add_files(self):
        """ Store files in a cab insde the MSI
        """
        f = msilib.Feature(self.db,
                           'default',
                           'Default Feature',
                           'Everything',
                           1,
                           directory='TARGETDIR')
        f.set_current()

        cab = msilib.CAB('distfiles')
        rootdir = os.path.abspath(self.bdist_dir)
        root = msilib.Directory(self.db, cab, None, rootdir, 'TARGETDIR',
                                'SourceDir')
        self.db.Commit()

        todo = [root]
        while todo:
            dir = todo.pop()
            for file in os.listdir(dir.absolute):
                comp = self.separate_components.get(
                    os.path.relpath(os.path.join(dir.absolute, file),
                                    self.bdist_dir))
                if comp is not None:
                    restore_component = dir.component
                    dir.start_component(component=comp,
                                        flags=0,
                                        feature=f,
                                        keyfile=file)
                    dir.add_file(file)
                    dir.component = restore_component
                elif os.path.isdir(os.path.join(dir.absolute, file)):
                    newDir = msilib.Directory(
                        self.db, cab, dir, file, file,
                        "{}|{}".format(dir.make_short(file), file))
                    todo.append(newDir)
                else:
                    dir.add_file(file)

        cab.commit(self.db)
Example #7
0
    def add_files(self):
        db = self.db
        cab = msilib.CAB("distfiles")
        rootdir = os.path.abspath(self.bdist_dir)

        root = Directory(db, cab, None, rootdir, "TARGETDIR", "SourceDir")
        f = Feature(db,
                    "Python",
                    "Python",
                    "Everything",
                    0,
                    1,
                    directory="TARGETDIR")

        items = [(f, root, "")]
        for version in self.versions + [self.other_version]:
            target = "TARGETDIR" + version
            name = default = "Python" + version
            desc = "Everything"
            if version is self.other_version:
                title = "Python from another location"
                level = 2
            else:
                title = "Python %s from registry" % version
                level = 1
            f = Feature(db, name, title, desc, 1, level, directory=target)
            dir = Directory(db, cab, root, rootdir, target, default)
            items.append((f, dir, version))
        db.Commit()

        seen = {}
        for feature, dir, version in items:
            todo = [dir]
            while todo:
                dir = todo.pop()
                for file in os.listdir(dir.absolute):
                    afile = os.path.join(dir.absolute, file)
                    if os.path.isdir(afile):
                        short = "%s|%s" % (dir.make_short(file), file)
                        default = file + version
                        newdir = Directory(db, cab, dir, file, default, short)
                        todo.append(newdir)
                    else:
                        if not dir.component:
                            dir.start_component(dir.logical, feature, 0)
                        if afile not in seen:
                            key = seen[afile] = dir.add_file(file)
                            if file == self.install_script:
                                if self.install_script_key:
                                    raise DistutilsOptionError(
                                        "Multiple files with name %s" % file)
                                self.install_script_key = "[#%s]" % key
                        else:
                            key = seen[afile]
                            add_data(
                                self.db,
                                "DuplicateFile",
                                [(
                                    key + version,
                                    dir.component,
                                    key,
                                    None,
                                    dir.logical,
                                )],
                            )
            db.Commit()
        cab.commit(db)