# Development

If you wish to install a copy of pibootctl for development purposes, clone the git repository and set up a configuration to use the cloned directory as the source of the boot configuration:

    $ sudo apt install python3-dev git virtualenvwrapper
    $ cd
    $ git clone https://github.com/waveform80/pibootctl.git
    $ mkvirtualenv -p /usr/bin/python3 pibootctl
    $ cd pibootctl
    $ workon pibootctl
    (pibootctl) $ make develop
    (pibootctl) $ cat > ~/.config/pibootctl.conf << EOF
    [defaults]
    boot_path=.
    store_path=store
    reboot_required=
    reboot_required_pkgs=
    EOF

At this point you should be able to call the pibootctl utility, and have it store the (empty) boot configuration as a PKZIP file under the working directory:

    $ pibootctl save foo
    $ pibootctl ls
    +------+--------+---------------------+
    | Name | Active | Timestamp           |
    |------+--------+---------------------|
    | foo  | x      | 2020-03-08 22:40:28 |
    +------+--------+---------------------+

To work on the clone in future simply enter the directory and use the workon command:

    $ cd ~/pibootctl
    $ workon pibootctl

To pull the latest changes from git into your clone and update your installation:

    $ cd ~/pibootctl
    $ workon pibootctl
    (pibootctl) $ git pull
    (pibootctl) $ make develop

To remove your installation, destroy the sandbox and the clone:

    (pibootctl) $ cd
    (pibootctl) $ deactivate
    $ rmvirtualenv pibootctl
    $ rm -fr ~/pibootctl

## Building the docs

If you wish to build the docs, you’ll need a few more dependencies. Inkscape is used for conversion of SVGs to other formats, Graphviz and Gnuplot are used for rendering certain charts, and TeX Live is required for building PDF output. The following command should install all required dependencies:

    $ sudo apt install texlive-xetex fonts-freefont-otf graphviz gnuplot inkscape

Once these are installed, you can use the “doc” target to build the documentation:

    $ cd ~/pibootctl
    $ workon pibootctl
    (pibootctl) $ make doc

The HTML output is written to `build/html` while the PDF output goes to `build/latex`.

## Test suite

If you wish to run the test suite, follow the instructions in Development above and then make the “test” target within the sandbox:

    $ cd ~/pibootctl
    $ workon pibootctl
    (pibootctl) $ make test

A tox configuration is also provided that will test the utility against all supported Python versions:

    $ cd ~/pibootctl
    $ workon pibootctl
    (pibootctl) $ pip install tox
    ...
    (pibootctl) $ tox -p auto

Note

If developing under Ubuntu, the Dead Snakes PPA is particularly useful for obtaining additional Python installations for testing.