Example #1
0
    def add_files(self, files):
        self.cab = CAB(self.package_name)
        self.root = Directory(self.db, self.cab, None, '\\', "TARGETDIR",
                              "SourceDir")
        print '(add_files) :: self.srcdir=(%s)' % (self.srcdir)

        dirs = {}
        # Add all other root files into the TARGETDIR component
        self.root.start_component("TARGETDIR", default_feature)
        # BEGIN: This block MUST remain intact, as-is or bad things may happen...
        _cur_dir = '\\'
        lib = self.root
        # END! This block MUST remain intact, as-is or bad things may happen...
        _parent = self.root
        _dir = "Lib"
        for f in files:
            if ((str(f.__class__).find("'tuple'") > -1)
                    or (str(f.__class__).find("'list'") > -1)):
                _f = f[1]
            else:
                _f = f
            f_dir = os.path.dirname(_f)
            print '(add_files) :: f_dir=(%s), _f=(%s)' % (f_dir, _f)
            if (_cur_dir != f_dir):
                print '(add_files) :: NEW DIRECTORY !\n'
                _dir = f_dir  # .split(os.sep)[-1]
                lib = Directory(self.db, self.cab, _parent, _dir, _dir,
                                "%s|%s" % (_parent.make_short(_dir), _dir))
                dirs[dir] = lib
                _cur_dir = f_dir
            lib.add_file(_f.split(os.sep)[-1])

        self.cab.commit(self.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 #3
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)
        return
Example #4
0
def add_files(db, msi_node, versions, other_version, install_script=None):
    if install_script is not None:
        raise NotImplementedError("Support for msi install script not yet implemented")
    cab = msilib.CAB("distfiles")
    rootdir = msi_node.abspath()

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

    items = [(f, root, "")]
    for version in versions + [other_version]:
        target = "TARGETDIR" + version
        name = default = "Python" + version
        desc = "Everything"
        if version is 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 == install_script:
                            if install_script_key:
                                raise DistutilsOptionError("Multiple files with name %s" % file)
                            install_script_key = "[#%s]" % key
                    else:
                        key = seen[afile]
                        add_data(db, "DuplicateFile", [(key + version, dir.component, key, None, dir.logical)])
        db.Commit()
    cab.commit(db)
Example #5
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)