Are you looking to make the shift from using snap packages to flatpaks? If so, you're in the right place! In this article, we're going to introduce you to a fantastic tool called Unsnap, which simplifies the process to migrate from Snap packages to Flatpak in Ubuntu and its derivatives.
Table of Contents
Unsnap is a shell script that enables a quick and easy transition from using snap packages for applications to flatpak. As its name suggests, Unsnap is all about assisting users to 'unsnap' or detach themselves from snap packages and migrate towards using flatpak.
Developed by Former Snap co-developer Alan Pope, Unsnap allows users to seamlessly migrate from using snap for applications to flatpak in Ubuntu and Ubuntu-based systems.
The Unsnap is licensed under the MIT license, which means it's free and open-source.
Unsnap operates as a two-stage process. Initially, Unsnap generates a set of scripts that are responsible for executing the actual migration from snap packages to flatpak. This feature allows users to view and, if necessary, edit the scripts before execution to validate or modify them according to their needs.
After generating the scripts, users can run them in sequence to complete the migration process. The procedure is pretty straightforward: clone the Unsnap repository, navigate to the Unsnap directory, and run the Unsnap command. For users who prefer to skip manual steps, there's an 'auto' option, which automatically generates and runs the scripts.
Running Unsnap is a straightforward process. All you need to do is clone the GitHub repository and run the unsnap command. This action will generate a set of scripts. You then run these generated scripts in sequence to achieve unsnappyness. Alternatively, you can run unsnap with the auto option to generate and run the scripts immediately.
Here's a step-by-step process to replace Snap packages with Flatpaks using Unsnap:
First, clone the repository:
$ git clone https://github.com/popey/unsnap
Change directory to the cloned repository:
$ cd unsnap
Run the unsnap command:
$ sudo ./unsnap
Or run unsnap with auto option:
$ sudo ./unsnap auto
This will take a while depending on the number of installed Snaps on your system. Please be patient!
Upon successful flatpak migration, you would see an output something like below:
[...] INFO: flatpaks installed <strong><mark>INFO: These flatpaks are now installed: Freedesktop Platform org.freedesktop.Platform 22.08.12.1 22.08 system Mesa org.freedesktop.Platform.GL.default 23.1.1 22.08 system Mesa (Extra) org.freedesktop.Platform.GL.default 23.1.1 22.08-extra system openh264 org.freedesktop.Platform.openh264 2.1.0 2.2.0 system Firefox org.mozilla.firefox 114.0.2 stable system</mark></strong> INFO: Removing snaps <strong><mark>firefox removed</mark></strong> INFO: Snaps removed WARNING: These snaps are still installed: Name Version Rev Tracking Publisher Notes bare 1.0 5 latest/stable canonical** base core20 20230613 1950 latest/stable canonical** base core22 20230612 766 latest/stable canonical** base gnome-3-38-2004 0+git.6f39565 140 latest/stable/… canonical** - gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical** - snap-store 41.3-71-g709398e 959 latest/stable/… canonical** - snapd 2.59.5 19457 latest/stable canonical** snapd snapd-desktop-integration 0.9 83 latest/stable/… canonical** -
The output above shows that the Firefox Snap application has been uninstalled and subsequently replaced with its Flatpak version.
Here is the list of installed Snaps before running Unsnap in my Ubuntu 22.04 LTS system:
$ snap list Name Version Rev Tracking Publisher Notes bare 1.0 5 latest/stable canonical** base core20 20230613 1950 latest/stable canonical** base core22 20230612 766 latest/stable canonical** base firefox 103.0-1 1589 latest/stable/… mozilla** - gnome-3-38-2004 0+git.6f39565 140 latest/stable/… canonical** - gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical** - snap-store 41.3-71-g709398e 959 latest/stable/… canonical** - snapd 2.59.5 19457 latest/stable canonical** snapd snapd-desktop-integration 0.9 83 latest/stable/… canonical** -
And here is the output of snap list command after the Snaps are migrated to Flatpaks.
$ snap list Name Version Rev Tracking Publisher Notes bare 1.0 5 latest/stable canonical** base core20 20230613 1950 latest/stable canonical** base core22 20230612 766 latest/stable canonical** base gnome-3-38-2004 0+git.6f39565 140 latest/stable/… canonical** - gtk-common-themes 0.1-81-g442e511 1535 latest/stable/… canonical** - snap-store 41.3-71-g709398e 959 latest/stable/… canonical** - snapd 2.59.5 19457 latest/stable canonical** snapd snapd-desktop-integration 0.9 83 latest/stable/… canonical** -
See? The Snap version of Firefox is removed.
As stated already, Unsnap generates a series of scripts to facilitate the migration process. Each script performs a specific function.
Here's a brief overview of the scripts generated by Unsnap and their functions:
One of the key features of Unsnap is its 'Package Mapping' capability. Unsnap ships with a file named 'applist.csv' that contains a mapping of snap package names to flatpak names. This one-to-one mapping, although not entirely complete, covers a substantial subset of applications available in the snap store and flathub.
To facilitate the checking of snap and flatpak names in the 'applist.csv' file, Unsnap has a 'Check Mode'. This mode allows users to verify the accuracy of the mapping between snap packages and flatpaks, ensuring a smooth migration process.
Please note that in the "Check" mode, the Unsnap program doesn't generate any scripts, alter any data, or install any Flatpaks. Instead, it creates an unsnap.logfile for reference and tracking.
Currently Unsnap executes a snap save for each snap that's being migrated. This operation leverages snapd's internal mechanism to create backups of application data. It's essential to ensure sufficient disk space and time for this process, considering that some applications might have substantial data to backup.
You can find more details about snap save in the snap snapshots documentation.
If you prefer to skip the backup, simply avoid running the backup scripts before initiating the actual migration.
By default, the backups created with snap save are stored as zip files in the /var/lib/snapd/snapshots directory.
At the moment, the task of restoring the data, if needed, is left to the user.
Unsnap provides output both to the console and to a log file. The log file, named unsnap.log, is located in the ./log-YYYY-MM-DD.HH.MM.SS subdirectory of the current directory where Unsnap is being run.
The excluded_snaps.txt file contains a list of snaps that don't have direct equivalents on Flathub. This list includes snaps like bare, core18, and core20. As such, it's not beneficial to prompt users to migrate from these particular snaps to another Flatpak.
It's worth noting that while there are conceptually similar packages available on Flathub, these are automatically included during the installation of relevant applications and do not require handling by Unsnap.
The role of excluded_snaps.txt is not to catalogue packages that have not yet been made available as a Flatpak, but rather to identify packages that will likely never be converted to a Flatpak.
The following is the list of excluded Snaps in my Ubuntu 22.04 LTS system:
bare canonical-livepatch core core18 core20 core22 gnome-3-28-1804 gnome-3-34-1804 gnome-3-38-2004 godot-runtime gtk-common-themes gtk2-common-themes kde-frameworks-5 qt513 qt551 snapd wine-platform-3-stable wine-platform-5-stable wine-platform-6-stable wine-platform-runtime
As of now, Unsnap is in its pre-alpha stage. This means that it has been tested and has shown promising results on the developer's computer. However, unless you're planning on contributing to the project, it's probably not ready for you yet. It's a work in progress, and contributions to improve its functionality and versatility are most welcome!
Here's the FAQ about Unsnap.
Q: What is Unsnap?A: Unsnap is a tool designed to help users migrate from using Snap packages to Flatpak. It works by generating scripts that handle the migration process, which users can review and modify before execution.
Q: Who is the developer of Unsnap?A: Unsnap was developed by Alan Pope, a former co-developer of Snap. Pope was with Canonical, the parent company of Ubuntu, for 10 years before leaving in 2021. After his departure, he created Unsnap to help users migrate from Snap packages to Flatpak.
Q: How do I use Unsnap?A: To use Unsnap, you need to clone the GitHub repository and run the unsnap command. This action will generate a set of scripts. You then run these generated scripts in sequence to migrate from Snap to Flatpak.
Q: What are the generated scripts?A: Unsnap generates a series of scripts to facilitate the migration process. They include scripts for backing up your Snap data, installing Flatpak, enabling Flathub, installing equivalent Flatpaks, and removing the original Snaps and snapd.
Q: What is the 'check' mode?A: The 'check' mode is a feature of Unsnap that allows you to verify the Snap and Flatpak names in the applist.csv file without making any changes to your system or installing any Flatpaks. It also generates an unsnap.logfile.
Q: What is the 'applist.csv' file?The 'applist.csv' file in Unsnap contains a mapping of Snap package names to Flatpak names. This facilitates the one-to-one mapping between the two, aiding the migration process.
Q: What is the 'excluded_snaps.txt' file?The 'excluded_snaps.txt' file lists Snap packages that do not have direct equivalents on Flathub, such as bare, core18, and core20. Unsnap will not prompt users to migrate these particular packages.
Q: Is Unsnap ready for use?A: As of now, Unsnap is in its pre-alpha stage. While it has shown promising results on the developer's computer, it might not be ready for general use yet unless you're planning on contributing to the project.
Q: Is Unsnap open-source?A: Yes, Unsnap is open-source and licensed under the MIT license. This allows anyone to use, modify, and distribute it under the same license.
Unsnap is an excellent tool for users looking to migrate from snap packages to flatpak. It's still in the pre-alpha stage, meaning it's in the early stages of development and might not be fully ready for all users. Use it with caution!
Resource:
Related Read:
以上がubuntuでunsnapを使用して、スナップパッケージからフラットパックに移行する方法の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。