Changes between Version 2 and Version 3 of waue/TracSubversion


Ignore:
Timestamp:
Feb 10, 2009, 4:12:00 PM (15 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/TracSubversion

    v2 v3  
    22
    33= Trac and Subversion =
    4 此篇是修改官網的[http://trac.edgewall.org/wiki/TracSubversion Trac and Subversion]
     4官網的svn設定落落長[http://trac.edgewall.org/wiki/TracSubversion Trac and Subversion]
    55
    6 Trac has supported the [http://subversion.tigris.org Subversion] VersioningSystemBackend since day one. Actually, Trac was even named `svntrac` back then!
    7 
    8 This page is intended to collect all the specific tips and tricks
    9 about Subversion support ''in Trac''. This is not the place for general
    10 Subversion help.
    11 You can get [wiki:TracSubversion#AskingforMoreSupportAboutSubversion more support]
    12 options elsewhere.
    13 
    14 == Getting Subversion ==
    15 
    16 From subversion.tigris.org, in the [http://subversion.tigris.org/servlets/ProjectDocumentList download] area:
    17  - [http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=260&expandFolder=260&folderID=91 Source] archives.
    18  - Pre-built binaries for [http://subversion.tigris.org/servlets/ProjectDocumentList?folderID=91&expandFolder=91&folderID=74 Windows].
    19    With Subversion 1.4.6, there are pre-built installers for Python 2.3, 2.4, and 2.5.
    20  - On the various BSDs use ports or pkgsrc to install Subversion complete with Python bindings. For FreeBSD see use `/usr/ports/devel/py-subversion`. For pkgsrc use the `devel/py*-subversion` package for getting the bindings.
    21 
    22 == Building Subversion ==
    23 
    24 The point is not to repeat the excellent build instructions found elsewhere,
    25 but rather to clarify the general approach: Trac actually needs the SWIG bindings
    26 for Subversion that are bundled with the Subversion distribution.
    27 In order to build them, you (obviously) need to build first Subversion,
    28 then the bindings.
    29  * Read the `INSTALL` file that sits at top level of the Subversion source distribution
    30  * Do `./configure ...; make; make install`; if you intend to use Subversion together with Apache, be sure to configure Subversion so that it will use a compatible version of `apr` and `apr-utils`, ideally those of Apache. If not, you'll be able to build Subversion and the bindings, but you most certainly have issues later on, when using mod_python (e.g. #2920).
    31  * Read `./subversion/bindings/swig/INSTALL` in order to build the bindings.
    32    In particular, pay attention to the version of SWIG which can be required
    33    (1.3.0 comes with pre-generated wrappers, though). Do not install swig 1.3.28 or 1.3.29. Version 1.3.27 seems to works fine (Although not in all cases. The subversion users mailing lists suggest going back to 1.3.25, which may be necessary).
    34  * In your subversion source root, do `make swig-py; make install-swig-py` (NOTE: there is a dash between 'install' and 'swig'!)
    35  * Adapt your `PYTHONPATH` so that it contains the `svn-python` folder
    36    (the one containing the `svn` and `libsvn` packages). [[br]]
    37    e.g. if svn is installed in `/opt/subversion-1.4.4`:
    38    {{{
    39 # export PYTHONPATH=$PYTHONPATH:/opt/subversion-1.4.4/lib/svn-python`
    40    }}}
    41    If you're using TracModPython, be sure that Apache will also see this environment variable, or alternatively use the [TracModPython#Subversionissues PythonPath] mod_python directive.[[br]][[br]]You may also just copy the libsvn/ and svn/ directories in the resulting installation directories, e.g. /usr/local/lib/svn-python/, to the site-packages/ directory in your /usr/lib/python2.x/ directory. Python will then find them without having to adapt your `PYTHONPATH`.
    42 
    43 === Getting Subversion working ===
    44 (this is a cite from TracOnDebianSarge as this is extremely useful for first time user setting up subversion repository)
    45 
    46 To create a Subversion project at '''/var/svn/project''', issue these commands to get SVN up and running:
     6其實只要修改 conf/trac.ini 檔的repository_dir的參數內容為svn的路徑即可。
     7{{{
     8sudo vim /var/lib/trac/waue/conf/trac.ini
     9}}}
    4710
    4811{{{
    49   $ mkdir /var/svn
    50   $ mkdir /var/svn/project
    51   $ mkdir /tmp/project
    52   $ mkdir /tmp/project/branches
    53   $ mkdir /tmp/project/tags
    54   $ mkdir /tmp/project/trunk
    55   $ svnadmin create /var/svn/project
    56   $ svn import /tmp/project file:///var/svn/project -m "initial import"
    57   $ rm -rf /tmp/project
     12#!diff
     13
     14-repository_dir = /var/lib/trac/waue
     15+repository_dir = /var/lib/svn/waue
    5816}}}
    59 
    60 Fix permissions to the repository:
    61 {{{
    62   $ find /var/svn/project -type f -exec chmod 660 {} \;
    63   $ find /var/svn/project -type d -exec chmod 2770 {} \;
    64   $ chown -R root.www-data /var/svn/project
    65 }}}
    66 
    67 
    68 
    69 == Trac and specific Subversion versions ==
    70 {{{
    71 #!comment
    72 The following info  about pre 1.3.0 versions is all ''by heart''
    73 and is probably inaccurate at places.
    74 This is mostly to get the page started.
    75 Feel free to correct me and publicly humiliate me :)
    76 }}}
    77 
    78 === Trac and Subversion 1.0 ===
    79 This is the oldest supported Subversion version.
    80 
    81 === Trac and Subversion 1.1 ===
    82 This release introduced the `fsfs` repository backend,
    83 which is to be preferred over the `bdb` one (see #571 for example).
    84 When creating a repository with this Subversion version,
    85 take care of using the `--fs-type fsfs` switch with the `svnadmin create`
    86 command.
    87 Version 1.1.4 is the last stable one for that maintenance branch.
    88 
    89 === Trac and Subversion 1.2 ===
    90 This release makes the `fsfs` storage the default.
    91 Version 1.2.3 is the last stable one for that maintenance branch.
    92 
    93 If you switched from a previous version to this one, chances are that you had
    94 a Berkeley DB repository. It would be a good idea to switch that repository
    95 to the FSFS backend. google:svn+convert+bdb+to+fsfs.
    96 
    97 === Trac and Subversion 1.3 ===
    98 This is the newest major release for Subversion, and it is currently
    99 support by Trac 0.9.x and beyond, with a few caveats.
    100 
    101 ==== Trac and Subversion 1.3.0 ====
    102 
    103 There are a few known issues with the stock 1.3.0 version:
    104  * Issue #2472 (spurious exception) [[BR]]
    105    which can be fixed by applying this
    106    [/trac/ticket/2472#change_12 patch] to
    107    `subversion/bindings/swig/python/svn/core.py` [[BR]]
    108    Should be fixed in Subversion 1.3.1 (!r17992).
    109  * Issue #2620 (memory leak) [[BR]]
    110    which can be fixed by applying this
    111    [/trac/ticket/2620#change_10 patch] to
    112    `subversion/bindings/swig/python/libsvn_swig_py/swigutil_py.c`. [[BR]]
    113    Should be fixed in Subversion 1.3.1 (!r18230).
    114 
    115 With those fixes, I've been able to use the Subversion backend
    116 flawlessly "in production", since end of January 2006.
    117 
    118 However, some people are seeing yet another problem, which requires
    119 one more fix:
    120  * Issue #2611 (intermittent fatal error, manifesting itself with `"argument number 0: a 'apr_pool_t *' is expected"` messages in the log and segfault of the apache server) [[BR]]
    121    was supposedly fixed by applying this
    122    [attachment:ticket:2611:application_pool_race_condition_fix.txt patch] to
    123    `subversion/bindings/swig/include/proxy_apr.swg`.
    124    Note that after applying this patch, the SWIG bindings would have to be regenerated,
    125    as explained [comment:ticket:2611:16 here].
    126    It should be emphasized that a compatible version of SWIG
    127    must be used (`1.3.24`, `1.3.25`). [[BR]]
    128    The issue was supposed to be fixed in Subversion 1.3.1, as the above patch was integrated as !r18721, but actually the patch was not enough to solve the issue. See below.
    129 
    130 ==== Trac and Subversion 1.3.1 ====
    131 
    132 As mentioned above, the issues found with 1.3.0 should be fixed
    133 by 1.3.1. This is mostly true, except for #2611.
    134 
    135 '''Issue #2611 was confirmed to still exists in Subversion 1.3.1''' and also in the stock 1.3.2,
    136 when compiled using the pre-generated bindings that were produced using SWIG 1.3.25[[br]]
    137 So it seems the patch discussed above was not enough to solve the problem.
    138 Also, ''the issue is most certainly related to the use of multiple python sub-interpreters'', either because those are created by default when different virtual hosts are used (#2965, #3455) or because different `"PythonInterpreter"` directives are used in different <Location> sections (#2713). '''A workaround consists to force the use of a single Python interpreter''', using the `"PythonInterpreter"` directive with the same argument for all the virtual hosts, as explained [comment:ticket:3455:5 here].
    139 
    140 ==== Trac and Subversion 1.3.2 ====
    141 
    142 This version adds support for SWIG 1.3.28.
    143 
    144 See also: [http://svn.collab.net/repos/svn/tags/1.3.2/CHANGES release notes for 1.3.2]
    145 
    146 === Trac and Subversion 1.4 ===
    147 
    148 Trac works well with Subversion 1.4.
    149 
    150 I've noticed that there has been some improvements to the `ra` layer ... unfortunately not available yet for the Python bindings
    151 
    152 Also, that version supports SWIG 1.3.29, but so far I used the 1.3.25 pre-generated wrappers that are bundled with the tarball.
    153 
    154 Same remark as above concerning #2611, if I have some time, I'll try to reproduce the issue.
    155 Update: according to comment:ticket:2965:14, the problem is still there for 1.4.
    156 
    157 See also: [http://svn.collab.net/repos/svn/tags/1.4.0/CHANGES release notes for 1.4.0]
    158 
    159 == Troubleshooting ==
    160 
    161 ==== `RuntimeError: instance.__dict__ not accessible in restricted mode` ==== #instance-dict-restricted-mode
    162 
    163 This is becoming one of the most frequently reported issues for Trac and the Subversion backend, when the TracModPython web front-end is used. The problem happen when Trac is running outside of the "main_interpreter" Python interpreter and can be fixed as explained in #3371:
    164 {{{
    165 <Location>
    166 ...
    167 PythonInterpreter main_interpreter
    168 ...
    169 </Location>
    170 }}}
    171 
    172 This problem can also occur when using mod_wsgi for both embedded mode or daemon mode. As documented in [http://code.google.com/p/modwsgi/wiki/IntegrationWithTrac integrating Trac with mod_wsgi], the solution is the same as for mod_python. That is, force Trac instance to run in main Python interpreter instance. When using mod_wsgi this is done using:
    173 {{{
    174 WSGIApplicationGroup %{GLOBAL}
    175 }}}
    176 
    177 ==== `TypeError: argument number 0: a 'apr_pool_t *' is expected, 'instance(<libsvn.core.GenericSWIGWrapper instance at 0x...>)' is received` ====
    178 Use the same fix as above. See #2611 for more information if needed.
    179 
    180 ==== `ImportError: /usr/local/lib/libsvn_ra_dav-1.so.0: undefined symbol: ...` ==== #ra_dav-undefined-symbol
    181 
    182 This error manifests itself quite frequently with Subversion 1.4, the `undefined symbol` in question may differ (`gss_delete_sec_context`, `SSL_shutdown`, etc.)
    183  
    184 See the advices of Garrett !McGrath in googlegroups:trac-users:1ec307bef7552e5e and also #3706.
    185 
    186 ==== `SubversionException: ("Expected version '3' of repository; found version '5'", ...` ==== #version-mismatch
    187 
    188 The bindings used are older than the Subversion version used to create the repository (#3943).
    189 
    190 ==== `SubversionException: ('No such revision XY', 160006)` ==== #no-such-revision
    191 
    192 This kind of error seems to happen frequently. Sometimes it seems to be related to the Trac cache being out-of-sync and needing a manual `resync` (#2739, #3301, #3728); this can happen if the repository was rebuilt and its UUID hasn't changed. Sometimes it seems to be because the repository is temporarily unavailable (#2346), and sometimes, we simply don't know yet (#3773, #3861, #3875).
    193 
    194 ==== `Unsupported version control system "svn"` ==== #unsupported-vcs
    195 
    196 By far one of our most commonly reported installation issue
    197 (search:'"Unsupported version control system"'), this simply means
    198 that the Python bindings for Subversion can't be loaded by Trac.
    199 
    200 If you use Debian an try this: TracOnDebianSarge
    201 
    202 This can be due to a variety of reasons, and you should go through the
    203 following check list to find out.
    204 
    205 ==== Check list ====
    206 
    207 When there's some trouble using the Subversion bindings,
    208 it usually helps to perform the following checks:
    209 
    210  1. Verify that you can load the bindings using the Python interactive interpreter
    211 
    212 {{{
    213 $ python
    214 Python ...
    215 >>> from svn import core
    216 }}}
    217 If this succeeds, that's a good start.
    218 
    219 If it doesn't,  it usually means that your bindings are located in
    220 a place they can't be loaded from. So either move the `svn` and `libsvn`
    221 found in the /opt/subversion-xxx/lib/svn-python folder
    222 into your site-packages folder, or add the above folder to your PYTHONPATH,
    223 or create a [http://docs.python.org/lib/module-site.html svn.pth] file
    224 in your Python site-packages folder with the above folder path as its
    225 single line content (an example on a FreeBSD installation, again: /usr/local/lib/pythonN.N/site-packages/). One simple solution for rpm-based operating systems, is to install the subversion-python bindings rpm. The [http://subversion.tigris.org/project_packages.html official subversion site] points [http://summersoft.fay.ar.us/pub/subversion/latest/ here] to download those packages.
    226 
    227 If you get the message {{{ImportError: libsvn_swig_py-1.so.0: cannot open shared object file: No such file or directory}}} even though you can see the .so file in the correct place, then try {{{ldconfig -v}}} as root.
    228 
    229 
    230  2. Check the version
    231 {{{
    232 >>> (core.SVN_VER_MAJOR, core.SVN_VER_MINOR, core.SVN_VER_MICRO, core.SVN_VER_PATCH)
    233 (1, 4, 3, 3)
    234 }}}
    235 Verify that the version given back matches your expectation.
    236 
    237  3. Check that you're using the right binaries (Linux)
    238 
    239 Get the pid of the above running Python interpreter (i.e. once the
    240 binding is loaded), and get the list of the libraries used by looking at the
    241 corresponding map file.
    242 
    243 e.g.
    244 {{{
    245 cat /proc/10213/maps | grep .so | cut -d/ -f2- | sort -u
    246 }}}
    247 
    248 In particular, pay attention to the `.../lib/svn-python/libsvn/_core.so` file
    249 and see if its location seems to be consistent with both those of the other
    250 svn libraries (`.../lib/*.so`) and the location of the Python code part of the
    251 bindings (`.../lib/svn-python/svn/core.py`).
    252 
    253 '''And if it doesnt....??'''
    254 
    255 (Mac OS X) Subversion 1.5.X defaults installs in /opt/subversion/. The svn.pth solution works up to this point, but Trac will still be unhappy: you will need to copy /opt/subversion/lib/svn-python/svn &  /opt/subversion/lib/svn-python/libsvn on top of  /System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/python/libsvn and /System/Library/Frameworks/Python.framework/Versions/Current/Extras/lib/python/svn.
    256 
    257  3. If you're using Apache / mod_python (Linux/Windows) (first tip)
    258 
    259 Get a similar list of libraries, but this time for one of your httpd process.
    260 Then compare the two, and pay attention to any difference between the `svn`
    261 libraries and the `apr` libraries. You ''have to'' have compatible APR libraries
    262 between Apache and Subversion, otherwise you risk to get a wide variety of subtle
    263 errors (e.g. #4985).
    264 
    265  4. If you're using Apache / mod_python (Linux) (second tip)
    266 
    267 If you have installed the Subversion .so-Files in some "remote" location, Apache may be unable to find them (and thus unable to pass them on to Python/Trac, such that Trac cannot find Subversion). To check if this is the case, do the following:
    268 
    269 {{{
    270 /etc/init.d/apache2 stop
    271 $export LD_LIBRARY_PATH=/usr/lib/python/site-packages/libsvn/:$LD_LIBRARY_PATH
    272 /etc/init.d/apache2 restart
    273 }}}
    274 
    275 If this works, you need to add the library path permanently. There are two options for this. Either add it in the Apache configuration file (http://httpd.apache.org/docs/2.2/mod/mod_env.html#setenv) or at the system level by adding the path to /etc/ld.so.conf, and then run ldconfig. More information on shared libraries can be found here: http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
    276 
    277 5. if you're getting 'undefined symbol: xmlCreatePushParserCtxt' while running make check-swig-py, it could be that your libneon is compiled against libxml2. If this is the case, try to recompile your libneon against expat instead of libxml2.
    278 
    279 == Tip for Debian Linux ==
    280 Try to install the Subversion Bindings using apt
    281 {{{
    282 apt-get install python-subversion
    283 }}}
    284 Works for Subversion 1.4.
    285 
    286 == Known Issues ==
    287 
    288 [[TicketQuery(status=!closed&keywords=~svn&type=defect)]]
    289 
    290 == Asking for More Support About Subversion ==
    291 
    292  * !ReadTheFineBook: http://svnbook.red-bean.com and/or the   
    293    [http://subversion.tigris.org/faq.html FAQ]
    294  * There's also a `#svn` channel on the `freenode` IRC network
    295  * If you think you've found a bug in Subversion, read these
    296    [http://subversion.tigris.org/project_issues.html instructions]
    297