Giter Club home page Giter Club logo

unsnap's Introduction

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.

  • 00-backup - runs snap save for each installed snap being migrated
  • 01-install-flatpak - if not already installed, will install flatpak package manager
  • 02-enable-flathub - if not enabled, will add the remote flathub location in flatpak
  • 03-install-flatpaks - installs equivalent flatpaks for each identified snap
  • 04-remove-snaps - removes snaps for which the flatpaks have been installed
  • 99-remove-snapd - removes snapd itself, which will remove all snaps

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!

  • Support distributions other than Ubuntu
    • According to snapcraft core18 store page (which I have no reason to disbelieve), the following distros are most popular in terms of snaps installed: Manjaro, Linux Mint, Zorin, Debian, Fedora, Pop_OS!, KDE Neon, Raspbian, Centos, elementary OS.
  • Update applist.csv to be a more complete list of migratable applications
    • Consider submitting the missingflatpak.txt report from running unsnap here
  • Update excluded_snaps.txt to contain further examples of non-migratable applications
  • Add feature to migrate data from the common snap directories to places flatpak'ed applications can find them
    • This is a bit hard and may need special cases for some applications. For example 'classic' snaps may store data anywhere, whereas well-confined applications might store in the snap-specific directories.

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.

unsnap's People

Contributors

ahayzen avatar archisman-panigrahi avatar ascopes avatar dominichayesferen avatar ferraridamiano avatar men1n2 avatar newbytee avatar orlandohuang avatar philclifford avatar popey avatar robje avatar stuartlangridge avatar zorono avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unsnap's Issues

Should log out or reboot after installing flatpak itself: suggest this

Apparently one should log out or perhaps restart the machine entirely after installing flatpak, otherwise various desktop integration things such as menus don't work right and apps don't show up. flatpak/flatpak#2886 is an example here.

Describe the solution you'd like
The install-flatpak script should perhaps instruct people to sign out and back in, or maybe reboot, whichever is required.

Describe alternatives you've considered
The script could actually do the reboot, but this will make people sad.

Support installing the same versions as the snaps

Is your feature request related to a problem? Please describe.
I use several Jetbrains IDEs such as CLion and Pycharm. If I stop paying for them I will need to use a fallback license, which requires specific versions of the software. Unfortunately unsnap does not seem to understand this, and will simply replace the snaps with the latest versions which I don't have a license for.

Describe the solution you'd like
unsnap should check the installed snap versions, and then install the same versions from flatpak when the snap version is held back.

Describe alternatives you've considered
Continuing to use snaps.

Additional context
This is apparently how you install a specific version.

AppImages and '.deb' support

Is your feature request related to a problem? Please describe.
I prefer AppImages and '.deb' packages rather than flatpak.

Describe the solution you'd like
I'd like to be able to use unsnap to automatically remove all snaps from my system and then install the equivalent AppImages or '.deb' packages. I'd be nice to have a fallback system such that if a preferred format isn't available or found, but for another second or third format that package is available, then unsnap would suggest that alternative instead.

Describe alternatives you've considered
Having to manually reinstall everything in another software format; or having to write some kind of script to do that; which feels strange since in my humble opinion unsnap should be capable of doing that.

Bonus
I believe utilities such as AppMan or Pacstall could be helpful to achieve this goal; in addition to, of course, the API of 'apt'.

Thank you for your time and this wonderful software! 🥰

related libs for snapd should be removed

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

Install gnome-software to substitute snap-store

The current unsnap version doesn't have a substitute for the snap-store.

The gnome-software can substitute the snap-store, in this case a new script can be generated to run sudo apt install gnome-software.

After the gnome software is installed the snap-store can be removed.

snap mounts seem to be left behind

snap mounts seem to be left behind

