From 7b6b519f962387925d55c4c8924ea6e31c2cdf30 Mon Sep 17 00:00:00 2001 From: timoxa0 Date: Sun, 27 Oct 2024 19:27:01 +0500 Subject: [PATCH] common_rpm: Add rpm profile --- common.d/common.rpm.sh | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 common.d/common.rpm.sh diff --git a/common.d/common.rpm.sh b/common.d/common.rpm.sh new file mode 100644 index 0000000..8bb0e4c --- /dev/null +++ b/common.d/common.rpm.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +source ./common.d/functions.sh +source ./common.d/build_functions.sh + +require "debootstrap" + +fetch_base_system() +{ + log "fetch_base_system is not implemented for rpm profiles" ierror + log "Use distro specific type. Or implement your own" ierror + return 3 +} + +prepare_system() +{ + log "prepare_system is not implemented for rpm imahe type" ierror + log "Use distro-specific image type. Or implement your own" ierror + return 3 +} + +setup_zram_generator() +{ + log "setup_zram_generator is not implemented for rpm imahe type" ierror + log "Use distro-specific image type. Or implement your own" ierror + return 3 +} + +install_nabu_packages() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + cp ./packages/*.rpm "$rootdir/opt/" + chroot "$rootdir" bash -c "rpm -i /opt/*.rpm" || { + log "Failed to install packages" ierror + return 1 + } + chroot "$rootdir" bash -c "rm /opt/*.rpm" + + log "Enabling userspace services" internal + chroot "$rootdir" systemctl enable qrtr-ns pd-mapper tqftpserv rmtfs || { + log "Failed to enable services" ierror + return 1 + } + return 0 +} + +# shellcheck disable=SC2086 +install_packages() +{ + local rootdir="$1" + local packages="${*:2}" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + chroot "$rootdir" dnf install $packages -y || { + log "Failed to install package(s)" ierror + return 1 + } + return 0 +} + +finish_system() +{ + local rootdir="$1" + [ ! -d "$rootdir" ] && { + log "Rootdir [$rootdir] does not exists" ierror + return 2 + } + + log "Cleaning dnf cache" internal + chroot "$rootdir" dnf clean all || { + log "Failed to clean dnf cache" ierror + return 1 + } + + log "Updating runtime linker bindings" internal + chroot "$rootdir" ldconfig || { + log "Failed to update runtime linker bindings" ierror + return 1 + } + + [ -L "$rootdir/etc/resolv.conf.1" ] && { + log "Restoring resolv.conf symlink" + mv "$rootdir/etc/resolv.conf.1" "$rootdir/etc/resolv.conf" + } + return 0 +} +