aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos.K <freedomrfox@gmail.com>2017-06-09 02:18:49 +0300
committerChristos.K <freedomrfox@gmail.com>2017-06-09 02:18:49 +0300
commit7e4eb25f105474f84b07853858965a5d5cbb1387 (patch)
tree64e2c7e7398ea3d3776b4e222b160edaaad7fcb6 /scripts
parentFirst option include (diff)
downloadGSE-7e4eb25f105474f84b07853858965a5d5cbb1387.tar.gz
GSE-7e4eb25f105474f84b07853858965a5d5cbb1387.tar.bz2
GSE-7e4eb25f105474f84b07853858965a5d5cbb1387.zip
Included general functions to avoid repeating parts
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/chroot_scripts/cfunctions624
-rw-r--r--scripts/functions/catalyst_functions252
-rwxr-xr-xscripts/functions/local_rbuild36
-rwxr-xr-xscripts/functions/sinit_functions586
4 files changed, 1498 insertions, 0 deletions
diff --git a/scripts/chroot_scripts/cfunctions b/scripts/chroot_scripts/cfunctions
new file mode 100755
index 0000000..614a36f
--- /dev/null
+++ b/scripts/chroot_scripts/cfunctions
@@ -0,0 +1,624 @@
+#!/bin/bash
+
+# SUBSHELL
+subshel_f() {
+ echo -e "\e[33mCalling bash subshell\e[0m"
+ sleep 2
+ echo 'echo -e "\e[33mInside Subshell\e[0m"' >> /root/.bashrc
+ echo 'echo -e "\e[33mExit to return back to parent\e[0m"' >> /root/.bashrc
+ (clear; exec /bin/bash;)
+ sed -i "/Inside Subshell/d" "/root/.bashrc"
+ sed -i "/Exit to return back to parent/d" "/root/.bashrc"
+ echo -e "\e[33mYou are back to parent\e[0m"
+}
+
+# ALL ERROR MESSAGES BUT FIRST
+chprint_inf_f() {
+ case $1 in
+ 1)
+ echo -e "[\e[32m*\e[0m] \e[34mDone\e[0m";;
+ 2)
+ echo -e "[\e[31m*\e[0m] \e[31mFAILED\e[0m";;
+ 3)
+ clear
+ echo "If this message is printed while using the Maim Menu"
+ echo "That means essential files are altered or something bad is happening."
+ echo
+ echo "Please run a health-check from the ~Main Menu~ and a Version check first."
+ echo "If you see this again after the health/version check, please submit a bug report"
+ echo "and stop using the program, or data loss may occur."
+ echo
+ echo "Exiting..."
+ sleep 2
+ exit 1;;
+ 4)
+ echo -e "[\e[31m*\e[0m] [\e[31mERROR\e[0m: Wrong parameters"
+ exit 1;;
+ 5)
+ echo -e "[\e[31m*\e[0m] Failed getting version";;
+ 6)
+ echo -e "[\e[31m*\e[0m] FATAL";;
+ esac
+}
+
+# PROCESS FLOW TWEAKER. DO NOT EDIT THIS.
+chsinit_mon_f() {
+ case "$1" in
+ UPDATE)
+ sed -i -e 's/UPDATE=0/UPDATE=1/g' "${CHDIR}/chsinprog";;
+ 2)
+ sed -i -e 's/BOOTSTRAP=0/BOOTSTRAP=1/g' "${CHDIR}/chsinprog";;
+ REBUILD)
+ sed -i -e 's/REBUILD=0/REBUILD=1/g' "${CHDIR}/chsinprog";;
+ CONFIGURE)
+ sed -i -e 's/CONFIGURE=0/CONFIGURE=1/g' "${CHDIR}/chsinprog";;
+ INSTALL)
+ sed -i -e 's/INSTALL=0/INSTALL=1/g' "${CHDIR}/chsinprog";;
+ RUNLEVEL)
+ sed -i -e 's/RUNLEVEL=0/RUNLEVEL=1/g' "${CHDIR}/chsinprog";;
+ KERNEL)
+ sed -i -e 's/KERNEL=0/KERNEL=1/g' "${CHDIR}/chsinprog";;
+ INITRAMFS)
+ sed -i -e 's/INITRAMFS=0/INITRAMFS=1/g' "${CHDIR}/chsinprog";;
+ PORTAGE)
+ sed -i -e 's/PORTAGE=0/PORTAGE=1/g' "${CHDIR}/chsinprog";;
+ CLEAN)
+ sed -i -e 's/CLEAN=0/CLEAN=1/g' "${CHDIR}/chsinprog";;
+ CHROOTPART)
+ sed -i -e 's/CHROOTPART=0/CHROOTPART=1/g' "${CHDIR}/chsinprog";;
+ dn) ;;
+ esac
+}
+
+repeat_part_f() {
+while true; do
+ echo -e "\e[33mPart $1: Has been completed\e[0m"
+ read -rp "Run again? Y/N: " YN
+ case "${YN}" in
+ [yN])
+ clear; eval "$2"
+ break;;
+ [nN])
+ break;;
+ esac
+done
+}
+
+emerge_resume_f() {
+ if [[ -n "$(grep "$2" <"${CHDIR}/emergeresume")" ]]; then
+ while true; do
+ echo -e "\e[33mA previous emerge action failed or stopped manually\e[0m"
+ echo -e "Do you wish to \e[34mresume\e[0m that action?"
+ read -rp "Answer Y/N: " YN
+ case "${YN:-y}" in
+ [yY])
+ echo -e "\e[33mResuming\e[0m"
+ emerge -qr && chprint_inf 1 && sed -i "/$2/d" "${CHDIR}/emergeresume" \
+ || { chprint_inf 2
+ while true; do
+ echo "Emerge could not complete that action"
+ echo "Do you wish to exit, check logs and fix it manually or continue"
+ echo -e "Answer: \e[31mEXIT\e[0m/\e[33mSHELL\e[0m/\e[34mCONTINUE\e[0m"
+ read -rp "Input :: <= " ANS
+ case "${ANS:-EXIT}" in
+ EXIT)
+ echo "Exiting..."
+ sleep 1
+ exit 1;;
+ SHELL)
+ while true; do
+ subshel_f
+ read -rp "Continue? Y/N: " AANS
+ case "${AANS:-Y}" in
+ [yY])
+ break;;
+ [nN])
+ ;;
+ esac
+ done
+ break;;
+ CONTINUE)
+ break;;
+ esac
+ done; }
+ echo -e "\e[32mContinuing\e[0m"
+ eval "$1" && sed -i "/$2/d" "${CHDIR}/emergeresume"
+ break;;
+ [nN])
+ eval "$1" && sed -i "/$2/d" "${CHDIR}/emergeresume"
+ break;;
+ esac
+ done
+ else
+ eval "$1" && sed -i "/$2/d" "${CHDIR}/emergeresume"
+ fi
+ unset YN
+ unset AANS
+ unset ANS
+}
+
+emerge_dep_clean_f() {
+ # DEPCLEAN BEFORE APPLYING NEW PROFILE CHANGES
+ echo -e "\e[34mOrphan depclean before continuing...\e[0m" \
+ && emerge --depclean >/dev/null 2>&1 \
+ && chprint_inf 1 \
+ || { chprint_inf 2 \
+ && echo "DEPC" >> "${CHDIR}/emergeresume" \
+ && emerge_resume_f "emerge --depclean" "DEPC"; }
+}
+
+port_prof_f() {
+ # GSE PROFILE DIRECTORIES AND FILES
+ mkdir -p /usr/local/portage/{metadata,profiles} \
+ && chown -R portage:portage /usr/local/portage \
+ && echo 'gse' > /usr/local/portage/profiles/repo_name \
+ && cp "${CHDIR}/localrepo/layout.conf" "/usr/local/portage/metadata/layout.conf" \
+ && cp "${CHDIR}/localrepo/localrepo.conf" "/etc/portage/repos.conf/localrepo.conf"
+
+ mkdir -p "/usr/local/portage/profiles/gse" \
+ && mkdir -p "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse" \
+ && cp "${CHDIR}/profiles/parent-gse/eapi" \
+ "/usr/local/portage/profiles/gse/eapi" \
+ && cp "${CHDIR}/profiles/parent-gse/make.defaults" \
+ "/usr/local/portage/profiles/gse/make.defaults" \
+ && cp "${CHDIR}/profiles/parent-gse/package.use" \
+ "/usr/local/portage/profiles/gse/package.use" \
+ && cp "${CHDIR}/profiles/parent-gse/package.use.force" \
+ "/usr/local/portage/profiles/gse/package.use.force" \
+ && cp "${CHDIR}/profiles/child-gse/eapi" \
+ "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/eapi" \
+ && cp "${CHDIR}/profiles/child-gse/parent" \
+ "/usr/local/portage/profiles/default/linux/${ARCH}/13.0/gse/parent" \
+ && echo "# Local profile" > "/usr/local/portage/profiles/profiles.desc" \
+ && echo "amd64 default/linux/amd64/13.0/gse exp" \
+ >> "/usr/local/portage/profiles/profiles.desc" \
+ && echo -e "[\e[32m*\e[0m] Creating [\e[34mprofile\e[0m]" \
+ || { echo -e "[\e[31m*\e[0m] Creating [\e[34profile\e[0m]"; return 1; }
+ # END OF GSE PROFILE
+}
+
+part_portage_f() {
+ # MAKE.CONF, PACKAGE.USE, FEATURES AND CCACHE
+ rm -f /etc/portage/make.conf \
+ && rm -r /etc/portage/package.use/sysbuild >/dev/null 2>&1 \
+ && mkdir -p "/etc/portage/package.use" \
+ && cp "${CHDIR}/make.conf" /etc/portage/make.conf \
+ && { echo -e "Configuring [\e[32mmake.conf\e[0m]" \
+ || echo -e "\e[31mFaild\e[0m Configuring [\e[32mmake.conf\e[0m]"; } \
+ && cp "${CHDIR}/package.use/sysbuild" "/etc/portage/package.use" \
+ && { echo -e "Configuring [\e[32mpackage.use\e[0m]" \
+ || echo -e "\e[31mFaild\e[0m Configuring [\e[32mpackage.use\e[0m]"; } \
+ && echo "FEATURES=\"\${FEATURES} ${CHFEATURES}\"" >> /etc/portage/make.conf \
+ && { echo -e "Configuring [\e[32mFEATURES\e[0m]" \
+ || echo -e "\e[31mFaild\e[0m Configuring \e[32mFEATURES\e[0m"; } \
+ && [[ -n "${CCCACHESIZE}" ]] && echo "CCACHE=\"${CCCACHESIZE}\"" >> /etc/portage/make.conf \
+ && { echo -e "Configuring make.conf [\e[32mCCACHE=${CCCACHESIZE}\e[0m]" \
+ || echo -e "\e[31mFaild\e[0m Failed configuring make.conf \e[32mCCACHE=${CCCACHESIZE}\e[0m"; } \
+ && dist_ccashe_f \
+ && emerge_resume_f "emerge_dep_clean_f" "DEPC" \
+ && port_prof_f || return 1
+
+ # SELECTING PROFILE
+ echo -e "Do you wish to enable \e[33mGSE\e[0m \e[34mprofile\e[0m ::: (\e[31mexperimental\e[0m)?"
+ echo -e "Say no here, to select a basic \e[35mGentoo\e[0m \e[34mprofile\e[0m manually"
+ read -rp "Answer Y/N: " YN
+ while true; do
+ case "${YN:-n}" in
+ [yY])
+ GSE_PROF=$(eselect profile list | grep gse | awk -F '[' '{print $2}' | awk -F ']' '{print $1}') \
+ && eselect profile set "${GSE_PROF}" && echo -e "\e[34mEnabled\e[0m" && BREAKVAR=0 \
+ || { chprint_inf_f 2 && YN=n; };;
+ [nN])
+ eselect profile list
+ echo -e "Please select a \e[34mprofile\e[0m listed from above:"
+ echo -e "Answer is only related \e[34mprofile\e[0m numbers"
+ read -rp "Input :: <== " ANS
+ [[ -n "${ANS}" ]] && eselect profile set "${ANS}" && echo -e "\e[34mEnabled\e[0m" && BREAKVAR=0 \
+ || { chprint_inf_f 2 && BREAKVAR=1; };;
+ esac
+ [[ "${BREAKVAR}" == 0 ]] && break \
+ || { echo "Could not set a profile"
+ YN=n; }
+ done
+
+ unset YN
+ unset ANS
+ unset BREAKVAR
+}
+
+dist_ccashe_f() {
+ # ADD OR REMOVE DISTCC FROM THE SYSTEM
+ if [[ -n "$(echo ${CHFEATURES} | grep distcc)" ]]; then
+ if ! eix --installed sys-devel/distcc >/dev/null 2>&1 ]]; then
+ echo -e "Configuring [\e[32mdistcc\e[0m]" \
+ && emerge -q sys-devel/distcc >/dev/null 2>&1 \
+ && chprint_inf 1 || chprint_inf 2
+
+ mkdir -p /etc/distcc \
+ && cp "${CHDIR}/hosts" /etc/distcc/hosts \
+ && echo -e "Configuring [\e[32mdistcc hosts\e[0m]" \
+ || echo -e "Faild configuring [\e[33mdistcc hosts\e[0m]"
+ fi
+ else
+ if eix --installed sys-devel/distcc >/dev/null 2>&1; then
+ echo -e "Removing [\e[32mdistcc\e[0m]" \
+ && emerge --deselect sys-devel/distcc >/dev/null 2>&1 \
+ && chprint_inf 1 || chprint_inf 2
+ fi
+ fi
+ if [[ -n "${CCCACHESIZE}" ]]; then
+ if ! eix --installed dev-util/ccache >/dev/null 2>&1; then
+ echo -e "Configuring [\e[32mccache\e[0m]" \
+ && emerge -q dev-util/ccache >/dev/null 2>&1 \
+ && chprint_inf 1 || chprint_inf 2
+ fi
+ else
+ if eix --installed dev-util/ccache >/dev/null 2>&1; then
+ echo -e "Removing [\e[33mccache\e[0m]" \
+ && emerge --deselect sys-devel/distcc >/dev/null 2>&1 \
+ && chprint_inf 1 || chprint_inf 2
+ fi
+ fi
+}
+
+apply_new_f() {
+ # APPLYING PROFILE CHANGES
+ echo -e "[\e[32m*\e[0m] \e[34mApplying new profile changes\e[0m"
+ emerge -q --update --deep --newuse --with-bdeps=y @world \
+ && chprint_inf 1 \
+ || { chprint_inf 2 && echo "UDN" >> "${CHDIR}/emergeresume" \
+ && emerge_resume_f "emerge -q --update --deep --newuse --with-bdeps=y @world" "UDN"
+ exit 1; }
+}
+
+emerge_rebuild_system_f() {
+ # EMERGIN WORLD
+ while true; do
+ echo "----------------------------------------------------------------------------"
+ echo "Do you wish to rebuild the system?"
+ echo "If catalyst built this system, simply say no"
+ read -rp "Answer Yes or No: " YN
+ case "${YN:-n}" in
+ [yY][eE][sS]|[yY])
+ emerge -eq @world && chprint_inf 1 \
+ || { echo "REBUILD" >> "${CHDIR}/emergeresume" \
+ && emerge_resume_f "emerge -eq" "REBUILD"; }
+ chsinit_mon "REBUILD"; break;;
+ [nN][oO]|[nN])
+ echo "Exiting Rebuilding Part"
+ sleep 1
+ chsinit_mon "REBUILD"; break;;
+ esac
+ done
+ unset YN
+}
+
+
+updating_portage_f(){
+ if emerge -q --deep --update portage >/dev/null 2>&1; then
+ chprint_inf_f 1
+ else
+ chprint_inf_f 2 && exit 1
+ fi
+}
+
+emerge_eix_f() {
+ if emerge -q app-portage/eix >/dev/null 2>&1; then
+ chprint_inf_f 1
+ else
+ chprint_inf_f 2 && exit 1
+ fi
+}
+
+update_eix_f() {
+ if eix-update >/dev/null 2>&1; then
+ chprint_inf_f 1 \
+ && chsinit_mon_f "UPDATE"
+ else
+ chprint_inf_f 2 && exit 1
+ fi
+}
+
+emerge_gentoolkit_f() {
+ emerge -q app-portage/gentoolkit >/dev/null 2>&1
+}
+
+upd_port_em_eix_f() {
+ mkdir -p "/etc/portage/repos.conf"
+ cp /usr/share/portage/config/repos.conf /etc/portage/repos.conf/gentoo.conf
+
+ if [[ -n $(echo "$@" | grep 'catalyst') ]]; then
+ emerge --sync >/dev/nill 2>&1 && chprint_inf_f 1 || { chprint_inf_f 2; exit 1; }
+ env-update >/dev/null 2>&1
+ elif [[ -n $(echo "$@" | grep 'precomp') ]]; then
+ emerge--webrsync >/dev/nill 2>&1 && chprint_inf_f 1 || { chprint_inf_f 2; exit 1; }
+ env-update >/dev/null 2>&1
+ fi
+
+ echo -e "\e[34mUpdating Portage\e[0m"
+ updating_portage_f
+ echo -e "\e[34mSearching for eix\e[0m"
+ if [[ -z $(command -v eix) ]]; then
+ echo -e "\e[33mCould not locate eix\e[0m"
+ echo -e "\e[34mEmerging eix\e[0m"
+ emerge_eix_f
+ echo -e "\e[34mUpdating eix database\e[0m"
+ update_eix_f
+ else
+ echo -e "\e[33meix located\e[0m"
+ echo -e "\e[34mUpdating eix database\e[0m"
+ update_eix_f
+ fi
+ if ! eix --installed app-portage/gentoolkit >/dev/null 2>&1; then
+ echo -e "\e[34mEmerging app-portage/gentoolkit\e[0m"
+ emerge_gentoolkit_f
+ echo -e "\e[34mRunning \e[34mGentoo's\e[0m Reverse Dependency rebuilder\e[0m"
+ revdep-rebuild
+ else
+ echo -e "\e[34mRunning \e[34mGentoo's\e[0m Reverse Dependency rebuilder\e[0m"
+ revdep-rebuild
+ fi
+}
+
+part_c_f() {
+ echo "============================================================================"
+ echo -e "\e[35mPart C: Syncing Portage\e[0m"
+ echo "============================================================================"
+ echo -e "\e[34mUpdating the database\e[0m"
+ upd_port_em_eix_f "$@"
+}
+
+configure_timezone_f() {
+ if [[ "${TIMEZONE}" != TMZ ]]; then
+ echo "----------------------------------------------------------------------------"
+ echo "${TIMEZONE}" > /etc/timezone && echo -e "[\e[32m*\e[0m] Configuring \e[34mTimezone\e[0m"
+ else
+ echo "----------------------------------------------------------------------------"
+ echo "UTC" > /etc/timezone && echo -e "[\e[32m*\e[0m] \e[34mConfiguring Timezone\e[0m"
+ fi
+
+ if emerge --config sys-libs/timezone-data | grep "invalid" >/dev/null 2>&1; then
+ echo "UTC" >/etc/timezone; emerge --config sys-libs/timezone-data \
+ && echo -e "[\e[32m*\e[0m] Resetting to UTC" \
+ || echo -e "[\e[31m*\e[0m] Resetting to UTC"
+ fi
+}
+
+configure_locale_f() {
+ if [[ -z $(cat "${CHDIR}/locale.gen" | sed '/^#/ d' | sed '/^\s*$/d') ]]; then
+ sed -i '/en_US.UTF-8/d' /etc/locale.gen
+ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && echo -e "[\e[32m*\e[0m] Configuring [\e[34mlocale\e[0m]" \
+ || echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+ else
+ echo "$(cat "${CHDIR}/locale.gen")" > /etc/locale.gen
+ sed -i '/en_US.UTF-8/d' /etc/locale.gen
+ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && echo -e "[\e[32m*\e[0m] Configuring \e[34mlocale\e[0m" \
+ || echo -e "[\e[31m*\e[0m] Configuring [\e[34mlocale\e[0m]"
+ fi
+
+ locale-gen
+ export LC_ALL="en_US.UTF-8"
+ SETLOC=$(eselect locale list | grep en_US | awk -F ' ' '{ print $1 }' \
+ | awk -F '[' '{ print $2 }' | awk -F ']' '{ print $1 }')
+
+ eselect locale set "${SETLOC}" && echo -e "[\e[32m*\e[0m] Setting locale to [\e[34men_US\e[0m]" \
+ || echo -e "[\e[31m*\e[0m] Failed setting locale to [\e[34men_US\e[0m]"
+ unset SETLOC
+}
+
+configure_fstab_f() {
+ cat "${CHDIR}/fstab" > /etc/fstab && echo -e "[\e[32m*\e[0m] Creating [\e[34mfstab\e[0m] entries" \
+ || { echo -e "[\e[31m*\e[0m] Creating [\e[34mfstab\e[0m] entries" && return 1; } \
+ && [[ -n $(cat "${CHDIR}/system_links" | sed '/^#/ d' | sed '/^\s*$/d') ]] \
+ && { while read -r i; do
+ case $(echo "$i" | awk -F ' ' '{ print $1 }') in
+ tmpfs)
+ echo >> /etc/fstab
+ echo "# $(echo "$i" | awk -F ' ' '{ print $2 }')" >> /etc/fstab
+ echo "tmpfs $(echo "$i" | awk -F ' ' '{ print $2 }') tmpfs nodev,nosuid,size=$(echo "$i" | awk -F ' ' '{ print $3 }')" >> /etc/fstab
+ echo >> /etc/fstab
+ ;;
+ symlink)
+ if [[ $(echo "$i" | awk -F ' ' '{ print $2 }') == 'f=n' ]]; then
+ echo "ln -s $(echo "$i" | awk -F ' ' '{ print $3 }') $(echo "$i" | awk -F ' ' '{ print $4 }')"
+ elif [[ $(echo "$i" | awk -F ' ' '{ print $2 }') == 'f=y' ]]; then
+ mkdir -p "$(echo "$i" | awk -F ' ' '{ print $3 }')"
+ echo "ln -s $(echo "$i" | awk -F ' ' '{ print $4 }') $(echo "$i" | awk -F ' ' '{ print $5 }')"
+ fi
+ ;;
+ bindmount)
+ if [[ $(echo "$i" | awk -F ' ' '{ print $2 }') == 'f=n' ]]; then
+ echo >> /etc/fstab
+ echo "# bind mount: $(echo "$i" | awk -F ' ' '{ print $3 }')" >> /etc/fstab
+ echo "$(echo "$i" | awk -F ' ' '{ print $3 }') $(echo "$i" | awk -F ' ' '{ print $4 }') none rw,bind 0 0" >> /etc/fstab
+ echo >> /etc/fstab
+ elif [[ $(echo "$i" | awk -F ' ' '{ print $2 }') == 'f=y' ]]; then
+ echo >> /etc/fstab
+ echo "# bind mount: $(echo "$i" | awk -F ' ' '{ print $4 }')" >> /etc/fstab
+ mkdir -p "$(echo "$i" | awk -F ' ' '{ print $3 }')"
+ echo "$(echo "$i" | awk -F ' ' '{ print $4 }') $(echo "$i" | awk -F ' ' '{ print $5 }') none rw,bind 0 0" >> /etc/fstab
+ echo >> /etc/fstab
+ fi
+ ;;
+ overlay)
+ echo >> /etc/fstab
+ echo "# overlay: $(echo "$i" | awk -F ' ' '{ print $2 }')" >> /etc/fstab
+ OVLFSLD=$(echo "$i" | awk -F ' ' '{ print $2 }')
+ OVLFSUD=$(echo "$i" | awk -F ' ' '{ print $3 }')
+ OVLFSWD=$(echo "$i" | awk -F ' ' '{ print $4 }')
+ echo "overlay /merged overlay noauto,lowerdir=${OVLFSLD},uperdir=${OVLFSUD},workdir=${OVLFSWD} 0 0" >> /etc/fstab
+ echo >> /etc/fstab
+ unset OVLFSLD
+ unset OVLFSUD
+ unset OVLFSWD
+ ;;
+ esac
+ done < <(cat "${CHDIR}/system_links" | sed '/^#/ d' | sed '/^\s*$/d') && chprint_inf_f 1 || { chprint_inf_f 2; exit 1; } \
+ && echo -e "[\e[32m*\e[0m] Creating \e[34msystem links\e[0m and requested \e[34mfstab\e[0m entries" \
+ || echo -e "[\e[31m*\e[0m] Creating \e[34msystem links\e[0m and requested \e[34mfstab\e[0m entries"; }
+}
+
+configure_cp_function_f() {
+ [[ -n $(cat "${CHDIR}/$1" | sed '/^#/ d' | sed '/^\s*$/d') ]] \
+ && if cp "${CHDIR}/$1" /etc/conf.d/"$2"; then
+ echo -e "[\e[32m*\e[0m] Configuring [\e[34m$3\e[0m]"
+ else
+ echo -e "[\e[31m*\e[0m] Configuring [\e[34m$3\e[0m]"
+ fi
+}
+
+configure_system_f() {
+ echo "============================================================================"
+ echo -e "\e[35mPart E: Configuring system\e[0m"
+ echo "============================================================================"
+ env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part E: Configuring system' ) $PS1"
+ export PATH=${PATH}:${CHDIR}
+
+ # TIMEZONE CONFIGURATION
+ configure_timezone_f
+
+ # LOCALE CONFIGURATION
+ configure_locale_f
+
+ # GENERATING FSTAB
+ configure_fstab_f
+
+ # CONFIGURE HOSTNAME
+ configure_cp_function_f "hostname" "hostname" "hostname"
+
+ # CONFIGURE /ETC/CONF.D/NET
+ configure_cp_function_f "net" "net" "/etc/conf.d/net"
+
+ # CONFIGURE /ETC/DEFAULT/GRUB
+ configure_cp_function_f "grub" "grub" "/etc/default/grub"
+
+ ### CUSTOM SCRIPTS ENTRIES WILL BE INCLUDED HERE
+
+ ### INSCRIPT ENTRIES WILL BE INCLUDED HERE
+
+ # CONFIGURE SSHD
+ configure_cp_function_f "sshd" "sshd" "/etc/ssh/sshd_config"
+
+ # CONFIGURE SSH.PUB
+ [[ -n $(cat "${CHDIR}/ssh.pub" | sed '/^#/ d' | sed '/^\s*$/d') ]] && mkdir -p /root/.ssh \
+ && if cat "${CHDIR}/ssh.pub" | sed '/^#/ d' | sed '/^\s*$/d' > /root/.ssh/authorized_keys; then
+ echo -e "\e[33m----------------------------------------------------------------------------\e[0m"
+ echo -e "[\e[32m*\e[0m] Adding ssh.pub key to [\e[34m/root/.ssh/authorized_keys\e[0m]"
+ echo -e "\e[33m----------------------------------------------------------------------------\e[0m"
+ else
+ echo -e "\e[31m----------------------------------------------------------------------------\e[0m"
+ echo -e "[\e[31m*\e[0m] Adding ssh.pub key to [\e[34m/root/.ssh/authorized_keys\e[0m]"
+ echo -e "\e[31m----------------------------------------------------------------------------\e[0m"
+ fi
+ chsinit_mon_f "CONFIGURE"
+}
+
+emerge_instp_f() {
+ echo -e "\e[34mEmerging\e[0m..."
+ if emerge -q --update --deep --with-bdeps=y ${INS_PARTF}; then
+ chprint_inf_f 1
+ else
+ echo "INSPARTF" >> "${CHDIR}/emergeresume"
+ emerge_resume_f "emerge -q --update --deep --with-bdeps=y ${INS_PARTF}" "INSPARTF" \
+ || { chprint_inf_f 2 && exit 1; }
+ fi
+}
+
+emerge_custom_pacl_f() {
+ mapfile -t CMPL < <(cat "${CHDIR}/custom_pacl" | sed '/^#/ d' | sed '/^\s*$/d')
+
+ if emerge -q --deep --update "${CMPL[@]}"; then
+ chprint_inf_f 1
+ else
+ echo "CMPL" >> "${CHDIR}/emergeresume"
+ emerge_resume_f "emerge -q --deep --update "${CMPL[@]}"" "CMPL" \
+ || { chprint_inf_f 2 && exit 1; }
+ fi
+}
+
+inst_req_f() {
+ echo
+ echo "----------------------------------------------------------------------------"
+ echo -e "\e[35mPart F: Installing required packages\e[0m"
+ echo "----------------------------------------------------------------------------"
+ env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part F: Installing required packages' ) $PS1"
+ export PATH=${PATH}:${CHDIR}
+
+ # EMERGE CHINIT.CONF DEFINED PACKAGES
+ emerge_instp_f
+
+ # EMERGE REQUESTED PACKAGES
+ emerge_custom_pacl_f
+
+ # DEPCLEAN
+ emerge_dep_clean_f
+
+ chsinit_mon_f "INSTALL"
+}
+
+kernel_conf_f() {
+ echo
+ echo "----------------------------------------------------------------------------"
+ echo -e "\e[35mPart H: Building the Kernel\e[0m"
+ echo "----------------------------------------------------------------------------"
+ env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part H: Building the Kernel' ) $PS1"
+ export PATH=${PATH}:${CHDIR}
+ MKPS=$(grep MAKEOPTS "/etc/portage/make.conf" | sed '/^#/ d' | sed -e "s_\"__g" | awk -F '-j' '{print $2}' | sed '/^\s*$/d')
+ while true; do
+ echo -e "Do you wish to configure the \e[34mkernel's\e[0m config file?"
+ echo -e "Please keep in mind that main function of the controller are related with \e[34mkernel builtins\e[0m"
+ read -rp "Select an option Y/N: " SELCT
+ case ${SELCT:-y} in
+ [Yy][eE][sS]|[yY])
+ if genkernel --install kernel --menuconfig --kernel-config="${CHDIR}/kernel-conf" \
+ --makeopts="-j${MKPS}" --btrfs --postclear --e2fsprogs; then
+ echo -e "The \e[34mkernel\e[0m built was \e[32msuccessful\e[0m"
+ chsinit_mon_f "KERNEL"
+ else
+ chprint_inf_f 2; exit 1
+ fi
+ break;;
+ [nN][oO]|[nN])
+ if genkernel --install kernel --menuconfig \
+ --makeopts="-j${MKPS}" --btrfs --postclear --e2fsprogs; then
+ echo -e "The \e[34mkernel\e[0m built was \e[32msuccessful\e[0m"
+ chsinit_mon_f "KERNEL"
+ else
+ chprint_inf_f 2; exit 1
+ fi
+ break;;
+ *) echo "Wrong option";;
+ esac
+ done
+}
+
+initramfs_f() {
+ echo
+ echo "----------------------------------------------------------------------------"
+ echo -e "\e[35mPart I: Building the Initramfs\e[0m"
+ echo "----------------------------------------------------------------------------"
+ env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part H: Building the Initramfs' ) $PS1"
+ export PATH=${PATH}:${CHDIR}
+ if dracut -f "initramfs-controller-${ARCH}-${GSEVER}"; then
+ echo "The \e[34minitramfs\e[0m built was successful"
+ chsinit_mon_f "INITRAMFS"
+ else
+ chprint_inf_f 2; exit 1
+ fi
+}
+
+runlevel_f() {
+ echo
+ echo "----------------------------------------------------------------------------"
+ echo -e "\e[35mPart G: Updating Runlevel Entries\e[0m"
+ echo "----------------------------------------------------------------------------"
+ env-update > /dev/null 2>&1 && source /etc/profile && export PS1="( 'Part G: Updating Runlevel Entries' ) $PS1"
+ export PATH=${PATH}:${CHDIR}
+ { while read -r i; do
+ rc-update "$(echo "$i" | awk -F ' ' '{ print $2 }')" "$(echo $i | awk -F ' ' '{ print $1 }')" \
+ "$(echo "$i" | awk -F ' ' '{ print $3 }')"
+ sleep 0.5
+ done < <(cat "${CHDIR}/runlevels" | sed '/^#/ d' | sed '/^\s*$/d'); } \
+ && { echo -e "[\e[32m*\e[0m] Updated successfully"; sleep 2; } || chprint_inf_f 2
+ chsinit_mon_f "RUNLEVEL"
+} \ No newline at end of file
diff --git a/scripts/functions/catalyst_functions b/scripts/functions/catalyst_functions
new file mode 100644
index 0000000..f75fde7
--- /dev/null
+++ b/scripts/functions/catalyst_functions
@@ -0,0 +1,252 @@
+#!/bin/bash
+
+
+# OPTIONS MENU
+opt_f() {
+ echo -e "################## \e[94m~~Snapshot~~\e[39m #################"
+ echo "## ##"
+ echo -e "## [ \e[32mI\e[39m ] Fetch new ##"
+ echo -e "## [ \e[32mII\e[39m ] Let me show you ##"
+ echo -e "## [ \e[32mIII\e[39m] Try and find it please ##"
+ echo -e "## [ \e[32mIV\e[39m ] Where is my shell? ##"
+ echo -e "## [ \e[32mV\e[39m ] Built new from portdir ##"
+ echo "## ##"
+ echo "####################################################"
+}
+
+# EXPORT CATALYST DIRECTORIES
+export_cat_dirs_f() {
+ # STOREDIR
+ export CATDIR=$(grep storedir "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g")
+
+ # PORTDIR
+ export CATPORTDIR=$(grep portdir "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g")
+
+ # SNAPSHOT_CACHE
+ export CATPORTCACHEDIR=$(grep "snapshot_cache" "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g")
+
+ # PORT_LOGDIR
+ export CATLOGDIR=$(grep "port_logdir" "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g")
+
+ # DISTDIR
+ export CATDISTDIR=$(grep "distdir" "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g")
+}
+
+# CREATE CATALYST DIRECTORIES
+create_cata_dirs_f() {
+ mkdir -p "${CATDIR}"
+ mkdir -p "${CATPORTDIR}"
+ mkdir -p "${CATPORTCACHEDIR}"
+ mkdir -p "${CATLOGDIR}"
+ mkdir -p "${CATDISTDIR}"
+ mkdir -p "${CATDIR}/builds/default"
+ mkdir -p "${CATDIR}/snapshots"
+}
+
+# CALL CATALYST TO CREATE THE SNAPSHOT
+call_cata_f() {
+ echo -e "\e[34mCreating snapshot...\e[0m"
+ catalyst -s "${SNAPSHOTNAME}" && { BRKVAR=0 && return 0; }|| { BRKVAR=1 && return 1; }
+}
+
+# BUILD PORTAGE
+build_port() {
+ echo -e "\e[35mIt is strongly recommended to update your portdir first\e[0m"
+ while true; do
+ read -rp "Do you wish to update? Y/N " YN
+ case "${YN:-n}" in
+ [yY][eE][sS]|[yY])
+ echo -e "\e[32mUpdating...\e[0m"
+ {
+ { eix-sync >/dev/null 2>&1 \
+ && echo -e "\e[32mDone\e[0m" && call_cata_f; } \
+ || { emerge --sync >/dev/null 2>&1 \
+ && echo -e "\e[32mDone\e[0m" && call_cata_f; } \
+ || { emerge-webrsync >/dev/null 2>&1 \
+ && echo -e "\e[32mDone\e[0m" && call_cata_f; }
+ } \
+ || { echo -e "\e[31mUpdate failed, build without update?\e[0m"
+ while true; do
+ read -rp "Answer: YN " ANS
+ case "${ANS:-n}" in
+ [yY])
+ echo -e "\e[34mProceeding\e[0m"
+ call_cata_f
+ break;;
+ [nN])
+ echo -e "\e[34mAborting...\e[0m"
+ sleep 1
+ BRKVAR=1
+ return 0;;
+ esac
+ done; }
+ break;;
+ [nN][oO]|[nN])
+ echo -e "\e[34mProceeding\e[0m"
+ call_cata_f
+ break;;
+ esac
+ done
+}
+
+# SUBTERMINAL
+subterm_f() {
+ echo -e "\e[33mCalling bash subshell\e[0m"
+ sleep 2
+ echo 'echo -e "\e[33mInside Subshell\e[0m"' >> /root/.bashrc
+ echo "echo -e "Please copy your snapshot to ${CATDIR}/snapshots with name: portage-${SNAPSHOTNAME}.tar.bz2""
+ echo 'echo -e "\e[33mExit to return back to parent\e[0m"' >> /root/.bashrc
+ (clear; exec /bin/bash;)
+ sed -i "/Inside Subshell/d" "/root/.bashrc"
+ sed -i "/Exit to return back to parent/d" "/root/.bashrc"
+ echo -e "\e[33mYou are back to parent\e[0m"
+}
+
+# EXPORT SPEC ENTRIES
+tar_path_name_f() {
+ TARGETPATH="$(grep 'source_subpath' "${CCONFDIR}/system/catalyst/stage$1.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g" | awk -F '/' '{ print $1 }')"
+
+ TARGETNAME="$(grep 'source_subpath' "${CCONFDIR}/system/catalyst/stage$1.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g" | awk -F '/' '{ print $2 }')"
+
+ TARGETSTAMP="$(grep 'version_stamp' "${CCONFDIR}/system/catalyst/stage$1.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")"
+
+ SNAPSHOTNAME="$(grep 'snapshot:' "${CCONFDIR}/system/catalyst/stage1.spec" \
+ | sed '/^#/ d' | sed '/^\s*$/d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")"
+}
+
+
+fetch_portage_f() {
+echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Snapshot \e[31mverified\e[0m"
+if [[ -e "${CATDIR}/portage-latest.tar.bz2" ]]; then
+ echo -e "[\e[31m*\e[0m] Purging old snapshot" \
+ && rm -f "${CATDIR}/portage-latest.tar.bz2"
+ # GETTING PORTAGE SNAPSHOT
+else
+ echo -e "[\e[31m*\e[0m] Local backup snapshot was not found!"
+fi
+ echo -e "[\e[32m*\e[0m] \e[34mGetting latest portage snapshot\e[0m" \
+ && wget -O "${CATDIR}/portage-latest.tar.bz2" \
+ http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2 >/dev/null 2>&1 \
+ && print_inf 1 && return 0 || { print_inf 2; return 1; }
+}
+
+verify_portage_f() {
+ [[ $(grep portage "${CATDIR}/portage-latest.tar.bz2.md5sum" | awk -F ' ' '{print $1}') \
+ == $(md5sum "${CATDIR}/portage-latest.tar.bz2" | awk -F ' ' '{ print $1 }') ]] \
+ && echo -e "[\e[32m*\e[0m] Verifying \e[35mmd5sums\e[0m" && return 0 \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Verifying \e[31mmd5sums\e[0m"; return 1; }
+}
+
+get_latest_portage_f() {
+ # PORTAGE MD5SUM
+ wget -O "${CATDIR}/portage-latest.tar.bz2.md5sum" \
+ http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2.md5sum >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] \e[34mGetting md5sum\e[0m" \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: \e[34mGetting md5sum\e[0m" \
+ && return 1; }
+
+ if verify_portage_f; then
+ echo "Copying to ${CATDIR}/snapshots" \
+ && cp "${CATDIR}/portage-latest.tar.bz2" "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2" \
+ && cp "${CATDIR}/portage-latest.tar.bz2.md5sum" "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2.md5sum" \
+ && print_inf 1 && return 0 || { print_inf 2; return 1; }
+ else
+ fetch_portage_f \
+ && verify_portage_f \
+ && echo "Copying to ${CATDIR}/snapshots" \
+ && cp "${CATDIR}/portage-latest.tar.bz2" "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2" \
+ && cp "${CATDIR}/portage-latest.tar.bz2.md5sum" "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2.md5sum" \
+ && print_inf 1 && return 0 || { print_inf 2; return 1; }
+ fi
+}
+
+# CHECK SNAPSHOT
+chk_snap_f() {
+[[ -z "$@" ]] && print_inf 4 && return 1
+[[ $(du -sh "$1" | awk -F ' ' '{print $1}' | sed 's/[^0-9]*//g') -le 220 ]] \
+&& [[ $(du -sh "$1" | awk -F ' ' '{print $1}' | sed 's/[^0-9]*//g') -ge 50 ]] \
+|| return 1
+}
+
+# SEARCH FOR SNAPSHOTS
+search_snap_f() {
+mapfile -t ARRAYSNAP < <(find / -name "*portage*.tar.bz2")
+
+
+for i in "${ARRAYSNAP[@]}"; do
+ if [[ $(du -sh "$i" | awk -F ' ' '{print $1}' | sed 's/[^M]*//g') == M && -n $(echo "$i" | grep portage) ]]; then
+ if chk_snap_f "$i"; then
+ while true; do
+ echo "$i"
+ read -rp "Is this the snapshot? Y/N " YN
+ case "${YN:-5}" in
+ [yY][eE][sS]|[yY])
+ echo -e "\e[34mCopying snapshot to ${CATDIR}/snapshots\e[0m"
+ cp "$i" "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2"
+ return 0
+ ESCINNER=0
+ break
+ ;;
+ [nN][oO]|[nN])
+ ESCINNER=1
+ break;;
+ esac
+ done
+ [[ "$ESCINNER" == 0 ]] && unset ESCINNER && break
+ fi
+ fi
+done
+return 1
+unset YN
+unset ESCINNER
+unset ARRAYSNAP
+}
+
+stageX_f() {
+ [[ -z "$@" ]] && print_inf 4 && return 1
+ if [[ -e "$1" ]]; then
+ # STAGE 2
+ echo -e "\e[35mBuilding stage$2\e[0m"
+
+ cat "${CCONFDIR}/system/catalyst/stage$2.spec" | sed '/^#/ d' | sed '/^\s*$/d' \
+ > "${CATDIR}/.stage$2.spec"
+
+ catalyst -c "${CCONFDIR}/system/catalyst/catalyst.conf" -f "${CATDIR}/.stage$2.spec" \
+ && print_inf 1 || { print_inf 2 && exit 1; }
+ else
+ echo -e "\e[31mCould not locate stage$2-${ARCH}-${TARGETSTAMP}.tar.bz2\e[0m"
+ return 1
+ fi
+}
+
+check_then_call_stageX_f() {
+ [[ -z "$@" ]] && print_inf 4 && return 1
+ if [[ -n $(echo $@ | grep '\--force-new') ]]; then
+ stageX_f "$1" "$2"
+ else
+ if [[ -e "${CATDIR}/builds/${TARGETPATH}/stage$2-${ARCH}-${TARGETSTAMP}.tar.bz2" && -n $(echo "$@" | grep "s$2") ]]; then
+
+ echo -e "\e[32mStage$2 located\e[0m"
+
+ while read -p "Do you wish to build new? Y/N " ANS; do
+ case $ANS in
+ [yY])
+ stageX_f "$1" "$2"
+ break;;
+ [nN])
+ break;;
+ esac
+ done
+ else
+ stageX_f "$1" "$2"
+ fi
+ fi
+}
diff --git a/scripts/functions/local_rbuild b/scripts/functions/local_rbuild
new file mode 100755
index 0000000..7e44631
--- /dev/null
+++ b/scripts/functions/local_rbuild
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+mkdir -p "${CDISTDIR}/workdir"
+MKCORES=$(( $(grep -c ^processor /proc/cpuinfo) + 1 ))
+source "${CCONFDIR}/system/coptions"
+mkdir -p "${CDISTDIR}/workdir/usr/portage"
+mkdir -p "${CDISTDIR}/workdir/etc/portage"
+mkdir -p "${CDISTDIR}/workdir/etc/portage/repos.conf"
+
+rsync -aAXPrh --exclude="-*" --include={"bin","make.conf.catalyst","postsync.d","repo.postsync.d","savedconfig","package.mask"} \
+"/etc/portage/" "${CDISTDIR}/workdir/etc/portage/" >/dev/null 2>&1
+rsync -aAXPrh "/usr/portage/profiles/" "${CDISTDIR}/workdir/usr/portage/profiles" >/dev/null 2>&1
+
+cp "${CCONFDIR}/system/portage/makeconf.backup" "${CDISTDIR}/workdir/etc/portage/make.conf"
+cp "/usr/share/portage/config/repos.conf" "${CDISTDIR}/workdir/etc/portage/repos.conf/gentoo.conf"
+
+ln -s "${CDISTDIR}/workdir/usr/portage/profiles/default/linux/amd64/13.0" "${CDISTDIR}/workdir/etc/portage/make.profile"
+
+declare -a ARRAYCBASE
+
+ARRAYCBASE=("sys-apps/baselayout" "app-arch/bzip2" "app-arch/gzip" "app-arch/tar" "app-arch/xz-utils" "app-shells/bash:0" \
+"net-misc/iputils" "net-misc/rsync" "net-misc/wget" "sys-apps/coreutils" "sys-apps/diffutils" "sys-apps/file" ">=sys-apps/findutils-4.4" \
+"sys-apps/gawk" "sys-apps/grep" "sys-apps/kbd" "sys-apps/less" "sys-apps/openrc" "sys-process/procps" "sys-process/psmisc" "sys-apps/sed" \
+"sys-apps/which" "sys-devel/binutils" "sys-devel/gcc" "sys-devel/gnuconfig" "sys-devel/make" ">=sys-devel/patch-2.7" "sys-fs/e2fsprogs" \
+"sys-fs/e2fsprogs" "virtual/dev-manager" "virtual/editor" "virtual/libc" "virtual/man" "virtual/modutils" "virtual/os-headers" "virtual/package-manager" \
+"virtual/pager" "virtual/pager" "virtual/service-manager" "virtual/service-manager" "virtual/shadow" "virtual/ssh")
+echo -e "\e[34mBasic system\e[0m"
+
+for i in "${ARRAYCBASE[@]}"; do
+PORTAGE_CONFIGROOT="${CDISTDIR}/workdir" MAKEOPTS="-j${MKCORES}" FEATURES="${FEATURES} ${CHFEATURES}" \
+CFLAGS="-O2 -pipe" ROOT="${CDISTDIR}/workdir" emerge -q --deep --update "$i"
+done \
+&& echo -e "\e[35mUpdating @system set\e[0m" \
+&& MAKEOPTS="-j${MKCORES}" FEATURES="${FEATURES} ${CHFEATURES}" CFLAGS="-O2 -pipe" ROOT="${CDISTDIR}/workdir" emerge -q --deep --update @system \
+&& print_inf 1 || { print_inf 2 ** exit 1; }
+unset ARRAYCBASE \ No newline at end of file
diff --git a/scripts/functions/sinit_functions b/scripts/functions/sinit_functions
new file mode 100755
index 0000000..7734e42
--- /dev/null
+++ b/scripts/functions/sinit_functions
@@ -0,0 +1,586 @@
+#!/bin/bash
+
+# CALL SUBSHELL
+subshel_f() {
+ echo -e "\e[33mCalling bash subshell\e[0m"
+ sleep 2
+ echo 'echo -e "\e[33mInside Subshell\e[0m"' >> /root/.bashrc
+ echo 'echo -e "\e[33mExit to return back to parent\e[0m"' >> /root/.bashrc
+ (clear; exec /bin/bash;)
+ sed -i "/Inside Subshell/d" "/root/.bashrc"
+ sed -i "/Exit to return back to parent/d" "/root/.bashrc"
+ echo -e "\e[33mYou are back to parent\e[0m"
+}
+
+repeat_part_f() {
+while true; do
+ echo -e "\e[33mPart $1: Has been completed\e[0m"
+ read -rp "Run again? Y/N: " YN
+ case "${YN}" in
+ [yN])
+ return 0;;
+ [nN])
+ return 9;;
+ esac
+done
+}
+
+
+calling_catalyst_f(){
+ echo -e "\e[34mCalling catalyst\e[0m"
+ source "${CWORKDIR}/scripts/functions/init_stage3_seq" "$@" \
+ && sinit_mon_f "CATALYST" || { print_inf_f 2 && exit; }
+}
+
+catalyst_extr_tar_f() {
+ CATDIR=$(grep storedir "${CCONFDIR}/system/catalyst/catalyst.conf" \
+ | sed '/^#/ d' | awk -F '=' '{ print $2 }' | sed -e "s_\"__g") \
+ && SNAPSHOTNAME="$(grep 'snapshot:' "${CCONFDIR}/system/catalyst/stage1.spec" \
+ | sed '/^#/ d' | sed '/^\s*$/d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")" \
+ && TARGETPATH="$(grep 'source_subpath' "${CCONFDIR}/system/catalyst/stage3.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g" | awk -F '/' '{ print $1 }')" \
+ && TARGETSTAMP="$(grep 'version_stamp' "${CCONFDIR}/system/catalyst/stage3.spec" \
+ | sed '/^#/ d' | awk -F ' ' '{ print $2 }' | sed -e "s_\"__g")" \
+ && check_dir_f "${CATDIR}/builds/${TARGETPATH}/stage3-${ARCH}-${TARGETSTAMP}.tar.bz2" \
+ "${CDISTDIR}/workdir-catalyst" \
+ "${CATDIR}/snapshots/portage-${SNAPSHOTNAME}.tar.bz2" \
+ && sinit_mon_f "EXTRACTION"
+}
+
+repeat_sub_part_f() {
+while true; do
+ echo -e "\e[33m$1: Has been $2\e[0m"
+ read -rp "Run again? Y/N: " YN
+ case "${YN}" in
+ [yN])
+ return 0;;
+ [nN])
+ return 9;;
+ esac
+done
+}
+
+sinit_mon_f() {
+# PROCESS FLOW TWEAKER DURING ALL BUT CHROOT STAGE. DO NOT EDIT THIS FILE!
+case "$1" in
+ EXTRACTION)
+ sed -i -e 's/EXTRACTION=0/EXTRACTION=1/g' "${CLOCALLG}/sinprog"
+ sed -i -e 's/PARTA=0/PARTA=1/g' "${CLOCALLG}/sinprog";;
+ RESET)
+ sed -i -e 's/1/0/g' "${CLOCALLG}/sinprog";;
+ PARTA)
+ sed -i -e 's/PARTA=0/PARTA=1/g' "${CLOCALLG}/sinprog";;
+ PARTB)
+ sed -i -e 's/PARTB=0/PARTA=1/g' "${CLOCALLG}/sinprog";;
+ CATALYST)
+ sed -i -e 's/CATALYST=0/CATALYST=1/g' "${CLOCALLG}/sinprog";;
+ PRECOMP)
+ sed -i -e 's/PRECOMP=0/PRECOMP=1/g' "${CLOCALLG}/sinprog"
+ sed -i -e 's/PARTA=0/PARTA=1/g' "${CLOCALLG}/sinprog";;
+ RDEP)
+ sed -i -e 's/RDEP=0/RDEP=1/g' "${CLOCALLG}/sinprog";;
+ dn)
+ ;;
+esac
+}
+
+# RDEP CHECK
+dep_c_f() {
+ if [[ "${CREL}" == "Gentoo" ]]; then
+ echo -e "\e[33mHost system:\e[0m \e[35m${CREL}\e[0m"
+ echo -e "\e[33mBefore you begin, it is strongly recommended to make a\e[0m \e[35mruntime dependency\e[0m \e[33mcheck on the host machine\e[0m"
+ echo -e "\e[33mThis check is a simple\e[0m \e[35meix\e[0m \e[33m--installed foo check, which will be very fast and also verify\e[0m"
+ echo -e "\e[33mthat during the process, nothing unexpected will occur\e[0m"
+ echo -e "\e[33mIf\e[0m \e[35meix\e[0m \e[33mis not installed, do no worry, it will get installed\e[0m"
+ echo
+ while true; do
+ read -rp "Check dependencies? Y/N: " YN
+ case "${YN:-n}" in
+ [yY])
+ echo -e "\e[34mChecking for dependencies\e[0m"
+ lcreq_f 1 || exit 1
+ sinit_mon_f "RDEP"
+ break;;
+ [nN])
+ echo "If you have not run a dependency check before, please abort"
+ for i in {1..0}; do
+ sleep 1
+ printf "\r $i"
+ done
+ break;;
+ esac
+ done
+ unset YN
+ else
+ echo -e "\e[33mHost system:\e[0m \e[33m${CREL}\e[0m"
+ echo -e "\e[33mBefore you begin, it is strongly recommended to make a\e[0m \e[35mruntime dependency\e[0m \e[33mcheck on the host machine\e[0m"
+ echo -e "\e[33mIf the all runtime dependencies are located, the process will continue, otherwise this window will exit. and expect you to manually install them\e[0m"
+ echo -e "\e[33mSince only Gentoo is officially upported, it is expected to manually install any missing dependencies\e[0m"
+ while true; do
+ read -rp "Check dependencies? Y/N: " YN
+ case "${YN:-n}" in
+ [yY])
+ echo -e "\e[34mChecking for dependencies\e[0m"
+ lcreq_f 2 || exit 1
+ break;;
+ [nN])
+ echo "If you have not run a dependency check before, please abort"
+ for i in {1..0}; do
+ sleep 1
+ printf "\r $i"
+ done
+ break;;
+ esac
+ done
+ fi
+unset YN
+}
+
+check_pds_f(){
+ [[ -n "$(grep "dist.d/workdir-" "/proc/mounts" | awk -F ' ' '{ print $2 }')" ]] \
+ && while true; do
+ while read -r i; do
+ umount -l "$i"/* >/dev/null 2>&1 >/dev/null 2>&1
+ umount -l "$i" >/dev/null 2>&1 >/dev/null 2>&1
+ done < <(grep 'dist.d/workdir-' "/proc/mounts" | awk -F ' ' '{ print $2 }')
+
+ [[ -z $(grep "dist.d/workdir-" "/proc/mounts" | awk -F ' ' '{ print $2 }') ]] \
+ && break
+ done
+
+ if [[ -n "$@" && -z "$(cat /proc/mounts | grep "workdir-$2")" ]]; then
+ rm -rf "$1"
+ else
+ print_inf_f 3
+ exit 1
+ fi
+}
+
+fundamentals_f() {
+ # CHECK FOR RUNTIME DEPENDENCIES
+ if [[ "$(awk -F '=' '/RDEP/{ print $2 }' <"${CLOCALLG}/sinprog")" == 0 ]]; then
+ dep_c_f
+ fi
+
+ # CHECK IF THERE IS ANY WORK DONE
+ if [[ -n $(echo "$@" | grep '\--force-new') || -n $(echo "$@" | grep '\-fn') ]]; then
+ start_new_f "force_new" "$1"
+ else
+ if [[ "$(awk -F '=' '/PARTA/{ print $2 }' <"${CLOCALLG}/sinprog")" == 1 ]]; then
+ start_new_f "ask_new" "$1"
+ fi
+ fi
+
+ clear
+ echo "============================================================================"
+ echo -e "\e[35mPART:A Fundamentals\e[0m"
+ echo "============================================================================"
+}
+
+start_new_f() {
+ # PROMPT TO CONTINUE OR START ANEW
+ if [[ "$1" == "ask_new" ]]; then
+ while true; do
+ clear; echo -e "\e[33mDo you want to continue from last time?\e[0m"
+ echo -e "\e[33mIf you choose\e[0m \e[31mSTART NEW\e[0m\e[33m, workdir will be\e[0m \e[31mpurged\e[0m"
+ echo -e "\e[33mAnswer Yes or START NEW: \e[0m"
+ read -p "Input :: <= " YN
+ echo
+ case "${YN:-n}" in
+ [Yy][eE][sS]|[yY])
+ break;;
+ "START NEW")
+ echo -e "\e[31mPurging...\e[0m"
+ check_pds_f "$2" \
+ && sinit_mon_f "RESET" && sed -i -e 's/1/0/g' "${CWORKDIR}/scripts/chroot_scripts/chsinprog"; break;;
+ * ) echo "Wrong answer";;
+ esac
+ done
+elif [[ "$1" == "force_new" ]]; then
+ echo -e "\e[31mStart new parameter detected\e[0m"
+ echo -e "\e[34mIf you select yes, workdir will be purged\e[0m"
+ echo -e "\e[34mDo you wish to use this option\e[0m"
+ echo "Answer: Y/N "
+ while true; do
+ read -p "Give input :: <= " YN
+ case "${YN:-n}" in
+ [Yy][eE][sS]|[yY])
+ echo -e "\e[31mPurging...\e[0m"
+ check_pds_f "$2" \
+ && sinit_mon_f "RESET" && sed -i -e 's/1/0/g' "${CWORKDIR}/scripts/chroot_scripts/chsinprog"
+ break;;
+ [nN][oO]|[nN])
+ echo -e "\e[34mExiting...\e[0m"
+ exit 1;;
+ * ) echo "Wrong answer";;
+ esac
+ done
+fi
+unset YN
+}
+
+export_dist_f() {
+ export GENTOOKEY="$(lynx -dump ${SIGNING_KEY} | grep "(4096-bit RSA)" | head -1 | awk -F '(' '{ print $1}')"
+ export "GENTOOKEY"
+ export GENTOOLATEST="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }')"
+ export STAGE3TB=$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }' | awk -F '/' '{ print $2 }')
+ export GENTOOLATESTASC="$DIST/$(wget -q -O- "${DIST}/latest-stage3-$ARCH.txt" | tail -n 1 | awk -F ' ' '{ print $1 }').DIGESTS.asc"
+}
+
+extract_tarball_f() {
+ [[ -z "$@" && -d "$2" ]] && print_inf 4 && return 1
+ mkdir -p "$2"
+
+ echo -e "\e[34mExtracting tarball\e[0m"
+ tar xvjpf "$1" -C "$2" --xattrs --numeric-owner >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Extracted" \
+ || echo -e "[\e[31m*\e[0m] AN ERROR OCCURRED" \
+ && [[ -n "$3" ]] \
+ && { echo -e "\e[34mExtracting portage\e[0m" \
+ && tar xvjpf "$3" --xattrs --numeric-owner -C "$2/usr/" >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Extracted" \
+ || echo -e "[\e[31m*\e[0m] AN ERROR OCCURRED"; }
+}
+
+check_dir_f() {
+ [[ -z "$@" && -d "$2" ]] && print_inf 4 && return 1
+ if [[ -d "$2" ]]; then
+ while true; do
+ echo -e "Seems that there already has been done some work at the \e[34mbuilderdir\e[0m"
+ echo "You could either continue from where you left, or backup/purge then start anew"
+ echo -e "Give one of: \e[32mCONTINUE\e[0m/\e[34mOLD\e[0m/\e[31mPURGE\e[0m "
+ read -rp "Input :: <= " ANS
+ case $ANS in
+ OLD)
+ echo "Backing up..."
+ mv "$2" "$2.old"
+ extract_tarball_f "$@"
+ break;;
+ PURGE)
+ echo "This may take some time"
+ echo "Purging..."
+ check_pds_f "$2"
+ extract_tarball_f "$@"
+ break;;
+ CONTINUE)
+ break;;
+ esac
+ done
+ else
+ extract_tarball_f "$@"
+ fi
+}
+
+amiroot() {
+ if [[ "$1" != "0" ]]
+ then
+ echo -e "\e[31mThis operation requires root privileges\e[0m"
+ echo "Returning back..."
+ sleep 2
+ BACKTO="MM"
+ return 1
+ fi
+ return 0
+}
+
+gentoo_key_f() {
+ [[ -z "${GENTOOKEY}" ]] && print_inf_f 4 && return 1
+ gpg --keyserver hkps.pool.sks-keyservers.net --recv-keys >/dev/null 2>&1 ${GENTOOKEY} \
+ && echo -e "[\e[32m*\e[0m]\e[32m Fetching Key\e[0m" \
+ || { echo -e "[\e[31m*\e[0m]\e[31m Fetching Key\e[0m"; return 1; }
+}
+
+get_latest_f() {
+ [[ -z "${GENTOOLATEST}" || -z "${GENTOOLATESTASC}" ]] && print_inf_f 4 && return 1
+ mkdir -p "${CDISTDIR}/dists" \
+ && echo -e "[\e[32m*\e[0m] Getting \e[34m${STAGE3TB}\e[0m"
+ wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" "${GENTOOLATEST}" \
+ && echo "${STAGE3TB}" > "${CDISTDIR}/dists/latest.info" \
+ && print_inf_f 1 || { print_inf_f 2; return 1; }
+
+ wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" "${GENTOOLATESTASC}" >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Getting \e[34m${GENTOOLATEST}\e[0m" \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Getting \e[34m${GENTOOLATEST}\e[0m"; exit 1; }
+
+ wget -c -O "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS" "${GENTOOLATEST}.DIGESTS" >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Getting \e[34m${GENTOOLATEST}.DIGESTS\e[0m" \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Getting $\e[34m${GENTOOLATEST}.DIGESTS\e[0m"; exit 1; }
+}
+
+verify_download_f() {
+ gpg --verify "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Verifying \e[35mcryptographic signature\e[0m" \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Verifying \e[31mcryptographic signature\e[0m"; exit 1; }
+
+ [[ $(grep -A 1 -i sha512 "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" | head -n 2 | grep stage3 | awk -F ' ' '{ print $1 }') \
+ == $(sha512sum "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" | awk -F ' ' '{ print $1 }') ]] \
+ && echo -e "[\e[32m*\e[0m] Verifying \e[35msha512sums\e[0m" \
+ || { echo -e "[\e[31m*\e[0m] \e[31mFAILD\e[0m: Verifying \e[31msha512sums\e[0m"; exit 1; }
+}
+
+fetch_new_f() {
+ # CHECK FOR THE POSITIONAL PARAMETERS AND BAILOUT IF THEY ARE MISSING
+ [[ -z "$@" ]] && print_inf_f 4 && exit 1
+ echo -e "\e[34mSearching for tarball...\e[0m"
+ if [[ -n $(echo "$@" | grep '\--fetch-new') || -n $(echo "$@" | grep '\-fn') ]]; then
+ rm -f "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2" >/dev/null 2>&1
+ rm -f "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS.asc" >/dev/null 2>&1
+ rm -f "${CDISTDIR}/dists/stage3-${ARCH}-latest.tar.bz2.DIGESTS" >/dev/null 2>&1
+ export_dist_f
+ # FETCH THE KEYS FOR THE CRYPTOGRAPHIC AUTHENTICATION
+ gentoo_key_f
+ # GET LATEST STAGE3 TARBALL, .DIGEST && .DIGEST.asc
+ get_latest_f
+ # VERIFY THE AUTHENTICATION OF THE DOWNLOADED FILES
+ verify_download_f
+ else
+ export_dist_f
+ # GET LATEST STAGE3 TARBALL, .DIGEST && .DIGEST.asc
+ local_stage3="$(cat "${CDISTDIR}/dists/latest.info")"
+ if [[ "${local_stage3}" == "${STAGE3TB}" ]]; then
+ echo -e "[\e[32m*\e[0m] Latest stage3 is already present locally"
+ else
+ # FETCH THE KEYS FOR THE CRYPTOGRAPHIC AUTHENTICATION
+ gentoo_key_f
+ # GET LATEST STAGE3 TARBALL, .DIGEST && .DIGEST.asc
+ get_latest_f
+ # VERIFY THE AUTHENTICATION OF THE DOWNLOADED FILES
+ verify_download_f
+ fi
+fi
+}
+
+print_inf_f() {
+case $1 in
+ 1)
+ echo -e "[\e[32m*\e[0m] \e[34mDone\e[0m";;
+ 2)
+ echo -e "[\e[31m*\e[0m] \e[31mFAILED\e[0m";;
+ 3)
+ clear
+ echo -e "[\e[31mFATAL\e[0m]"
+ echo -e "\e[31mIf this message is printed while using the Maim Menu\e[0m"
+ echo -e "\e[31mThat means essential files are altered or something bad is happening.\e[0m"
+ echo
+ echo -e "\e[31mPlease run a health-check from the ~Main Menu~ and a Version check first.\e[0m"
+ echo -e "\e[31mIf you see this again after the health/version check, please submit a bug report\e[0m"
+ echo -e "\e[31mand stop using the program, or data loss may occur.\e[0m"
+ echo
+ echo -e "\e[31mExiting...\e[0m"
+ sleep 5
+ exit 1;;
+ 4)
+ echo -e "[\e[31m*\e[0m] [\e[31mERROR\e[0m: Wrong parameters"
+ exit 1;;
+ 5)
+ echo -e "[\e[31m*\e[0m] Failed getting version";;
+ 6)
+ echo -e "[\e[31m*\e[0m] FATAL";;
+esac
+}
+
+umnt_l_f() {
+ [[ -n "$(grep "dist.d/workdir-"$2 "/proc/mounts" | awk -F ' ' '{ print $2 }')" ]] \
+ && while true; do
+ while read -r i; do
+ umount -l "$i"/* >/dev/null 2>&1 >/dev/null 2>&1
+ umount -l "$i" >/dev/null 2>&1 >/dev/null 2>&1
+ done < <(grep 'dist.d/workdir-' "/proc/mounts" | awk -F ' ' '{ print $2 }')
+
+ [[ -z $(grep "dist.d/workdir-"$2 "/proc/mounts" | awk -F ' ' '{ print $2 }') ]] \
+ && break
+ done
+}
+
+mount_dev_sys_f() {
+ [[ -z "$@" ]] && print_inf_f 3 && exit 1
+ mount --rbind /dev "$1/$2" \
+ && mount --make-rslave "$1/$2" \
+ && echo -e "[\e[32m*\e[0m] Mounting $2" \
+ || { echo -e "[\e[31*\e[0m] Mounting $2"; return 1; }
+}
+
+mount_proc_f() {
+ [[ -z "$@" ]] && print_inf_f 3 && exit 1
+ mount -t proc /proc "$1/proc" \
+ && echo -e "[\e[32m*\e[0m] Mounting proc" \
+ || { echo -e "[\e[31m*\e[0m] Mounting proc"; return 1; }
+}
+
+pr_chroot_f() {
+ [[ -z "$@" ]] && print_inf_f 3 && exit 1
+
+ cp -L /etc/resolv.conf "$1/etc/" || exit 1
+
+ if [[ -n $(echo "$@" | grep 'catalyst') ]]; then
+ # CHECK IF PSEUDOS ARE MOUNTED
+ if [[ -n $(cat /proc/mounts | grep 'dist.d/workdir-catalyst' | awk -F ' ' '{ print $1 }') ]]; then
+ echo -e "\e[31mPseudos possibly mounted at target directory\e[0m"
+ echo -e "\e[33mResolving the issue...\e[0m"
+ umnt_l_f "catalyst"
+ fi
+ echo -e "\e[34mMounting pseudo\e[0m"
+ [[ -z $(grep 'dist.d/workdir-catalyst' /proc/mounts | awk -F ' ' '{ print $1 }') ]] \
+ && mount_proc_f "$1"
+ elif [[ -n $(echo "$@" | grep 'precomp') ]]; then
+ if [[ -n $(cat /proc/mounts | grep 'dist.d/workdir-precomp' | awk -F ' ' '{ print $1 }') ]]; then
+ echo -e "\e[31mPseudos possibly mounted at target directory\e[0m"
+ echo -e "\e[33mResolving the issue...\e[0m"
+ umnt_l_f "precomp"
+ fi
+ echo -e "\e[34mMounting pseudo\e[0m"
+ [[ -z $(grep 'dist.d/workdir-precomp' /proc/mounts | awk -F ' ' '{ print $1 }') ]] \
+ && mount_proc_f "$1"
+ fi \
+ && mount_dev_sys_f "$1" "dev" \
+ && mount_dev_sys_f "$1" "sys" \
+ || { echo -e "[\e[31m*\e[0m] Something went wrong" && exit 1; }
+
+ mkdir -p "$1/sinit.d"
+
+ [[ ! -e "$1/sinit.d/chsinprog" ]] && rsync -aAXr "${CWORKDIR}/scripts/chroot_scripts/" "$1/sinit.d/" >/dev/null 2>&1 \
+ || rsync -aAXr --exclude="chsinprog" "${CWORKDIR}/scripts/chroot_scripts/" "$1/sinit.d/" >/dev/null 2>&1 \
+ && rsync -aAXr "${CCONFDIR}/system/portage/" "$1/sinit.d/" >/dev/null 2>&1 \
+ && rsync -aAXr --exclude="portage" "${CCONFDIR}/system/" "$1/sinit.d/" >/dev/null 2>&1 \
+ && echo -e "[\e[32m*\e[0m] Copying \e[34mbuilder's\e[0m files to new system" \
+ || { echo -e "[\e[31m*\e[0m] Copying \e[34mbuilder's\e[0m files to new system"; return 1; }
+
+ # CREATE REPOS.CONF DIRECOTRY & AND COPY REPOS.CONF TO IT
+ mkdir -p "$1/etc/portage/repos.conf"
+ cp "$1/usr/share/portage/config/repos.conf" "$1/etc/portage/repos.conf/gentoo.conf"
+
+ # Set local timezone if set
+ if [[ -n $(cat /etc/timezone) ]]; then
+ TIMEZONE=$(cat /etc/timezone)
+ sed -i -e "s_TMZ_${TIMEZONE}_g" "$1/sinit.d/chinit.conf"
+ unset TIMEZONE
+ fi
+
+ echo -e "[\e[32m*\e[0m] Copying requested files"
+ if [[ -n $(cat ${CCONFDIR}/system/inject_files | sed '/^#/ d' | sed '/^\s*$/d') ]]; then
+
+ while read -r INJFL;do
+ f1="$(echo $INJFL | awk -F ' ' '{ print $1 }')"
+ f2="${BWORKDIR}/(echo $INJFL | awk -F ' ' '{ print $2 }')"
+ echo "Copying $f1 to $f2"
+ rsync -aAXPhrv "$f1" "$f2" >/dev/null 2>&1 \
+ && print_inf 1 || { print_inf 2 mapfile -t INJFLERR < <($INJFL | awk -F ' ' '{ print $1 }'); }
+ done < <(cat "${CCONFDIR}/system/inject_files" | sed '/^#/ d' | sed '/^\s*$/d')
+ unset INJFL
+
+ if [[ -n "${INJFLERR}" ]]; then
+ echo "Failed to copy the following packages: "
+ echo "${INJFLERR[@]}"
+ while true; do
+ echo "You can list the failed files again, continue, request terminal or exit"
+ read -rp "Please choose: LIST/CONTINUE/TERMINAL/EXIT" INJFLANS
+ case "$INJFLANS" in
+ LIST)
+ clear; echo "${INJFLERR[@]}";;
+ CONTINUE)
+ while true; do
+ read -p "Are you sure? Y/N " YN
+ case $YN in
+ [yY])
+ echo "Proceeding"
+ INJFLESC=0
+ break;;
+ [nN])
+ INJFLESC=1
+ ;;
+ esac
+ done;;
+ TERMINAL)
+ subshel_f
+ INJFLESC=0;;
+ EXIT)
+ while true; do
+ read -p "Are you sure? Y/N " YN
+ case $YN in
+ [yY])
+ echo "Aborting..."
+ exit 0;;
+ [nN])
+ INJFLESC=1
+ break;;
+ esac
+ done;;
+ esac
+ [[ "$INJFLESC" == 0 ]] && break
+ done
+ fi
+ unset YN
+ unset INJFLESC
+ unset INJFLANS
+ unset INJFLERR
+ else
+ echo -e "[\e[32m*\e[0m] List empty"
+ fi
+
+ echo -e "\e[34mChrooting at new system\e[0m"
+ sleep 2
+ chroot "$1" "sinit.d/chroot_init" "$@" || { echo -e "[\e[31m*\e[0m] Chrooting at new system"; return 1; } \
+ && sinit_mon_f "PARTB"
+}
+
+lcreq_f() {
+ # THIS SCRIPT IS SOURCED AT THE BEGINING FOR CHECKING THE BUILDER'S RUNTIME DEPENDENCIES
+ CRDPENDS=''
+ amiroot_sub_f() {
+ if [[ "$1" == "0" ]]; then
+ return 0
+ else
+ return 1
+ fi
+}
+
+case "$1" in
+ 1)
+ [[ $(command -v eix) ]] \
+ || { echo -e "[\e[33m*\e[0m] \e[35mPlease install eix to proceed!\e[0m" \
+ && { amiroot $UID && echo -e "[\e[32m*\e[0m] Root privileges found" \
+ && emerge -aq eix && echo -e "[\e[33m*\e[0m] \e[35mUpdating database\e[0m" \
+ && eix-sync -a >/dev/null 2>&1; } \
+ || { echo -e "[\e[31m*\e[0m] Could not get root privileges" \
+ && echo "Please resolve this issue and start again" && exit 1; }; }
+
+ mapfile -t lreq < <(cat "${CLOCALLG}/loc_req" | sed '/^#/ d' | sed '/^\s*$/d')
+
+ for i in "${lreq[@]}"; do
+ sleep 0.1
+ if eix --installed "$i" >/dev/null 2>&1; then
+ echo -e "[\e[32m*\e[0m] Searching for \e[32m$i\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] Searching for $i"
+ echo -e "[\e[33m*\e[0m] Attempting to resolve the missing dependency"
+ amiroot $UID && echo -e "[\e[32m*\e[0m] Root privileges found" \
+ && emerge -aq "$i" \
+ || { echo -e "[\e[31m*\e[0m] Could not get root privileges" \
+ && echo "Please resolve this issue and start again" && exit 1; }
+ fi
+ done;;
+ 2)
+ mapfile -t lreq < <(cat "${CLOCALLG}/nogloc_req" | sed '/^#/ d' | sed '/^\s*$/d')
+
+ for i in "${lreq[@]}"; do
+ sleep 0.1
+ if command -v "$i" >/dev/null 2>&1; then
+ echo -e "[\e[32m*\e[0m] Searching for \e[32m$i\e[0m"
+ else
+ echo -e "[\e[31m*\e[0m] Searching for $i"
+ CRDPENDS=1
+ fi
+ done
+ [[ "${CRDPENDS}" == 1 ]] && while true; do
+ echo -e "\e[33mIf you think some of those dependencies are name missmatch or not important\e[0m"
+ echo -e "\e[33mYou can choose to continue at your own ristk\e[0m"
+ read -rp "Continue? Y/N: " ANS
+ case "${ANS}" in
+ [yY])
+ break;;
+ [nN])
+ echo "Exiting..." && sleep 1 && exit 1;;
+ esac
+ done
+esac
+} \ No newline at end of file