Skip to content

Commit 8446ead

Browse files
author
Sam Kleinman
committed
DOCS-646: dynamically compiling release versions into download commands
1 parent d5aa64d commit 8446ead

9 files changed

+95
-43
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ build/*
88
*.bak
99
.DS_Store
1010
source/includes/hash.rst
11+
source/includes/install-curl-release*.rst

bin/update_hash.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/python
22

3-
43
from mongodb_docs_meta import get_commit
54

65
def main():

bin/update_release.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/python
2+
3+
import sys
4+
import os
5+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../")))
6+
import conf
7+
8+
def cli():
9+
try:
10+
builder = sys.argv[1]
11+
except IndexError:
12+
exit('[build]: Error. No builder specified.')
13+
14+
if builder == 'linux-32':
15+
builder = 'linux-i686'
16+
platform = 'linux'
17+
elif builder == 'linux-64':
18+
builder = 'linux-x86_86'
19+
platform = 'linux'
20+
elif builder == 'osx':
21+
builder = 'osx-x86_86'
22+
platform = 'osx'
23+
else:
24+
print(sys.argv[1])
25+
exit('[build]: Error. Builder argument, must be "linux-32", "linux-64", or "osx".')
26+
27+
try:
28+
outputfile = sys.argv[2]
29+
except IndexError:
30+
exit('[build]: Error. No output file specified to "update_release.py"')
31+
32+
return { 'outputfile': outputfile, 'builder': builder, 'platform': platform }
33+
34+
def generate_output(builder, platform, version):
35+
BREAK = '\n\n'
36+
INDENT = ' '
37+
38+
output = ('.. code-block:: sh' + '\n\n' +
39+
' curl http://downloads.mongodb.org/' + platform + '/mongodb-' +
40+
builder + '-' + version + '.tgz > mongo.tgz' + '\n')
41+
42+
return output
43+
44+
def main():
45+
interface = cli()
46+
output = generate_output(interface['builder'], interface['platform'], conf.version)
47+
48+
with open(interface['outputfile'], 'w') as f:
49+
f.write(output)
50+
51+
if __name__ == '__main__':
52+
main()

conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@
4848

4949
# The version info for the project you're documenting, acts as replacement for
5050
# |version| and |release|, also used in various other places throughout the
51-
# built documents.
52-
#
53-
# The short X.Y version.
51+
# built documents. The value of ``version`` is used in the paths for the curl commands.
52+
5453
version = '2.2.0'
5554
release = version
5655

makefile

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ endif
113113
# access these targets through the ``publish`` target.
114114
.PHONY: initial-dependencies static-components sphinx-components post-processing
115115

116-
pre-build-dependencies:setup source/includes/hash.rst source/about.txt
116+
pre-build-dependencies:setup source/tutorial/install-mongodb-on-linux.txt source/tutorial/install-mongodb-on-os-x.txt source/includes/hash.rst source/about.txt
117117
initial-dependencies:$(public-branch-output)/MongoDB-Manual.epub
118118
@echo [build]: completed the pre-publication routine for the $(manual-branch) branch of the Manual.
119119
static-components:$(public-output)/index.html $(public-output)/10gen-gpg-key.asc $(public-output)/10gen-security-gpg-key.asc $(public-branch-output)/.htaccess $(public-branch-output)/release.txt $(public-output)/osd.xml
@@ -127,15 +127,35 @@ sphinx-components:$(public-branch-output)/MongoDB-Manual.pdf $(public-branch-out
127127
# Build the HTML components of the build.
128128
#
129129

130+
.PHONY:instalation-guides source/tutorial/install-mongodb-on-linux.txt source/tutorial/install-mongodb-on-os-x.txt
131+
.PHONY:source/includes/install-curl-release-linux-64.rst source/includes/install-curl-release-linux-32.rst source/includes/install-curl-release-osx-64.rst
132+
instalation-guides:source/tutorial/install-mongodb-on-linux.txt source/tutorial/install-mongodb-on-os-x.txt
133+
source/tutorial/install-mongodb-on-linux.txt:source/includes/install-curl-release-linux-64.rst
134+
@touch $@
135+
@echo [build]: touched $@ to ensure a clean build.
136+
source/tutorial/install-mongodb-on-os-x.txt:source/includes/install-curl-release-osx-64.rst
137+
@echo [build]: touched $@ to ensure a clean build.
138+
source/includes/install-curl-release-linux-64.rst:source/includes/install-curl-release-linux-32.rst
139+
@$(PYTHONBIN) bin/update_release.py linux-64 $@
140+
# @git update-index --assume-unchanged $@
141+
@echo [build]: \(re\)generated $@.
142+
source/includes/install-curl-release-linux-32.rst:
143+
@$(PYTHONBIN) bin/update_release.py linux-32 $@
144+
# @git update-index --assume-unchanged $@
145+
@echo [build]: \(re\)generated $@.
146+
source/includes/install-curl-release-osx-64.rst:
147+
@$(PYTHONBIN) bin/update_release.py osx $@
148+
# @git update-index --assume-unchanged $@
149+
@echo [build]: \(re\)generated $@.
150+
130151
.PHONY:source/about.txt source/includes/hash.rst setup
131152

132153
setup:source/includes/hash.rst
133154
@mkdir -p $(public-branch-output)
134155
@echo [build]: created $(public-branch-output)
135-
136156
source/includes/hash.rst:
137157
@$(PYTHONBIN) bin/update_hash.py
138-
@git update-index --assume-unchanged source/includes/hash.rst
158+
@git update-index --assume-unchanged $@
139159
@echo [build]: \(re\)generated $@.
140160
source/about.txt:setup
141161
@touch $@
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. this file is generated with a dynamic release number by the build
2+
process.
3+
4+
.. code-block:: sh
5+
6+
curl http://downloads.mongodb.org/linux/mongodb-linux-i686-x.y.z.tgz > mongo.tgz
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.. this file is generated with a dynamic release number by the build
2+
process.
3+
4+
.. code-block:: sh
5+
6+
curl http://downloads.mongodb.org/linux/mongodb-osx-x86_64-x.y.z.tgz > mongo.tgz

source/tutorial/install-mongodb-on-linux.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,11 @@ Download MongoDB
4040
In a terminal session, begin by downloading the latest release. In
4141
most cases you will want to download the 64-bit version of MongoDB.
4242

43-
.. code-block:: sh
44-
45-
curl http://downloads.mongodb.org/linux/mongodb-linux-x86_64-x.y.z.tgz > mongo.tgz
43+
.. include:: /includes/install-curl-release-linux-64.rst
4644

4745
If you need to run the 32-bit version, use the following command.
4846

49-
.. code-block:: sh
50-
51-
curl http://downloads.mongodb.org/linux/mongodb-linux-i686-x.y.z.tgz > mongo.tgz
52-
53-
.. note::
54-
55-
Replace x.y.z with the current stable version (i.e. |version|).
56-
57-
You may also choose to install a development release, in which case
58-
you will need to specify that version number above.
47+
.. include:: /includes/install-curl-release-linux-32.rst
5948

6049
Once you've downloaded the release, issue the following command to
6150
extract the files from the archive:

source/tutorial/install-mongodb-on-os-x.txt

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -127,36 +127,16 @@ OS X, which may provide a more straightforward installation process.
127127
Download MongoDB
128128
~~~~~~~~~~~~~~~~
129129

130-
In a terminal session, begin by downloading the latest release. In
131-
most cases you will want to download the 64-bit version of MongoDB.
130+
In a terminal session, begin by downloading the latest release. Use
131+
the following command at the system prompt:
132132

133-
.. code-block:: sh
134-
135-
curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-x.y.z.tgz > mongo.tgz
136-
137-
If you need to run the 32-bit version, use the following command:
138-
139-
.. code-block:: sh
140-
141-
curl http://downloads.mongodb.org/osx/mongodb-osx-i386-x.y.z.tgz > mongo.tgz
142-
143-
.. note::
144-
145-
Replace x.y.z with the current stable version (i.e. |version|).
146-
147-
You may also choose to install a development release, in which case
148-
you will need to specify that version number above.
133+
.. include:: /includes/install-curl-release-osx-64.rst
149134

150135
.. note::
151136

152137
The :program:`mongod` process will not run on older Macintosh computers
153138
with PowerPC (i.e. non-Intel) processors.
154139

155-
While 32-bit builds of MongoDB are fine for testing purposes, it is
156-
impossible to use multi-gigabyte databases with 32-bit systems. All
157-
recent Macintosh systems (including all Intel-based systems) have
158-
support for 64-bit builds of MongoDB.
159-
160140
Once you've downloaded the release, issue the following command to
161141
extract the files from the archive:
162142

0 commit comments

Comments
 (0)