To Reproduce
On Ubuntu 22.04, I executed the generated scripts. Some snap applications were reported as not having flatpak counterpart.
I installed via apt gnome-software. I then restarted Linux.
At the console pgrep snapd confirmed snapd was not running anymore.
Then I inspected the list of mounts with mount. The mounts are still polluted by the snap entries.
Example:
/var/lib/snapd/snaps/gnome-42-2204_141.snap on /snap/gnome-42-2204/141 type squashfs (ro,nodev,relatime,errors=continue,x-gdu.hide)
It would seem that systemd mount units are left behind. Indeed
/etc/systemd/system/snapd.mounts.target.wants contains lots of *.mount files. Example: snap-gnome\x2d42\x2d2204-141.mount.
Did I do anything wrong? Is it perhaps because some snap applications were reported as not having flatpak counterpart?
Even though I was not 100% sure of what I was doing, I deleted that directory and all other entries starting with snap under ``/etc/systemd/system/`.
After a restart, the snap-related "spurious" mounts were gone.

Expected behaviour
I expected everything snap-related to disappear.

Desktop (please complete the following information):

  • OS: Ubuntu
  • Version: 22.04

Additional context
I noticed that under /etc/systemd/user there is an entry called snap.snapd-desktop-integration.snapd-desktop-integration.service. Also, there seem to be other remnants of snap around.
By the way, thanks for writing this utility! I had put off getting rid of snap for so long :-)

Add support for Manjaro

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Add support for Pop_OS!

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Test and add support for non amd64/x86_64 architectures

This has so far only been tested on an x86_64 / AMD64 architecture system.
It would be great if this worked on arm64/armhf systems as well. Not sure how many applications are published in flathub, and whether any other constraints may be needed.

Support parallel installs

Is your feature request related to a problem? Please describe.
I have Blender 2 and Blender 3 installed in parallel using snap. unsnap doesn't support this configuration and only offers to replace Blender 3. It claims that Blender 2 has no flatpak.

Describe the solution you'd like
I would like unsnap to duplicate my existing setup and install Blender 2 & 3 in parallel.

Describe alternatives you've considered
Continuing to use snaps.

Additional context
Parallel installs are currently unsupported in flatpak, so you will need to implement them there first. #36 must also be implemented.

Missing report (filtered for reported ones)

anbox
ascii-image-converter
authy
bottom
bpytop
brave
btop
bucklespring
bw
cannonball
caprine
castersoundboard
cheat
clari3d-lite-64
code-insiders
cura-slicer
dotrun
duf-utility
emote
evince
fakecam
fluffychat
foobar2000
fractal
freecad
freemind
glimpse-editor
gnome-3-26-1604
hollywood
joplin-desktop
jupyter
lbry
mqtt-explorer
natron
node
novnc
obs-cli
obsidian
openscad
persepolis
poedit
prusa-slicer
pulsemixer
qr-code-generator-desktop
redis-desktop-manager
shotcut
shutter
software-boutique
ticker
tio
ubuntu-accomplishments
ubuntu-mate-welcome
v4l2-rtspserver
xonotic
zsync

Missing Flatpaks

btop
dotnet-runtime-21
dotnet-runtime-22
dotnet-runtime-30
dotnet-runtime-31
dotnet-runtime-50
dotnet-sdk
scrcpy
snap-store

Please create ppa repository for easier installation

Is your feature request related to a problem? Please describe.
It's a boring and tiring process of installation, even if the file is installed it takes space in user home.

Describe the solution you'd like
Adding a ppa repository would help in easier installation of the package and raising a request to serve the utility in Ubuntu universe, will make it a lot easier for developers to get rid of snap and snapd packages & switching to flatpak packages.

Unsnap - Issue When flatpak version is behind snap version . . .

Is your feature request related to a problem? pak rather than snap package management.
And the idea of Please describe.**

I am all for flatpak rather than snap package management.
And the idea of unsnap is great for those of us migrating application installations to flatpak from snap.
Except for those applications whose app data is updated with each new version of the application.
For example, Mozilla Thunderbird updates the mails folder every time a new version is installed.
As of yesterday 12:00 GMT+1 Thunderbird cannot be unsnapped - i.e. removed as a snap package and reinstalled as a flatpak because the latter is version 102.0 and the flatpak version is just 91.11 . . .

Describe the solution you'd like
Try to keep major applications up to the latest released version.

Describe alternatives you've considered
Equivalent snap package.

Additional context
Add any other context or screenshots about the feature request here.

Add support for Debian.

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Only remove matched snaps by default

At the moment we're a bit brutal in that we may remove all snaps even if there's no matching alternative flatpak.

Perhaps for now we should only remove those that successfully matched a flatpak, and offer the option to nuke the full list, but not do that by default.

Snapstore release

It is currently not possible to install unsnap from the snapstore

unsnap available on snapstore

Provide better messages for unexpected behaviour

Someone might stumble on this script and run it without knowing they have snaps or not. Not everyone is a packaging expert! :D
So we should provide very friendly messages if snapd is found not to be installed or running, and explain why the script terminates.

Block future snapd installation (to avoid recommends pulling it back in)

Is your feature request related to a problem? Please describe.
I have an Ubuntu 22.04 (Jammy) without snaps thanks to unsnap but this morning unattended software updates installed snapd/firefoxz debs/snaps back on my system. The ubuntu-desktop package has an update to recommend firefox and while it's staged and not yet installed on my system, the apt resolver pulled it in early (it would have happened anyway I guess). At the root of the issue is a change in the ubuntu-desktop recommends focused on pulling in the firefox deb/snap for upgrades to Jammy that didn't consider explicit removal of snapd/firefox (or chose to favor one case over the other with the fix).

Describe the solution you'd like
I'd like to prevent future snapd installation through other package recommends/depends. One possible solution I've tested is blocking snapd installation via apt preferences:

$ cat  /etc/apt/preferences.d/snapd
# Configure apt to never install snapd
# P<0 prevents the version from being installed
Package: snapd
Pin: version *
Pin-Priority: -1

This makes it impossible to install snapd but users might forget how this was done if they do want to intentionally install it later.

$ sudo apt install snapd
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package snapd is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'snapd' has no installation candidate

Describe alternatives you've considered
You could also install a dummy snapd package with a very high epoch, not sure this is better.

Add support for CentOS

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Handle existing installed flatpaks

Is your feature request related to a problem? Please describe.

Unsnap does not consider installed flatpaks. It would be nice if it would detect (or provide candidate matches) where the system already has both the snap and the flatpak installed. (I have a couple, but this also might arise for a sane user from attempts to migrate with or without using this utility)

Describe the solution you'd like

I would like the script to match installed flatpaks (and/or make them candidate suggestions) rather than report them as missing, and maybe to comment out their entry in the generated installation script, and if they do not exist in the mapping also provide a possible mapping and a note to maybe submit an issue ...

For example:

$snap list obsidian fractal
Name      Version                Rev  Tracking       Publisher    Notes
fractal   4.4.0-244-g8781378a79  106  latest/stable  ken-vandine  -
obsidian  0.14.2                 x2   -              -            -
$sort missingflatpak.txt|grep -v snap-store >missing
$flatpak list|sort -u |join -i - missing
Fractal org.gnome.Fractal 4.4 stable system
Obsidian md.obsidian.Obsidian 0.14.2 stable system

Note the case of the flatpaks. joining the other way round can generate some suggested matches.

flatpak list|sort -u |join -i  missing - |awk '{print $1 "," $2}' |tee -a extra-applist.csv
fractal,org.gnome.Fractal
obsidian,md.obsidian.Obsidian

I don't have any flatpaks and snaps installed that are already in the applist.csv but I guess handling that then handling the "unknown"/"candidate" scenario would be OK - for such an edge-case I'd expect to end up with a candidate match list to submit as well as a a missing list, and to be able to chose to merge the "candidates" and re-generate new scripts to review/use.

Desktop (please complete the following information):

OS: Ubuntu MATE 21.10 x86_64
Kernel: 5.13.0-39-lowlatency
Shell: bash 5.1.8

Describe alternatives you've considered
Just ignoring the daft edge-case users who might be in this situation would be fine too .

Add support for Zorin OS.

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Prevent snapd from ever being installed again

Adding the following apt config would prevent snapd from being installed either directly or indirectly:

Package: snapd
Pin: release a=*
Pin-Priority: -10

Linux Mint already does something similar. This is important because Ubuntu made the Chromium apt package install snapd and install the Snap version of Chromium.

Handling Leftover Snaps

I'm sorry if this seems like a novice question, but I'm not super familiar with snap and what is considered necessary and really don't want to mess up my system.

I couldn't find any detailed documentation within the repository. What should I do about these remaining packages?

WARNING: These snaps are still installed:
Name                       Version           Rev    Tracking         Publisher    Notes
bare                       1.0               5      latest/stable    canonical**  base
core20                     20230404          1879   latest/stable    canonical**  base
core22                     20230503          634    latest/stable    canonical**  base
gnome-3-38-2004            0+git.6f39565     140    latest/stable/…  canonical**  -
gnome-42-2204              0+git.587e965     102    latest/stable    canonical**  -
gtk-common-themes          0.1-81-g442e511   1535   latest/stable/…  canonical**  -
mesa-core20                21.2.6            125    latest/stable    canonical**  -
snap-store                 41.3-71-g709398e  959    latest/stable/…  canonical**  -
snapd                      2.59.2            19122  latest/stable    canonical**  snapd
snapd-desktop-integration  0.9               83     latest/stable/…  canonical**  -

Thanks!

Add support for elementary OS

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Add support for Fedora

This will likely require minor changes to the functions determine_distro, generate_remove_snapd_script, generate_flatpak_install_script

Semi-automate identifying matching snaps/flatpaks

It's kinda time consuming and potentially error-prone to match the various snaps with their equivalent flatpaks. So far I've just been browsing the stores to look for matches, but I think we can do better.

The list of published snaps is easily found on a system running snapd, it's in /var/cache/snapd/names. There's (currently) 4671 snaps in that list.

The list of flatpaks is easy to get too, with a simple flatpak search . --columns=application. There's 2338 in the list. We can filter out some which aren't likely to match with flatpak search . --columns=application | grep -v Gtk3theme | grep -v org.freedesktop.Sdk which gets us down to 1950 flatpaks.

It feels like it might be possible to iterate through the snaps and find flatpaks from the list with some fuzzy matching. We can then verify and submit them as pull requests to applist.csv. Volunteers for this sought! :D

I've attached the snap names file and flatpak list in case anyone wants to play with the data.

flatpak_2022-04-11.txt
snap_2022-04-11.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.