Vanat

Dependency Manager for Vala

  •   Introduction

    What is Vanat?
    Vanat is a tool for dependency management in Vala. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

    Dependency management
    Vanat is not a package manager in the same sense as Yum or Apt are. Yes, it deals with "packages" or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. It does not install anything globally.

    This idea is not new and Vanat is inspired by composer and node's npm.

    Suppose:
    • 1. You have a project that depends on a number of libraries.
    • 2. Some of those libraries depend on other libraries.
    Vanat:
    • 1. Enables you to declare the libraries you depend on.
    • 2. Finds out which versions of which packages can and need to be installed, and installs them (meaning it downloads them into your project).

    See the Basic usage chapter for more details on declaring dependencies.

  •   Installation on Linux

    System Requirements
    The Vana has a few system requirements.You will need to make sure your desktop meets the following requirements:

    • vala (>=0.36)
    • meson (>=0.40)
    • git
    • gee-0.8
    • libarchive
    • libsoup-2.4
    • json-glib-1.0

    First install the tools and libraries used by the project
    Install Vala
    sudo apt install valac
    Install Meson
    sudo apt install meson
    Install Git
    sudo apt install git
    Install Libgee-0.8
    sudo apt install libgee-0.8-dev
    Install Libarchive
    sudo apt install libarchive-dev
    Install Libsoup
    sudo apt install libsoup2.4-dev
    Install Json-glib
    sudo apt install libjson-glib-dev

    Installing Vanat
    Make the clone of the repository and then go to the folder.

    git clone https://github.com/vanat/vanat.git
    Access the project folder
    cd vanat

    Run meson build to configure the build environment. Change to the build directory and run ninja test to build and run automated tests

    meson build && cd build
    meson configure -Dprefix=/usr
    ninja 

    To install, use ninja install, then execute with valet

    sudo ninja install

    To verify that Vanat has been properly installed, type in the terminal:

    vanat -v

    If the output is correctly installed, the output should be:

    vanat version 0.1.0
  •   Installation on macOS

    System Requirements
    The Vana has a few system requirements.You will need to make sure your desktop meets the following requirements:

    • vala (>=0.36)
    • meson (>=0.40)
    • git
    • gee-0.8
    • libarchive
    • libsoup-2.4
    • json-glib-1.0

    First install the tools and libraries used by the project
    Install Homebrew
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    Install Vala
    brew install vala
    Install Meson
    brew install meson
    Install Git
    brew install git
    Install Libarchive
    brew install libarchive
    The libarchive is keg-only, which means it was not symlinked into /usr/local,
    because macOS already provides this software and installing another version in
    parallel can cause all kinds of trouble.
    
    If you need to have libarchive first in your PATH, run:
    echo 'export PATH="/usr/local/opt/libarchive/bin:$PATH"' >> ~/.zshrc
    
    For compilers to find libarchive you may need to set:
    export LDFLAGS="-L/usr/local/opt/libarchive/lib"
    export CPPFLAGS="-I/usr/local/opt/libarchive/include"
    
    The CPPFLAGS and CXXFLAGS are environment variables used to set compilation options that will 
    be passed to the preprocessor and compiler, respectively. These options can include, for example, 
    directories for header file inclusion, optimization flags, among others.
    
    To configure multiple items in CPPFLAGS and CXXFLAGS, you can use the shell's list syntax, 
    separating each item with a whitespace. For example:
    
    export LDFLAGS="-L/usr/local/opt/openssl@3/lib -L/usr/local/opt/libarchive/lib"
    export CPPFLAGS="-I/usr/local/opt/openssl@3/include -I/usr/local/opt/libarchive/include"
    
    For pkg-config to find libarchive you may need to set:
    export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig"
    
    To configure multiple items in PKG_CONFIG_PATH, you can use the following command in a Linux or macOS terminal:
    
    export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig:/usr/local/opt/libarchive/lib/pkgconfig:$PKG_CONFIG_PATH"
    
    Note that you can add as many directory paths as you need, separated by :. Make sure to add 
    the directories in the correct order so that dependencies are resolved correctly.
    
    Install Libsoup
    brew install libsoup
    Install Json-glib
    brew install json-glib

    Installing Vanat
    Make the clone of the repository and then go to the folder.
    git clone https://github.com/vanat/vanat.git
    Access the project folder
    cd vanat
    Run meson build to configure the build environment. Change to the build directory and run ninja test to build and run automated tests
    meson build && cd build
    meson compile

    To install, use ninja install, then execute with valet

    meson install

    To verify that Vanat has been properly installed, type in the terminal:

    vanat -v

    If the output is correctly installed, the output should be:

    vanat version 0.1.0
  •   Using Vanat

    Project Setup
    To start using Vanat in your project, all you need to do is create a vanat.json file. This file will have the dependency settings for your project. It can be considered as a search list for Vanat; It will only download the packages (dependencies) for your project that are mentioned in this file.

    Below is a basic skeleton of vanat.json, the file in which the dependencies will be described, then the same will be clarified.

    {
        "name":"Project name",
        "description": "Brief description of what the application proposes to do", 
        "require":{
            "vala":"0.36.*"
        }
    }

    The name is the name of your application. This marking is optional but recommended.

    The description is a brief description of what your application proposes to do. Also optional.

    The require is basically the key of everything and the only obligatory markup. In it you make clear what are the dependencies of your application. In this case if the vala version is below 0.36 then an error message will be thrown when installing the dependencies informing you that it is not possible to proceed because not all requirements are satisfied.

    As you can see above this is the skeleton of a very basic application, with no advanced settings and no indication of any third party library.

    Okay, but what now?
    Now that you already have the vanat skeleton configured in your application we will include some packages. Vanat uses as its repository the VPackagist where any developer can create their own packages and make them available to the community similar to github. VPackagist can provide you with several packages.

    A small example
    For teaching purposes I will show here the use of a library for vdk created by Robert San. In the section where you define the requirements (require) in the vanat.json file simply add just below the line that defines that the vala needs the desired package name and version. In this case the package is vala-development-kit/vdk and the version is 0.1.*. With this the new structure of vanat.json is:

    {
        "name":"Project name",
        "description": "Brief description of what the application proposes to do", 
        "require":{
            "vala":"0.36.*"
            "vala-development-kit/vdk":"0.1.*"
        }
    }

    Vanat works with a package repository, VPackagist (the official destination for packages created for Vanat). This is where you find the name and version of the packages you can use in your project. Then it is assumed that the vala-development-kit/vdk package is registered in VPackagist.

    All ready
    Okay, now it's all ready for you to see the vanat in action. In the root folder of your application (which is the same as vanat.json is) run the vanat install command. This command will make the vanat read the settings set in the json file and install all the libraries/packages needed for your application and also these same libraries that have dependencies will have the same ones solved. Think of vanat more or less like Linux debian apt-get. In it, when installing any package, all its dependencies are resolved automatically.

    Note that in the folder where your application is now there is the vendor folder, a vanat file (which was already there) and a vanat.lock file - which is the file that was automatically generated after the installation was successful.

    Installing a library directly
    If you decide to install a package without having to edit the vanat.json file, simply notify the vanat of your choice so that it can add it to your project. To do this, type the following command on the terminal:

    $ vanat require vala-development-kit/vdk

    Package Names
    The package name consists of a vendor name and the project's name. Often these will be identical - the vendor name just exists to prevent naming clashes. For example, it would allow two different people to create a library named json. One might be named igorw/json while the other might be seldaek/json.

  •   VPackagist

    What is VPackagist?
    VPackagist is the default Vanat package repository. It lets you find packages and lets Vanat know where to get the code from.

    You can find the https://github.com/vpackagist source on GitHub.

  •   Report problems or improvement

    Found a bug or did you have any idea how to improve vanat? We'd love to hear about it! Please report all issues about the issues in our github.