Based on feedback, here is the revised proposal.

1. Change package.release from a ForeignKey to a ManyToMany relationship 
with
   release. A spec can, through another spec file, specify more than one 
module.
   A release has a 1-1 relationship with a module. This means that a 
package can
   point to more than one release - as long as their modules are different.

2. Add a table

  class IPS_package_file(models.Model):
    filename = models.CharField(max_length=1024)
    location = models.CharField(max_length=4096)

There will be one entry for each file in this table. The combination of
location + filename will be unique. We cannot have the same file twice. 
This
will basically be a copy of the contents of all of the repos we are 
interested
in.

3. Add ManyToMany relationship between package and IPS_package_file:

  class package(models.Model):
    ...
    files = models.ManyToMany(IPS_package_file)

A package contains multiple files.

4. Add a function to the package class that returns the parent spec.

  package.parent_spec().
 
5. Add a function to the package class that returns True|False for a package
containing a file, package.has_file(path).

6. Add a way to sort the packages by fmri.

7. We need to store a list of repos we know about in the DB.

  class IPS_repo(models.Model):
    URL = models.CharField(max_length=4096)


After building the package, we do the following (this is rough, there
are errors):

# update our representation of what's in the repos, including /dev, 
/release,
# etc.
for repo in repo.objects.all():
  for package in repo.get_packages():
    if not package in IPS_repo_package.objects.all():
      # package is new
      for file in package.contents():
        new_file = IPS_repo_file(.....)
        new_file.save()

# check for file conflicts
for some_file in new package's manifest:
  packages_containing_some_file = package.objects.filter(...)
  if packages_containing_some_file.count() > 0:
    for p in packages_containing_some_file:
      if p.parent_spec() != new package's spec file:
        # Maybe we're moving this file from one spec to another
        # Make sure the newest version of p, does *not* contain some_file
        if 
package.objects.filter(name=p.name).sort_by(fmri)[0].has_file(some_file):
          # COLISSION!


Reply via email to