annotate www/build-www.py @ 2668:67c5fe4fd3f0 octave-forge

Use alphabetic contents of package rather than categories page that might include functions from octaev itself
author adb014
date Thu, 12 Oct 2006 20:27:30 +0000
parents 4ea46b848cf2
children 3f938458f716
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
1 #!/usr/bin/env python
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
2
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
3 import sys
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
4 import os
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
5 import shutil
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
6 import time
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
7
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
8 ## This function parses a DESCRIPTION file
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
9 def parse_description(filename):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
10 try:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
11 fid = open(filename, 'r');
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
12 keyword = "";
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
13 desc = {};
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
14 line = fid.readline();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
15 while (line != ""):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
16 ## Comments
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
17 if (line[0] == "#"):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
18 # Do nothing
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
19 print("Skip");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
20 ## Continuation lines
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
21 elif (line[0].isspace()):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
22 if (keyword != "" & desc.has_key(keyword)):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
23 desc[keyword] += line;
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
24 ## Keyword/value pair
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
25 else:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
26 colon = line.find(":");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
27 if (colon == -1):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
28 print "Skipping line";
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
29 else:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
30 keyword = line[0:colon].strip().lower();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
31 value = line[colon+1:];
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
32 if (len(value) == 0):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
33 print("The keyword " + keyword + " has an empty value\n.");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
34 fid.close();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
35 return;
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
36 desc[keyword] = value.strip();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
37 line = fid.readline();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
38 fid.close();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
39 return desc;
2573
dfef43367689 Fixed various INDEX files
hauberg
parents: 2558
diff changeset
40 except Exception, e:
dfef43367689 Fixed various INDEX files
hauberg
parents: 2558
diff changeset
41 print(e);
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
42 print("Couldn't parse the DESCRIPTION file " + filename);
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
43 raise
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
44
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
45 def local_documentation(outdir, packdir):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
46 try:
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
47 ## Copy any local documentation to packdir/local
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
48 cmd = 'find ' + packdir + ' -name "[hH][tT][mM][lL]" -type d -print; find ' + packdir + ' -name "[hH][tT][mM]" -type d -print'
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
49 docdir = None;
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
50 for file in os.popen(cmd).readlines():
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
51 name = file[:-1];
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
52 docdir = 1;
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
53 if (not os.path.exists(outdir + "/local")):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
54 os.mkdir(outdir + "/local");
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
55 for root, dirs, files in os.walk(name, topdown=False):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
56 for file2 in files:
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
57 shutil.copy2(root + "/" + file2, outdir + "/local/");
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
58
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
59 if (not docdir):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
60 cmd = 'find ' + packdir + ' -name "*.[hH][tT][mM][lL]" -print; find ' + packdir + ' -name "*.[hH][tT][mM]" -print'
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
61 for file in os.popen(cmd).readlines():
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
62 if (not os.path.exists(outdir + "/local")):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
63 os.mkdir(outdir + "/local");
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
64 name = file[:-1];
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
65 shutil.copy2(name, outdir + "/local/");
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
66
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
67 if (os.path.exists(outdir + "/local/index.html")):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
68 return "local/index.html";
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
69 elif (os.path.exists(outdir + "/local/index.htm")):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
70 return "local/index.htm";
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
71 elif (os.path.exists(outdir + "/local")):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
72 ## This could really be improved as it only returns the first
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
73 ## html page that find returns.
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
74 cmd2 = 'cd ' + outdir + '; find local -name "*.[hH][tT][mM][lL]" -print; find local -name "*.[hH][tT][mM]" -print';
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
75 for file in os.popen(cmd2).readlines():
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
76 name = file[:-1];
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
77 return name;
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
78 return None;
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
79 else:
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
80 return None;
2573
dfef43367689 Fixed various INDEX files
hauberg
parents: 2558
diff changeset
81 except Exception, e:
dfef43367689 Fixed various INDEX files
hauberg
parents: 2558
diff changeset
82 print(e);
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
83 print("Bad copy " + packdir);
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
84 return None;
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
85
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
86 def create_INDEX(desc, packdir, p):
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
87 try:
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
88 wd = os.getcwd();
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
89 name_version = desc['name'].lower() + "-" + desc['version'];
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
90
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
91 ## Create a tarball to be installed
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
92 install_dir = wd + "/install/";
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
93 tarball = name_version + ".tar.gz";
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
94 if (os.system("tar -zcf " + tarball + " -C " + packdir + "/.. " + p) != 0):
2517
b18fa83aa9c4 Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents: 2515
diff changeset
95 os.system("rm -rf " + tarball);
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
96 raise Exception("Can't create tarball");
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
97
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
98 ## Run octave installation
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
99 command = 'pkg("prefix","' + install_dir + '"); ';
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
100 command = command + 'pkg("install", "-nodeps", "' + tarball + '");';
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
101 if (os.system("HOME=" + wd + "; octave -H -q --no-site-file --no-init-file --eval '" + command + "' > /dev/null 2>&1") != 0):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
102 os.system("ls -la " + install_dir);
2517
b18fa83aa9c4 Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents: 2515
diff changeset
103 os.system("rm -rf " + install_dir + " " + tarball);
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
104 raise Exception("Can't run Octave");
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
105
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
106 ## Copy the INDEX file to local INDEX file
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
107 index = open(install_dir + name_version + "/packinfo/INDEX", "r");
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
108 local_index = open("INDEX","a");
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
109 local_index.writelines(index.readlines());
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
110 local_index.close();
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
111 index.close();
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
112
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
113 ## Clean up
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
114 command = 'pkg("prefix","' + install_dir + '"); ';
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
115 command = command + 'pkg("uninstall", "-nodeps", "' + desc['name'].lower() + '");';
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
116 if (os.system("HOME=" + wd + "; octave -H -q --no-site-file --no-init-file --eval '" + command + "' > /dev/null 2>&1") != 0):
2517
b18fa83aa9c4 Autogenerated INDEX files in build-www are now generated in a sandbox
hauberg
parents: 2515
diff changeset
117 os.system("rm -rf " + install_dir + " " + tarball);
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
118 raise Exception("Can't run Octave");
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
119 os.system("rm -rf " + install_dir + " " + tarball);
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
120 except:
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
121 raise;
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
122
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
123 ## Creates the index.html files for a package in packdir.
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
124 ## The result is placed in outdir.
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
125 def create_index_html(packdir, outdir, p):
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
126 try:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
127 desc = parse_description(packdir + "/DESCRIPTION");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
128 except:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
129 raise;
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
130
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
131 ## Write header
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
132 fid = open(outdir + "/index.in", "w");
2486
34d81b0e0600 Removed packages.in because it gets generated
hauberg
parents: 2468
diff changeset
133 fid.write("__HEADER__([[[The " + desc['name'] + " package]]])");
2497
f68cd4dab747 Just minor changes
hauberg
parents: 2486
diff changeset
134
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
135 ## Write important data
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
136 fid.write(' <table id="main_package_table">\n');
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
137 fid.write(' <tr><td>Package Name:</td><td>' + desc["name"] + "</td></tr>\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
138 fid.write(' <tr><td>Package Version:</td><td>' + desc["version"] + "</td></tr>\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
139 fid.write(' <tr><td>Last Release Date:</td><td>' + desc["date"] + "</td></tr>\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
140 fid.write(' <tr><td>Package Author:</td><td>' + desc["author"] + "</td></tr>\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
141 fid.write(' <tr><td>Package Maintainer:</td><td>' + desc["maintainer"] + "</td></tr>\n");
2497
f68cd4dab747 Just minor changes
hauberg
parents: 2486
diff changeset
142 fid.write(' <tr><td colspan="2"><img src="../download.png" alt="Download"/>');
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
143 fid.write('<a href="__PACKAGE__/' + desc['name'].lower() + '-' + desc['version'] + '.tar.gz?download">Download this package</a></td></tr>\n');
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
144 fid.write(' <tr><td colspan="2"><img src="../doc.png" alt="Function Reference"/>');
2668
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
145 fid.write('<a href="../doc/funref_' + desc['name'].lower() + '.html">Read package function reference</a></td></tr>\n');
2541
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
146 local = local_documentation(outdir, packdir);
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
147 if (local):
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
148 fid.write(' <tr><td colspan="2"><img src="../doc.png" alt="Documentation"/>');
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
149 fid.write('<a href="' + local + '">Documentation</a></td></tr>\n');
4ff100278d10 Add what will probably be the real path to download the packages. First attempt at adding local documentation if it exists
adb014
parents: 2517
diff changeset
150
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
151 fid.write(" </table>\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
152 fid.write(' <div id="description_box">\n');
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
153 if (desc.has_key("html-file")):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
154 html_fid = open(packdir + "/" + desc["html-file"].strip(), "r");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
155 fid.write(" " + html_fid.read() + "\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
156 html_fid.close();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
157 else:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
158 fid.write(" " + desc["description"] + "\n");
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
159 fid.write(' </div>\n\n');
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
160
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
161 ## Write less important data
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
162 keys = desc.keys();
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
163 fid.write(" <h3>Other information</h3>\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
164 fid.write(' <table id="extra_package_table">\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
165 ## License
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
166 fid.write(' <tr><td>License: </td><td><a href="license.html">');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
167 if (desc.has_key("license")):
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
168 fid.write(desc['license']);
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
169 else:
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
170 fid.write('details');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
171 fid.write('</a></td></tr>\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
172 ## URL
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
173 if (desc.has_key("url")):
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
174 fid.write(' <tr><td>Web page: </td><td><a href="' + desc['url'] + '">');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
175 fid.write(desc['url']);
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
176 fid.write('</a></td></tr>\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
177 ## Dependencies
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
178 if (desc.has_key("depends")):
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
179 fid.write(' <tr><td>Dependencies: </td><td>');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
180 fid.write(desc['depends']);
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
181 fid.write('</td></tr>\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
182 ## Everything else
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
183 already_shown_keys = ["title", "name", "version", "date", "author",
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
184 "maintainer", "description", "html-file",
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
185 "license", "url", "depends"];
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
186 for k in keys:
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
187 if (already_shown_keys.count(k) == 0):
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
188 value = desc[k];
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
189 fid.write(" <tr><td>" + k + ":</td><td>" + value + "</td></tr>\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
190 fid.write(" </table>\n");
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
191
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
192 ## Write footer
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
193 fid.write("__TRAILER__\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
194 fid.close();
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
195
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
196 ## Check if the package has an INDEX file (if not create one)
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
197 INDEX_file = packdir + "/INDEX";
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
198 if (not os.path.isfile(INDEX_file)):
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
199 create_INDEX(desc, packdir, p);
2513
3b7ee0e3bb88 INDEX files can be autogenerated
hauberg
parents: 2497
diff changeset
200
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
201 return desc;
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
202
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
203 def create_license_html(package_name, packdir, outdir):
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
204 ## Read License
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
205 filename = packdir + "/COPYING";
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
206 fid = open(filename, 'r');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
207 license = fid.readlines();
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
208 fid.close();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
209
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
210 ## Write output
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
211 fid = open(outdir + "/license.in", "w");
2486
34d81b0e0600 Removed packages.in because it gets generated
hauberg
parents: 2468
diff changeset
212 fid.write("__HEADER__([[[The " + package_name + " package]]])\n");
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
213 fid.write("<h3>The license terms for the " + package_name + " package are as follows</h3>\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
214 fid.write('<p><textarea rows="20" cols="80" readonly>');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
215 for c in license:
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
216 fid.write(c)
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
217 fid.write('</textarea></p>\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
218 fid.write('<p><a href="index.html">Back to the package page</a></p>\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
219 fid.write("__TRAILER__\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
220 fid.close();
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
221
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
222
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
223 def rm_rf(p):
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
224 #print("Deleting " + p);
2463
ea49b549015d Added a clean target to the Makefile
hauberg
parents: 2461
diff changeset
225 if (p == "./CVS"):
ea49b549015d Added a clean target to the Makefile
hauberg
parents: 2461
diff changeset
226 return;
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
227 for root, dirs, files in os.walk(p, topdown=False):
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
228 for name in files:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
229 os.remove(os.path.join(root, name));
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
230 for name in dirs:
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
231 os.rmdir(os.path.join(root, name));
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
232 os.rmdir(p);
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
233
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
234 def handle_package(packdir, outdir, p):
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
235 if (os.path.isdir(packdir)):
2668
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
236 if (not os.path.exists(packdir + "/NOINSTALL")):
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
237 if (os.path.exists(outdir)):
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
238 rm_rf(outdir);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
239 os.mkdir(outdir);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
240 try:
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
241 desc = create_index_html(packdir, outdir, p);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
242 create_license_html(desc['name'], packdir, outdir);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
243 return desc;
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
244 except Exception, e:
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
245 print(e);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
246 rm_rf(outdir);
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
247 raise Exception("Can't create index.html");
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
248 else:
67c5fe4fd3f0 Use alphabetic contents of package rather than categories page that might include functions from octaev itself
adb014
parents: 2651
diff changeset
249 raise Exception("Package marked NOINSTALL");
2497
f68cd4dab747 Just minor changes
hauberg
parents: 2486
diff changeset
250 raise Exception('not packdir');
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
251
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
252 def main():
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
253 ## Start the package file
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
254 index = open("packages.in", "w");
2486
34d81b0e0600 Removed packages.in because it gets generated
hauberg
parents: 2468
diff changeset
255 index.write("__HEADER__([[[Packages]]])");
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
256 index.write('<p>The following packages are currently available in the repository.\n');
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
257 index.write("If you don't know how to install the packages please read the\n");
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
258 index.write('relevant part of the <a href="FAQ.html#install">FAQ</a>.\n</p>');
2468
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
259 index.write('<p>Currently Octave-Forge is divided into seperate repositories\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
260 index.write('<ul><li><a href="#main">Main repository</a> contains packages that\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
261 index.write('are well tested and suited for most users.</li>\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
262 index.write('<li><a href="#extra">Extra packages</a> contains packages that\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
263 index.write("for various reasons aren't suited for everybody.</li>\n");
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
264 index.write('<li><a href="#nonfree">Non-free packages</a> contains packages\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
265 index.write('that have license issues. Usually the packages themselves are\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
266 index.write('Free Software that depend on non-free libraries.</li></ul>\n');
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
267 if (os.path.exists("INDEX")):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
268 os.system("rm -f INDEX");
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
269
2468
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
270 main_dirs = ["main", "extra", "nonfree"];
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
271 headers = ["Main repository", "Extra packages", "Non-free packages"];
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
272 for i in range(len(main_dirs)):
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
273 name = main_dirs[i];
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
274 main_dir = "../" + name + "/";
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
275 header = headers[i];
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
276 packages = os.listdir(main_dir);
2609
5897fc687b42 sort packages alphabetically
adb014
parents: 2573
diff changeset
277 packages.sort(key=str.lower);
2468
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
278
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
279 index.write('<h2 id="' + name + '">' + header + '</h2>\n');
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
280
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
281 for i in range(0, len(packages)):
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
282 p = packages[i];
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
283 packdir = main_dir + p;
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
284 if (os.path.isdir(packdir) and p != "CVS"):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
285 outdir = "./" + p;
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
286 try:
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
287 desc = handle_package(packdir, outdir, p);
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
288 archiv = desc['name'].lower() + '-' + desc['version'] + '.tar.gz';
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
289 index.write('<div class="package">\n');
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
290 index.write(' <b>' + desc['name'] + '</b>\n');
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
291 index.write('<p>' + desc['description'][:100]);
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
292 if (len(desc['description']) > 100):
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
293 index.write('...');
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
294 index.write('</p>\n');
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
295 index.write('<p class="package_link">&raquo; <a href="' + outdir + '/index.html">details</a> | ');
2651
4ea46b848cf2 No longer have global OCTAVE_PACKAGE_PREFIX. Use the 'prefix' directive to pkg to replae it
adb014
parents: 2646
diff changeset
296 index.write('<a href="__PACKAGE__/' + archiv + '?download">download</a></p>\n');
2558
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
297 index.write('</div>\n');
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
298 except Exception, e:
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
299 print("Skipping " + p);
d5a7f97cc2f6 Latest mega package manager update
adb014
parents: 2541
diff changeset
300 print(e)
2468
a640288875d9 build-www now creates pages for package in extra and nonfree as well
hauberg
parents: 2463
diff changeset
301
2461
f4dda5563e72 Updated www/build-www
hauberg
parents: 2429
diff changeset
302 index.write('__TRAILER__\n');
2429
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
303 index.close();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
304
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
305 main();
768fc6540e8a Added a basic script for creating webpages from DESCRIPTION files
hauberg
parents:
diff changeset
306