<?xml version="1.0" encoding="iso-8859-2"?>
<!DOCTYPE zprava SYSTEM "techrep.dtd">

<zprava cislo="21/2003" jazyk="en">
<nazev>API description for Netopeer repository library</nazev>
<autor>Ondřej Zloský</autor>
<datum>17.11.2003</datum>
<h1>Motivation</h1>
<p>
Our motivation for writing a repository library was to provide higher-level functions
to using them in frontends and backends and thus simplify the access to the repository.
Programers of Netopeer's utilities want to put in their codes something like
<prikaz>conf_checkout(url)</prikaz> and everything else could be hidden.
They only need to get the requested configuration. Whether the repository is under Subversion, CVS or other
version control system is not important.
</p>
<p>Our API design tries to offer this funcionality. The current version is written for
Subversion because Subversion has some features that are good for our project. First,
Subversion has it's own API that provides communication with repository through
direct call of Subversion's functions. It is much better than writing some wrapper around
Subversion, CVS or other clients. For example, we have Subversion's internal error structures,
we can change visual output from functions and it is for sure that we can't forget something
in wrapping. Second, Subversion provides the opportunity to use other programs instead of the usual text 'diff'
so we can use 'xmldiff' that is better for our XML configurations.
</p>
<p>
The repository API design is still in progress and some functions could be incomplete or
missing in this document.
</p>
<h1>Using repository API</h1>
<h2>API description</h2>
<p>
For using repository API you need to install Subversion including devel packages (or
install Subversion from source). See the installation instructions on how to get and install Subversion and other
tools properly.
</p>
<p>
The repository library is now written in the C language and every public functions in it has prefix
'conf_' for better orientation and in order to aovid naming conflicts. Every function is well documented in the source code. The
following functions are defined:</p>
<dl>

<dt>conf_list (char *repos_url);</dt>
<dd>Same as '<prikaz>svn list url</prikaz>'. <br/>
Return a repository listing with information about stored files</dd>

<dt>conf_checkout (const char *repos_url, char *target_path, char *rev_wanted);</dt>
<dd>Same as '<prikaz>svn checkout URL [path] [-r revision]'</prikaz>.<br/>
Returns a repository directory and store it in target_path parameter</dd>

<dt>conf_copy (const char *source_path, const char *dest_path, const char *message);</dt>
<dd>Same as '<prikaz>svn copy URL URL -m "message"</prikaz>').<br/>
Copy a codument in the repository from source URL to destination URL where URLs are directories in repository</dd>

<dt>conf_diff (const char *repos_url, char *rev_wanted, const char *type);</dt>
<dd>Almost same as '<prikaz>svn diff URL -r revision:revision</prikaz>'.<br/>
Return a diff between two revisions of the same file. The third argument 'type' is the type of
diff wanted. It could be 'xml' for xmldiff or anything else for normal diff.</dd>

<dt>conf_import (const char *source_path, const char *repos_url, const char *message);</dt>
<dd>Same as '<prikaz>svn import path URL -m "message"</prikaz>'.<br/>
Import new configuration from source_path to repository URL.</dd>

<dt>conf_commit (const char *items, const char *message);</dt>
<dd>Same as '<prikaz>svn commit path -m "message"</prikaz>'.<br/>
Commit changes made on working copy.</dd>

