Create a new function to create the splitSRPM dirs

Use this function to create split SRPM dirs on the fly
This commit is contained in:
Jesse Keating 2009-05-18 14:33:18 -07:00
parent ff3b72a97e
commit a73e976bc8

View File

@ -292,6 +292,15 @@ self.reserve_size : Additional size needed to be reserved on the first disc.
def createSRPMSplitDir(self):
"""Create a new SRPM split dir to overflow into, linking common files"""
i = self.src_list[-1]
os.makedirs("%s-disc%d/SRPMS" % (self.dist_dir, i))
self.linkFiles(self.dist_dir, "%s-disc%d" %(self.dist_dir, i), self.common_files)
def splitRPMS(self, reportSize = 1): def splitRPMS(self, reportSize = 1):
"""Creates links in the split dirs for the RPMs""" """Creates links in the split dirs for the RPMs"""
@ -398,12 +407,11 @@ self.reserve_size : Additional size needed to be reserved on the first disc.
def splitSRPMS(self): def splitSRPMS(self):
"""Puts the srpms onto the SRPM split discs. The packages are """Puts the srpms onto the SRPM split discs. The packages are
ordered by size, and placed one by one on the disc with the ordered by size, and placed one by one on the disc with
most space available""" space available"""
srpm_list = [] srpm_list = []
srpm_disc_list = self.src_list
# create a list of [[size, srpm]] # create a list of [[size, srpm]]
for srpm in os.listdir("%s" % self.src_dir): for srpm in os.listdir("%s" % self.src_dir):
if not srpm.endswith('.rpm'): if not srpm.endswith('.rpm'):
@ -414,24 +422,36 @@ self.reserve_size : Additional size needed to be reserved on the first disc.
srpm_list.sort() srpm_list.sort()
srpm_list.reverse() srpm_list.reverse()
# Make the first src disc dir
self.src_list = [1]
self.createSRPMSplitDir()
# Create a dict of src discs to current size.
src_dict = {1: 0}
for i in range(0, len(srpm_list)): for i in range(0, len(srpm_list)):
# make sure that the src disc is within the size limits, # make sure that the src disc is within the size limits,
# if it isn't, pull it out of the list. If there's only # if it isn't, make a new one.
# one disk make loud noises over the overflow srpmsize = srpm_list[i][0]
for disc in self.src_list: fit = None
if self.getIsoSize("%s-disc%s" % (self.dist_dir, disc)) > self.target_size:
if len(self.src_list) < 2:
self.logfile.append("Overflowing %s on disc%d" % (srpm_list[i][1], disc))
break
else:
discsize = self.getIsoSize("%s-disc%d" % (self.dist_dir, disc))
self.logfile.append("%s-disc%d size: %s" % (self.arch, disc, discsize))
self.src_list.pop(self.src_list.index(disc))
os.link("%s/%s" % (self.src_dir, srpm_list[i][1]),
"%s-disc%d/SRPMS/%s" % (self.dist_dir, self.getLeastUsedTree()[1], srpm_list[i][1]))
for i in range(0, len(srpm_disc_list)): for disc in src_dict.keys():
self.reportSizes(srpm_disc_list[i]) if src_dict[disc] + srpmsize < self.target_size:
fit = disc
continue
if not fit:
# We couldn't find a disc to fit on, make a new one
self.src_list.append(self.src_list[-1] + 1)
self.createSRPMSplitDir()
fit = src_list[-1]
# now link the srpm to the disc we found (or created) that had room
os.link("%s/%s" % (self.src_dir, srpm_list[i][1]),
"%s-disc%d/SRPMS/%s" % (self.dist_dir, fit, srpm_list[i][1]))
src_dict[fit] = src_dict.setdefault(fit, 0) + srpmsize
for i in range(0, len(src_list)):
self.reportSizes(src_list[i])
def main(self): def main(self):