You can use snap to safely run python3 incompatible python2 programs on Ubuntu 20.04 (Focal Fossa).
Why is bup missing on Ubuntu 20.04?
I use bup as one way to backup my systems. It’s exactly what you should expect of a good backup system. I love it!
I thought “WTF? Really?” and started to google. I found a discourse thread on the issue: On 2020-01-01 Python 2 reached its end-of-life. Consequently, Ubuntu 20.04 (Focal Fossa) does not include Python 2 any more. Debian dropped bup, as well.
The next logical step was to google about bup’s roadmap towards python 3. The bup mailing list thread about the Python 3 migration status turned out to be awesome reading. Rob Browning shares his insights
- about the troubles behind the migration, including design flaws in python 3, and
- about creative approaches to overcome the situation, including some interesting ideas about switching base technology altogether.
In the meantime, Rob Browning and Johannes Berg seem to have gone on a tour de force and created a set of patches on bup’s master branch, which will be released as 0.40 soon after 0.30.1. The team is also active on keeping bup in Debian-based distros.
So long story short: It’s worth waiting. To bridge the time until the new bup is available, I offer a little workaround here. It’s inspired by merlijn-sebrechts discourse post.
Forward-porting packages from Ubuntu 18.04 LTS using snap core18
In order to port python2 packages forward to Ubuntu 20.04, you can use core18 on snap.
Snap is a packaging system for creating portable, batteries-included and immutable snapshot images of applications. Actually, I avoided Snap until now for 3 main reasons:
- Snap falls behind in terms of some fundamental freedom aspects.
- Snap bloats my mount list with its proliferating use of squashfs mounts.
- Snap keeps a snapd process running on my system all the time. Why should a package manager need this?
But for the very use case at hand, it just seems perfect.
core18 is a snap image based on Ubuntu 18.04, so it still supports python2. Even better: bup is available as a native apt package on Ubuntu 18.04.
Let’s dive into the creation of our bup snap.
First, I install snapcraft. Snapcraft is a tool for creating your own snap packages.
sudo snap install snapcraft --classic
Create a snapcraft.yaml
snapcraft uses a declarative file snapcraft.yaml to describe its packages. Mine is really quick and dirty, but serves its purpose. It’s inspired by the tutorial about snap for python apps.
name: bup version: "0.29" summary: "It backs things up" description: | bup is a program that backs things up. It's short for "backup." base: core18 confinement: classic parts: bup: plugin: nil stage-packages: - bup apps: bup: command: bup
nil plugin does not actually do anything, but enables you to use snapcraft base features without performing a real plugin execution. For example, I will use
stage-packages in order to install Ubuntu 18.04 apt packages.
Build the snap
snap will prompt you before setting up the necessary dependencies.
Install the snap
Next, I install the freshly created snap package.
sudo snap install bup_0.29_amd64.snap --classic --dangerous
This command line sounds creepy, right?
Thou shalt not fear: The
classic option is snap’s confinement mode that resembles classic local packages. The
dangerous option overrides the signature checks, which is perfectly fine for a package you created yourself.
Have fun with bup
Afterwards, use bup as usual!
BUP_DIR=/path/to/my-bup-backup/ bup index --one-file-system /home BUP_DIR=/path/to/my-bup-backup/ bup save -n my-backup /home