xref: /OpenGrok/tools/README.md (revision 2d57dc692b4dd10e696ca6922510f6cecded1bfd)
1*2d57dc69SVladimir Kotal
2*2d57dc69SVladimir Kotal# OpenGrok tools
3*2d57dc69SVladimir Kotal
4*2d57dc69SVladimir KotalSet of scripts to facilitate project synchronization and mirroring
5*2d57dc69SVladimir Kotal
6*2d57dc69SVladimir KotalThe scripts require Python 3 and they rely on a binary/symlink `python3` to be
7*2d57dc69SVladimir Kotalpresent that points to the latest Python 3.x version present on the system.
8*2d57dc69SVladimir Kotal
9*2d57dc69SVladimir KotalCurrently it is assumed that Python 3.6 and greater is used.
10*2d57dc69SVladimir Kotal
11*2d57dc69SVladimir KotalSee https://github.com/oracle/opengrok/wiki/Repository-synchronization
12*2d57dc69SVladimir Kotalfor more details.
13*2d57dc69SVladimir Kotal
14*2d57dc69SVladimir Kotal# Content
15*2d57dc69SVladimir Kotal
16*2d57dc69SVladimir KotalThis is a list of the binaries in this package.
17*2d57dc69SVladimir Kotal
18*2d57dc69SVladimir Kotal```text
19*2d57dc69SVladimir Kotalopengrok-config-merge
20*2d57dc69SVladimir Kotalopengrok-deploy
21*2d57dc69SVladimir Kotalopengrok-groups
22*2d57dc69SVladimir Kotalopengrok
23*2d57dc69SVladimir Kotalopengrok-indexer
24*2d57dc69SVladimir Kotalopengrok-java
25*2d57dc69SVladimir Kotalopengrok-mirror
26*2d57dc69SVladimir Kotalopengrok-projadm
27*2d57dc69SVladimir Kotalopengrok-reindex-project
28*2d57dc69SVladimir Kotalopengrok-sync
29*2d57dc69SVladimir Kotal```
30*2d57dc69SVladimir Kotal
31*2d57dc69SVladimir Kotal# Development
32*2d57dc69SVladimir Kotal
33*2d57dc69SVladimir Kotal## Environment
34*2d57dc69SVladimir Kotal
35*2d57dc69SVladimir KotalPrepare a virtual environment
36*2d57dc69SVladimir Kotal
37*2d57dc69SVladimir Kotal```bash
38*2d57dc69SVladimir Kotalpython3 -m venv env
39*2d57dc69SVladimir Kotal. env/bin/activate
40*2d57dc69SVladimir Kotal```
41*2d57dc69SVladimir Kotal
42*2d57dc69SVladimir Kotal## Developing
43*2d57dc69SVladimir Kotal
44*2d57dc69SVladimir KotalWhen you start developing, install the package in a development mode.
45*2d57dc69SVladimir Kotal
46*2d57dc69SVladimir Kotal```bash
47*2d57dc69SVladimir Kotalpython setup.py develop
48*2d57dc69SVladimir Kotal```
49*2d57dc69SVladimir Kotal
50*2d57dc69SVladimir KotalThis installs the package however keeping the links directly to your source,
51*2d57dc69SVladimir Kotalso you can edit the files and see the immediate results.
52*2d57dc69SVladimir Kotal
53*2d57dc69SVladimir KotalStart developing, making changes in files. Test your changes with calling the entry points.
54*2d57dc69SVladimir Kotal
55*2d57dc69SVladimir Kotal```bash
56*2d57dc69SVladimir Kotalexport PYTHONPATH=`pwd`/src/main/python:$PYTHONPATH
57*2d57dc69SVladimir Kotalopengrok-groups
58*2d57dc69SVladimir Kotalopengrok-sync
59*2d57dc69SVladimir Kotal```
60*2d57dc69SVladimir Kotal
61*2d57dc69SVladimir KotalIt is necessary to set the python path as the python interpreter is not able to find the packages
62*2d57dc69SVladimir Kotalin our provided structure on its own.
63*2d57dc69SVladimir Kotal
64*2d57dc69SVladimir KotalAlso you call the opengrok tools scripts by the entry points then (`opengrok-groups`, ...).
65*2d57dc69SVladimir KotalCalling directly the python script `groups.py` would lead to error related to relative imports.
66*2d57dc69SVladimir Kotal
67*2d57dc69SVladimir KotalNote that on macOS, you will need to install libgit2 library for the tests
68*2d57dc69SVladimir Kotalto pass.
69*2d57dc69SVladimir Kotal
70*2d57dc69SVladimir Kotal## Installation
71*2d57dc69SVladimir Kotal
72*2d57dc69SVladimir KotalTest installing your package into the local environment
73*2d57dc69SVladimir Kotal
74*2d57dc69SVladimir Kotal```bash
75*2d57dc69SVladimir Kotalpython setup.py install
76*2d57dc69SVladimir Kotal# now you can try console scripts
77*2d57dc69SVladimir Kotalopengrok-groups
78*2d57dc69SVladimir Kotalopengrok-sync
79*2d57dc69SVladimir Kotal```
80*2d57dc69SVladimir Kotal
81*2d57dc69SVladimir Kotalor make a distribution tarball.
82*2d57dc69SVladimir Kotal
83*2d57dc69SVladimir Kotal```bash
84*2d57dc69SVladimir Kotalpython setup.py sdist
85*2d57dc69SVladimir Kotalls -l dist/
86*2d57dc69SVladimir Kotal```
87*2d57dc69SVladimir Kotal
88*2d57dc69SVladimir Kotal### Installation on the target system
89*2d57dc69SVladimir Kotal
90*2d57dc69SVladimir KotalUse the distribution tarball and run `pip`.
91*2d57dc69SVladimir Kotal
92*2d57dc69SVladimir Kotal```bash
93*2d57dc69SVladimir Kotalpython3 -m pip install opengrok_tools.tar.gz
94*2d57dc69SVladimir Kotal```
95*2d57dc69SVladimir Kotal
96*2d57dc69SVladimir KotalThis will download all dependencies and install the package to your local python3 modules.
97*2d57dc69SVladimir KotalYou can use console scripts to run the package binaries.
98*2d57dc69SVladimir Kotal
99*2d57dc69SVladimir Kotal#### Installing to a specified directory
100*2d57dc69SVladimir Kotal
101*2d57dc69SVladimir KotalYou can also install the tools to a specified directory, we suggest you to use the python virtual environment for it.
102*2d57dc69SVladimir Kotal
103*2d57dc69SVladimir Kotal```bash
104*2d57dc69SVladimir Kotalcd /opt/opengrok
105*2d57dc69SVladimir Kotalpython3 -m venv opengrok-tools
106*2d57dc69SVladimir Kotalopengrok-tools/bin/python -m pip install opengrok_tools.tar.gz
107*2d57dc69SVladimir Kotal```
108*2d57dc69SVladimir Kotal
109*2d57dc69SVladimir KotalThis will install the package and all the dependencies under the `/opt/opengrok/opengrok-tools` directory.
110*2d57dc69SVladimir KotalYou can then call the scripts with
111*2d57dc69SVladimir Kotal
112*2d57dc69SVladimir Kotal```bash
113*2d57dc69SVladimir Kotal/opt/opengrok/opengrok-tools/bin/opengrok-indexer
114*2d57dc69SVladimir Kotal/opt/opengrok/opengrok-tools/bin/opengrok-groups
115*2d57dc69SVladimir Kotal...
116*2d57dc69SVladimir Kotal```
117*2d57dc69SVladimir Kotal
118*2d57dc69SVladimir Kotal#### Uninstalling
119*2d57dc69SVladimir Kotal
120*2d57dc69SVladimir Kotal```bash
121*2d57dc69SVladimir Kotalpython3 -m pip uninstall opengrok_tools
122*2d57dc69SVladimir Kotal```
123*2d57dc69SVladimir Kotal
124*2d57dc69SVladimir Kotal## Testing
125*2d57dc69SVladimir Kotal
126*2d57dc69SVladimir Kotal```bash
127*2d57dc69SVladimir Kotalpython setup.py install test
128*2d57dc69SVladimir Kotal./mvnw test
129*2d57dc69SVladimir Kotal```
130*2d57dc69SVladimir Kotal
131*2d57dc69SVladimir Kotal## Cleanup
132*2d57dc69SVladimir Kotal
133*2d57dc69SVladimir KotalDeactivate the virtual environment
134*2d57dc69SVladimir Kotal```bash
135*2d57dc69SVladimir Kotaldeactivate
136*2d57dc69SVladimir Kotal# optionally
137*2d57dc69SVladimir Kotal# rm -r env
138*2d57dc69SVladimir Kotal```
139*2d57dc69SVladimir Kotal
140