def scan_packages(self, isoFileList, tmpdir): self.time_start = 1 self.steps.set_current(1) self.progress.update_progress(0) self.progress.progress_widget.set_text( '') self.progress.progress_text = constants.MESSAGE_0019 gui.processEvents() for cds in isoFileList.keys(): #cd destination folder media_folder_name = self.values['media_type'] + str(cds) current_msg = constants.MESSAGE_0021 + ' (' + media_folder_name + ')' self.steps.set_current_text(1,current_msg ) tmpmetapackageDir = utils.join_path(tmpdir , 'metapackage/' + media_folder_name) tmppackages = utils.join_path(tmpdir , 'packages') destination = utils.join_path(tmppackages, media_folder_name) pkg_destination = utils.join_path(destination , 'packages') controlFile = utils.join_path(tmpmetapackageDir, 'DEBIAN/control') #create the deb file for metapackage if self.values['createmeta']: command = 'dpkg-deb -b %s %s > /dev/null 2> /dev/null' % \ (tmpmetapackageDir.replace(' ','\ '), utils.join_path(pkg_destination.replace(' ','\ '), self.mPack.get_mtFileName()) ) result = utils.run_command(command) #remove the file needed to create the metapackage utils.del_file(controlFile) packages_files = utils.join_path(destination.replace(' ','\ ') , 'Packages') command = 'apt-ftparchive packages packages/' if self.progress.cancel_status: errorMsg = constants.MESSAGE_0027 return False, errorMsg apt_ftp = AptFtpArchive() self.progress.stop = 100 apt_ftp.set_progress_hook(self.on_update) apt_ftp.execute(command, destination, packages_files) if self.progress.cancel_status: errorMsg = constants.MESSAGE_0027 return False, errorMsg #creates a tar file using bz2 compression result, path = utils.compress(packages_files) result, msg = utils.zip_file(utils.join_path(destination,'Packages.gz'), utils.join_path(destination,'Packages')) packages_files = utils.join_path(destination.replace(' ','\ ') , 'Release') command = 'apt-ftparchive release .' apt_ftp.set_progress_hook(self.on_update) apt_ftp.execute(command, destination, packages_files) if self.progress.cancel_status: errorMsg = constants.MESSAGE_0027 return False, errorMsg #Create aptoncd.inf file infoFile = utils.join_path(destination, 'aptoncd.info') info = mediainfo.MediaInfo(infoFile) info.write() if self.progress.cancel_status: errorMsg = constants.MESSAGE_0027 return False, errorMsg #Creates .disk/info diskinfodir = utils.join_path(destination ,'.disk') utils.mkdir(diskinfodir, True) infoDiskFile = utils.join_path(diskinfodir,'info') infoDisk = mediainfo.aptDiskInfo(infoDiskFile, media_folder_name) infoDisk.write() #write README.diskdefines infoDiskDefinesFile = utils.join_path(destination, 'README.diskdefines') infoDiskDefines = mediainfo.aptDiskDefines(infoDiskDefinesFile,media_folder_name) infoDiskDefines.write() gui.processEvents() utils.removePath(tmpmetapackageDir) self.progress.cancel_pulse() self.steps.set_current_text(1,constants.MESSAGE_0021) self.steps.set_done(1) self.progress.update_progress(0) return True, None
def copy_files(self, isoFileList, tmpdir): """ this will copy each package from every cd to the destination. """ self.controlFile = {} #start mounting the cd/dvd layout for cds in isoFileList.keys(): #show the first step in bold with an arrow at its left self.steps.set_current(0) media_folder_name = self.values['media_type'] + str(cds) current_msg = constants.MESSAGE_0020 + ' (' + media_folder_name + ')' self.steps.set_current_text(0,current_msg ) self.progress.progress_text = constants.MESSAGE_0002 tmpmetapackageDir = utils.join_path(tmpdir , 'metapackage/' + media_folder_name) tmppackages = utils.join_path(tmpdir , 'packages') #if we are creating a metapackage #we must create a DEBIAN folder print 'Create Meta:', self.values['createmeta'] if self.values['createmeta']: utils.mkdir(utils.join_path(tmpmetapackageDir, 'DEBIAN'),True) controlFile = utils.join_path(tmpmetapackageDir, 'DEBIAN/control') utils.del_file(controlFile) self.mPack = MetaPackage(controlFile) else: utils.removePath(tmpmetapackageDir ) #cd destination folder destination = utils.join_path(tmppackages, media_folder_name) utils.mkdir(destination, True) #destination for each package inside this media pkg_destination = utils.join_path(destination , 'packages') utils.mkdir(pkg_destination, True) #start to copy files from source to destination self.progress.stop = len(isoFileList[cds]) for index, pkg in enumerate(isoFileList[cds]): #update the progress bar self.progress.update_progress(index + 1) #if we must create metapackage we will add this #package to the meta list if self.values['createmeta']: self.mPack.appendPackage(pkg.package) #set the folder destination of the package filedestination = utils.join_path(pkg_destination, pkg.deb_filename) #if user has canceled #stop iterating if self.progress.cancel_status: errorMsg = constants.MESSAGE_0027 return False, errorMsg #copy file to destination pkg.copy_to(filedestination ) #update the progress message self.progress.progress_text = constants.MESSAGE_0029 % pkg.package gui.processEvents() #close the packfile for this cd if self.values['createmeta']: self.mPack.write() #update processes #marking first as done and starting a new one self.steps.set_current_text(0,constants.MESSAGE_0020) self.steps.set_done(0) return True, None