1
0
Fork 0
mirror of https://github.com/KingDuckZ/dindexer.git synced 2024-11-25 00:53:43 +00:00
2 Setting up a development environment
King_DuckZ edited this page 2016-06-16 22:37:30 +01:00

Linux

Setting up your system

Make sure you have a compiler with C++11 support installed, such as gcc 5.

Generic list of dependencies

In order to build dindexer you will need:

  • boost (program_options, system, filesystem) 1.53
  • libpq (for PostgreSQL)
  • libmagic
  • libyaml-cpp 0.5.1
  • libblkid (only needed if you build with DINDEXER_WITH_MEDIA_AUTODETECT enabled)
  • libreadline

Ubuntu Xenial

    sudo apt-get install libblkid-dev libyaml-cpp-dev libmagic-dev libpq-dev libboost1.60-all-dev libboost-program-options1.60-dev cmake git

Gentoo

Run as root:

    emerge -av dev-db/postgresql dev-cpp/yaml-cpp dev-libs/boost dev-util/cmake dev-vcs/git

Getting the code

Make sure you have git installed on your system, then clone the repository with the commands:

    git clone https://github.com/KingDuckZ/dindexer.git
    git submodule update --init

At this point you have the full source and you are ready to start browsing the code.

Building

If you are not familiar with cmake, this short video shows how to start building on an Ubuntu system, assuming you have all the required dependencies.

asciicast

Or, if you prefer a step-by-step list of commands:

    cd ~
    mkdir -p dindexer_build/debug
    cd dindexer_build/debug
    # in the following command replace ~/dindexer with the path to where you cloned the git repository
    cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -DPBL_WITH_TESTS=off -DDB_OWNER_NAME=dindexer-user ~/dindexer
    cmake --build .
    ctest

I personally like to have a directory structure like this for my code:

dev
    code
        dindexer  <-- my source code

    build
        dindexer
            debug  <-- build files
            release  <-- build files

If you have a similar structure, it probably makes sense to have one shared location for your dindexer config file. In this case, pass the full path to cmake with the -DDINDEXER_CONFIG_FILE option:

    cd build/dindexer/debug
    cmake -DDINDEXER_CONFIG_FILE=$HOME/dev/build/dindexer.yml .

This will override whatever default was chosen by the first invocation of cmake.

Setting up PostgreSQL

Assuming you already have PostgreSQL already up and running, you need to create a new database and the tables that dindexer will use. Follow these steps:

  • Create a user if you want to have a separate user for dindexer - I generally call it dindexer-user. This has to match the value you passed to the -DDB_OWNER_NAME option in cmake.
  • Create a database, you can call it however you like but in this example I'll just call it dindexer-db
  • Build dindexer as explained in this page
  • Find a file called dindexer.sql in your build directory, it contains the schema you need to create.
  • If you are using pgadmin3, connect to the database you just created, then in the list on the left right-click on dindexer-db and choose Restore; in the popup dialog put the full path to dindexer.sql in the Filename field, choose dindexer-user as the Rolename and click the Restore button.

Setting up dindexer

At this point you only need to tell dindexer the parameters to connect to PostgreSQL.

  • Copy the sample dindexer.yml from your source to where dindexer expects to find it - if you're not sure where you should put it, simply run ./dindexer -b and look at the path next to the CONFIG_FILE_PATH field.
  • Open the configuration file you just copied and fill in the options with the right parameters to connect to PostgreSQL

At this point you're ready to go. Try running ./dindexer locate test.txt. You should get no output at all. If you get any error message instead, you're still missing something.