def rmpackage(self): current_pkg = package.package() if self.deb.endswith('deb'): current_pkg.setBinary(True) elif self.deb.endswith('dsc'): current_pkg.setBinary(False) else: print "Error: Unknown file format" sys.exit(7) if not os.path.exists(os.path.join(os.sep, self.apt_conf, 'apt_%s.conf'%self.dist)): print "Error: No se encuentra el fichero de configuraci�n de apt" sys.exit(9) print "File: %s"%os.path.join(os.sep, self.repo, self.deb) current_pkg.importInfo(os.path.join(os.sep, self.repo, self.deb)) architecture = self.arch if current_pkg.isBinary(): architecture = 'binary-%s'%self.arch else: architecture = 'source' index_location = os.path.join(os.sep, self.repo, 'dists', self.dist, self.section, architecture) self.branch = index_location self.lockBranch() plist = packagesList.packagesList() print 'Index location: %s'%index_location file_content,index_file = self.getIndexContent(index_location) plist.loadInfo(file_content) #The package is searched by it's path in the pool result = plist.searchByName(self.deb, current_pkg.isBinary()) if result: print "Localizando.............OK\nPath: %s"%self.deb plist.removePackage(result) path = os.path.join(os.sep, self.repo, 'dists', self.dist, self.section, architecture) print 'Index file: ' + os.path.join(os.sep, self.repo, 'dists', self.dist, self.section, architecture, index_file) plist.newFiles(path, current_pkg.isBinary()) dirs = os.walk(path) dirs = dirs.next()[-1] for f in dirs: if not f.startswith('.'): try: print "cambiando permisos a %s"%(path + os.sep + f) os.chmod(path + os.sep + f, 0664) print "cambiando grupo a %s"%(path + os.sep + f) os.chown(path + os.sep + f, os.getuid(), self.gid) except: print 'Error cambiando permisos a %s'%(os.sep.join([path,f])) print "File removed from index....%s"%os.path.join(os.sep, self.repo, self.deb) done = True self.unLockBranch() else: print "No se ha localizado el paquete....%s"%self.deb self.unLockBranch() sys.exit(2) done = False return done
def updateIndexFiles(self, current, file): #Build index files path f_packages_path = os.path.join(os.sep,self.repo, 'dists', self.dist, self.section, self.arch) section_path = os.path.join(os.sep, self.repo, 'dists', self.dist, self.section) #create new branch if needed if not os.path.exists(f_packages_path): newdir = os.path.join(os.sep,self.repo, 'dists', self.dist, self.section, self.arch) try: os.makedirs(newdir) except: print "Error creando directorio: %"%newdir sys.exit(10) os.chown(newdir, os.getuid(), self.gid) print "Creada rama nueva: %s"%f_packages_path #Explore both .gz & .bz2 files index_file = self.getContent(f_packages_path, current.isBinary()) pkglist = packagesList.packagesList() pkglist.loadInfo(index_file) file_Source = current.get('Source') file_Package = current.get('Package') #The package isn't in the Packages file. if not pkglist.searchPackage(current): #Making destination path name = file_Source if not name: name = file_Package name = name.strip() if name[0:3] == 'lib': dir = name[0:4] else: dir = name[0] #destination = os.path.join(os.sep,self.repo, self.pool, self.section, dir, name.strip()) #set Filename field in debian control structure. if current.isBinary(): deb_filename = os.path.join(os.sep, self.pool, self.section, dir, name.strip(), file)[1:] print "filename field at debian index file: %s"%deb_filename current.set('Filename', deb_filename) #Directory information of current source package (for Sources.gz) else: directory = os.path.join(os.sep, self.pool, self.section, dir, name.strip())[1:] print "Directory field: %s"%directory current.set('Directory', directory) print "Adding it to the Packages/Sources file....." pkglist.addPackage(current) print "archivo: %s"%f_packages_path pkglist.newFiles(f_packages_path, current.isBinary()) dirs = os.walk(f_packages_path) dirs = dirs.next()[-1] for f in dirs: if not f.startswith('.'): try: os.chmod(f_packages_path + os.sep + f, 0664) # print "cambiando grupo a %s"%(f_packages_path + os.sep + f) os.chown(f_packages_path + os.sep + f, os.getuid(), self.gid) except: print 'Error cambiando los permisos a %s'%(f_packages_path + os.sep + f) #sys.exit(12) else: continue del dirs self.gen_Release() else: print "The package is in the current distribution" self.unLockBranch() sys.exit(1)