diff --git a/etc/calamares/modules/tde_pre_install.conf b/etc/calamares/modules/tde_pre_install.conf new file mode 100644 index 0000000..17eb857 --- /dev/null +++ b/etc/calamares/modules/tde_pre_install.conf @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# packages with pre-install scripts +# +--- +# package: +# pre-install: command/script + +package: tde-tdebase +pre-install: + - /usr/bin/sh /usr/bin/setup-trinity \ No newline at end of file diff --git a/etc/calamares/settings_online.conf b/etc/calamares/settings_online.conf index 56229d6..2366614 100644 --- a/etc/calamares/settings_online.conf +++ b/etc/calamares/settings_online.conf @@ -40,6 +40,7 @@ sequence: - localecfg - hwclock - keyboard + - pre_install@tde - packages@packages_online - users - networkcfg @@ -88,6 +89,11 @@ instances: # config: hostinfo.conf # No config weight: 1 # ========== +- module: pre_install + id: tde + config: tde_pre_install.conf + weight: 1 +# ========== - module: partition id: partition config: partition.conf diff --git a/packaging/build_package.sh b/packaging/build_package.sh index 01664da..caaf735 100644 --- a/packaging/build_package.sh +++ b/packaging/build_package.sh @@ -5,9 +5,9 @@ PROJECT_DIRECTORY="$(dirname -- "$SCRIPT_DIRECTORY")" BUILD_DIRECTORY="$PROJECT_DIRECTORY"/build PACKAGE_DIRECTORY_STUB="calamares-configuration" MODE="$(echo "$1" | tr "[:upper:]" "[:lower:]")" -if [ "$MODE" != "stable" ] && [ "$MODE" != "git" ] && [ "$MODE" != "local" ]; then +if [ "$MODE" != "stable" ] && [ "$MODE" != "local" ]; then echo "" - echo "ERROR: Please specify \"stable\", \"git\", or \"local\" as the first argument to this script, to indicate the mode to run this script in." + echo "ERROR: Please specify \"stable\" or \"local\" as the first argument to this script, to indicate the mode to run this script in." exit 1 fi shift 1 diff --git a/packaging/calamares-configuration-local/PKGBUILD b/packaging/calamares-configuration-local/PKGBUILD index 2b961ab..36c6a5f 100644 --- a/packaging/calamares-configuration-local/PKGBUILD +++ b/packaging/calamares-configuration-local/PKGBUILD @@ -1,10 +1,10 @@ # Maintainer: shivanandvp pkgname=calamares-configuration-rpi-local -pkgver=v0.0.18.r4.ga540bee +pkgver=r499.87d1927 pkgrel=1 -arch=('aarch64') +arch=('any') pkgdesc='Configuration for the RebornOS Calamares installer.' url='https://github.com/RebornOS-Developers/calamares-configuration' license=('GPL3') @@ -103,13 +103,12 @@ package() { -exec \ install -Dm 700 "{}" "${pkgdir}/$TARGET_DIRECTORY_STUB/{}" \; ) - ( # ------------------- - # Copy local packages - # ------------------- - cd "$DIST_DIRECTORY" && \ - find local_packages \ + ( + cd "$PROJECT_DIRECTORY" && \ + find pre_install \ -type f \ -exec \ - install -Dm 700 "{}" "${pkgdir}/$TARGET_DIRECTORY_STUB/{}" \; + install -Dm 755 "{}" "${pkgdir}/usr/lib/calamares/modules/pre_install/{}" \; ) + } diff --git a/packaging/calamares-configuration/PKGBUILD b/packaging/calamares-configuration/PKGBUILD index 9d7bd74..d5fabb9 100644 --- a/packaging/calamares-configuration/PKGBUILD +++ b/packaging/calamares-configuration/PKGBUILD @@ -103,4 +103,11 @@ package() { -exec \ install -Dm 700 "{}" "${pkgdir}/$TARGET_DIRECTORY_STUB/{}" \; ) + ( + cd "$PROJECT_DIRECTORY" && \ + find pre_install \ + -type f \ + -exec \ + install -Dm 755 "{}" "${pkgdir}/usr/lib/calamares/modules/pre_install/{}" \; + ) } diff --git a/packaging/install_package.sh b/packaging/install_package.sh index 5798445..71c34f9 100644 --- a/packaging/install_package.sh +++ b/packaging/install_package.sh @@ -5,7 +5,7 @@ PROJECT_DIRECTORY="$(dirname -- "$SCRIPT_DIRECTORY")" BUILD_DIRECTORY="$PROJECT_DIRECTORY"/build PACKAGE_DIRECTORY_STUB="calamares-configuration" MODE="$(echo "$1" | tr "[:upper:]" "[:lower:]")" -if [ "$MODE" != "stable" ] && [ "$MODE" != "git" ] && [ "$MODE" != "local" ]; then +if [ "$MODE" != "stable" ] && [ "$MODE" != "local" ]; then echo "" echo "ERROR: Please specify \"stable\", \"git\", or \"local\" as the first argument to this script, to indicate the mode to run this script in." exit 1 diff --git a/pre_install/main.py b/pre_install/main.py new file mode 100644 index 0000000..702587a --- /dev/null +++ b/pre_install/main.py @@ -0,0 +1,54 @@ +import os +import shutil +from typing import Optional, Union, Dict, List + +import libcalamares +from libcalamares.utils import gettext_path, gettext_languages + + +import gettext +_ = gettext.translation("calamares-python", + localedir=libcalamares.utils.gettext_path(), + languages=libcalamares.utils.gettext_languages(), + fallback=True).gettext + + +def pretty_name(): + return _("Running pre-install commands") + +def pick_out_packages(item: Union[Dict, List, str], cumulative_package_list: List[str]): + if isinstance(item, dict): + for key in item: + if key == "packages": + for package in item["packages"]: + if isinstance(package, dict): + if "name" in package: + if package["name"] is not None: + cumulative_package_list.append(package["name"]) + elif isinstance(package, str): + cumulative_package_list.append(package) + else: + pick_out_packages(item= item[key], cumulative_package_list= cumulative_package_list) + elif isinstance(item, list): + for list_item in item: + pick_out_packages(item= list_item, cumulative_package_list= cumulative_package_list) + +cumulative_package_list: list[str] = [] + +def run(): + packagechooser = libcalamares.globalstorage.value("netinstallAdd") + package = libcalamares.job.configuration["package"] + pre_commands = libcalamares.job.configuration["pre_install"] + netinstall = libcalamares.globalstorage.value("packageOperations") + print(netinstall) + pick_out_packages(item= packagechooser, cumulative_package_list= cumulative_package_list) + print(pre_commands) + if package in cumulative_package_list: + libcalamares.utils.debug("Match found") + for command in pre_commands: + command_ = command.split(' ') + libcalamares.utils.debug("Running command: {}".format(command)) + libcalamares.utils.target_env_call(command_) + else: + libcalamares.utils.debug("Match not found") + return None diff --git a/pre_install/module.desc b/pre_install/module.desc new file mode 100644 index 0000000..74888d1 --- /dev/null +++ b/pre_install/module.desc @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# Module metadata file for dummy python jobmodule +# Syntax is YAML 1.2 +--- +type: "job" +name: "pre_install" +interface: "python" +script: "main.py" diff --git a/pre_install/pre_install.conf b/pre_install/pre_install.conf new file mode 100644 index 0000000..cd3fdc5 --- /dev/null +++ b/pre_install/pre_install.conf @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: no +# SPDX-License-Identifier: CC0-1.0 +# +# packages with pre-install scripts +# +--- +# package: +# pre-install: command/script + +package: tde-tdebase +pre-install: /usr/bin/notify-send "asaddddddddddddddddddddd" \ No newline at end of file