#!/bin/bash
###################################################################################
# File.......: /usr/lib/setup/armedslack-postinstall-scripts/000-env-postinst-setup
# Called from: /usr/lib/setup/armedslack-run-postinstall-scripts
#              (sourced from SeTconfig)
#              This has a prefix of '000-' to ensure it's run first.
# Purpose....: Update the Installer environment's linked library cache so that we
#              can use tools within the mounted OS file system.
#              This is required for the Boot Loader Flashing tool that uses the
#              'file' command, which is linked to libmagic.
# Version....: 1.00
# Date.......: 18-Sep-2023
# Author.....: Stuart Winter <mozes@slackware.com>
###################################################################################

# Location of the root file system, passed as an argument to this script:
T_PX=$1

# The ldconfig can take a while, so let's leave a message:
dialog \
   --backtitle "Post Installation Setup" \
   --sleep 2 \
   --infobox "Preparing environment ..." 3 30

# Hack to enable 'file' to use the OS's versions.  This avoids us having to run
# the Boot Loader flash tool within a chroot (which would unnecessarily complicate
# matters), or to copy file's data repository into the Installer:
ln -fs $T_PX/etc/file /etc/

# 'grub-install' requires this:
ln -fs $T_PX/usr/share/locale /usr/share/

# Add the OS's library to the Installer environment search path to
# enable us to use the installed tools:
cat << EOF >> /etc/ld.so.conf
$T_PX/lib64
$T_PX/lib
$T_PX/usr/lib64
$T_PX/usr/lib
EOF
ldconfig

