Here is the code you need to use the virtualbox modules and remove them if you find the system while if installed on virtualbox it does not remove them.
create the mrpacman folder in src/modules ( calamares installer )
Add main.py and add code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <http://github.com/calamares> ===
#
# Copyright 2014, Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> [packages]
# Copyright 2016, Mike KrĂĽger <mikekrueger81@gmail.com> [mrpacman]
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Calamares is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import libcalamares
import subprocess
from libcalamares.utils import check_target_env_call, target_env_call
class PackageManager:
""" Package manager class.
:param backend:
"""
def __init__(self, backend):
self.backend = backend
def install(self, pkgs, from_local=False):
""" Installs packages.
:param pkgs:
:param from_local:
"""
if self.backend == "pacman":
if from_local:
pacman_flags = "-U"
else:
pacman_flags = "-Sy"
check_target_env_call(["pacman", pacman_flags, "--noconfirm"
] + pkgs)
def remove(self, pkgs):
""" Removes packages.
:param pkgs:
"""
if self.backend == "pacman":
check_target_env_call(["pacman", "-Rs", "--noconfirm"]
+ pkgs)
def upgrade(self):
""" upgrades all packages.
"""
if self.backend == "pacman":
try:
check_target_env_call(["pacman", "-Syyu", "--noconfirm"])
except:
print("unresolvable package conflicts detected")
def get_language():
output = libcalamares.globalstorage.value("localeConf")
lang = output["LANG"]
parts = lang.split(".")
if len(parts) < 1:
return ""
lang = parts[0].lower()
lang = lang.replace("_", "-")
return lang
virtualbox = False #global var for virtualbox_check
def virtualbox_check():
command = "dmidecode -s system-product-name"
output = subprocess.check_output(['sh','-c', command]).decode('ascii')
substring = output[0:10].lower()
global virtualbox
if substring == "virtualbox":
virtualbox = True
else:
virtualbox = False
return virtualbox
def packagelist_filter(pkgs, pkg_remove_filter, first_index, last_index):
new_package_list = []
for pkg in pkgs:
part = pkg[first_index:last_index].lower()
if part != pkg_remove_filter:
new_package_list.append(pkg)
return new_package_list
def run_operations(pkgman, entry):
""" Call package manager with given parameters.
:param pkgman:
:param entry:
"""
for key in entry.keys():
if key == "install":
pkgman.install(entry[key])
elif key == "remove":
if virtualbox:
pkgman.remove(packagelist_filter(entry[key], "virtualbox", 0, 10))
else:
pkgman.remove(entry[key])
elif key == "localInstall":
pkgman.install(entry[key], from_local=True)
def run():
""" Calls routine with detected package manager to install locale packages
or remove drivers not needed on the installed system.
:return:
"""
virtualbox_check()
backend = libcalamares.job.configuration.get("backend")
if backend not in ("pacman"):
return "Bad backend", "backend=\"{}\"".format(backend)
pkgman = PackageManager(backend)
operations = libcalamares.job.configuration.get("operations", [])
for entry in operations:
run_operations(pkgman, entry)
if libcalamares.globalstorage.contains("packageOperations"):
run_operations(pkgman,
libcalamares.globalstorage.value("packageOperations"
))
return None
Create module.desc
---
type: "job"
name: "mrpacman"
interface: "python"
script: "main.py"
Create mrpacman.conf
---
# Pacman is the man! ;)
# Which package manager to use, options are:
# - pacman - Pacman
#
backend: pacman
#
# List of maps with package operations such as install or remove.
# Distro developers can provide a list of packages to remove
# from the installed system (for instance packages meant only
# for the live system).
#
# A job implementing a distro specific logic to determine other
# packages that need to be installed or removed can run before
# this one. Distro developers may want to install locale packages
# or remove drivers not needed on the installed system.
# This job will populate a list of dictionaries in the global
# storage called "packageOperations" and it is processed
# after the static list in the job configuration.
#
#operations:
# - install:
# - pkg1
# - pkg2
# - remove:
# - pkg3
# - pkg4
# - install:
# - pkg5
# - remove:
# - pkg2
# - pkg1
# install:
# - pkgs6
# - pkg7
# - localInstall:
# - /path/to/pkg8
operations:
- remove:
- calamares
- virtualbox-guest-utils
- virtualbox-host-dkms
- virtualbox-guest-dkms
Now enable the module from the calamares setting:
- exec:
- mrpacman
You can try and if there are problems I can help you solve them. The module was used on Condres without problems.
To be sure that you need to remove the packages you need to insert the virtualbox dkms into the iso image packages.
Without that, the script fails to find the required packages and fails to install.
I hope I have been helpful.