-
Notifications
You must be signed in to change notification settings - Fork 9
/
webkit-release
executable file
·795 lines (645 loc) · 28.4 KB
/
webkit-release
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
#!/usr/bin/env python3
import tarfile
import re
import errno, os, re, sys
import lzma
import shutil
import subprocess
import tempfile
from datetime import date
def human_size(size):
for x in ['bytes','KB','MB','GB','TB']:
if size < 1024.0:
return "%3.1f%s" % (size, x)
size /= 1024.0
return None
def hexdigest(fd, h):
f = open(fd, 'rb')
retval = h(f.read()).hexdigest()
f.close()
return retval
# Copied from git://git.gnome.org/sysadmin-bin/ftpadmin
# to support xz tarballs
class _LZMAProxy:
"""Small proxy class that enables external file object
support for "r:lzma" and "w:lzma" modes. This is actually
a workaround for a limitation in lzma module's LZMAFile
class which (unlike gzip.GzipFile) has no support for
a file object argument.
"""
blocksize = 16 * 1024
def __init__(self, fileobj, mode):
self.fileobj = fileobj
self.mode = mode
self.name = getattr(self.fileobj, "name", None)
self.init()
def init(self):
self.pos = 0
if self.mode == "r":
self.lzmaobj = lzma.LZMADecompressor()
self.fileobj.seek(0)
self.buf = ""
else:
self.lzmaobj = lzma.LZMACompressor()
def read(self, size):
b = [self.buf]
x = len(self.buf)
while x < size:
raw = self.fileobj.read(self.blocksize)
if not raw:
break
try:
data = self.lzmaobj.decompress(raw)
except EOFError:
break
b.append(data)
x += len(data)
self.buf = "".join(b)
buf = self.buf[:size]
self.buf = self.buf[size:]
self.pos += len(buf)
return buf
def seek(self, pos):
if pos < self.pos:
self.init()
self.read(pos - self.pos)
class XzTarFile(tarfile.TarFile):
OPEN_METH = tarfile.TarFile.OPEN_METH.copy()
OPEN_METH["xz"] = "xzopen"
@classmethod
def xzopen(cls, name, mode="r", fileobj=None, **kwargs):
"""Open gzip compressed tar archive name for reading or writing.
Appending is not allowed.
"""
if len(mode) > 1 or mode not in "rw":
raise ValueError("mode must be 'r' or 'w'")
if fileobj is not None:
fileobj = _LMZAProxy(fileobj, mode)
else:
fileobj = lzma.LZMAFile(name, mode)
try:
# lzma doesn't immediately return an error
# try and read a bit of data to determine if it is a valid xz file
fileobj.read(_LZMAProxy.blocksize)
fileobj.seek(0)
t = cls.taropen(name, mode, fileobj, **kwargs)
except IOError:
raise tarfile.ReadError("not a xz file")
except lzma.error:
raise tarfile.ReadError("not a xz file")
t._extfileobj = False
return t
if not hasattr(tarfile.TarFile, 'xvopen'):
tarfile.open = XzTarFile.open
class WebKitTarball:
def __init__(self, tarball):
self._tarball = tarball
self._size = None
self._sha256sum = None
self._md5sum = None
self._sha1sum = None
self._tar = tarfile.open(tarball)
self._basedir = self._tar.getmembers()[0].name.split(os.path.sep)[0]
self._api = None
self._parse_versions()
def _parse_versions_cmake(self, versions):
versions_file = self._tar.extractfile(versions)
version_pattern = re.compile('^SET_PROJECT_VERSION\(([0-9]+) ([0-9]+) ([0-9]+) ?([0-9]+)?\)$');
self._required_deps = []
for line in versions_file.readlines():
line = line.decode('utf-8').strip(' \t\n')
if not line:
continue
if self._major is None:
match = version_pattern.match(line)
if match:
self._major = int(match.group(1))
self._minor = int(match.group(2))
self._micro = int(match.group(3))
patch = match.group(4)
if patch is not None:
self._patch = int(patch)
versions_file.close()
def _parse_versions(self):
self._minimum_versions = {}
self._major = self._minor = self._micro = self._patch = self._api = None
versions = self._tar.getmember(os.path.join(self._basedir, 'Source', 'cmake', 'OptionsGTK.cmake'))
self._parse_versions_cmake(versions)
def delete(self):
os.unlink(self._tarball)
self._tarball = None
def is_patched(self):
return self._patch is not None
def get_version(self):
if self.is_patched():
return self._major, self._minor, self._micro, self._patch
return self._major, self._minor, self._micro, 0
def get_api_version(self):
if self._api is not None:
return self._api
for module_name in ["webkitgtk", "webkit2gtk"]:
docdir = os.path.join(self._basedir, "Documentation", module_name + "-")
for api_version in ["6.0", "4.1", "4.0"]:
versioned_docdir = docdir + api_version
for html_dir in ["", "html"]:
docfile = os.path.join(versioned_docdir, html_dir, "index.html")
try:
self._tar.getmember(docfile)
self._api = api_version
return self._api
except KeyError:
continue
return None
def get_version_str(self):
version_str = "%d.%d.%d" % (self._major, self._minor, self._micro)
if self.is_patched():
version_str += ".%d" % self._patch
return version_str
def is_stable(self):
return self._minor % 2 == 0
def is_unstable(self):
return not self.is_stable()
def get_tarball(self):
return self._tarball
def get_name(self):
return os.path.basename(self._tarball)
def get_path(self):
return self._tarball
def get_size(self):
if self._size is None:
stat = os.stat(self._tarball)
self._size = stat.st_size
return self._size
def get_sha256sum(self):
if self._sha256sum is None:
from hashlib import sha256
self._sha256sum = hexdigest(self._tarball, sha256)
return self._sha256sum
def get_md5sum(self):
if self._md5sum is None:
from hashlib import md5
self._md5sum = hexdigest(self._tarball, md5)
return self._md5sum
def get_sha1sum(self):
if self._sha1sum is None:
from hashlib import sha1
self._sha1sum = hexdigest(self._tarball, sha1)
return self._sha1sum
def get_news(self):
retval = []
news = self._tar.getmember(os.path.join(self._basedir, 'NEWS'))
news_file = self._tar.extractfile(news)
separator = re.compile("^=+$")
n_separator = 0
ignore_next = False
ignore_empty = True
for line in news_file.readlines():
line = line.decode('utf-8')
if ignore_empty and not line.strip(' \n'):
continue
if ignore_next:
ignore_next = False
continue
if separator.match(line.strip()):
n_separator += 1
if n_separator == 1:
ignore_next = True
elif n_separator == 3:
break
continue
if line.strip().startswith("What's new in WebKitGTK"):
ignore_empty = False
continue
retval.append(line)
news_file.close()
return retval
def extract_docs(self, path, html_dir):
docdir = os.path.join(self._basedir, html_dir)
print("Extract docs from %s to %s" % (docdir, path))
for member in self._tar.getmembers():
if not os.path.dirname(member.name) == docdir:
continue
source = self._tar.extractfile(member)
dest = open(os.path.join(path, os.path.basename(member.name)), 'w+b')
dest.write(source.read())
dest.close()
source.close()
class WebKitRelease:
WK1_PKG_NAME = "webkitgtk"
WK2_PKG_NAME = "webkit2gtk"
WK_PKG_NAME = "webkitgtk"
WK2WE_PKG_NAME = "webkit2gtk-web-extension"
WKWE_PKG_NAME = "webkitgtk-web-process-extension"
WKDOM_PKG_NAME = "webkitdomgtk"
JSC_PKG_NAME = "jsc-glib"
RELEASE_BASE_URL = "https://webkitgtk.org/releases/"
ONLINE_DOCS_BASE_URL = "http://developer.gnome.org"
def __init__(self, tarball):
self._tarball = WebKitTarball(tarball)
def _get_release_description(self):
major, minor, micro, patch = self._tarball.get_version()
is_stable = self._tarball.is_stable()
description = "This is "
if micro == 1 or micro == 0:
description += "the first "
else:
description += "a "
if is_stable:
if micro == 0:
description += "stable release in the "
else:
description += "bug fix release in the stable "
else:
description += "development release leading toward "
if is_stable:
description += "%d.%d series.\n" % (major, minor)
else:
description += "%d.%d series.\n" % (major, minor + 1)
return description
def _get_announcement_text(self):
body = ''
version = self._tarball.get_version_str()
# Header
body += "WebKitGTK %s is available for download at:\n" % version
body += "\n"
body += "%s%s (%s)\n" % (self.RELEASE_BASE_URL, self._tarball.get_name(), human_size(self._tarball.get_size()))
body += " md5sum: %s\n" % (self._tarball.get_md5sum())
body += " sha1sum: %s\n" % (self._tarball.get_sha1sum())
body += " sha256sum: %s\n" % (self._tarball.get_sha256sum())
body += "\n"
body += self._get_release_description()
body += "\n"
# NEWS
whatsnew = "What's new in the WebKitGTK %s release?\n" % version
body += whatsnew
body += "=" * (len(whatsnew) - 1)
body += "\n"
body += "".join(self._tarball.get_news())
# What's WebKitGTK
whatswkgtk = "What is WebKitGTK?\n"
body += whatswkgtk
body += "=" * (len(whatswkgtk) - 1)
body += "\n"
body += '''
WebKitGTK is the GNOME platform port of the WebKit rendering engine.
Offering WebKit's full functionality through a set of GObject-based
APIs, it is suitable for projects requiring any kind of web
integration, from hybrid HTML/CSS applications to full-fledged web
browsers.
'''
body += "\n"
# More info
morinfo = "More information\n"
body += morinfo
body += "=" * (len(morinfo) - 1)
body += "\n"
body +='''
If you want to know more about the project or get in touch with us
you may:
- Visit our website at https://www.webkitgtk.org or the upstream
site at https://www.webkit.org - people interested in contributing
should read: https://www.webkit.org/coding/contributing.html.
- Browse the bug list at https://bugs.webkit.org
WebKitGTK bugs are typically prefixed by "[GTK]." A bug report with
a minimal, reproducible test case is often just as valuable as a patch.
- Join the #webkitgtk:matrix.org Matrix channel.
- Subscribe to the WebKitGTK mailing list,
https://lists.webkit.org/mailman/listinfo/webkit-gtk or the
WebKit development mailing list,
https://lists.webkit.org/mailman/listinfo/webkit-dev
'''
body += "\n"
# Thanks
thanks = "Thanks\n"
body += thanks
body += "=" * (len(thanks) - 1)
body += "\n"
#FIXME: are they really so many to list?
body += '''
Thanks to all the contributors who made possible this release, they
are far too many to list!
'''
body += "\n"
# Footer
body += "The WebKitGTK team,\n"
body += date.strftime(date.today(), "%B %d, %Y")
body += "\n"
return body
def print_announcement(self):
sys.stdout.write("\n")
sys.stdout.write("============================== CUT HERE ==============================\n")
sys.stdout.write(self._get_announcement_text())
sys.stdout.write("============================== CUT HERE ==============================\n")
sys.stdout.write("\n")
sys.stdout.flush()
def _rebase_docs(self, docdir, wk_pkg):
subs = {}
xref_map = {
'jsc-glib-4.0' : 'jsc-glib',
'libsoup-2.4' : 'libsoup',
'webkit2gtk-4.0' : 'webkit2gtk',
'webkitdomgtk-4.0' : 'webkitdomgtk'
}
def rebase_link(match):
href = match.group(1)
if not href.startswith('../'):
return '<a href="%s' % href
match = re.search(r'^\.\./(.*)/([^/]+)', href)
if not match:
return '<a href="%s' % href
try:
module = xref_map[match.group(1)]
except KeyError:
module = match.group(1)
if module in [WebKitRelease.JSC_PKG_NAME, WebKitRelease.WKDOM_PKG_NAME]:
sub = '%s -> ../../%s/%s/' % (match.group(1), module, os.path.basename(docdir))
else:
sub = '%s -> %s/%s/stable/' % (match.group(1), WebKitRelease.ONLINE_DOCS_BASE_URL, module)
subs.setdefault(sub, 0)
subs[sub] += 1
if module in [WebKitRelease.JSC_PKG_NAME, WebKitRelease.WKDOM_PKG_NAME]:
return '<a href="../../%s/%s/%s' % (module, os.path.basename(docdir), match.group(2))
return '<a href="%s/%s/stable/%s' % (WebKitRelease.ONLINE_DOCS_BASE_URL, module, match.group(2))
for filename in os.listdir(docdir):
if not filename.endswith('.html'):
continue
path = os.path.join(docdir, filename)
tmp_file = tempfile.NamedTemporaryFile(mode="w", delete=False)
fd = open(path, 'r')
tmp_file.write(re.sub(r'<a href=[\'"]?([^\'" >]+)', rebase_link, fd.read()))
fd.close()
tmp_file.close()
mode = os.stat(path).st_mode
shutil.move(tmp_file.name, path)
os.chmod(path, mode)
for sub in subs:
sys.stdout.write("%s (%d)\n" % (sub, subs[sub]))
def _create_doc_tarball(self, docdir, tar_path):
tar = tarfile.open(tar_path, 'w:gz')
basedir = os.path.splitext(os.path.splitext(os.path.basename(tar_path))[0])[0]
for f in os.listdir(docdir):
# Don't include tgz symlink of a previous run
if f == 'webkitgtk-html.tar.gz':
continue
file_path = os.path.join(docdir, f)
member = tar.gettarinfo(file_path, '%s/%s' % (basedir, f))
tar.addfile(member, open(file_path, "r+b"))
tar.close()
def _get_doc_pkg_names(self):
pkg_names = []
api_version = self._tarball.get_api_version()
major, minor, micro, patch = self._tarball.get_version()
# DOM Bindings API docs were introduced in 2.3 and removed in 2.37
if major == 2 and (minor >= 3 and minor < 2.37):
pkg_names.append(self.WKDOM_PKG_NAME)
# WebKit1 was removed in 2.5
if major <= 2 and minor < 5:
pkg_names.append(self.WK1_PKG_NAME)
# JSC API docs were introduced in 2.21.
if major > 2 or (major == 2 and minor >= 21):
pkg_names.append(self.JSC_PKG_NAME)
# WebExtension API docs have its own moduel since 2.37.
if major > 2 or (major == 2 and minor >= 37):
if api_version == '6.0':
pkg_names.append(self.WKWE_PKG_NAME)
else:
pkg_names.append(self.WK2WE_PKG_NAME)
if api_version == '6.0':
pkg_names.append(self.WK_PKG_NAME)
else:
pkg_names.append(self.WK2_PKG_NAME)
return pkg_names
def _get_versioned_pkg_name(self, pkg_name):
api_version = self._tarball.get_api_version()
if api_version is None:
return pkg_name
return pkg_name + '-' + api_version
def install_docs(self, docs_dir):
version = self._tarball.get_version_str()
# gi-docgen is used since version 2.37.
major, minor, micro, patch = self._tarball.get_version()
is_gi_docgen = major > 2 or (major == 2 and minor >= 37)
for wk_pkg in self._get_doc_pkg_names():
docdir = os.path.join(docs_dir, wk_pkg, version)
try:
os.makedirs(docdir)
except OSError as e:
if e.errno != errno.EEXIST:
raise
html_dir = os.path.join("Documentation", self._get_versioned_pkg_name(wk_pkg))
if not is_gi_docgen:
html_dir = os.path.join(html_dir, "html")
self._tarball.extract_docs(docdir, html_dir)
if not is_gi_docgen:
self._rebase_docs(docdir, wk_pkg)
doc_tarball = os.path.join(os.path.dirname(docdir), wk_pkg + "-html-" + version + ".tar.gz")
self._create_doc_tarball(docdir, doc_tarball)
# Create symlinks
if self._tarball.is_stable():
symlink = os.path.join(os.path.dirname(docdir), "stable")
else:
symlink = os.path.join(os.path.dirname(docdir), "unstable")
if os.path.islink(symlink):
if os.readlink(symlink) != version:
os.unlink(symlink)
try:
os.symlink(version, symlink)
except OSError as e:
if e.errno != errno.EEXIST:
raise
symlink = os.path.join(docdir, "%s-html.tar.gz" % (wk_pkg))
try:
os.symlink(os.path.join(os.path.pardir, os.path.basename(doc_tarball)), symlink);
except OSError as e:
if e.errno != errno.EEXIST:
raise
def install_tarball(self, host, releases_dir, update_symlinks):
tarball_name = self._tarball.get_name()
command = ['ssh', host, 'test ! -e %s/%s' % (releases_dir, tarball_name)]
if subprocess.call(command) != 0:
sys.stderr.write("Found: %s:%s/%s. This should never happen\n" % (host, releases_dir, tarball_name))
sys.exit(1)
tarball_file = self._tarball.get_tarball()
# Create the news file.
news_file = tarball_file + ".news"
tmp = tempfile.NamedTemporaryFile(mode="w", delete=False)
whatsnew = "What's new in the WebKitGTK %s release?\n" % self._tarball.get_version_str()
tmp.write(whatsnew)
tmp.write("%s\n" % ("=" * (len(whatsnew) - 1)))
tmp.write("%s\n" % ("".join(self._tarball.get_news())))
tmp.close()
shutil.move(tmp.name, news_file)
# Create the sums file.
sums_file = tarball_file + ".sums"
tmp = tempfile.NamedTemporaryFile(mode="w", delete=False)
tmp.write("%s (%s)\n" % (self._tarball.get_name(), human_size(self._tarball.get_size())))
tmp.write(" md5sum: %s\n" % (self._tarball.get_md5sum()))
tmp.write(" sha1sum: %s\n" % (self._tarball.get_sha1sum()))
tmp.write(" sha256sum: %s\n" % (self._tarball.get_sha256sum()))
tmp.close()
shutil.move(tmp.name, sums_file)
# Sign the tarball file.
gpg_file = tarball_file + ".asc"
subprocess.call(['gpg', '--armor', '--detach-sign', tarball_file])
# Set same file perms as tarball to generated files.
mode = os.stat(tarball_file).st_mode
os.chmod(news_file, mode)
os.chmod(sums_file, mode)
os.chmod(gpg_file, mode)
# Upload the files.
command = ['scp', tarball_file, news_file, sums_file, gpg_file, '%s:%s' % (host, releases_dir)]
if subprocess.call(command) != 0:
sys.stderr.write("Error uploading %s to %s:%s\n" % (tarball_file, host, releases_dir))
sys.exit(1)
# Remove generated files.
os.unlink(news_file)
os.unlink(sums_file)
os.unlink(gpg_file)
if update_symlinks:
# Create the LATEST symlink.
if self._tarball.is_stable():
symlink_prefix = "LATEST-STABLE-"
generic_symlink = "webkitgtk-stable.tar.xz"
else:
symlink_prefix = "LATEST-UNSTABLE-"
generic_symlink = "webkitgtk-unstable.tar.xz"
latest = symlink_prefix + self._tarball.get_version_str()
command = ['ssh', host, 'rm -f %s/%s[0-9]* %s/%s && ln -s %s %s/%s && ln -s %s %s/%s' %
(releases_dir, symlink_prefix, releases_dir, generic_symlink, tarball_name, releases_dir, latest, tarball_name, releases_dir, generic_symlink)]
subprocess.call(command)
def _update_config_file(self, website_dir):
config_file = os.path.join(website_dir, "_config.yml")
is_stable = self._tarball.is_stable()
version = self._tarball.get_version_str()
fd = open(config_file, 'r')
tmp = tempfile.NamedTemporaryFile(mode="w", delete=False)
for line in fd.readlines():
if is_stable and line.startswith("stable-release-version:"):
tmp.write("stable-release-version: %s\n" % version)
elif not is_stable and line.startswith("unstable-release-version:"):
tmp.write("unstable-release-version: %s\n" % version)
else:
tmp.write(line)
fd.close()
tmp.close()
mode = os.stat(config_file).st_mode
shutil.move(tmp.name, config_file)
os.chmod(config_file, mode)
subprocess.call(['git', 'add', config_file])
def _add_new_docs(self, website_dir):
is_stable = self._tarball.is_stable()
version = self._tarball.get_version_str()
doc_dirs = [os.path.join(website_dir, "reference", pkg) for pkg in self._get_doc_pkg_names()]
if is_stable:
symlink_name = "stable"
else:
symlink_name = "unstable"
doc_files = [os.path.join(doc_dir, symlink_name) for doc_dir in doc_dirs]
doc_files.extend([os.path.join(doc_dir, os.path.basename(doc_dir) + "-html-" + version + ".tar.gz") for doc_dir in doc_dirs])
doc_files.extend([os.path.join(doc_dir, version) for doc_dir in doc_dirs])
subprocess.call(['git', 'add'] + doc_files)
def _write_post(self, website_dir):
def get_news():
news = ""
CVE_PATTERN = "(CVE-[0-9][0-9][0-9][0-9]-[0-9]+)"
CVE_BASE_URL = "https://cve.mitre.org/cgi-bin/cvename.cgi?name="
for line in self._tarball.get_news():
news += re.sub(CVE_PATTERN, lambda m: "[%s](%s%s)" % (m.group(1), CVE_BASE_URL, m.group(1)), line[1:])
return news
version = self._tarball.get_version_str()
post_name = date.strftime(date.today(), "%Y-%m-%d") + "-webkitgtk%s-released.md" % version
post_file = os.path.join(website_dir, "_posts", post_name)
post = "---\n"
post += "layout: post\n"
post += "title: WebKitGTK %s released!\n" % version
post += "---\n\n"
post += self._get_release_description()
post += "\n"
post += "### What's new in the WebKitGTK %s release?\n" % version
post += "\n"
post += get_news()
post += "\n"
post += "Thanks to all the contributors who made possible this release."
tmp = tempfile.NamedTemporaryFile(mode="w", delete=False)
tmp.write(post)
tmp.close()
shutil.move(tmp.name, post_file)
os.chmod(post_file, 0o644)
subprocess.call(['git', 'add', post_file])
def update_website(self, website_dir):
self._update_config_file(website_dir)
self._add_new_docs(website_dir)
self._write_post(website_dir)
p = subprocess.Popen(['git', 'commit', '-m', "Release: %s" % self._tarball.get_version_str()], stdout=subprocess.PIPE)
if p.wait() == 0:
sys.stdout.write("Website changes committed, run git push to update the website\n")
def release(self, delete, host, releases_dir, update_symlinks, docs_dir, website_dir):
sys.stdout.write("Releasing WebKitGTK %s\n" % self._tarball.get_version_str())
sys.stdout.write("Installing tarball %s to %s:%s\n" % (self._tarball.get_name(), host, releases_dir))
self.install_tarball(host, releases_dir, update_symlinks)
sys.stdout.write("\n")
sys.stdout.write("Intalling API documentation\n")
self.install_docs(docs_dir)
sys.stdout.write("\n")
sys.stdout.write("Updating website\n")
self.update_website(website_dir)
sys.stdout.write("\n")
sys.stdout.write("Generating announcement email\n")
self.print_announcement()
sys.stdout.write("\n")
if delete:
sys.stdout.write("Deleting tarball %s\n" % self._tarball.get_name())
self._tarball.delete()
sys.stdout.write("WebKitGTK %s succesfully released\n" % self._tarball.get_version_str())
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(
prog = 'webkit-release',
usage = '%(prog)s [options ...] command [command-options ...] tarball')
subparsers = parser.add_subparsers(dest = 'command')
subparser = subparsers.add_parser('install-tarball', help = 'Install sources tarball')
subparser.add_argument('--host', dest = 'host', default = 'localhost',
help = 'Host to upload the tarball')
subparser.add_argument('--releases-dir', dest = 'releases-dir', default = '/var/www/webkitgtkdotorg/releases',
help = 'Directory to upload the tarball')
subparser.add_argument('--no-symlinks', action = 'store_true', dest = 'no-update-symlinks', default = False,
help = 'Do not update the LATEST symlinks')
subparser.add_argument('tarball')
subparser = subparsers.add_parser('install-docs', help = 'Install API documentation')
subparser.add_argument('--docs-dir', dest = 'docs-dir', default = 'reference',
help = 'Directory to install the docs')
subparser.add_argument('tarball')
subparser = subparsers.add_parser('update-website', help = 'Update website')
subparser.add_argument('--website-dir', dest = 'website-dir', default = '.',
help = 'Website directory [.]')
subparser.add_argument('tarball')
subparser = subparsers.add_parser('print-announcement', help = 'Print annoucement email')
subparser.add_argument('tarball')
subparser = subparsers.add_parser('release', help = 'Release a new tarball')
subparser.add_argument('--no-delete', action = 'store_true', dest = 'no-delete', default = False,
help = 'Do not delete the tarball file after successfully released')
subparser.add_argument('--host', dest = 'host', default = 'localhost',
help = 'Host to upload the tarball')
subparser.add_argument('--releases-dir', dest = 'releases-dir', default = '/var/www/webkitgtkdotorg/releases',
help = 'Directory to upload the tarball')
subparser.add_argument('--no-symlinks', action = 'store_true', dest = 'no-update-symlinks', default = False,
help = 'Do not update the LATEST symlinks')
subparser.add_argument('--docs-dir', dest = 'docs-dir', default = 'reference',
help = 'Directory to install the docs')
subparser.add_argument('--website-dir', dest = 'website-dir', default = '.',
help = 'Website directory [.]')
subparser.add_argument('tarball')
ns = parser.parse_args()
options = vars(ns)
command = options['command']
wk = WebKitRelease(options['tarball'])
if command == 'print-announcement':
wk.print_announcement()
elif command == 'install-docs':
wk.install_docs(options['docs-dir'])
elif command == 'install-tarball':
wk.install_tarball(options['host'], options['releases-dir'], not options['no-update-symlinks'])
elif command == 'update-website':
wk.update_website(options['website-dir'])
elif command == 'release':
wk.release(not options['no-delete'], options['host'], options['releases-dir'], not options['no-update-symlinks'], options['docs-dir'], options['website-dir'])