<dt>conf_status (const char *source_path);</dt>
<dd>Same as '<prikaz>svn status path</prikaz>'.<br/>
Show status of the files in the working copy.</dd>
</dl>
<p>
Every function takes care about memory managment and administration of user context. It means
that programmers of front&amp;backends need not code these functions themselves.
</p>
<h2>Requirements</h2>
<p>
All you need is to include header file <soubor>repos.h</soubor> using<br/>
<prikaz>#include "parser.h"</prikaz><br/> and have the file <soubor>repos.c</soubor> in the working directory.
This is an interim setup, the final solution will use a shared library. For now, however, it has to be built directly into clients.</p>
<h2>Compilation</h2>
<p>
Compilation is system dependent respectively in that it depends on installed libraries and parameters with
which Subversion was compiled. Check the latest Makefile to see the actual versions of libraries necessary for a successful compilation
</p>
<h2>Other planned functions</h2>
<ul>
<li>
Syntactic control. Our installation of Subversion implements syntactic validation of configurations.
It is done by a <soubor>pre-commit</soubor> hook installed in <soubor>/path/to/repos_db/hooks</soubor>.
Semantic checker is a bash script which uses a program written by Petr Novak.
</li>
<li>
Access control through WebDAV. Controlled access should be applicable to every configuration separately.
</li>
<li>
Unified configuration list independt of the version control system (Every control version system
has it's own numbering and Subversion's numbering scheme is not satisfactory for our purposes.)
</li>
</ul>
<h1>Subversion repository installation</h1>
<p>
Subversion repository can be installed either from source using the usual procedure
or as pre-built binary packages. The latter approach is slightly easier. When installing
from source, you should have all the libraries and header files that are needed for a correct operation of
the Netopeer's repository library. When installing from binary packages, you
have to install devel packages as well.
</p>
<p>
<a href="http://subversion.tigris.org">Subversion</a> can be installed
on various operating systems and pre-built binary packages are available from the
<a href="http://subversion.tigris.org/getting_subversion.html">download page</a> of Subversion.
</p>
<h2>Installation from source code</h2>
<h3>Client</h3>
<p>
Client-only installation of Subversion is simpler and depends on just a few software packages. With this installation you can use actions like
<prikaz>checkout, commit, list</prikaz> and others.
</p>
<p>
In order to compile and use the Subversion client, you need to have the following:
<ol>
<li><a href="http://apr.apache.org/">Apache Portable Runtime 0.9.4</a> (included in Subversion distribution)</li>
<li>autoconf 2.50 or newer</li>
<li>libtool 1.4 or newer</li>
<li>bison or yacc</li>
<li><a href="http://www.webdav.org/neon/">Neon library 0.24.2</a> (included in Subversion distribution)</li>
</ol>
</p>
<p>
After downloading the latest source you can compile and install it using the standard procedure:
<prikaz>./configure</prikaz><br/>
<prikaz>make</prikaz><br/>
<prikaz>make install</prikaz><br/>
</p>
<p>
For advanced functions you may want to use few special parameters for <prikaz>./configure</prikaz>:
<ul>
<li><prikaz>--enable-maintainer-mode</prikaz> - turns on debugging</li>
<li><prikaz>--with-ssl</prikaz> - turns on ssl comunnication with neon - you need to
have OpenSSl installed on your system</li>
<li><prikaz>--with-zlib</prikaz> - turns on support for sending compressed data
using the zlib library</li>
<li>other parameters can be found by <prikaz>./configure --help</prikaz></li>
</ul>
</p>
<p>
The installation can be tested by running some svn commands, e.g., <prikaz>
svn co http://svn.collab.net/repos/svn/trunk svn</prikaz>. If everything
works, after checkout you will have files from the Subversion's tree in the svn directory.
</p>
<h3>Server</h3>
<p>
In addition to all third-party tools neede for the client installation, the Subversion's server requires:
<ol>
<li><a href="http://www.sleepycat.com/download/patchlogs.shtml">Berkeley DB 4.0.14 or newer</a></li>
<li><a href="http://httpd.apache.org/download.cgi">Apache Web Server 2.0.47 or newer</a></li>
</ol>
</p>
<p>
If these components are present in your system than Subversion will be compiled as a server. You can
do it by the same procedure again:<br/>
<prikaz>./configure</prikaz><br/>
<prikaz>make</prikaz><br/>
<prikaz>make install</prikaz><br/>
If you have Berkeley DB in a non-standard location, you can add the parameter <prikaz>
--with-berkeley-db="/path/to/berkeleydb/"</prikaz> and a non-standard location of Apache
can be specified by the parameter <prikaz>--with-apxs="/path/to/apache/apxs"</prikaz>.
</p>
After installation, you can test the functionality of the server by:<br/>
<prikaz>svnadmin create /path/to/repos/</prikaz><br/>
<prikaz>svn co file:///path/to/repos</prikaz><br/>
and you should see <vstup>Checked out revision 0.</vstup> without any errors.
<h3>Note</h3>
<p>
There are many other configuration options and details enabling or disabling
special features, libraries, etc. This is just a mini guide on how to install Subversion
if there are no specific troubles and/or requirements. If you encounter problems or miss some functions,
please consult the Subversion INSTALL file or documentation.
</p>
<h2>Installation from pre-built binary packages</h2>
<p>
You can download binary packages from <a href="http://summersoft.fay.ar.us/pub/linux/redhat/RPMS/i386/subversion/">
http://summersoft.fay.ar.us/pub/linux</a>. All other packages that are needed
for Subversion can be downloaded from usual distribution-specific places. For example, on a RPM-based Linux distribution, you can
install Subversion by running the following command as root:<br/>
<prikaz>rpm -ivh subversion*.i386.rpm</prikaz>
</p>
<p>
After installation you can test the functionality by running the same tests as before.
</p>

<h1>XMLdiff installation</h1>
<p>
XMLdiff is used by the Netopeer configuration repository is XMLdiff for identifying changes in two
configurations. Because our configuration data are in the XML format, it is better than the normal
text diff. Subversion can use various diff commands and our library supports this function
too.
</p>
<h2>Requirements</h2>
<p>
XMLdiff is written in Python. You need to have <a href="http://www.python.org/">
Python</a> version 2.0 or higher. For extended functions of XMLdiff the PyXML module is also needed.
</p>
<h2>Installation</h2>
<p>
Download <a href="http://www.logilab.org/xmldiff/">XMLdiff</a>, untar it and install
by running:<br/>
<prikaz>python setup.py install</prikaz> or <br/>
<prikaz>python setup.py help</prikaz> to see advanced parameters.
</p>
<p>
Or you can download rpm from the internet and install it (as root) simply by:<br/>
<prikaz>rpm -ivh xmldiff*.rpm</prikaz>
</p>
</zprava>
