7675.1090.13
by Jeroen Vermeulen
Ah yes, copyright. |
1 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.12
by Karl Fogel
Add the copyright header block to files under lib/lp/archivepublisher/ |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
3 |
#
|
1932
by Canonical.com Patch Queue Manager
Merge in publishing work from soyuz sprint. r=jamesh |
4 |
# This is the python package that defines the
|
8426.7.1
by Julian Edwards
migrate archivepublisher to the lp tree. |
5 |
# 'lp.archivepublisher.config' package. This package is related
|
1932
by Canonical.com Patch Queue Manager
Merge in publishing work from soyuz sprint. r=jamesh |
6 |
# to managing the archive publisher's configuration as stored in the
|
4285.2.4
by Mark Shuttleworth
Test fixes with renamed distrorelease |
7 |
# distribution and distroseries tables
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
8 |
|
3500.2.37
by Celso Providelo
Sanitising archivepubliser.Config class, preparation to land interface and zope adapters for it. |
9 |
import os |
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
10 |
|
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
11 |
from zope.component import getUtility |
12 |
||
14605.1.1
by Curtis Hovey
Moved canonical.config to lp.services. |
13 |
from lp.services.config import config |
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
14 |
from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet |
7675.1090.12
by Jeroen Vermeulen
Unified archive name suffixes. |
15 |
from lp.soyuz.enums import ( |
13812.2.1
by Jeroen Vermeulen
Quietly skip archives without publisher configs. |
16 |
archive_suffixes, |
7675.1090.12
by Jeroen Vermeulen
Unified archive name suffixes. |
17 |
ArchivePurpose, |
18 |
)
|
|
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
19 |
|
20 |
||
7675.994.4
by William Grant
Move apt_ftparchive_purposes into the module root. |
21 |
APT_FTPARCHIVE_PURPOSES = (ArchivePurpose.PRIMARY, ArchivePurpose.COPY) |
22 |
||
23 |
||
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
24 |
def getPubConfig(archive): |
25 |
"""Return an overridden Publisher Configuration instance.
|
|
26 |
||
27 |
The original publisher configuration based on the distribution is
|
|
28 |
modified according local context, it basically fixes the archive
|
|
29 |
paths to cope with non-primary and PPA archives publication workflow.
|
|
30 |
"""
|
|
7675.996.10
by William Grant
Remove series stuff from lucilleconfig. This means we no longer skip unconfigured series, but this was never used in practice. |
31 |
pubconf = Config() |
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
32 |
ppa_config = config.personalpackagearchive |
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
33 |
db_pubconf = getUtility( |
34 |
IPublisherConfigSet).getByDistribution(archive.distribution) |
|
13812.2.1
by Jeroen Vermeulen
Quietly skip archives without publisher configs. |
35 |
if db_pubconf is None: |
36 |
return None |
|
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
37 |
|
7675.996.4
by William Grant
Only set misc/cache/override roots, and set the temp directory strangely (but the tests like it). |
38 |
pubconf.temproot = os.path.join( |
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
39 |
db_pubconf.root_dir, '%s-temp' % archive.distribution.name) |
7675.996.4
by William Grant
Only set misc/cache/override roots, and set the temp directory strangely (but the tests like it). |
40 |
|
7675.996.2
by William Grant
Extract all path calculation into getPubConfig. This makes lucilleconfig almost entirely redundant. |
41 |
if archive.is_ppa: |
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
42 |
if archive.private: |
43 |
pubconf.distroroot = ppa_config.private_root |
|
44 |
pubconf.htaccessroot = os.path.join( |
|
45 |
pubconf.distroroot, archive.owner.name, archive.name) |
|
46 |
else: |
|
47 |
pubconf.distroroot = ppa_config.root |
|
48 |
pubconf.htaccessroot = None |
|
49 |
pubconf.archiveroot = os.path.join( |
|
50 |
pubconf.distroroot, archive.owner.name, archive.name, |
|
51 |
archive.distribution.name) |
|
7675.996.2
by William Grant
Extract all path calculation into getPubConfig. This makes lucilleconfig almost entirely redundant. |
52 |
elif archive.is_main: |
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
53 |
pubconf.distroroot = db_pubconf.root_dir |
7675.996.2
by William Grant
Extract all path calculation into getPubConfig. This makes lucilleconfig almost entirely redundant. |
54 |
pubconf.archiveroot = os.path.join( |
55 |
pubconf.distroroot, archive.distribution.name) |
|
7675.1090.12
by Jeroen Vermeulen
Unified archive name suffixes. |
56 |
pubconf.archiveroot += archive_suffixes[archive.purpose] |
10344.1.1
by Julian Edwards
fix getPubConfig so it handles copy archives |
57 |
elif archive.is_copy: |
7675.1069.3
by Julian Edwards
make the publisher config come from the db instead of canonical.config |
58 |
pubconf.distroroot = db_pubconf.root_dir |
10344.1.1
by Julian Edwards
fix getPubConfig so it handles copy archives |
59 |
pubconf.archiveroot = os.path.join( |
60 |
pubconf.distroroot, |
|
10391.1.1
by Julian Edwards
fix the publishing location for copy archives |
61 |
archive.distribution.name + '-' + archive.name, |
62 |
archive.distribution.name) |
|
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
63 |
else: |
64 |
raise AssertionError( |
|
65 |
"Unknown archive purpose %s when getting publisher config.", |
|
66 |
archive.purpose) |
|
67 |
||
7675.994.2
by William Grant
Only set misc/cache/override roots, and set the temp directory strangely (but the tests like it). |
68 |
# There can be multiple copy archives, so the temp dir needs to be
|
69 |
# within the archive.
|
|
70 |
if archive.is_copy: |
|
71 |
pubconf.temproot = pubconf.archiveroot + '-temp' |
|
7675.996.4
by William Grant
Only set misc/cache/override roots, and set the temp directory strangely (but the tests like it). |
72 |
|
7675.994.4
by William Grant
Move apt_ftparchive_purposes into the module root. |
73 |
if archive.purpose in APT_FTPARCHIVE_PURPOSES: |
7675.996.4
by William Grant
Only set misc/cache/override roots, and set the temp directory strangely (but the tests like it). |
74 |
pubconf.overrideroot = pubconf.archiveroot + '-overrides' |
75 |
pubconf.cacheroot = pubconf.archiveroot + '-cache' |
|
76 |
pubconf.miscroot = pubconf.archiveroot + '-misc' |
|
14434.2.1
by Colin Watson
Add germinateroot attribute to publisher configuration. |
77 |
pubconf.germinateroot = pubconf.archiveroot + '-germinate' |
7675.996.9
by William Grant
Clean up lucilleconfig a bit. |
78 |
else: |
79 |
pubconf.overrideroot = None |
|
80 |
pubconf.cacheroot = None |
|
81 |
pubconf.miscroot = None |
|
14434.2.1
by Colin Watson
Add germinateroot attribute to publisher configuration. |
82 |
pubconf.germinateroot = None |
7675.996.9
by William Grant
Clean up lucilleconfig a bit. |
83 |
|
7675.994.5
by William Grant
Merge update_pub_config into getPubConfig. |
84 |
pubconf.poolroot = os.path.join(pubconf.archiveroot, 'pool') |
85 |
pubconf.distsroot = os.path.join(pubconf.archiveroot, 'dists') |
|
7675.996.2
by William Grant
Extract all path calculation into getPubConfig. This makes lucilleconfig almost entirely redundant. |
86 |
|
11091.4.1
by Steve Kowalik
* Refactor metaroot from the publish_META_DATA function into the publisher |
87 |
meta_root = os.path.join( |
88 |
pubconf.distroroot, archive.owner.name) |
|
89 |
pubconf.metaroot = os.path.join( |
|
90 |
meta_root, "meta", archive.name) |
|
91 |
||
8255.13.1
by Julian Edwards
Move IArchive.getPubConfig() to archivepublisher. |
92 |
return pubconf |
93 |
||
94 |
||
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
95 |
class Config(object): |
1932
by Canonical.com Patch Queue Manager
Merge in publishing work from soyuz sprint. r=jamesh |
96 |
"""Manage a publisher configuration from the database. (Read Only)
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
97 |
This class provides a useful abstraction so that if we change
|
1932
by Canonical.com Patch Queue Manager
Merge in publishing work from soyuz sprint. r=jamesh |
98 |
how the database stores configuration then the publisher will not
|
1102
by Canonical.com Patch Queue Manager
Lucille had some XXXs which should have been NOTEs |
99 |
need to be re-coded to cope"""
|
100 |
||
3500.2.37
by Celso Providelo
Sanitising archivepubliser.Config class, preparation to land interface and zope adapters for it. |
101 |
def setupArchiveDirs(self): |
7675.996.8
by William Grant
Strop down lucilleconfig to the absolute minimum. |
102 |
"""Create missing required directories in archive."""
|
3500.2.37
by Celso Providelo
Sanitising archivepubliser.Config class, preparation to land interface and zope adapters for it. |
103 |
required_directories = [ |
104 |
self.distroroot, |
|
105 |
self.poolroot, |
|
106 |
self.distsroot, |
|
107 |
self.archiveroot, |
|
108 |
self.cacheroot, |
|
109 |
self.overrideroot, |
|
4162.4.1
by Celso Providelo
Fix bug #110351 (lost doffiles in archive breaks dsync/mirroring). Adding a temporary directory in the archive-tree for storing files while they are downloaded from librarian. |
110 |
self.miscroot, |
14434.2.1
by Colin Watson
Add germinateroot attribute to publisher configuration. |
111 |
self.germinateroot, |
4162.4.1
by Celso Providelo
Fix bug #110351 (lost doffiles in archive breaks dsync/mirroring). Adding a temporary directory in the archive-tree for storing files while they are downloaded from librarian. |
112 |
self.temproot, |
3500.2.37
by Celso Providelo
Sanitising archivepubliser.Config class, preparation to land interface and zope adapters for it. |
113 |
]
|
114 |
||
115 |
for directory in required_directories: |
|
3691.448.3
by Celso Providelo
Land the PPA-based Publish Configuration override system. It fix the paths contained in configuration to match the PPA publication schema. |
116 |
if directory is None: |
117 |
continue
|
|
3500.2.37
by Celso Providelo
Sanitising archivepubliser.Config class, preparation to land interface and zope adapters for it. |
118 |
if not os.path.exists(directory): |
4115.1.1
by Celso Providelo
Fix #107068 (os.makedirs is creating world-writable directories in archive). Now we simply force '0755' despite of the local environment umask. |
119 |
os.makedirs(directory, 0755) |