popey / unsnap

Quickly migrate from using snap packages to flatpaks
MIT License
1.01k stars 48 forks source link

unsnap
unsnap

Quickly migrate from using snap packages to flatpaks.

unsnap screenshot

Made with 💝 for

Introduction

Quickly and easily migrate from using snap for applications to flatpak. unsnap runs as a two-stage process. unsnap itself generates the scripts to do the actual migration. This enables users to view and/or edit the scripts prior to execution to validate or tweak them.

Project Status

Let's say it's "Pre-alpha", as in "It kinda works on my computer".

Unless you plan on contributing (see below) it's probably not ready for you, yet.

We have a Discord for this project: Discord

Also, please see the Friendly notice below.

Running unsnap

Simply clone this repo and then run unsnap. After some warnings and checks, this will generate a set of scripts. Run those generated scripts in sequence to achieve unsnappyness.

git clone https://github.com/popey/unsnap
cd unsnap
./unsnap

Alternatively run unsnap with the auto option to generate and run the scripts immediately.

./unsnap auto

Generated Scripts

These scripts are generated by unsnap.

Package Mapping

unsnap ships with a applist.csv file that contains a mapping of snap package names to flatpak names. This is a one to one mapping. The list is not complete, but contains a subset of applications available in the snap store and flathub. Contributions to this list are most welcome

Check Mode

To facilitate checking the snap and flatpak names in the applist.csv file, unsnap has a "check" mode. This simply runs through the applist.csv file to check for the existence of every snap and flatpak listed. For this mode to work, both the snap and flatpak commands should be installed. This is an unsnap developer feature, and typically isn't required to be run by users.

./unsnap check

Note: In this mode, no scripts are generated, no data is changed, and no flatpaks are installed, but an unsnap.logfile is generated.

Application data

Currently unsnap runs a snap save for each snap being migrated. This uses the snapd internal mechanism to backup application data. You should ensure you have enough disk space and time for this operation, as some applications will have a lot of data to backup.

More information about snap save can be found in the snap snapshots documentation.

The backup can be skipped by omitting running the backup scripts before starting the migration proper.

The backups made with snap save are (by default) stored in /var/lib/snapd/snapshots as zip files.

It's (currently) left as an exercise for the user, to actually restore the data, should they need to.

Logging

unsnap writes to the console, and to a log file called unsnap.log in ./log-YYYY-MM-DD.HH.MM.SS beneath the current directory.

Excluded snaps

There's a list of snaps in excluded_snaps.txt which are packages from the snap store for which there's no real equivalent in flathub. This includes snaps like bare, core18, and core20. As such we don't want to prompt to migrate people from these to some other flatpak.

Note: Yes, I know there are conceptually equivalent packages in flathub to these, but those get pulled in as part of the application installs, and do not require management by unsnap itself.

The purpose of excluded_snaps.txt is not to list packages which are not yet available as a flatpak. The purpose is to list packages which will likely never be a flatpak.

Contributions

I knocked this prototype up over the weekend, but it's far from complete. Here're some features that aren't yet complete. Contributions welcome!

Example Generated Script Output

In this example I installed all the 'featured' snaps (output of snap find) on my laptop then ran unsnap which generated these scripts.

00-backup

#!/usr/bin/env bash
# Documentation: https://snapcraft.io/docs/snapshots
snap save bitwarden blix cecconoid chromium discord firefox flock-chat gimp kdenlive keepassxc krita libreoffice liveforspeed obs-studio onlyoffice-desktopeditors pinta skype slack spotify telegram-desktop thunderbird typeapp-mail vidcutter vlc warble 

01-install-flatpak

#!/usr/bin/env bash
# Documentation: https://flatpak.org/setup/Ubuntu
sudo apt update
sudo apt install flatpak
# sudo apt install gnome-software-plugin-flatpak

02-enable-flathub

#!/usr/bin/env bash
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

03-install-flatpaks

#!/usr/bin/env bash
for f in com.bitwarden org.chromium.Chromium com.discordapp.Discord org.mozilla.firefox org.gimp.GIMP org.kde.kdenlive org.keepassxc.KeePassXC org.kde.krita org.libreoffice.LibreOffice com.obsproject.Studio org.onlyoffice com.github.PintaProject.Pinta com.skype.Client com.slack.Slack com.spotify.Client org.mozilla.Thunderbird com.ozmartians.VidCutter org.videolan.VLC  ; do
  flatpak install flathub --noninteractive -y $f
done

04-remove-snaps

#!/usr/bin/env bash
for s in bitwarden blix cecconoid chromium discord firefox flock-chat gimp kdenlive keepassxc krita libreoffice liveforspeed obs-studio onlyoffice-desktopeditors pinta skype slack spotify telegram-desktop thunderbird typeapp-mail vidcutter vlc warble  ; do
  snap remove $s 
done

99-remove-snapd

#!/usr/bin/env bash
echo Removing snapd
sudo apt remove snapd

missingflatpak.txt

blix
cecconoid
flock-chat
liveforspeed
telegram-desktop
typeapp-mail
warble

Related projects

The custom-desktop project by Natan Junges which provides a set of packages to revert an existing Ubuntu install back to something many users may appreciate more.

deb-get enables Ubuntu users to install and update deb-based packages of popular applications.

Friendly notice

Note: The existence of unsnap is merely a tool to enable users to switch from snapped applications to flatpak applications. This is not intended as a commentary or slight against any software. It's just a utility.