GOPHERSPACE.DE - P H O X Y
gophering on raymii.org
This is a text-only version of the following page on https://raymii.org:
---
Title       :  Installing PyGopherd on Ubuntu 20.04
Author      :  Remy van Elst
Date        :  04-07-2020
URL         :  https://raymii.org/s/tutorials/Installing_PyGopherd_on_Ubuntu_20.04.html
Format      :  Markdown/HTML
---



Ubuntu 20.04 dropped the Pygopherd package. There is no way to install it from
the official repositories. In this guide I'll show you two ways to install the 
version from Ubuntu 18.04, which still works perfectly on 20.04. Either via 
just downloading the 2 deb packages, or via `apt pinning` from the previous 
repository. Ubuntu removed the package [as seen here][8] because it's not 
in the current debian development release, due to debian removing all python 2
packages and their dependencies. IMHO that's stupid, but that is a discussion
for another time. The author of Pygopherd in the [bug report says he is 
working on a python 3 port][9], but as of now it's not in 20.04.

Here is a screenshot of the [Castor][4] browser showing my Ubuntu 20.04 server
serving gopher pages via pygopherd:

![castor][7].

 Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics.
 Please, if you found this content useful, consider a small donation using any of the options below:


 ://leafnode.nl">I'm developing an open source monitoring app called  Leaf Node Monitoring, for windows, linux & android. Go che
ck it out!

 Consider sponsoring me on Github. It means the world to
 me if you show your appreciation and you'll help pay the server costs.

 ode=7435ae6b8212">You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60
 days. 

 




Pygopherd is a gopher server written in python, as the name suggests. I use it 
to provide this [website over gopher][1] as well as over http. I've even written
[a log analyzer to get some statistics][2] for pygopherd. Gopher is a protocol
predating 'the web', a simple document (mostly text only) oriented protocol, which
has seen a resurgence as of the last years because people are not happy with the
current state of 'the web'. See also [Gemini][3].

I recently came across [Castor][4], a graphical client for Gopher and Gemini,
for Linux, Windows and Mac OS X. Lynx is nice, but new shiny stuff is also fun
to play with.

###  .deb packages

The easiest one off way is to just grab the `.deb` packages from Ubuntu 18.04,
both [pygopherd][5] and [python-simpletal][6]. Download the files from the 
two links to your server and use the following command to install them:

    dpkg -i python-simpletal*.deb
    dpkg -i pygopherd*.deb

You might also need python2:

    apt install python2
    apt -f install

Start the server up and you're ready to go on port 70:

    systemctl enable pygopherd
    systemctl restart pygopherd

Since it's just two packages without complicated dependencies this route is fine.
If you want to use apt and also receive updates to this package, you might want
to consider the next method (pinning).

### apt pinning

Apt (the package manager) provides a way to handle multiple repositories that 
provide the same packages, named pinning. You add all the repositories, the one
for the current ubuntu version is the default with the highest priority (all 
the packages will come from there by default), and all the packages you want 
from other repositories you add to a configuration file.

Lets gets started. Add the Ubuntu 18.04 repositories to your 20.04 `sources.list`:

    vim /etc/apt/sources.list.d/gopher.list

Choose a mirror you like, I used this one close to me. Both our packages are 
in `universe`, therefore I just add that, not the rest of the repo's:

    deb http://ams3.clouds.archive.ubuntu.com/ubuntu/ bionic universe
    deb http://ams3.clouds.archive.ubuntu.com/ubuntu/ bionic-updates universe


**Do not apt update yet!**.

Add a preferences file in which we tell apt to only install pygopherd from 
this older repository:

    vim /etc/apt/preferences.d/gopher.pref

Add the following:

    Package: *
    Pin: release n=focal
    Pin-Priority: -10

    Package: pygopherd
    Pin: release n=bionic
    Pin-Priority: 500

The topmost block tells apt to use the default 20.04 (focal) repositories for all
packages, the last blocks tell apt to use the older repository for our specific
package.

Check that the system does not know about pygoherd yet:

    apt-cache policy pygopherd

Output:

    N: Unable to locate package pygopherd

You can now update the apt cache:

    apt update

Afterwards, check that apt now knows about it in the repo:

    apt-cache policy pygopherd

Output:

    pygopherd:
      Installed: (none)
      Candidate: 2.0.18.5
      Version table:
         2.0.18.5 500
            500 http://ams3.clouds.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
            100 /var/lib/dpkg/status


You can now use apt to install pygopherd:

    apt install pygopherd

The python dependency will be installed as well:

    The following NEW packages will be installed:
        pygopherd python-simpletal


Thats all there is to this method. The advantage is that you use the package 
manager for everything and also receive updates if they ever arrive.

[1]: /s/blog/Site_updates_raymii.org_now_on_gopher.html
[2]: /s/software/Simple_pygopherd_log_analyzer.html
[3]: https://gemini.circumlunar.space/
[4]: https://git.sr.ht/~julienxx/castor
[5]: https://packages.ubuntu.com/bionic/pygopherd
[6]: https://packages.ubuntu.com/bionic/python-simpletal
[7]: /s/inc/img/castor.png
[8]: https://launchpad.net/ubuntu/+source/pygopherd/+publishinghistory
[9]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=937449

---

License:
All the text on this website is free as in freedom unless stated otherwise. 
This means you can use it in any way you want, you can copy it, change it 
the way you like and republish it, as long as you release the (modified) 
content under the same license to give others the same freedoms you've got 
and place my name and a link to this site with the article as source.

This site uses Google Analytics for statistics and Google Adwords for 
advertisements. You are tracked and Google knows everything about you. 
Use an adblocker like ublock-origin if you don't want it.

All the code on this website is licensed under the GNU GPL v3 license 
unless already licensed under a license which does not allows this form 
of licensing or if another license is stated on that page / in that software:

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see .

Just to be clear, the information on this website is for meant for educational 
purposes and you use it at your own risk. I do not take responsibility if you 
screw something up. Use common sense, do not 'rm -rf /' as root for example. 
If you have any questions then do not hesitate to contact me.

See https://raymii.org/s/static/About.html for details.