| 1 |
#!/usr/bin/python
|
| 2 |
# -*- coding: utf-8 -*-
|
| 3 |
|
| 4 |
# Make sure tabs expand to 8 spaces in vim
|
| 5 |
# vim: expandtab
|
| 6 |
|
| 7 |
# Copyright 2002 Raphaƫl Hertzog
|
| 8 |
# This file is distributed under the terms of the General Public License
|
| 9 |
# version 2 or (at your option) any later version.
|
| 10 |
|
| 11 |
import os, os.path, sys, email, common
|
| 12 |
|
| 13 |
from config import dir, odir, root
|
| 14 |
from common import hash_name
|
| 15 |
|
| 16 |
os.nice(19)
|
| 17 |
os.umask(0002)
|
| 18 |
os.environ["PATH"] = "/bin:/sbin:/usr/bin:/usr/sbin"
|
| 19 |
|
| 20 |
msg = email.message_from_file(sys.stdin)
|
| 21 |
|
| 22 |
info = common.extract_info(msg)
|
| 23 |
|
| 24 |
subdir = "news"
|
| 25 |
if info.has_key("static") or (len(sys.argv) >= 2 and sys.argv[1] == "static"):
|
| 26 |
subdir = "static"
|
| 27 |
|
| 28 |
if info.has_key("package"):
|
| 29 |
pkg = info["package"]
|
| 30 |
hash = hash_name(pkg)
|
| 31 |
srcdir = "%s/base/%s/%s" % (root, hash, pkg)
|
| 32 |
if not os.path.isdir(srcdir):
|
| 33 |
sys.exit("Invalid source package: %s" % pkg)
|
| 34 |
outdir = srcdir + "/" + subdir
|
| 35 |
htmldir = "%s/web/%s/%s/%s" % (root, hash, pkg, subdir)
|
| 36 |
common.save_msg_in_dir(msg, outdir)
|
| 37 |
# Synchronize the XML document
|
| 38 |
f = os.popen("%s/bin/update_news.py" % root, "w")
|
| 39 |
f.write(pkg+"\n")
|
| 40 |
f.close()
|
| 41 |
# Regenerate the HTML page
|
| 42 |
f = os.popen("%s/bin/generate_html.sh" % root, "w")
|
| 43 |
f.write(pkg+"\n")
|
| 44 |
f.close()
|
| 45 |
else:
|
| 46 |
# We should give a meaningful error here but we don't
|
| 47 |
# because it generates backscatter on the spam received
|
| 48 |
# on the aliases
|
| 49 |
sys.exit(0)
|