~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
= Debian Installer Custom Uploads =

Debian Installer uploads are treated as one of the Soyuz "custom"
types.

They come from buildd as result of the 'debian-installer' source
build. This binary upload usually contains:

 * The debian-installer binaries (DEB)
 * The debian-installer translation (TAR.GZ, custom ROSETTA_TRANSLATIONS)
 * The debian-installer special archive files (TAR.GZ, custom DEBIAN_INSTALLER)

We have a special processor to publish debian-installer special archive
file contents.

The debian-installer filename should be something like:

<BASE>_<VERSION>_<ARCH>.tar.gz

Where:

 * BASE: base name (usually 'debian-installer-images')

 * VERSION: encoded version (something like '20061102ubuntu14')
   * if the version string contains '.0.' we assume it is a
     'daily-installer', otherwise, it is a normal 'installer'

 * ARCH: targeted architecture tag ('i386', 'amd64', etc)

The contents are extracted in the archive, respecting its type
('installer' or 'daily-installer'), in the following path:

 * <ARCHIVE>/dists/<SUITE>/main/<TYPE>-<ARCH>/


Let's try one test upload and verify the results of its publication.
In order to keep the tests simple we will upload only the
debian-installer tarball, despite the fact that it's very unlikely to
happen in production:

  >>> from lp.testing.gpgkeys import import_public_test_keys
  >>> import_public_test_keys()
  >>> login('foo.bar@canonical.com')

  >>> from lp.registry.interfaces.distribution import IDistributionSet
  >>> ubuntutest = getUtility(IDistributionSet)['ubuntutest']

  >>> from lp.archiveuploader.nascentupload import NascentUpload
  >>> from lp.archiveuploader.tests import datadir, getPolicy

  >>> anything_policy = getPolicy(
  ...     name='anything', distro='ubuntutest', distroseries=None)
  >>> anything_policy.setDistroSeriesAndPocket('hoary-test')

Set the email address for annoucements emails:

  >>> anything_policy.distroseries.changeslist = 'announce@example.com'

  >>> from lp.services.log.logger import DevNullLogger
  >>> upload = NascentUpload.from_changesfile_path(
  ...     datadir(
  ...       'debian-installer/debian-installer_20070214ubuntu1_i386.changes'),
  ...     anything_policy, DevNullLogger())
  >>> upload.process()
  >>> success = upload.do_accept()
  >>> success
  True

Upload was successfully 'processed' and 'accepted'. Two email messages
were generated (acceptance and announcement). Inspect the queue (IDRQ)
information we find out that it contains one custom upload.

  >>> upload.queue_root.status.name
  'ACCEPTED'

Make librarian files available for publication:

  >>> import transaction
  >>> transaction.commit()

  >>> from lp.services.mail import stub
  >>> len(stub.test_emails)
  2
  >>> upload.queue_root.customfiles.count()
  1

Let's force an error simulating a conflict in archive:

  >>> import os
  >>> archive_path = "/var/tmp/archive/"
  >>> installer_path = os.path.join(
  ...     archive_path, "ubuntutest/dists/hoary-test/main/installer-i386")

  >>> os.makedirs(os.path.join(installer_path, '20070214ubuntu1'))

Try to publish the custom upload, but it will be skipped due the disk
conflict and the queue item will remain in ACCEPTED

  >>> from lp.services.log.logger import FakeLogger
  >>> pub_records = upload.queue_root.realiseUpload(FakeLogger())
  DEBUG Publishing custom debian-installer-images_20070214ubuntu1_i386.tar.gz to ubuntutest/hoary-test
  ERROR Queue item ignored: installer build i386 for architecture 20070214ubuntu1 already exists
  >>> upload.queue_root.status.name
  'ACCEPTED'

Let's remove the conflicted directory from disk and expect it to work
next time:

  >>> os.rmdir(os.path.join(installer_path, '20070214ubuntu1'))

The upload task requires that the umask be 022, otherwise things will end up
with the wrong permission.

  >>> old_mask = os.umask(002)
  >>> pub_records = upload.queue_root.realiseUpload(FakeLogger())
  DEBUG ...
  ERROR Queue item ignored: Bad umask; expected 022, got 002

Reset the umask, remove any residual directories, and try again.

  >>> os.rmdir(os.path.join(installer_path, '20070214ubuntu1'))
  >>> print '%03o' % os.umask(old_mask)
  002

Process (publish) the custom upload:

  >>> pub_records = upload.queue_root.realiseUpload(DevNullLogger())
  >>> upload.queue_root.status.name
  'DONE'

The current debian-installer directory (20070214ubuntu1) and a link to
the last version (we only have the one we uploaded) should be
presented:

  >>> sorted(os.listdir(installer_path))
  ['20070214ubuntu1', 'current']

As a consistency check, let's verify one of the files inside the
tarball:

  >>> the_file = ("current/images/netboot/ubuntu-installer/i386/"
  ...             "pxelinux.cfg.serial-9600/default")
  >>> the_file_path = os.path.join(installer_path, the_file)
  >>> print open(the_file_path).read()
  hey

Also check if the symbolic link included in the installer tarball
looks sane:

  >>> the_link = "current/images/netboot/foo"
  >>> the_link_path = os.path.join(installer_path, the_link)
  >>> os.readlink(the_link_path)
  'ubuntu-installer/i386/pxelinux.cfg.serial-9600/default'

  >>> the_dir_link = "current/images/netboot/link_to_dir"
  >>> the_dir_link_path = os.path.join(installer_path, the_dir_link)
  >>> os.readlink(the_dir_link_path)
  'ubuntu-installer/i386/pxelinux.cfg.serial-9600/'

Check permissions on the created directories to satisfy the
publication path. They are created with os.makedirs() and forced to
set permission '0755' instead of the default '0777' (see further
details in bug #107068):

  >>> oct(os.stat(installer_path).st_mode & 0777)
  '0755'

  >>> the_path = os.path.join(installer_path, os.pardir)
  >>> oct(os.stat(the_path).st_mode & 0777)
  '0755'

Check permissions of created files and directories:

  >>> the_file = ("current/images/netboot/ubuntu-installer/i386/"
  ...             "pxelinux.cfg.serial-9600/default")
  >>> the_file_path = os.path.join(installer_path, the_file)
  >>> oct(os.stat(the_file_path).st_mode & 0777)
  '0644'

  >>> the_dir = ("current/images/netboot/ubuntu-installer/i386/"
  ...            "pxelinux.cfg.serial-9600/")
  >>> the_dir_path = os.path.join(installer_path, the_dir)
  >>> oct(os.stat(the_dir_path).st_mode & 0777)
  '0755'


Remove local archive contents:

  >>> import shutil
  >>> shutil.rmtree(archive_path)