~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/archivepublisher/model/ftparchive.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-15 10:35:32 UTC
  • mfrom: (14517.1.3 new-bzr)
  • Revision ID: launchpad@pqm.canonical.com-20111215103532-q2m4uyk0r8ugiayx
[r=sinzui, poolie][bug=509016] Always load foreign plugins,
 but restrict probers to avoid accidentally opening foreign branches.
 (re-land)

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
from storm.store import EmptyResultSet
12
12
from zope.component import getUtility
13
13
 
 
14
from canonical.launchpad.components.decoratedresultset import (
 
15
    DecoratedResultSet,
 
16
    )
14
17
from canonical.launchpad.database.librarian import LibraryFileAlias
15
18
from canonical.launchpad.webapp.interfaces import (
16
19
    DEFAULT_FLAVOR,
24
27
    OutputLineHandler,
25
28
    ReturnCodeReceiver,
26
29
    )
27
 
from lp.services.database.decoratedresultset import DecoratedResultSet
28
30
from lp.services.database.stormexpr import Concatenate
29
31
from lp.soyuz.enums import PackagePublishingStatus
30
32
from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
119
121
        self.distro = distro
120
122
        self.publisher = publisher
121
123
 
 
124
        # We need somewhere to note down where the debian-installer
 
125
        # components came from. in _di_release_components we store
 
126
        # sets, keyed by distroseries name of the component names
 
127
        # which contain debian-installer binaries.  This is filled out
 
128
        # when generating overrides and file lists, and then consumed
 
129
        # when generating apt-ftparchive configuration.
 
130
        self._di_release_components = {}
 
131
 
122
132
    def run(self, is_careful):
123
133
        """Do the entire generation and run process."""
124
134
        self.createEmptyPocketRequests(is_careful)
206
216
 
207
217
    def createEmptyPocketRequest(self, distroseries, pocket, comp):
208
218
        """Creates empty files for a release pocket and distroseries"""
 
219
        if pocket == PackagePublishingPocket.RELEASE:
 
220
            # organize distroseries and component pair as
 
221
            # debian-installer -> distroseries_component
 
222
            # internal map. Only the main pocket actually
 
223
            # needs these, though.
 
224
            self._di_release_components.setdefault(
 
225
                distroseries.name, set()).add(comp)
 
226
            f_touch(self._config.overrideroot,
 
227
                    ".".join(["override", distroseries.name, comp,
 
228
                              "debian-installer"]))
 
229
 
209
230
        suite = distroseries.getSuite(pocket)
210
231
 
211
232
        # Create empty override lists.
212
 
        for path in (
213
 
            (comp, ),
214
 
            ("extra", comp),
215
 
            (comp, "debian-installer"),
216
 
            (comp, "src"),
217
 
            ):
 
233
        for path in ((comp, ), ("extra", comp), (comp, "src")):
218
234
            f_touch(os.path.join(
219
235
                self._config.overrideroot,
220
236
                ".".join(("override", suite) + path)))
405
421
            if priority:
406
422
                # We pick up debian-installer packages here
407
423
                if section.endswith("debian-installer"):
 
424
                    # XXX: kiko 2006-08-24: This is actually redundant with
 
425
                    # what is done in createEmptyPocketRequests. However,
 
426
                    # this code does make it possible to unit test this
 
427
                    # method, so I'm sure if it should be removed.
 
428
                    self._di_release_components.setdefault(
 
429
                        suite, set()).add(component)
408
430
                    suboverride['d-i'].add((packagename, priority, section))
409
431
                else:
410
432
                    suboverride['bin'].add((packagename, priority, section))
675
697
                            architecture, file_names, suite, component)
676
698
 
677
699
    def writeFileList(self, arch, file_names, dr_pocketed, component):
678
 
        """Output file lists for a series and architecture.
 
700
        """Outputs a file list for a series and architecture.
679
701
 
680
 
        This includes a debian-installer file list.
 
702
        Also outputs a debian-installer file list if necessary.
681
703
        """
682
704
        files = []
683
705
        di_files = []
686
708
        f = file(f_path, "w")
687
709
        for name in file_names:
688
710
            if name.endswith(".udeb"):
689
 
                # Note the name for output later
 
711
                # Once again, note that this component in this
 
712
                # distroseries has d-i elements
 
713
                self._di_release_components.setdefault(
 
714
                    dr_pocketed, set()).add(component)
 
715
                # And note the name for output later
690
716
                di_files.append(name)
691
717
            else:
692
718
                files.append(name)
695
721
        f.write("\n")
696
722
        f.close()
697
723
 
698
 
        # Once again, some d-i stuff to write out...
699
 
        self.log.debug(
700
 
            "Writing d-i file list for %s/%s/%s" % (
 
724
        if len(di_files):
 
725
            # Once again, some d-i stuff to write out...
 
726
            self.log.debug("Writing d-i file list for %s/%s/%s" % (
701
727
                dr_pocketed, component, arch))
702
 
        di_overrides = os.path.join(
703
 
            self._config.overrideroot,
704
 
            "%s_%s_debian-installer_%s" % (dr_pocketed, component, arch))
705
 
        f = open(di_overrides, "w")
706
 
        di_files.sort(key=package_name)
707
 
        f.write("\n".join(di_files))
708
 
        f.write("\n")
709
 
        f.close()
 
728
            di_overrides = os.path.join(self._config.overrideroot,
 
729
                                        "%s_%s_debian-installer_%s" %
 
730
                                        (dr_pocketed, component, arch))
 
731
            f = open(di_overrides, "w")
 
732
            di_files.sort(key=package_name)
 
733
            f.write("\n".join(di_files))
 
734
            f.write("\n")
 
735
            f.close()
710
736
 
711
737
    #
712
738
    # Config Generation
784
810
                                    else "false",
785
811
                         })
786
812
 
787
 
        if archs:
788
 
            for component in comps:
 
813
        if archs and suite in self._di_release_components:
 
814
            for component in self._di_release_components[suite]:
789
815
                apt_config.write(STANZA_TEMPLATE % {
790
816
                    "LISTPATH": self._config.overrideroot,
791
817
                    "DISTRORELEASEONDISK": "%s/%s" % (suite, component),
804
830
        for comp in comps:
805
831
            component_path = os.path.join(
806
832
                self._config.distsroot, suite, comp)
807
 
            safe_mkdir(os.path.join(component_path, "source"))
808
 
            if not distroseries.include_long_descriptions:
809
 
                safe_mkdir(os.path.join(component_path, "i18n"))
810
 
            for arch in archs:
811
 
                safe_mkdir(os.path.join(component_path, "binary-" + arch))
812
 
                safe_mkdir(os.path.join(
813
 
                    component_path, "debian-installer", "binary-" + arch))
 
833
            base_paths = [component_path]
 
834
            if suite in self._di_release_components:
 
835
                if comp in self._di_release_components[suite]:
 
836
                    base_paths.append(os.path.join(component_path,
 
837
                                                   "debian-installer"))
 
838
            for base_path in base_paths:
 
839
                if "debian-installer" not in base_path:
 
840
                    safe_mkdir(os.path.join(base_path, "source"))
 
841
                    if not distroseries.include_long_descriptions:
 
842
                        safe_mkdir(os.path.join(base_path, "i18n"))
 
843
                for arch in archs:
 
844
                    safe_mkdir(os.path.join(base_path, "binary-" + arch))