-
-
Notifications
You must be signed in to change notification settings - Fork 24
How to add support for a new distro type
The Toshy installer script is designed to work across many Linux distributions, each with its own package manager and package naming conventions. If you want to add support for a new distribution, this guide will walk you through the process. Don't worry - while it might look complex at first, the modular design makes it quite straightforward once you understand the components.
- Located in
distro_groups_map
- Maps distribution types to one or more specific distro IDs
- Example:
'fedora-based': ["fedora", "fedoralinux", "nobara", "ultramarine"]
- Located in
pkg_groups_map
- Maps distribution types to required native packages
- Each distribution type has its own list of package names
-
PackageManagerGroups
class - Maintains lists of distributions for each package manager
- Creates dispatch map linking distro lists to installer methods
- Example attributes:
self.apt_distros # Debian/Ubuntu distros self.dnf_distros # Fedora/RHEL/OpenMandriva distros
-
PackageInstallDispatcher
class - Contains static methods for each package manager type
- Each method implements the specific installation logic
Let's walk through adding support for a new distribution, using a hypothetical example. Say we're adding support for a new distribution called "NewLinux" that uses a package manager called "newpkg".
First, we need to tell Toshy about our new distribution. In distro_groups_map
, we'll add an entry that lists all the variants of our distribution:
'newlinux-based': ["newlinux", "newlinux-community", "newlinux-enterprise"]
The IDs here should match what's in the distribution's /etc/os-release
file - we're not using the "pretty" names, but rather the short identifiers.
Now comes the trickier part - defining what packages our new distribution needs. In pkg_groups_map
, we'll add our list, following the pattern of similar distributions:
'newlinux-based': [
"gcc", # For building Python modules
"python3-devel", # Python development files
"libxkbcommon-devel", # For keyboard layout handling
"cairo-devel", # For GUI elements
# ... and so on
]
This step often requires some trial and error in a test environment. Look at the package lists for similar distributions as a starting point - for instance, if your new distribution is RPM-based, the Fedora package list might be a good reference.
In the PackageManagerGroups
class, we need to add our new package manager type:
# In __init__:
self.newpkg_distros = [] # 'newpkg': NewLinux package manager
# In populate_lists():
# 'newpkg': NewLinux types
self.newpkg_distros += distro_groups_map['newlinux-based']
Some package managers are used across different distro types that use different package lists. Add the distro types
Now we create the method that knows how to install packages on our new distribution. In PackageInstallDispatcher
:
@staticmethod
def install_on_newpkg_distro():
"""Handler for NewLinux distributions using newpkg"""
cmd_lst = ['sudo', 'newpkg', 'install', '--yes', '--quiet']
native_pkg_installer.install_pkg_list(cmd_lst, cnfg.pkgs_for_distro)
The key here is finding the right command-line options to make the package manager install packages non-interactively. Always include the appropriate non-interactive flags for the new package manager, to avoid interrupting the overall Toshy setup process by asking for input.
Finally, connect everything together in PackageManagerGroups.create_dispatch_map()
:
self.dispatch_map = {
# ... existing entries ...
tuple(self.newpkg_distros): PackageInstallDispatcher.install_on_newpkg_distro,
}
Sometimes distributions need special handling. Here's how to handle common scenarios:
Need to add or remove specific packages for certain distribution versions? Use these maps:
# Add extra packages
extra_pkgs_map = {
('newlinux', '2.0'): ["extra-package-1", "extra-package-2"]
}
# Remove problematic packages
remove_pkgs_map = {
('newlinux', None): ["incompatible-package"]
}
If your distribution needs special setup (like enabling extra repositories), add a method to DistroQuirksHandler
:
@staticmethod
def handle_quirks_NewLinux():
print('Preparing NewLinux environment...')
# Add your special handling here
The best way to test your additions is in a clean virtual machine:
- Start with a fresh install of your distribution
- Take a snapshot (so you can easily retry)
- Run the Toshy installer
- Watch for any package installation errors
- Verify Toshy works after installation
- Document any special requirements
-
Package Names: Different distributions often use different names for the same package. For example,
python3-devel
on RPM-based systems might bepython3-dev
on Debian-based systems. - Build Dependencies: Some distributions might need additional packages for building Python modules.
- Package Manager Options: Each package manager has its own way of handling non-interactive installation. Check the distribution's documentation for the right options.
- Start with a distribution similar to yours as a template
- Keep a log of what packages you needed to add or remove during testing
- Test thoroughly in a clean environment
- Document any special steps in the code comments
- Submit a pull request with your changes!