Exemple #1
0
 def __init__(self,
              name,
              installer_name,
              install_dir,
              src_dir,
              dist_dir,
              data_files=[],
              sys_files=[],
              exe_files=[],
              version="0.0.1",
              author_name=None,
              author_url=None,
              postfix_name=None,
              verbose=1):
     self.verbose = verbose
     installer_name = to_filename(installer_name, version, postfix_name)
     self.iss_path = os.path.join(src_dir, "%s.iss" % installer_name)
     self.src_dir = src_dir
     if not self.src_dir[-1] in "\\/":
         self.src_dir += os.sep
     self.dist_dir = dist_dir
     self.name = name
     self.installer_name = installer_name
     self.install_dir = install_dir
     self.version = version
     self.author_name = author_name
     self.author_url = author_url
     self.data_files = [self.chop(p) for p in data_files]
     self.sys_files = [self.chop(p) for p in sys_files]
     self.exe_files = exe_files
Exemple #2
0
    def on_install(self, reporthook=None):
        """
            We will take the approach of installing by copying the lists to
            /var/lib/apt/lists and the packages to /var/cache/apt/archives and
            calling apt-get update and then apt-get install on the packages 
            which have the status of "to be installed". This prevents tampering
            with sources.list and works more or less the exact same if we made
            a local repository.
        """
        
        if not os.geteuid() == 0:    
            raise PermissionsError, "You may only install as root"
        
        # Copy lists over
        for repo in self.__iter_repositories():
            url = to_url(repo, self.architecture, "Packages")
            filename = to_filename(os.path.join(self.download_directory, "lists"), url)

            try:
                # Extract the gz
                g = gzip.open("%s.gz" % filename, "rb")
                f = open(os.path.join("/var/lib/apt/lists", os.path.basename(filename)), "wb")
                f.write(g.read())
                f.close()
                g.close()
            except IOError, e:
                # We will just ignore this, it only trip out if the user did download=False on update()
                pass
Exemple #3
0
    def _download_lists(self, reporthook=None):
        """
            on_update helper function
        """
        
        if not reporthook:
            reporthook = textprogress
        
        directory = os.path.join(self.download_directory, "lists")

        # If the download directory does not exist, create it
        if not os.path.exists(directory):
            os.makedirs(directory)

        for repo in self.__iter_repositories():

            # Build the strings
            url = to_url(repo, self.architecture, "Packages")
            filename = to_filename(directory, url)
            display_name = "Repository => %s / %s" % (repo["dist"], repo["section"])

            # Download
            #TODO: catch exceptions
            #TODO: Support bz2 and unarchived Packages files
            filename = "%s.gz" % filename
            download_url("%s.gz" % url, 
                         filename, 
                         display_name, 
                         progress=reporthook,
                         proxy=self.proxy["proxy"], 
                         username=self.proxy["user"], 
                         password=self.proxy["pass"])
Exemple #4
0
    def _build_lists(self, directory, lists=[]):

        # Build the strings
        for repo in self.__iter_repositories():
            url = to_url(repo, self.architecture, "Packages")
            filename = to_filename(directory, url)
            filename = "%s.gz" % filename  # Works only if the index files are gz
            lists.append((repo, filename))
            
        return lists