Trac

Category: /knowledge /linux
Tags: linux

Ubuntu 12.04 Update

Ubuntu 12.04 LTS comes with trac 0.12 which supports svn and git. Installation is easier than ever.

sudo aptitude install apache libapache2-mod-wsgi trac subversion git
sudo a2enmod ssl 
sudo a2ensite default-ssl
sudo htpasswd -b /etc/apache2/dav_svn.passwd $USER your_password

Follow Apache self-signed certificate to generate SSL certificate.

edit /etc/apache2/envvars

export APACHE_RUN_GROUP=dev

Installation

I think trac installation is easy, but it requires a lot of prep work in Apache2 & Subversion. I always forget to make/install Subversion’s python bindings. Usually, I don’t need to compile it from source code. But Ubuntu 10.04 LTS ships only 0.11 which doesn’t support multi-reposities. So I install 0.12 separately.

  • dependencies: aptitude install python-subversion python-setuptools python-genshi
  • Debian/Ubuntu: apt-get install trac
  • or from source: python setup.py install

Setup cheat sheet

Also, you’d better set up subversion properly first. To initialize a trac project ‘mytrac’, do the following steps

  1. You must have a svn project in reposity first like /opt/svn/myprj. If it’s not imported/initialized yet, type

       export prj_name=your_prj
       mkdir $prj_name
       cd $prj_name
       mkdir branches tags trunk       
       cd ..
       svn import $prj_name file:///opt/svn/$prj_name -m "My Project" 
    
  2. (Optional) You may add a user for authentication

       htpasswd2 -b /etc/apache2/dav_svn.passwd newuser yourpassword
    
  3. Initialize a trac project using $prj_name

       $ trac-admin /opt/trac/$prj_name initenv 
       Project Name [My Project]> My Trac Project
       Database connection string [sqlite:db/trac.db]> [ENTER] for default value
       Repository type [svn]>  [ENTER] for default value
       Path to repository [/path/to/repos]> /opt/svn/$prj_name
       Templates directory>  [ENTER] for default value 
       sudo chown -R www-data:dev /opt/trac/$prj_name
       sudo chmod g+w -R /opt/trac/$prj_name/db
    
  4. I like to setup permissions for each individual project to have more control

       # go to trac project directory, i.e. /opt/trac/$prj_name
       # to view the permissions
       $ trac-admin . permission list
    
       # remove access control from ''anonymous''
       trac-admin . permission remove anonymous BROWSER_VIEW CHANGESET_VIEW\
       FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW REPORT_VIEW  \
       ROADMAP_VIEW SEARCH_VIEW TICKET_CREATE TICKET_MODIFY TICKET_VIEW \
       TIMELINE_VIEW WIKI_CREATE WIKI_MODIFY WIKI_VIEW 
    
       # assign VIEW permission for ''authenticated''
       trac-admin . permission add authenticated WIKI_VIEW BROWSER_VIEW \
       CHANGESET_VIEW FILE_VIEW LOG_VIEW MILESTONE_VIEW REPORT_SQL_VIEW \
       REPORT_VIEW  ROADMAP_VIEW SEARCH_VIEW TICKET_CREATE TICKET_MODIFY \
       TICKET_VIEW TIMELINE_VIEW WIKI_CREATE WIKI_MODIFY MILESTONE_CREATE \
       MILESTONE_MODIFY REPORT_CREATE REPORT_MODIFY TICKET_APPEND TICKET_CHGPROP
    
       # assign myself to have full control
       trac-admin . permission add $USER TRAC_ADMIN MILESTONE_ADMIN \
       REPORT_ADMIN TICKET_ADMIN WIKI_ADMIN                                            
    
  5. I need to update some milestones.

       # list all milestones
       trac-admin . milestone list
       # create a new milestone
       trac-admin . milestone add <name> [due]
       # rename
       trac-admin . milestone rename <name> <newname>
       # assign a due date
       trac-admin . milestone add anniversary 'Jun 3, 2003'
       # remove a milestone
       trac-admin . milestone remove mockup
    
  6. I need to change some components. Assume you are in the trac directory such as /opt/trac/myprj

       # list all components
       trac-admin . component list
       # add a new component/user
       trac-admin . component add comp_name my_user_name
       # rename
       trac-admin . component rename component1 mockup
       # change owner of a component
       trac-admin . component chown somebody my_user_name
       # remove/uninstall component
       trac-admin . component remove <name>
    
  7. Add some minor versions

     trac-admin . version list
     trac-admin . version add 1.1
     trac-admin . version add 1.2
    
  8. To make it available to Apache

     sudo chown -R my_user_name:dev /opt/trac/$prj_name
     chmod -R 775 /opt/trac/$prj_name/db
    

