1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
.. title: Build Instructions
.. slug: build-instructions
.. date: 2015-04-06 12:09:11 UTC
.. tags:
.. category:
.. link:
.. description:
.. type: text
.. sectnum::
.. class:: alert alert-info pull-right
.. contents:: Table of Contents
:depth: 2
Quick Background
================
The Ubuntu Africa site is a static HTML site generated by the `Nikola <http://getnikola.com/>`_ site generator. Content is written using `reStructuredText <http://docutils.sourceforge.net/rst.html>`_, an easy-to-read, what-you-see-is-what-you-get plaintext markup syntax and parser system, a component of `Docutils <http://docutils.sourceforge.net/index.html>`_. Nikola is written in Python and is in the Ubuntu repositories.
.. note::
Nikola version 7.3 or higher is required
The tutorial below will show you how to checkout, modify, commit, and propose a merge for the Ubuntu Africa web site. While these instructions are specific about the site, they will work for almost any other project on `Launchpad <https://launchpad.net/>`_.
Our QA site is available at: http://ubuntu-africa.snyman.info/
Build Environment (Simple Method)
=================================
Packages to install
-------------------
::
$ sudo apt-get install bzr qbzr python-virtualenv python-webassets python-dev
Make a virtual environment
--------------------------
virtualenv is a tool to create isolated Python virtual environments and creates a folder which contains all the necessary executables to use the packages that a Python project would need. `More... <http://docs.python-guide.org/en/latest/dev/virtualenvs/>`_
::
$ virtualenv --system-site-packages ~/virtualenv
$ ~/virtualenv/bin/pip install --upgrade nikola
This allows you to run Nikola like so:
::
$ ~/virtualenv/bin/nikola build
Set up an alias (optional)
~~~~~~~~~~~~~~~~~~~~~~~~~~
Edit your .bashrc file and add the following line:
::
alias activate_nikola="source ~/virtualenv/bin/activate"
Then you can simply activate your virtual environment and use Nikola like so:
::
$ activate_nikola
$ nikola build
To deactivate, simply type in "deactivate":
::
$ deactivate
Build Environment (Alternative / Longer Method)
===============================================
Packages to install
-------------------
::
$ sudo apt-get install bzr git libxml2-dev libxslt1-dev python-dateutil python-dev python-pygments python-virtualenv zlib1g-dev qbzr
Make a virtual environment
--------------------------
`pyenv install instructions <https://github.com/alanorth/nairobilug.or.ke/blob/9e8ec6fb9240b03dea74dada1a6d3a0af752057b/README.md>`_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
$ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
$ git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv
Use editor of your choice to add following lines to end of ~/.bashrc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
# Enable pyenv
# See: https://github.com/yyuu/pyenv#basic-github-checkout
if [[ -d ~/.pyenv ]]; then
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# optionally enable pyenv-virtualenv
# See: https://github.com/yyuu/pyenv-virtualenv
if [[ -d ~/.pyenv/plugins/pyenv-virtualenv ]]; then
eval "$(pyenv virtualenv-init -)"
fi
fi
Read and execute commands from modified ~/.bashrc
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
$ source ~/.bashrc
Setup Projects folder and nikola environment
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
::
$ pyenv virtualenv Nikola
$ pyenv activate Nikola
$ pip install --upgrade nikola
$ pip install webassets
$ nikola version
Bazaar Project Checkout and Testing
===================================
- `Bazaar User Guide <http://doc.bazaar.canonical.com/latest/en/user-guide/index.html>`_
- `Bazaar in five minutes <http://doc.bazaar.canonical.com/latest/en/mini-tutorial/>`_
Initialise Bazaar environment
-----------------------------
If you don't have an account on Launchpad.net, go to `<https://launchpad.net/+login>`_ to create one and log in. Once logged in, you'll need to make sure you have your SSH public key uploaded to your account at https://launchpad.net/people/+me/+editsshkeys. See `Creating an SSH Key Pair <https://help.launchpad.net/YourAccount/CreatingAnSSHKeyPair>`_ for more info.
You need to configure Bazaar with your name and email address so that your commits can be identified. You should use your email address which is registered on Launchpad::
$ bzr whoami "MyName MySurname <MyEmail@address.com>"
$ bzr launchpad-login MyLaunchPadID
$ bzr launchpad-login
Checkout latest code and test with Nikola
-----------------------------------------
::
$ mkdir ~/Projects && cd ~/Projects
$ bzr init-repo ubuntu-africa
$ cd ~/Projects/ubuntu-africa
$ bzr co lp:ubuntu-africa trunk
$ cd ~/Projects/ubuntu-africa/trunk/
$ nikola build && nikola serve
Create your own Branch
~~~~~~~~~~~~~~~~~~~~~~
In order to work on the project you need to create branches to do the work in, edit and commit your changes and then push your local branch up to Launchpad, and then propose a merge, and finally merge your changes in to the main branch.
.. note::
You can see the history of a branch by browsing its log with `bzr log`.
Once you have completed some work, it’s a good idea to review your changes prior to permanently recording it. This way, you can make sure you’ll be committing what you intend to.
Two bzr commands are particularly useful here: **status** and **diff**.
::
$ cd ~/Projects/ubuntu-africa
$ bzr branch trunk new-feature-page
$ cd new-feature-page
Make your edits
~~~~~~~~~~~~~~~
::
$ nikola new_page
....
Title: New Feature
....
$ vim pages/new-feature.rst
$ bzr add
adding pages/new-feature.rst
Commit your edits
~~~~~~~~~~~~~~~~~
::
$ bzr commit -m "Added a new-feature page"
Committing to: ~/Projects/ubuntu-africa/new-feature-page/
added pages/new-feature.rst
Committed revision ##.
Push a Branch
-------------
In order to have your branch visible to the other developers, and in order to propose a merge, you need to push it up to Launchpad. This will create a remote branch on Launchpad, identical to your local branch.::
$ bzr push lp:~MyLaunchPadID/ubuntu-africa/new-feature-page
Using default stacking branch /+branch-id/######## at chroot-#####:///~MyLaunchPadID/ubuntu-africa/
Created new stacked branch referring to /+branch-id/########.
Propose a Merge
---------------
Go to your code page on Launchpad at ``https://code.launchpad.net/~MyLaunchPadID`` or to the main `Ubuntu Africa Project Code Page <https://code.launchpad.net/ubuntu-africa>`_, click on your branch in the list and then click on "Propose a Merge" or ask others to review your code before requesting a merge proposal.
Merging
-------
.. attention::
Merging into trunk is done by the core developers. If you are not a core developer, you won't be able to commit to trunk.
In your local ``trunk`` directory, run the merge command::
$ bzr merge lp:~john-doe/ubuntu-africa/new-contact-page
+N pages/contact.rst
All changes applied successfully.
This merges the changes from that remote branch into your local files. Now you need to commit those changes into the repository, which will send them up to the main branch::
$ bzr commit -m "Add a new contact page" --author="John Doe <john.doe@example.com>"
Once again, you need to specify a commit message (usually just a copy of the merge proposal message or the last commit message in the remote branch), and the author of the commit. This author flag gives credit to the original author of the changes, even if they do not have permission to write to the main repository. Give credit where credit is due.
Update your local copy with changes made by others
--------------------------------------------------
One of the important aspects of working with others in a team is keeping your checkout up to date with the latest changes made by others to the central trunk.::
$ cd ~/Projects/ubuntu-africa/trunk/
$ bzr update
|