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)
Esempio n. 2
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)
Esempio n. 3
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)
Esempio n. 4
0
 def __buildMSIHiarchy(self, dirPath, rootDirObj = None):
     """
     build the Installation hiarchy of Folders/files
     this will make changes to the following tables in the mis: Directory, Component, FeatureComponents, File 
     """
     for folder in  os.listdir(dirPath):
         path = os.path.join(dirPath,folder)
         if os.path.isdir(path):
             root = msilib.Directory(self.database, self.cabFile, rootDirObj, folder, folder , folder)
             self.__buildMSIHiarchy(path , root)
         elif os.path.isfile(path):
             rootDirObj.add_file(folder)
Esempio n. 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)