Apache setup

Make sure to set the ini file and its parent folder writable by apache user. For example

sudo adduser www-data dev
chmod 775 /opt/trac/myprj
chmod 664 /opt/trac/myprj/trac.ini

mod_python

  • Apache config for mod_python

        #
        # For Subversion repository
        #
        <Location /svn>
                DAV svn
    
        #        # All repos subdirs of /opt/svn
        #        # any "/svn/foo" URL will map to a repository /usr/local/svn/foo
                SVNParentPath /opt/svn
        #        #SVNIndexXSLT "/svn/svnindex.xsl"
        #
        #        # how to authenticate a user
                Require valid-user
                AuthType Basic
                AuthName "Subversion repository"
                AuthUserFile /etc/apache2/dav_svn.passwd
        #        AuthzSVNAccessFile /opt/svn/.svn-policy-file
        #        Satisfy Any
        </Location>
    
        #
        # For Trac
        #
        <Location /projects>
           SetHandler mod_python
           PythonHandler trac.web.modpython_frontend
           PythonOption TracEnvParentDir /opt/trac
           PythonOption TracUriRoot /projects
           PythonDebug on
        </Location>
        <LocationMatch "/projects/[^/]+/login">
          AuthType Basic
          AuthName "Trac"
          AuthUserFile /etc/apache2/dav_svn.passwd
          Require valid-user
        </LocationMatch>
    
  • Install packages

        sudo apt-get install trac libapache2-svn libapache2-mod-python libapache2-mod-python-doc
    
  • 64-bit OS might have problems, may need to compile clearsilver from source

        wget http://www.clearsilver.net/downloads/clearsilver-0.10.4.tar.gz
        ./configure  --disable-ruby --with-python=/usr/bin/python2.5
        make 
        make install
    

mod_wsgi

Add the following section to your apache site config

WSGIScriptAlias /projects /opt/trac/mysite.wsgi

<Directory /opt/trac>
    WSGIApplicationGroup %{GLOBAL}
    Order deny,allow
    Allow from all
</Directory>

<LocationMatch "/projects/[^/]+/login">
  AuthType Basic
  AuthName "Trac"
  AuthUserFile /etc/apache2/dav_svn.passwd
  Require valid-user
</LocationMatch>

sample WSGI file

import os

os.environ['TRAC_ENV_PARENT_DIR'] = '/opt/trac'
os.environ['PYTHON_EGG_CACHE'] = '/opt/cache/eggs'

import trac.web.main
application = trac.web.main.dispatch_request

Upgrade

trac-admin [path] upgrade
apt-get install python-subversion

multiple repositories

  • You should now run trac-admin $ENV repository resync “projects” to synchronize Trac with the repository.

    cd /opt/trac/my_project trac-admin . repository resync “(default)”

  • You should also set up a post-commit hook on the repository to call trac-admin $ENV changeset added “projects” $REV for each committed changeset.

move pages

You can export and load with trac-admin.

On the old box… trac-admin /path/to/old/env wiki export

On the new box… trac-admin /path/to/new/env wiki load

Basic knowledge

  • The timeline provides a historic view of the project in a single report. It’s kind of a view-only feature.
  • The roadmap provides a view on the ticket system that helps planning and managing the future development of a project. Use trac-admin help grep milestone for help.

Instructions to users

Dear $user:

I setup a project management web site for our web development, which includes document/ticket/source code management. You may feel a little awkward when seeing a new tool, but surely you will like it after a few tries. Here is your login information:

  1. go to $trac_prj_url
  2. You will see “Permission Denied” message which is correct because I turn off the switch to public. You need to click “login” button on the top right.
  3. Then you will be prompted to enter login information. Your user ID: Password:

You should be in. If you see any errors, let me know. Thanks. Wish we enjoy working together.

