教學:Ubuntu 18.04 上的 GNUnet

簡介

Welcome to the hopefully painless GNUnet tutorial for Ubuntu 18.04! It provides very concrete instructions on how to compile, install and configure a current version of GNUnet. The goal is to support newcomers, either end users or developers, who want to get in touch with GNUnet for the first time. After installing GNUnet we will make sure that out new GNUnet installation is working correctly.

Attention: If you came across the official gnunet package for Ubuntu 18.04, ignore it! It is ancient and not compatible with current GNUnet installations.

Now let's start!

需求

First let's install the following Ubuntu 18.04 packages to use GNUnet painlessly. Optional dependencies are listed in Appendix A. They are required for some experimental GNUnet features.

$ sudo apt install git libtool autoconf autopoint libargon2-dev\
build-essential libgcrypt-dev libidn11-dev zlib1g-dev \
libunistring-dev libglpk-dev miniupnpc libextractor-dev \
libjansson-dev libcurl4-gnutls-dev gnutls-bin libsqlite3-dev \
openssl libnss3-tools libmicrohttpd-dev libopus-dev libpulse-dev \
libogg-dev libsodium-dev

製作安裝目錄

Next we create a directory in our home directory where we store the source code later. We should keep this directory after installation because it contains Makefiles that can be used for uninstalling GNUnet again (see chapter Uninstall GNUnet and its dependencies).

$ mkdir ~/gnunet_installation

取得原始碼

We download the GNUnet source code using git.

$ cd ~/gnunet_installation
$ git clone --depth 1 https://gnunet.org/git/gnunet.git

編譯與安裝

Installing GNUnet is not hard. We have two options: installing a production version and installing a development version. If you want to start writing GNUnet applications or join the GNUnet development choose the development version (it will print more debug output and contains debug symbols that can be displayed with a debugger). Otherwise choose the production version.

選項1:用於測試/使用的 GNUnet

$ cd ~/gnunet_installation/gnunet
$ export GNUNET_PREFIX=/usr/local # for example, other locations possible
$ ./bootstrap
$ ./configure --prefix=$GNUNET_PREFIX --disable-documentation --with-microhttpd=/opt/libmicrohttpd
$ sudo addgroup gnunetdns
$ sudo adduser --system --group --disabled-login --home /var/lib/gnunet gnunet
$ sudo usermod -aG gnunet $USER
$ make -j$(nproc || echo -n 1)
$ sudo make install

選項2:用於開發的 GNUnet

$ cd ~/gnunet_installation/gnunet
$ ./bootstrap
$ export GNUNET_PREFIX=/usr/local # for example, other locations possible
$ export CFLAGS="-g -Wall -O0"
$ ./configure --prefix=$GNUNET_PREFIX --disable-documentation --enable-logging=verbose
$ sudo addgroup gnunet
$ sudo usermod -aG gnunet $USER
$ make -j$(nproc || echo -n 1)
$ sudo make install

創建配置文件

Congratulations! GNUnet is now installed! Before we start it we need to create a configuration file. By default GNUnet looks in our home directory for the file `~/.config/gnunet.conf`. We can start with an empty file for now:


$ mkdir -p ~/.config $ touch ~/.config/gnunet.conf

Now we created the configuration file. Please check the handbook for a first minimal configuration. But in general, we dont need to configure anything in particular for now.

To go on, please move over here:

使用 GNUnet!

Please head over here: Use!

卸載 GNUnet 及其附屬物

$ cd ~/gnunet_installation/gnunet
$ sudo make uninstall
$ cd ~/gnunet_installation/libmicrohttpd
$ sudo make uninstall
$ sudo apt remove git libtool autoconf autopoint build-essential libgcrypt-dev libidn11-dev zlib1g-dev libunistring-dev libglpk-dev miniupnpc libextractor-dev libjansson-dev libcurl4-gnutls-dev libsqlite3-dev
$ sudo apt autoremove
$ sudo userdel -r gnunet
$ sudo groupdel gnunet
$ sudo groupdel gnunetdns
$ sudo mv /etc/nsswitch.conf.original /etc/nsswitch.conf
$ sudo rm /lib/$(uname -m)-linux-gnu/libnss_gns.so.2