Skip to content
This repository has been archived by the owner on Aug 7, 2023. It is now read-only.

Commit

Permalink
add preinstall module
Browse files Browse the repository at this point in the history
  • Loading branch information
Rippanda12 committed Dec 4, 2022
1 parent 87d1927 commit d544320
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 11 deletions.
12 changes: 12 additions & 0 deletions etc/calamares/modules/tde_pre_install.conf
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions etc/calamares/settings_online.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ sequence:
- localecfg
- hwclock
- keyboard
- pre_install@tde
- packages@packages_online
- users
- networkcfg
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packaging/build_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions packaging/calamares-configuration-local/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Maintainer: shivanandvp <[email protected], [email protected]>

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')
Expand Down Expand Up @@ -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/{}" \;
)

}
7 changes: 7 additions & 0 deletions packaging/calamares-configuration/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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/{}" \;
)
}
2 changes: 1 addition & 1 deletion packaging/install_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
54 changes: 54 additions & 0 deletions pre_install/main.py
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions pre_install/module.desc
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 11 additions & 0 deletions pre_install/pre_install.conf
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit d544320

Please sign in to comment.