Edgewall Software

Changes between Version 1 and Version 2 of Ubuntu-10.04.04-Mercurial


Ignore:
Timestamp:
Aug 31, 2012, 2:14:22 PM (7 years ago)
Author:
crotale@…
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ubuntu-10.04.04-Mercurial

    v1 v2  
    1212== Installing the software and its dependencies ==
    1313
    14 = Progress indication, to be removed =
    1514
    1615=== Base packages ===
     16Make sure your system is updated.
     17{{{
     18sudo apt-get update
     19sudo apt-get upgrade
     20}}}
    1721
    18 In order to get Trac and Subversion installed, you will need to get a few packages listed below. Also, make sure your system is updated.
    19 
     22In order to get Trac and Mercurial installed, you will need to get a few packages listed below.
    2023{{{
    2124sudo apt-get install apache2 libapache2-mod-python python-setuptools python-genshi mysql-server python-mysqldb
    2225}}}
    2326
    24 === Subversion ===
     27=== Mercurial ===
    2528
    26 Installing Subversion (SVN) is pretty straight forward. Just run:
     29For this guide we will use a newer Mercurial than the one in the 10.04/Lucid repository.
     30Mercurial 2.3 binaries can be found at Launchpad:
    2731
     32https://launchpad.net/~mercurial-ppa/+archive/releases/+packages
     33
     34More specific for 10.04/Lucid:
     35
     36Common: [[https://launchpad.net/~mercurial-ppa/+archive/releases/+files/mercurial-common_2.3-0ppa2%7Elucid1_all.deb]]
     37
     3864-bit: [[https://launchpad.net/~mercurial-ppa/+archive/releases/+files/mercurial_2.3-0ppa2%7Elucid1_amd64.deb]]
     39
     4032-bit: [[https://launchpad.net/~mercurial-ppa/+archive/releases/+files/mercurial_2.3-0ppa2%7Elucid1_i386.deb]]
     41
     42Download the Common binary and either the 32- or 64-bit binary to the server.
     43
     44Install the Mercurial packages by running:
    2845{{{
    29 sudo apt-get install subversion
     46sudo dpkg -i mercurial*.deb
    3047}}}
    3148
    3249=== Trac ===
    3350
    34 There are different ways of installing Trac. But since this tutorial is focused on Ubuntu, you'll do the Ubuntu way:
     51The same goes for Trac, we want a newer version. Download the Trac 0.12.3 binary for Ubuntu:
    3552
     53[[https://launchpad.net/ubuntu/+source/trac/0.12.3-1/+build/3547374/+files/trac_0.12.3-1_all.deb]]
     54
     55Install it with:
    3656{{{
    37 sudo apt-get install trac
     57sudo dpkg -i trac*.deb
    3858}}}
    3959
    40 == Configuring ==
    4160
    42 This part is maybe the most important section on this tutorial. You'll learn how to syncronize Trac and Subversion in order to be able to see on your Trac Project website what's going on in your repository and also how to automate some tasks.
     61= Progress indication, to be removed =
    4362
    44 === Subversion ===
     63To be continued... trac 0.12.x requires python 2.7 which is non-trivial to install on 10.04/Lucid.
    4564
    46 ==== Creating the project ====
    47 
    48 You may already know how to do this, but let's make a review just in case.
    49 
    50 Create a directory to store the SVN projects:
    51 {{{
    52 sudo mkdir /var/lib/svn
    53 }}}
    54 
    55 Create a the project directory:
    56 {{{
    57 sudo mkdir /var/lib/svn/YourProject
    58 }}}
    59 
    60 Use svnadmin to create a project in the previously created folder:
    61 {{{
    62 sudo svnadmin create /var/lib/svn/YourProject
    63 }}}
    64 
    65 In order to perform some changes to the project, Trac needs write access to it:
    66 {{{
    67 sudo chown -R www-data /var/lib/svn/YourProject
    68 }}}
    69 
    70 Start the Subversion server (or use your preferred method):
    71 {{{
    72 sudo svnserve -d
    73 }}}
    74 
    75 === Setup the MySQL database ===
    76 
    77 Before configuring your new Trac project, you'll need to setup the MySQL database.
    78 
    79 Log into MySQL database, using the root credentials you've setup during the installation:
    80 {{{
    81 mysql -u root -p
    82 }}}
    83 
    84 Once logged in, create the database for Trac:
    85 {{{
    86 CREATE DATABASE trac DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
    87 }}}
    88 
    89 Now create the username which Trac is going to use to connect to the database:
    90 {{{
    91 GRANT ALL ON trac.* TO trac@localhost IDENTIFIED BY 'yourpassword';
    92 }}}
    93 
    94 You can now exit the MySQL command line.
    95 
    96 === Trac ===
    97 
    98 ==== Initiate the enviroment
    99 
    100 Let's create a directory to contain all the Trac project (just like we did for SVN projects).
    101 {{{
    102 sudo mkdir /var/lib/trac
    103 }}}
    104 
    105 Create a directory where to store the Trac project in:
    106 {{{
    107 sudo mkdir /var/lib/trac/YourProject
    108 }}}
    109 
    110 As you did for Subversion, change the ownership of the project files to Apache's user www-data:
    111 {{{
    112 sudo chown -R www-data:www-data /var/lib/trac/YourProject
    113 }}}
    114 
    115 Use trac-admin to create the new project:
    116 {{{
    117 sudo trac-admin /var/lib/trac/YourProject initenv
    118 }}}
    119 
    120 Also you will need to fill in some information, like the project name. It will ask you for the MySQL connection string. Input the following (according to the way we did setup the MySQL database in the step 2.2).
    121 {{{
    122 mysql://trac:yourpassword@localhost/trac
    123 }}}
    124 
    125 Pay attention to the question about the location of the Subversion project. Enter the path as discussed before:
    126 {{{
    127 /var/lib/svn/YourProject
    128 }}}
    129 
    130 If the MySQL default engine wasn't InnoDB, you might need to convert the tables tha trac-admin has just created. Issue the following within your MySQL client:
    131 {{{
    132 USE trac; \
    133 ALTER TABLE `attachment` ENGINE = InnoDB; \
    134 ALTER TABLE `auth_cookie` ENGINE = InnoDB; \
    135 ALTER TABLE `cache` ENGINE = InnoDB; \
    136 ALTER TABLE `component` ENGINE = InnoDB; \
    137 ALTER TABLE `enum` ENGINE = InnoDB; \
    138 ALTER TABLE `milestone` ENGINE = InnoDB; \
    139 ALTER TABLE `node_change` ENGINE = InnoDB; \
    140 ALTER TABLE `permission` ENGINE = InnoDB; \
    141 ALTER TABLE `report` ENGINE = InnoDB; \
    142 ALTER TABLE `repository` ENGINE = InnoDB; \
    143 ALTER TABLE `revision` ENGINE = InnoDB; \
    144 ALTER TABLE `session` ENGINE = InnoDB; \
    145 ALTER TABLE `session_attribute` ENGINE = InnoDB; \
    146 ALTER TABLE `system` ENGINE = InnoDB; \
    147 ALTER TABLE `ticket` ENGINE = InnoDB; \
    148 ALTER TABLE `ticket_change` ENGINE = InnoDB; \
    149 ALTER TABLE `ticket_custom` ENGINE = InnoDB; \
    150 ALTER TABLE `version` ENGINE = InnoDB; \
    151 ALTER TABLE `wiki` ENGINE = InnoDB;
    152 }}}
    153 
    154 ==== Explicit syncronization ====
    155 
    156 '''Note''': For more information about the Explicit Syncronization method, please read TracRepositoryAdmin#ExplicitSync
    157 
    158 First, edit the '''trac.ini''' file, located in ''/var/lib/trac/YourProject/conf/''. Modify the "repository_sync_per_request" directive and set it to an empty value.
    159 
    160 Now you need to create the Subversion hooks. First, create the post-commit hook the in ''/var/lib/svn/YourProject/hooks/'' directory, with the following content:
    161 {{{
    162 #!/bin/sh
    163 export PYTHON_EGG_CACHE="/path/to/cache/dir"
    164 /usr/bin/trac-admin /var/lib/trac/YourProject changeset added "$1" "$2"
    165 }}}
    166 
    167 Make sure you give the script execution perms:
    168 {{{
    169 sudo chmod +x /var/lib/svn/YourProject/hooks/post-commit
    170 }}}
    171 
    172 Another important hook script to have is post-revprop-change. The procedures are similiar as above, but the script is slightly different:
    173 {{{
    174 #!/bin/sh
    175 export PYTHON_EGG_CACHE="/path/to/cache/dir"
    176 /usr/bin/trac-admin /var/lib/trac/YourProject changeset modified "$1" "$2"
    177 }}}
    178 
    179 Again, make sure you give exec perms to the script.
    180 
    181 Now Trac will be notified about changes you make to your repository and will make them availables in the timeline.
    182 
    183 
    184 === Apache ===
    185 
    186 ==== Set up Trac handling ====
    187 
    188 Apache needs to know how to handle Trac. Use the following block to set up Trac handling:
    189 {{{
    190 <Location /projects> #set up Trac handling
    191     SetHandler mod_python
    192     PythonHandler trac.web.modpython_frontend
    193     PythonOption TracEnvParentDir /var/lib/trac
    194     PythonOption TracUriRoot /projects
    195 </Location>
    196 }}}
    197 
    198 Note that it's pointing to the main Trac directory. It means it will expose all of your Trac projects. You may need to apply this configuration to Apache:
    199 {{{
    200 sudo a2ensite trac
    201 }}}
    202 
    203 ==== Authentication ====
    204 
    205 In order to allow users to log in Trac, you will need the following section in your Apache configuration:
    206 {{{
    207 <LocationMatch "/projects/[^/]+/login">
    208     AuthType Basic
    209     AuthName "Trac"
    210     AuthUserFile /var/lib/trac/.htpasswd
    211     Require valid-user
    212 </LocationMatch>
    213 }}}
    214 
    215 You should now create the .htpasswd file, with an admin user:
    216 {{{
    217 sudo htpasswd -c .htpasswd admin
    218 }}}
    219 
    220 Go ahead and restart Apache:
    221 {{{
    222 sudo /etc/init.d/apache2 restart
    223 }}}
    224 
    225 Finally, you must grant admin rights to the user you've just created:
    226 {{{
    227 sudo trac-admin /var/lib/trac/YourProject permission add admin TRAC_ADMIN
    228 }}}
    229 
    230 == Automatic reference to the SVN changesets in Trac tickets ==
    231 
    232 Something useful is to reference tickets on your commits. That way you can keep a better track of them and also easly access them from the timeline.
    233 
    234 Make sure you have the following line in your trac.ini configuration file:
    235 {{{
    236 [components]
    237 tracopt.ticket.commit_updater.* = enabled
    238 }}}
    239 
    240 Now, whenever you commit some change related to a ticket, use ''Refs #tn'' to reference this changeset in #tn ticket. For example:
    241 {{{
    242 svn commit -m "Refs #123 - added this and that"
    243 }}}
    244 
    245 In order to mark a ticket as fixed, use the following:
    246 {{{
    247 svn commit -m "Fixes #123 - Removed an infinite loop which was causing the application to freeze"
    248 }}}
     65Updates paused for now...