12d57dc69SVladimir Kotal 22d57dc69SVladimir Kotal# OpenGrok tools 32d57dc69SVladimir Kotal 42d57dc69SVladimir KotalSet of scripts to facilitate project synchronization and mirroring 52d57dc69SVladimir Kotal 62d57dc69SVladimir KotalThe scripts require Python 3 and they rely on a binary/symlink `python3` to be 72d57dc69SVladimir Kotalpresent that points to the latest Python 3.x version present on the system. 82d57dc69SVladimir Kotal 92d57dc69SVladimir KotalCurrently it is assumed that Python 3.6 and greater is used. 102d57dc69SVladimir Kotal 112d57dc69SVladimir KotalSee https://github.com/oracle/opengrok/wiki/Repository-synchronization 122d57dc69SVladimir Kotalfor more details. 132d57dc69SVladimir Kotal 142d57dc69SVladimir Kotal# Content 152d57dc69SVladimir Kotal 162d57dc69SVladimir KotalThis is a list of the binaries in this package. 172d57dc69SVladimir Kotal 182d57dc69SVladimir Kotal```text 192d57dc69SVladimir Kotalopengrok-config-merge 202d57dc69SVladimir Kotalopengrok-deploy 212d57dc69SVladimir Kotalopengrok-groups 222d57dc69SVladimir Kotalopengrok 232d57dc69SVladimir Kotalopengrok-indexer 242d57dc69SVladimir Kotalopengrok-java 252d57dc69SVladimir Kotalopengrok-mirror 262d57dc69SVladimir Kotalopengrok-projadm 272d57dc69SVladimir Kotalopengrok-reindex-project 282d57dc69SVladimir Kotalopengrok-sync 292d57dc69SVladimir Kotal``` 302d57dc69SVladimir Kotal 312d57dc69SVladimir Kotal# Development 322d57dc69SVladimir Kotal 332d57dc69SVladimir Kotal## Environment 342d57dc69SVladimir Kotal 352d57dc69SVladimir KotalPrepare a virtual environment 362d57dc69SVladimir Kotal 372d57dc69SVladimir Kotal```bash 382d57dc69SVladimir Kotalpython3 -m venv env 392d57dc69SVladimir Kotal. env/bin/activate 402d57dc69SVladimir Kotal``` 412d57dc69SVladimir Kotal 422d57dc69SVladimir Kotal## Developing 432d57dc69SVladimir Kotal 442d57dc69SVladimir KotalWhen you start developing, install the package in a development mode. 452d57dc69SVladimir Kotal 462d57dc69SVladimir Kotal```bash 472d57dc69SVladimir Kotalpython setup.py develop 482d57dc69SVladimir Kotal``` 492d57dc69SVladimir Kotal 502d57dc69SVladimir KotalThis installs the package however keeping the links directly to your source, 512d57dc69SVladimir Kotalso you can edit the files and see the immediate results. 522d57dc69SVladimir Kotal 532d57dc69SVladimir KotalStart developing, making changes in files. Test your changes with calling the entry points. 542d57dc69SVladimir Kotal 552d57dc69SVladimir Kotal```bash 562d57dc69SVladimir Kotalexport PYTHONPATH=`pwd`/src/main/python:$PYTHONPATH 572d57dc69SVladimir Kotalopengrok-groups 582d57dc69SVladimir Kotalopengrok-sync 592d57dc69SVladimir Kotal``` 602d57dc69SVladimir Kotal 612d57dc69SVladimir KotalIt is necessary to set the python path as the python interpreter is not able to find the packages 622d57dc69SVladimir Kotalin our provided structure on its own. 632d57dc69SVladimir Kotal 642d57dc69SVladimir KotalAlso you call the opengrok tools scripts by the entry points then (`opengrok-groups`, ...). 652d57dc69SVladimir KotalCalling directly the python script `groups.py` would lead to error related to relative imports. 662d57dc69SVladimir Kotal 672d57dc69SVladimir KotalNote that on macOS, you will need to install libgit2 library for the tests 682d57dc69SVladimir Kotalto pass. 692d57dc69SVladimir Kotal 702d57dc69SVladimir Kotal## Installation 712d57dc69SVladimir Kotal 722d57dc69SVladimir KotalTest installing your package into the local environment 732d57dc69SVladimir Kotal 742d57dc69SVladimir Kotal```bash 752d57dc69SVladimir Kotalpython setup.py install 762d57dc69SVladimir Kotal# now you can try console scripts 772d57dc69SVladimir Kotalopengrok-groups 782d57dc69SVladimir Kotalopengrok-sync 792d57dc69SVladimir Kotal``` 802d57dc69SVladimir Kotal 812d57dc69SVladimir Kotalor make a distribution tarball. 822d57dc69SVladimir Kotal 832d57dc69SVladimir Kotal```bash 842d57dc69SVladimir Kotalpython setup.py sdist 852d57dc69SVladimir Kotalls -l dist/ 862d57dc69SVladimir Kotal``` 872d57dc69SVladimir Kotal 882d57dc69SVladimir Kotal### Installation on the target system 892d57dc69SVladimir Kotal 902d57dc69SVladimir KotalUse the distribution tarball and run `pip`. 912d57dc69SVladimir Kotal 922d57dc69SVladimir Kotal```bash 93*a840d4e0SAdam Hornacekpython3 -m pip install opengrok-tools.tar.gz 942d57dc69SVladimir Kotal``` 952d57dc69SVladimir Kotal 962d57dc69SVladimir KotalThis will download all dependencies and install the package to your local python3 modules. 972d57dc69SVladimir KotalYou can use console scripts to run the package binaries. 982d57dc69SVladimir Kotal 992d57dc69SVladimir Kotal#### Installing to a specified directory 1002d57dc69SVladimir Kotal 1012d57dc69SVladimir KotalYou can also install the tools to a specified directory, we suggest you to use the python virtual environment for it. 1022d57dc69SVladimir Kotal 1032d57dc69SVladimir Kotal```bash 1042d57dc69SVladimir Kotalcd /opt/opengrok 1052d57dc69SVladimir Kotalpython3 -m venv opengrok-tools 106*a840d4e0SAdam Hornacekopengrok-tools/bin/python -m pip install opengrok-tools.tar.gz 1072d57dc69SVladimir Kotal``` 1082d57dc69SVladimir Kotal 1092d57dc69SVladimir KotalThis will install the package and all the dependencies under the `/opt/opengrok/opengrok-tools` directory. 1102d57dc69SVladimir KotalYou can then call the scripts with 1112d57dc69SVladimir Kotal 1122d57dc69SVladimir Kotal```bash 1132d57dc69SVladimir Kotal/opt/opengrok/opengrok-tools/bin/opengrok-indexer 1142d57dc69SVladimir Kotal/opt/opengrok/opengrok-tools/bin/opengrok-groups 1152d57dc69SVladimir Kotal... 1162d57dc69SVladimir Kotal``` 1172d57dc69SVladimir Kotal 1182d57dc69SVladimir Kotal#### Uninstalling 1192d57dc69SVladimir Kotal 1202d57dc69SVladimir Kotal```bash 1212d57dc69SVladimir Kotalpython3 -m pip uninstall opengrok_tools 1222d57dc69SVladimir Kotal``` 1232d57dc69SVladimir Kotal 1242d57dc69SVladimir Kotal## Testing 1252d57dc69SVladimir Kotal 1262d57dc69SVladimir Kotal```bash 1272d57dc69SVladimir Kotalpython setup.py install test 1282d57dc69SVladimir Kotal./mvnw test 1292d57dc69SVladimir Kotal``` 1302d57dc69SVladimir Kotal 1312d57dc69SVladimir Kotal## Cleanup 1322d57dc69SVladimir Kotal 1332d57dc69SVladimir KotalDeactivate the virtual environment 1342d57dc69SVladimir Kotal```bash 1352d57dc69SVladimir Kotaldeactivate 1362d57dc69SVladimir Kotal# optionally 1372d57dc69SVladimir Kotal# rm -r env 1382d57dc69SVladimir Kotal``` 1392d57dc69SVladimir Kotal 140