1<title>How The Fossil Download Page Works</title>
2<h1 align="center">How The Download Page Works</h1>
3
4<h2>1.0 Overview</h2>
5
6The [/uv/download.html|Download] page for the Fossil self-hosting
7repository is implemented using [./unvers.wiki|unversioned files].
8The "download.html" screen itself, and the various build products
9are all stored as unversioned content.  The download.html page
10uses XMLHttpRequest() to retrieve the [/help?cmd=/juvlist|/juvlist] webpage
11for a list of all unversioned files.  Javascript in the
12[/uv/download.js?mimetype=text/plain|download.js] file (which is
13sourced by "download.html") then figures out which unversioned files are
14build products and paints appropriate icons on the displayed
15download page.
16
17Except, the "Source Tarball" download products are not stored as
18unversioned files.  They are computed on-demand by the
19[/help?cmd=/tarball|/tarball web page].
20
21When a new version is generated, the developers use the
22[/help?cmd=uv|fossil uv edit] command to make minor changes
23to the "[/uv/download.js?mimetype=text/plain|download.js]"
24file so that it knows about the
25new version number.  Then the developers run
26the [/help?cmd=uv|fossil uv add] command for each
27build product.  Finally, the
28[/help?cmd=uv|fossil uv sync] command is run to push all
29the content up to servers.  All
30[./selfhost.wiki|three self-hosting repositories] for Fossil
31are updated automatically.
32
33<h2>2.0 Details</h2>
34
35The current text of the "download.html" and "download.js" files can
36be seen at:
37
38   *   [/uv/download.html?mimetype=text/plain]
39   *   [/uv/download.js?mimetype=text/plain]
40
41Notice how the hyperlinks above use the "mimetype=text/plain"
42query parameter in order to display the file as plain text
43instead of the usual HTML or Javascript.
44
45The default mimetype for "download.html" is
46text/html.  But because the entire page is enclosed within
47
48    <b>&lt;div class='fossil-doc' data-title='Download Page'&gt;...&lt;/div&gt;</b>
49
50Fossil knows to add its standard header and footer information to the
51document, making it look just like any other page.  See
52"[./embeddeddoc.wiki|embedded documentation]" for further details on
53how &lt;div class='fossil-doc'&gt; this works.
54
55With each new release, the "releases" variable in the javascript on
56the [/uv/download.js?mimetype=text/plain|download.js] page is
57edited (using "[/help?cmd=uv|fossil uv edit download.js]") to add
58details of the release.
59
60When the JavaScript in the "download.js" file runs, it requests
61a listing of all unversioned content using the /juvlist URL.
62([/juvlist|sample /juvlist output]).  The content of the download page is
63constructed by matching unversioned files against regular expressions
64in the "releases" variable.
65
66Build products need to be constructed on different machines.  The precompiled
67binary for Linux is compiled on Linux, the precompiled binary for Windows
68is compiled on Windows10, and so forth.  After a new release is tagged,
69the release manager goes around to each of the target platforms, checks
70out the release and compiles it, then runs
71[/help?cmd=uv|fossil uv add] for the build product followed by
72[/help?cmd=uv|fossil uv sync] to push the new build product to the
73[./selfhost.wiki|various servers].  This process is repeated for
74each build product.
75
76When older builds are retired from the download page, the
77[/uv/download.js?mimetype=text/plain|download.js] page is again
78edited to remove the corresponding entry from the "release" variable
79and the edit is synced using
80[/help?cmd=uv|fossil uv sync].  This causes the build products to
81disappear from the download page immediately.  But those build products
82are still taking up space in the unversioned content table of the
83server repository.  To purge the obsolete build products, one or
84more [/help?cmd=uv|fossil uv rm] commands are run, followed by
85another [/help?cmd=uv|fossil uv sync].  It is important to purge
86obsolete build products since they take up a lot of space.
87At [/repo-tabsize] you can see that the unversioned table takes up
88a substantial fraction of the repository.
89
90<h2>3.0 Security</h2>
91
92Only users with the [/setup_ulist_notes|"y" permission] are allowed
93to push unversioned content up to the servers.  Having the ability
94to push check-ins (the [/setup_ulist_notes|"i" permission]) is not
95sufficient.
96
97On the Fossil project there are 67 people (as of 2017-03-24) who have
98check-in privileges.  But only 3 core developers
99can push unversioned content and thus
100change the build products on the download page.  Minimizing the number
101of people who can change the build products helps to ensure that
102rogue binaries do not slip onto the download page unnoticed.
103