Plugins

  • ChildTicketsPlugin: following the instruction on the page, 1. download the source code. 1. sudo python setup.py install 1. edit trac.ini 1. open a browser for the project 1. verify when you open a ‘New Ticket’, you should see ‘Parent ID’ in ‘Modify Ticket’ section.

  • Agilo for Trac

      # trac.ini
      [components]
      agilo.* = enabled
    
      sudo trac-admin /opt/trac/$repo upgrade
    

    Agile task layout:

    • Trac Milestone
      • Agile Sprint
        • Agile Story
          • Trac ticket (task)

      trac-admin . permission list trac-admin . permission add authenticated PRODUCT_OWNER
      CONTINGENT_ADMIN, CREATE_DEFECT, CREATE_ENHANCEMENT SCRUM_MASTER

      trac-admin . permission add authenticated MILESTONE_ADMIN
      REPORT_ADMIN TICKET_ADMIN WIKI_ADMIN
      AGILO_BACKLOG_EDIT AGILO_BACKLOG_VIEW AGILO_CONFIRM_COMMITMENT
      AGILO_CONTINGENT_ADD_TIME AGILO_CONTINGENT_ADMIN AGILO_CREATE_BUG
      AGILO_CREATE_REQUIREMENT AGILO_CREATE_STORY AGILO_CREATE_TASK
      AGILO_DASHBOARD_VIEW AGILO_LINK_EDIT AGILO_SAVE_REMAINING_TIME
      AGILO_SPRINT_ADMIN AGILO_SPRINT_EDIT AGILO_SPRINT_EDIT
      AGILO_SPRINT_VIEW AGILO_SPRINT_VIEW AGILO_TEAM_CAPACITY_EDIT
      AGILO_TEAM_VIEW AGILO_TICKET_EDIT AGILO_TICKET_EDIT_PAGE_ACCESS
      ATTACHMENT_CREATE BROWSER_VIEW CHANGESET_VIEW CONFIG_VIEW
      CONTINGENT_ADMIN CREATE_DEFECT CREATE_ENHANCEMENT EMAIL_VIEW
      FILE_VIEW LOG_VIEW MILESTONE_ADMIN MILESTONE_CREATE MILESTONE_DELETE
      MILESTONE_MODIFY MILESTONE_VIEW PERMISSION_ADMIN PERMISSION_GRANT
      PERMISSION_REVOKE PRODUCT_OWNER REPORT_ADMIN REPORT_CREATE
      REPORT_DELETE REPORT_MODIFY REPORT_SQL_VIEW REPORT_VIEW ROADMAP_ADMIN
      ROADMAP_VIEW SCRUM_MASTER SEARCH_VIEW TEAM_MEMBER TICKET_ADMIN
      TICKET_ADMIN TICKET_APPEND TICKET_CHGPROP TICKET_CHGPROP
      TICKET_CREATE TICKET_EDIT_CC TICKET_EDIT_COMMENT
      TICKET_EDIT_DESCRIPTION TICKET_EDIT_DESCRIPTION TICKET_MODIFY
      TICKET_MODIFY TICKET_VIEW TIMELINE_VIEW TRAC_ADMIN
      VERSIONCONTROL_ADMIN WIKI_ADMIN WIKI_CREATE WIKI_DELETE WIKI_MODIFY
      WIKI_RENAME WIKI_VIEW

  • [Git] [trac]

Trouble shooting

  1. The Trac Environment needs to be upgraded. Run “trac-admin /opt/trac/*** upgrade”

Solution: sudo chown -R www-data:dev /opt/trac/$trac_env

  1. GitError: GIT control files not found, maybe wrong

Solution: sudo chown -R www-data:dev /opt/git/$git_repo

[trac]
repository_dir = /opt/git/maidgency.git
repository_type = git
repository_sync_per_request = 

[components]
tracext.git.* = enabled
tracopt.ticket.commit_updater.committicketreferencemacro = enabled
tracopt.ticket.commit_updater.committicketupdater = enabled
tracopt.versioncontrol.git.* = enabled

讨论

提示

  • 如果看不到讨论部分, 请暂时关掉adblock in Firefox/Chrome
  • 本网站使用Javascript实现评论功能, 此处外链对提高您的网站PR没有帮助. (潜台词: 请不要灌水, 谢谢)