]> git.donarmstrong.com Git - lilypond.git/blob - scripts/build/create-weblinks-itexi.py
Merge remote branch 'origin/release/unstable'
[lilypond.git] / scripts / build / create-weblinks-itexi.py
1 #!@PYTHON@
2 # create-version-itexi.py
3
4 """ when being called on lilypond.org, pass it the location of the
5 top source dir on the command-line. """
6
7 import sys
8 import os
9 import glob
10
11 # these links are relative from /website/
12 depth = "../"
13
14
15 VERSION_STABLE = ""
16 VERSION_DEVEL = ""
17
18 try:
19     topDir = sys.argv[1]
20 except:
21     myDir = os.path.dirname(sys.argv[0])
22     # use two abspaths to work around some windows python bug
23     topDir = os.path.join(os.path.abspath(myDir)+os.sep+'..'+os.sep+'..'+os.sep)
24     topDir = os.path.abspath( topDir )
25
26
27 # TODO: this might be useful for other scripts; can we make it available?
28 manuals = map(lambda x: os.path.splitext(x)[0],
29               map(os.path.basename,
30                   glob.glob(os.path.join(topDir,'Documentation', '*.te??'))))
31 #manuals = map(lambda x: 'glossary' if x=='music-glossary' else x, manuals)
32 manuals.append('internals')
33
34
35 version_file_path = os.path.join(topDir, "VERSION")
36
37 version_contents = open(version_file_path).readlines()
38 major = 0
39 minor = 0
40 patch = 0
41 for line in version_contents:
42     if (line.startswith('MAJOR_VERSION')):
43         major = line[14:-1]
44     if (line.startswith('MINOR_VERSION')):
45         minor = line[14:-1]
46     if (line.startswith('PATCH_LEVEL')):
47         patch = line[12:-1]
48     if (line.startswith('VERSION_STABLE')):
49         VERSION_STABLE = line[15:-1]
50     if (line.startswith('VERSION_DEVEL')):
51         VERSION_DEVEL = line[14:-1]
52
53 VERSION = str(major)+'.'+str(minor)+'.'+str(patch)
54
55 def make_macro(name, string):
56     print "@macro", name
57     print string
58     print "@end macro"
59     print ""
60
61 def make_download(name, osA, osB, version, revision, text):
62     string = "@uref{http://download.linuxaudio.org/lilypond/binaries/"
63     string += osA + "lilypond-"
64     string += version + "-" + revision
65     string += "." + osB + ",\n"
66     string += text
67     string += ": LilyPond "
68     string += version + "-" + revision
69     string += "}"
70     make_macro(name, string)
71
72 def make_download_source(name, vstring, version):
73     string = "@uref{http://download.linuxaudio.org/lilypond/sources/"
74     string += vstring + "/"
75     string += "lilypond-" + version + ".tar.gz"
76     string += ", "
77     string += "Source: lilypond-" + version + ".tar.gz"
78     string += "}"
79     make_macro(name, string)
80
81 def make_all_downloads(macroName, version):
82     make_download("download"+macroName+"LinuxNormal", "linux-x86/",
83         "linux-x86.sh",    version, "1", "Linux x86")
84     make_download("download"+macroName+"LinuxBig", "linux-64/",
85         "linux-64.sh", version, "1", "Linux 64")
86     make_download("download"+macroName+"LinuxPPC", "linux-ppc/",
87         "linux-ppc.sh", version, "1", "Linux PPC")
88
89     make_download("download"+macroName+"FreeBSDNormal", "freebsd-x86/",
90         "freebsd-x86.sh", version, "1", "FreeBSD i386")
91     make_download("download"+macroName+"FreeBSDBig", "freebsd-64/",
92         "freebsd-64.sh", version, "1", "FreeBSD amd64")
93
94     make_download("download"+macroName+"DarwinNormal", "darwin-x86/",
95         "darwin-x86.tar.bz2", version, "1", "MacOS X x86")
96     make_download("download"+macroName+"DarwinPPC", "darwin-ppc/",
97         "darwin-ppc.tar.bz2", version, "1", "MacOS X PPC")
98
99     make_download("download"+macroName+"Windows", "mingw/",
100         "mingw.exe", version, "1", "Windows")
101
102 def make_ver_link(macroname, url, linktext):
103     string = "@uref{"
104     string += url
105     string += ","
106     string += linktext
107     string += "}"
108     make_macro(macroname, string)
109
110 # TODO: this kind of thing should really be in a central place for
111 # lilypond python build scripts
112 def translateNameToUrl(manual, version):
113     ver_split = version.split('.')
114     ver_minor = ver_split[0] + '.' + ver_split[1]
115     url = depth + "doc/v" + ver_minor + "/Documentation/"
116
117     if (ver_minor == '2.13'):
118         return url+manual
119     if (ver_minor == '2.12'):
120         if (manual=='learning'):
121             return url+'user/lilypond-learning'
122         elif (manual=='internals'):
123             return url+'user/lilypond-internals'
124         elif (manual=='notation'):
125             return url+'user/lilypond'
126         elif (manual=='usage'):
127             return url+'user/lilypond-program'
128         elif (manual=='snippets'):
129             return url+'../input/lsr/lilypond-snippets'
130         elif (manual=='changes'):
131             return url+'topdocs/NEWS.html'
132         elif (manual=='music-glossary'):
133             return url+'user/music-glossary'
134         elif (manual=='essay'):
135             return url+'user/lilypond-learning/Background.html'
136         elif (manual=='extending'):
137             return url+'user/lilypond/Interfaces-for-programmers.html'
138         else:
139             return ''
140
141
142 def make_manual_links(name, version):
143     for m in manuals:
144         manual = m
145         if (m=='music-glossary'):
146             mshort = 'Glossary'
147         else:
148             mshort = m.capitalize()
149         url = translateNameToUrl(m, version)
150
151         if (url == ''):
152             # can't have a comma here due to texinfo
153             make_ver_link("manual"+name+mshort+'Pdf',
154                 "http://lilypond.org",
155                 mshort+" (did not exist in 2.12)")
156             make_ver_link("manual"+name+mshort+'Split',
157                 "http://lilypond.org",
158                 mshort+" (did not exist in 2.12)")
159             make_ver_link("manual"+name+mshort+'Big',
160                 "http://lilypond.org",
161                 mshort+" (did not exist in 2.12)")
162             make_ver_link("manual"+name+mshort+'SplitNoName',
163                 "http://lilypond.org",
164                 mshort+" (did not exist in 2.12)")
165             continue
166         make_ver_link("manual"+name+mshort+'Pdf',
167                   url + '.pdf',
168                   manual.capitalize() + '.pdf')
169         make_ver_link("manual"+name+mshort+'Split',
170                   url + '/index.html',
171                   manual.capitalize() + ' (split HTML)')
172         make_ver_link("manual"+name+mshort+'Big',
173                   url + '-big-page.html',
174                   manual.capitalize() + ' (big HTML)')
175         # this is stupid and I shouldn't have bothered trying
176         # to support the 2.12 docs and it will be deleted once
177         # 2.14 is out and the website won't be visible to users
178         # until 2.14 is out.  -gp
179         if (url.endswith('.html')):
180             newurl = url
181         else:
182             newurl = url + '/index.html'
183         make_ver_link("manual"+name+mshort+'SplitNoName',
184                   newurl,
185                   manual.capitalize())
186
187 def make_regtest_links(name, version):
188     ver_split = version.split('.')
189     ver_minor = ver_split[0] + '.' + ver_split[1]
190     url = depth + "doc/v" + ver_minor + "/input/regression/"
191
192     make_ver_link("regtest"+name, url+"collated-files.html",
193         "Regression tests for "+version)
194     make_ver_link("regtest"+name+"Pdf", url+"collated-files.pdf",
195         "pdf of "+version+" regtests")
196     make_ver_link("regtest"+name+"Xml", url+"musicxml/collated-files.html",
197         "MusicXML Regression tests for "+version)
198     make_ver_link("regtest"+name+"XmlPdf", url+"musicxml/collated-files.html",
199         "pdf of "+version+" musicxml regtests")
200
201 def make_doctarball_links(name, version):
202     url = depth + "download/binaries/documentation/lilypond-"
203     # ugly FIXME, but proper build number support isn't Critical.
204     url += version + "-1"
205     url += ".documentation.tar.bz2"
206     make_ver_link("doctarball"+name, url, "Doc tarball for "+version)
207
208 print "@c ************************ Download binaries ************"
209 make_all_downloads("Stable", VERSION_STABLE)
210 make_all_downloads("Devel", VERSION_DEVEL)
211
212 print "@c ************************ Download source ************"
213 # FIXME: icky hard-coding!  -gp
214 make_download_source("downloadStableSource", "v2.12", VERSION_STABLE)
215 make_download_source("downloadDevelSource", "v2.13", VERSION_DEVEL)
216
217 print "@c ************************ Manual links ************"
218 make_manual_links("Stable", VERSION_STABLE)
219 make_manual_links("Devel", VERSION_DEVEL)
220 make_doctarball_links("Stable", VERSION_STABLE)
221 make_doctarball_links("Devel", VERSION_DEVEL)
222
223 print "@c ************************ Regtest links ************"
224 make_regtest_links("Stable", VERSION_STABLE)
225 make_regtest_links("Devel", VERSION_DEVEL)
226