3 # Output html for packages in NEW
4 # Copyright (C) 2007 Joerg Jaspert <joerg@debian.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ################################################################################
22 # <elmo> I'm James Troup, long term source of all evil in Debian. you may
23 # know me from such debian-devel-announce gems as "Serious
26 ################################################################################
28 import copy, os, sys, time
30 import examine_package
31 import daklib.database
43 ################################################################################
44 ################################################################################
45 ################################################################################
47 def html_header(name):
48 if name.endswith('.changes'):
49 name = ' '.join(name.split('_')[:2])
50 print """<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
51 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">"""
52 print "<title>%s - Debian NEW package overview</title>" % (name)
53 print """<link type="text/css" rel="stylesheet" href="/style.css">
54 <link rel="shortcut icon" href="http://www.debian.org/favicon.ico">
58 <a href="http://www.debian.org/">
59 <img src="http://www.debian.org/logos/openlogo-nd-50.png" border="0" hspace="0" vspace="0" alt=""></a>
60 <a href="http://www.debian.org/">
61 <img src="http://www.debian.org/Pics/debian.png" border="0" hspace="0" vspace="0" alt="Debian Project"></a>
64 <table class="reddy" width="100%">
67 <img src="http://www.debian.org/Pics/red-upperleft.png" align="left" border="0" hspace="0" vspace="0"
68 alt="" width="15" height="16"></td>"""
69 print """<td rowspan="2" class="reddy">Debian NEW package overview for %s</td>""" % (name)
70 print """<td class="reddy">
71 <img src="http://www.debian.org/Pics/red-upperright.png" align="right" border="0" hspace="0" vspace="0"
72 alt="" width="16" height="16"></td>
76 <img src="http://www.debian.org/Pics/red-lowerleft.png" align="left" border="0" hspace="0" vspace="0"
77 alt="" width="16" height="16"></td>
79 <img src="http://www.debian.org/Pics/red-lowerright.png" align="right" border="0" hspace="0" vspace="0"
80 alt="" width="15" height="16"></td>
86 print "<p class=\"validate\">Timestamp: %s (UTC)</p>" % (time.strftime("%d.%m.%Y / %H:%M:%S", time.gmtime()))
87 print """<a href="http://validator.w3.org/check?uri=referer">
88 <img border="0" src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" height="31" width="88"></a>
89 <a href="http://jigsaw.w3.org/css-validator/check/referer">
90 <img border="0" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!"
91 height="31" width="88"></a>
93 print "</body></html>"
96 ################################################################################
99 def do_pkg(changes_file):
100 Upload.pkg.changes_file = changes_file
103 files = Upload.pkg.files
104 changes = Upload.pkg.changes
106 changes["suite"] = copy.copy(changes["distribution"])
108 # Find out what's new
109 new = daklib.queue.determine_new(changes, files, projectB, 0)
111 stdout_fd = sys.stdout
113 htmlname = changes["source"] + "_" + changes["version"] + ".html"
114 sources.add(htmlname)
115 # do not generate html output if that source/version already has one.
116 if not os.path.exists(os.path.join(Cnf["Show-New::HTMLPath"],htmlname)):
117 sys.stdout = open(os.path.join(Cnf["Show-New::HTMLPath"],htmlname),"w")
118 html_header(changes["source"])
120 daklib.queue.check_valid(new)
121 examine_package.display_changes(Upload.pkg.changes_file)
123 for pkg in new.keys():
124 for file in new[pkg]["files"]:
125 if ( files[file].has_key("new") and not
126 files[file]["type"] in [ "orig.tar.gz", "orig.tar.bz2", "tar.gz", "tar.bz2", "diff.gz", "diff.bz2"] ):
127 if file.endswith(".deb") or file.endswith(".udeb"):
128 examine_package.check_deb(file)
129 elif file.endswith(".dsc"):
130 examine_package.check_dsc(file)
133 if sys.stdout != stdout_fd:
135 sys.stdout = stdout_fd
137 ################################################################################
139 def usage (exit_code=0):
140 print """Usage: dak show-new [OPTION]... [CHANGES]...
141 -h, --help show this help and exit.
145 ################################################################################
148 global Cnf, Options, Upload, projectB
150 Cnf = daklib.utils.get_conf()
152 Arguments = [('h',"help","Show-New::Options::Help")]
155 if not Cnf.has_key("Show-New::Options::%s" % (i)):
156 Cnf["Show-New::Options::%s" % (i)] = ""
158 changes_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv)
159 Options = Cnf.SubTree("Show-New::Options")
164 Upload = daklib.queue.Upload(Cnf)
166 projectB = Upload.projectB
171 ################################################################################
172 ################################################################################
175 changes_files = init()
177 examine_package.use_html=1
179 for changes_file in changes_files:
180 changes_file = daklib.utils.validate_changes_file_arg(changes_file, 0)
183 print "\n" + changes_file
184 do_pkg (changes_file)
185 files = set(os.listdir(Cnf["Show-New::HTMLPath"]))
186 to_delete = files.difference(sources)
187 for file in to_delete:
188 os.remove(os.path.join(Cnf["Show-New::HTMLPath"],file))
190 ################################################################################
192 if __name__ == '__main__':