#!/bin/bash
# set -x
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# title			:Repostorm														▒
# description	:Auto build, repository management script						▒
# author		:Glenn Cady <theemahn@repostorm.com>							▒
# date			:07/24/2014														▒
# version		:1.8.6															▒
# usage			:repostorm --help												▒
# manual		:man repostorm													▒
# notes			:See change-log below for further information.					▒
# bash_version	:4.2.8(1)-release												▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# Change-log: 1.8.6:	Currently unreleased / unleashed						▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ${APPNAME} - Auto build, repository management script
# Script via Glenn "TheeMahn" Cady <theemahn@${APPNAME}.com>
#
# This script will extract, build all debs in each sub-folder
# as well as lintian each resulting deb recording any
# error result to a separate log and move resulting deb
# to then .debs/ if no errors.Eventually will not move
# any with warnings (does so now). The script will eventually fix all errors
# without human intervention. Who makes errors? Not computers.
# The script now implements -f or fix switch still not 100% and
# why you do not have it beyond copy-write.
#
# Beyond that, if that was not enough, will publish your repository on-line.
# It will GPG key sign your debs generate you a release file and dists,
# auto assign each prospective deb accordingly via architecture,
# rsyncing it to your server of choice or for a local repository.
#
# The goal is 100% error / warning free debs we are at about 90% off the rip.
# Most are in permission rights. Amazing what automation in programming can do
# for you.
#
# Repostorm if ran as a service will automatically fix error(s) prior to
# entering your system. Ultimately, a bulletproof O/S. Ultimate Edition will be
# the first operating system on the planet to utilize this technology.
#
# End user fret not. I will be paid, but not by you. Once you see the code
# I have written you will understand I deserve it ;)Largest script I have ever
# seen by one guy.What started as a simple script to lose a few of my jobs as
# a distrowriter, repository maintainer & programmer has became quite
# complicated.
#
# We begin - first we grab all sub-folders.If you do not wish to
# have a certain deb compiled or built please rename the folder beginning
# with a period, which makes it hidden to this software.

# Version Control
REPOVERSION="2.1.6"
PROGNAME="RepoStorm"
APPNAME="repostorm"
PROGRAMMER="TheeMahn"
BUILDDATE="02/02/2026"
VERSION="2.1.6"
WEBSITE="${APPNAME}.com"
EMAIL="<$PROGRAMMER@$WEBSITE>"
COMMANDEXEC="$*"

if [[ -f "/etc/os-release" ]]; then
	OS_NAME=$(grep -i "PRETTY_NAME" /etc/os-release | cut -d "=" -f2 | tr -d '"')
	OSTYPE=$(echo "${OS_NAME}" | grep -i "Ultimate")
else
	Error "This O/S  is unsupported. Exiting."
	exit 1;
fi
ULTIMATE_VERSION="Ultimate Edition"
ISULTIMATE=$(echo "${OS_NAME}" | grep -i "${ULTIMATE_VERSION}")
OS_VERSION=$(grep -i "VERSION_ID" /etc/os-release | cut -d "=" -f2 | tr -d '"')

# Create an array for DEB(s)
declare -a ISDEBS=();

# Pull in common software
if [[ -f "ultimate-common" ]]; then
	source ultimate-common
elif [[ -f "/usr/share/ultimate_edition/ultimate-common" ]]; then
	source /usr/share/ultimate_edition/ultimate-common
else
	echo "No Ultimate Edition common source. Please install ultimate-edition-common."
	exit 0;
fi

Exit () {
	if ! [[ "${SUPPRESS}" ]]; then
		Timer "Stop" "${APPNAME}"
		FullBar
	fi
}

trap Exit EXIT
# OVERRIDE Warnings.  I suggest you do not use this switch unless you know what you are doing.
# Example: Warning: W: theemahn-settings-3950X: file-in-unusual-dir var/cache/ultimate-media/art_cache/media/24TB/Shared Videos/TV/Threes.Company/Season 07/folder.jpg Logged to all_warnings.txt.
# Error(s): 10 | Warning(s): 163186 | Info: 0

OverrideWarnings () {
	# Let's see if they want a perticular type. ie file-in-unusual-dir
	REQESTEDWARNING=$(echo "$@" | grep -i "overridewarnings=" | cut -d "=" -f1)
	if ! [[ "${REQESTEDWARNING}" ]]; then
		# now they are asking to supress all?
		REQESTEDWARNING=$(echo "$@" | grep -i "overridewarnings")
	fi
	# if not this function won't do squat.  We got here for a reason.  Don't chew CPU cycles unless they ask.
	if  [[ "${REQESTEDWARNING}" ]]; then
		# snap open a few arrays.
		declare -a REQUESTEDAPP=();
		declare -a WARNINGS=();
		declare -a WARNINGTYPE=();
		# Load up all the warnings into an array, we will process them individually.  We will use memory, it is much faster.
		if [[ -f "all_warnings.txt" ]]; then  # do not assume they scanned for error(s) or built.
			WARNINGS=$(grep -i "Warning:" "all_warnings.txt")
			for EACH in "${WARNINGS[@]}"
			do
				REQUESTEDAPP=$(echo "${EACH}")
				THEISSUE=$(echo "${EACH}" | grep "${REQESTEDWARNING}")
				if [[ "${THEISSUE}" || "${REQESTEDWARNING}" ]]; then
					echo "The ISSUE: ${THEISSUE} Requested Warning: ${REQESTEDWARNING} APP: ${REQUESTEDAPP}"
				fi
			done
		else
			echo "No warnings present"
		fi
	else
		echo "No warnings present"
	fi
}

DetectLicences () {  # Non standard license.  I will not fix your shit and will shove it to its own folder.  Copywitten shit does not get fixed.
	if ! [[ -d ".licensed" ]]; then
		mkdir -p ".licensed"
	fi
}

#Fix broken symlinks
Symlink () {
	# symlink-contains-spurious-segments
	RTD="${PWD}"
	TARGET="${FILE// /_}"
	#target=$(echo "${FILE}" | sed -e "s/ /_/")
	DEB="${TARGET%/}.deb"
	FOLDER="${FILE%%.deb}"
	#	echo "1: ${1} 2: ${2}"
	STARTM=$(date -u "+%s")
	PROPER=$(readlink "${1}")
	SLT=$(ls -al "${1}" | cut -d'/' -f2)
	Encapsulate "Please wait this may take a long time depending on the amount of error(s) involved."
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		#		SLT=`ls -al ${1} | cut -d' ' -f12`
		BINARY=$(echo "${ERRORS}" | grep "symlink-contains-spurious-segments" | cut -d: -f3 | sed "s/ symlink-contains-spurious-segments //g")
		if [[ "${BINARY}" != "" ]]; then
			SLT=$(echo "${ERRORS}" | grep "symlink-contains-spurious-segments" | cut -d: -f3 | cut -d" " -f4 | sed "s/\.\///g")
			CONTAININGFOLDER=$(dirname "${BINARY}")
			FILENAME=$(basename "${BINARY}")
			PROPER=$(readlink -m "${BINARY}")
			#echo "BASEFILENAME=" basename CONTAININGFOLDER"
			if [[ -d "${FILE}/${CONTAININGFOLDER}" ]]; then
				cd "${FILE}/${CONTAININGFOLDER}" || exit 1;
			fi
			Encapsulate "Removing ${FILENAME} in ${PWD}"
			rm "${FILENAME}"
			Encapsulate "Relinking: ${SLT} to ${FILENAME}"
			ln -s "${SLT}" "${FILENAME}"
			cd "${RTD}" || exit 1;
		fi
	done
	#Report if acclible
	ERROR=0
	ERROR=$(cat "${DEB}.errors" | grep 'symlink-contains-spurious-segments' | wc -l)
	if [ "${ERROR}" -gt 0 ]; then
		Encapsulate "${ERROR} symlink-contains-spurious-segments error(s) fixed."
		sed -i "/symlink-contains-spurious-segments/d" "${DEB}.errors"
	fi
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		BINARY=$(echo "${ERRORS}" | grep "symlink-ends-with-slash" | cut -d: -f3 | cut -d" " -f3)
		if [[ "${BINARY}" != "" ]]; then
			SLT=$(echo "${ERRORS}" | grep "symlink-ends-with-slash" | cut -d: -f3 | cut -d" " -f4 | sed "s/\///g")
			CONTAININGFOLDER=$(dirname "${BINARY}")
			FILENAME=$(basename "${BINARY}")
			PROPER=$(readlink -m "${BINARY}")
			TRASHFOLDER=$(basename "${CONTAININGFOLDER}")
			#			echo "TRASHING: ${TRASHFOLDER}"
			ATARGET=$(echo "${1}/${CONTAININGFOLDER}" | sed "s/${TRASHFOLDER}//g")
			#			echo "ATARGET:" $ATARGET
			#			if [ ! -d ${1}/${CONTAININGFOLDER} ]; then
			#				echo "ATARGET:" $ATARGET
			#				echo "ln -s /usr/local/nginx/conf/ /etc/nginx > /dev/null 2>&1"
			#			fi
			cd "${ATARGET}" || exit 1;
			rm -R "${TRASHFOLDER}" > /dev/null 2>&1
			ln -s "${SLT}" "${TRASHFOLDER}" > /dev/null 2>&1
			cd "${CURRENT}" || exit 1;
		fi
	done

	#Report runtime and data.
	ERROR=$(grep 'symlink-ends-with-slash' "${DEB}.errors" | wc -l)
	if [ "${ERROR}" -gt 0 ]; then
		Encapsulate "${ERROR} symlink-ends-with-slash error(s) fixed."
		sed -i "/symlink-ends-with-slash/d" "${DEB}.errors"
	fi
}

SoftLink () {
	# Package maintainers like to hardlink files. This shows up in most Icon theme packages.
	# This function reverses the damage incurred.
	RTD="${PWD}"
	if [[ "${1}" ]]; then
		FOLDER="${1}"
	else
		FOLDER="${FILE%%.deb}"
	fi
	#echo "1: ${1} 2: ${2}"
	Encapsulate "Please wait this may take a long time depending on the amount of error(s) involved."
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		if [[ -d "${FOLDER}" ]]; then
			cd "${FOLDER}" || exit 1;
		fi
		BINARY=''
		BINARY=$(echo "${ERRORS}" | grep "package-contains-hardlink" | cut -d: -f3 | cut -d" " -f3)
		SYMLINK=$(echo "${ERRORS}" | grep "package-contains-hardlink" | cut -d: -f3 | cut -d" " -f5)
		if [[ "${BINARY}" ]]; then
			if [[ -f "${SYMLINK}" ]]; then
				#echo "WE ARE IN ${PWD}"
				rm "${SYMLINK}" 2>/dev/null
				#sync
				ln -s "${BINARY}" "${SYMLINK}"
			else
				Error "ERROR: Binary ${PWD}/${BINARY} not found."
			fi
		fi
	done
}

#Set proper naming conventions
VersionControl () {
	FOLDER="${FILE%%.deb}"
	PACKAGENAME=$(grep "Package: " "${FOLDER}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	PVERSION=$(grep "Version: " "${FOLDER}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	ARCH=$(grep -i "architecture: " "${FOLDER}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	FOLDER2="${PACKAGENAME}_${PVERSION}_${ARCH}"
	#if [[ -d "${FOLDER2}" ]]; then
	#	Encapsulate "${FOLDER2} is properly named."
	#else
	#	Encapsulate "Proper name for ${FOLDER} should be ${FOLDER2}"
	#	#Should we rename it?
	#	#mv "${FOLDER}" "${FOLDER2}"
	#fi
	# Let's scan for errors in extraction.We logged them right?
	# we do not want to delete a invalid deb, let the end user make the
	# decision & let's please inform them.
	X=$(cat "ar.log" | cut -d: -f2 | sed "s/ is not a valid archive//g")
	if [[ "${X}" == "" ]]; then
		rm "debian-binary" 2>/dev/null
		if [[ -w "${FILE}" ]]; then
			Encapsulate "Extraction of ${FILE} complete."
			Encapsulate "Removing ${FILE}."
			rm "${FILE}" 2>/dev/null
		else
			Error "Insufficient premissions to delete ${FILE}"
		fi
	else
		Error "Error: Extraction of ${FILE} failed. Please pursue, valid Debian archive?."
		Encapsulate "We are keeping the archive for your viewing pleasure."
		sudo mv "debian-binary" "${FILE}.ERRORED" 2>/dev/null
		sudo rm "ar.log"
	fi
}

# Build shlibs
BuildShlibs () {
	echo "Scanning for libs and building shlibs control file."
	#Library=objdump -p find -name ${FILE}/usr/lib/*so* | sed -n -e's/^[[:space:]]*SONAME[[:space:]]*//p' | sed -e's/\([0-9]\)\.so\./\1-/; s/\.so\.//'
}

# Strip Binaries
StripBin () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		BINARY=$(echo "${ERRORS}" | grep "unstripped-binary-or-object" | cut -d: -f3 | cut -d" " -f3)
		if [[ "${BINARY}" != "" ]]; then
			Encapsulate "Fixing Error: unstripped-binary-or-object. Striping ${FILE}/${BINARY}."
			strip "${FILE}/${BINARY}" 2>/dev/null
		fi
	done
}

WriteLogs (){
	CheckRoot "$@"
	CONTAINS=$(echo "$@" | grep -i "suppress")
	if ! [[ "${CONTAINS}" ]]; then
		DUMMY=""
	fi
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			DEB="${EACH}"
		fi
	done

	if ! [[ "${DEB}" ]]; then
		#ENTER MULTI-MODE
		#echo "COMMAND: $COMMANDEXEC"
		Encapsulate "Writing permanent logs."
		TSTAMP=$(date -R)
		echo "$TSTAMP" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		echo "=========================== BEGIN SESSION ============================" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		echo "Command executed: ${PROGNAME} $COMMANDEXEC" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		echo "In folder: ${PWD}" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null

		if [[ -s "all_errors.txt" ]]; then
			echo "==== BEGIN SESSION ERRORS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			cat "all_errors.txt" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "==== END SESSION ERRORS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		fi

		if [[ -s "all_warnings.txt" ]]; then
			echo "==== BEGIN SESSION WARNINGS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			cat "all_warnings.txt" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "==== END SESSION WARNINGS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		fi

		if [[ -s "all_information.txt" ]]; then
			echo "==== BEGIN SESSION INFO ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			cat "all_information.txt" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "==== END SESSION INFO ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
		fi

		echo "============================ END SESSION =============================" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
	else
		#SINGLE MODE

		TSTAMP=$(date -R)
		GOOD="${DEB}"
		DEB+=".errors"
		if [[ -s "${DEB}" ]]; then
			Encapsulate "Writing permanent logs for ${DEB}."
			echo "$TSTAMP" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "Command executed: ${PROGNAME} ${COMMANDEXEC}" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "==== BEGIN SESSION WARNINGS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			cat "${DEB}" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			echo "==== END SESSION WARNINGS ====" | sudo tee -a "/var/log/${APPNAME}_errors.log" >/dev/null
			#Report "${DEB}"
		else
			rm "${DEB}" 2>/dev/null
			Encapsulate "No error(s) detected in ${GOOD}."
		fi
	fi
}

# Relax Subroutine
Relax () {
	CheckRoot "$@"
	Center "${PROGNAME} ${REPOVERSION} is entering relaxation routine."
	shopt -s dotglob
	shopt -s nullglob
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			FOLDERS="${EACH}"
		fi
	done
	if ! [[ "${FOLDERS}" ]]; then
		FOLDERS=(*/)
		DELETEELEMENT=(".debs/")
		FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
		DELETEELEMENT=(".arch/")
		FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	fi
	if [[ "${#FOLDERS[@]}" -lt 1 ]]; then
		Error "Error: Nothing to process.  ${APPNAME} --help for help or man ${APPNAME} for further information."
		exit 1;
	fi
		FullBar
		PromptYN "${WARNING}WARNING: Recursively set permissions to 777 and chown the above folders to ${USER} (Y/N)? "
		case "${YN}" in
			[Nn]* ) Encapsulate "Exiting..."
			exit 0;;
			[Yy]* ) Encapsulate "Relaxing permissions...";
			for EACH in "${FOLDERS[@]}"
			do
				Encapsulate "Relaxing: ${EACH}"
				sudo chown -R "${USER}:${USER}" "${EACH}"
				sudo chmod -R 777 "${EACH}"
			done
			Encapsulate "${PROGNAME} relaxation process complete."
			FullBar
			exit 0;;
			* ) Encapsulate "Please answer y or n.";;
		esac
}

# Relax Subroutine internal for processing errors w/o prompting.
Relax2 () {
	INDEX=0
	TRUEUSER="${USER}"
	root_inode=$(stat -c %i /);
	if [ "$root_inode" -ne 2 ]; then
		Encapsulate "Chroot environment detected. Chowning for root"
		TRUEUSER="root"
	fi
	if [[ -f "${3}" ]]; then
		FILE="${3}"
		Encapsulate "Relaxing: ${FILE}"
		sudo chown -R "${TRUEUSER}:${TRUEUSER}" "${FILE}"
		sudo chmod -R 777 "${FILE}"
	else
		shopt -s dotglob
		shopt -s nullglob
		FOLDERS=(*/)
		INDEX=0
		DELETEELEMENT=(".debs/")
		FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
		DELETEELEMENT=("partial/")
		FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
		DELETEELEMENT=(".arch/")
		FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
		NUMFOLDERS="${#FOLDERS[@]}"
		CLEN="${NUMFOLDERS} of ${NUMFOLDERS}"
		LONGESTFOLDERNAME=$(find . -maxdepth 1 -type d | awk 'function base(f){sub(".*/", "", f); return f;} {print length(base($0))}'| sort -nr | head -1)
		(( LONGESTFOLDERNAME = LONGESTFOLDERNAME + 2 )) # add 2 characters for the Encapsulation.
		FormatNUM "${NUMFOLDERS}"
		TOTALFOLDERS="${OUTPUTNUM}"
		Center "Relaxing: ${TOTALFOLDERS}: folder(s) please wait."
		if [[ "${NUMFOLDERS}" -gt 0 ]]; then

			for EACH in "${FOLDERS[@]}"
			do
				INDEX=$((INDEX + 1))
				FormatNUM "${INDEX}"
				NUMBERFOLDERS="${OUTPUTNUM}"
				PCOMP=$((100*INDEX / NUMFOLDERS))
				#ProgressBar "${PCOMP}" "Relaxing folder ${EACH}: ${INDEX} of ${NUMFOLDERS}"
				BigBarFolders "${LONGESTFOLDERNAME}" "${EACH}:" "${#CLEN}" "${NUMBERFOLDERS} of ${TOTALFOLDERS}" "${PCOMP}"
				if ! [[ -w "${EACH}" ]]; then
					# BigBarFolders "${LONGESTFOLDERNAME}" "${EACH}:" "${#CLEN}" "${NUMBERFOLDERS} of ${TOTALFOLDERS}" "${PCOMP}"
					if [[ -d "${EACH}" ]]; then
						sudo chown -R "${TRUEUSER}:${TRUEUSER}" "${EACH}"
						sudo chmod -R 777 "${EACH}"
					fi
				fi
			done
		fi
	fi
	Center "Relaxation process complete."
	FullBar
}

UnArch () {
	CURRENT="${PWD}"
	declare -i TCOUNT;
	declare -a COMPRESSIONTYPES=();
	COMPRESSIONTYPES=( "XZ" "Zstandard" )
	TCOUNT=0
	if [[ "${#ARCHPACKAGES[@]}" -gt 0 ]]; then
		for FILE in "${ARCHPACKAGES[@]}"
		do
			TARGET=$(echo "${FILE}" | sed -e "s/ /_/")
			ARCHFILE="${TARGET%/}.pkg.tar.zst"
			EXTENSION="Zstd"
			if [[ -f "${FILE}" ]]; then
				INSTALLED=$(type -p file)
				if [[ "${INSTALLED}" ]]; then
					for EACH in "${COMPRESSIONTYPES[@]}"
					do
						GREPIT=$(file "${FILE}" | grep "${EACH}")
						if [[ "${GREPIT}" ]]; then
							if ! [[ "${SUPPRESS}" ]]; then
								Center "FILE: ${GREPIT}"
							fi
							EXTENSION="${EACH}"
						fi
						case "${EXTENSION}" in
							XZ ) EXTENSION="xz"; FOLDER="${FILE%%.pkg.tar.xz}";;
							Zstandard* ) FOLDER="${FILE%%.pkg.tar.zst}"; if ! [[ "${SUPPRESS}" ]]; then Center "Beginning extraction..."; fi;;
						esac
					done
				else
					Error "Unknown format."
					exit 1;
				fi
				#FOLDER="${FILE%%.pkg.tar.zst}"
			else
				FOLDER="${FILE%%.pkg.tar.xz}"
				Extension="tarball (Tape Archive) - xz"
			fi
			FS=$(type -p stat)
			if [[ "${FS}" ]]; then
				if [[ -f "${FILE}" ]]; then
					FILESIZE=$(stat --printf="%s" "${FILE}")
				fi
			fi
			#Toss a little eye candy
			TCOUNT=$(( TCOUNT +1 ))
			if ! [[ "${SUPPRESS}" ]]; then
				Timer "Start" "Extracting Arch Package: ${FILE}"
				FormatNUM " ${TCOUNT} of" "${#ARCHPACKAGES[@]}"
				Thousands "${FILESIZE}"
				FILESIZE="${FORMATTED}"
				Encapsulate "Beginning extraction of ${FILE}. (${FILESIZE} bytes)"
				Encapsulate "to ${FOLDER/.\//}/"
			fi
			mkdir -p "${FOLDER}/"
			if [[ -f "${FILE}" ]]; then
				if [[ "${TAR}" ]]; then
					if [[ "${EXTENSION}" == "Zstandard" ]]; then
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Compression detected: ${EXTENSION} (Facebook compression)"
						fi
						tar --use-compress-program=unzstd -xf "${FILE}" -C "${FOLDER}/" | Spinner
					else
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Compression detected: ${EXTENSION} (XZ compressed data)"
						fi
						tar -xf "${FILE}" -C "${FOLDER}/" 2>/dev/null | Spinner
					fi
				else
					if ! [[ "${ISARCH}" ]]; then
						Error "tar is not installed exiting: sudo apt-get install tar"
						exit 1;
					else
						Error "tar is not installed exiting: sudo pacman -S tar"
						exit 1;
					fi
				fi
			fi

			if ! [[ "${SUPPRESS}" ]]; then
				if [[ "${USAGE}" ]]; then
					if [[ -d "${FOLDER}" ]]; then
						FullBar
						EXTRACTEDFOLDER=$(du -hs "${FOLDER}")
						FOLDERSIZE=$(echo "${EXTRACTEDFOLDER}" | awk '{print $1}')
						EXTRACTEDFOLDER=$(echo "${EXTRACTEDFOLDER}" | awk '{print $2}')
						NUMFILES=$(find "${EXTRACTEDFOLDER}" -type f | wc -l)
						Thousands "${NUMFILES}"
						NUMFILES="${FORMATTED}"
						Thousands "${FILESIZE}"
						FILESIZE="${FORMATTED}"
						Columnize -t "FILENAME" "FILESIZE BYTES" "FOLDER" "DISKSIZE" "# FILES"
						DEBIANFOLDER=$(echo "${EXTRACTEDFOLDER}" | sed "s/.\///g")
						THEFILE=$(echo "${FILE}" | sed "s/.\///g")
						Columnize "${THEFILE}" "${FILESIZE}" "${DEBIANFOLDER}/" "${FOLDERSIZE}" "${NUMFILES}"
						Timer "Stop" "Extracting Arch Package: ${FILE}"
					fi
				fi
			fi
			cd "${CURRENT}"
			if [[ -f "${FOLDER}/.PKGINFO" ]]; then
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Compression detected: tarball (Tape Archive) - Zstd"
					Encapsulate "Package: ${FILE} successfully extracted. Removing Package."
				fi
				rm "${FILE}"
			fi
		done
		if [[ -s "ar.log" ]]; then
			if ! [[ "${SUPPRESS}" ]]; then
				Notification 'Extraction complete. Error(s) in extraction: please review ar.log.'
				cat ar.log
			fi
		else
			if [[ -f "ar.log" ]]; then
				rm "ar.log" 2>/dev/null
			fi
		fi
		if [[ -f "tar.log" ]]; then
			rm "tar.log"
		fi
		cd "${CURRENT}"
	fi
}

UnArchSMP () {
	Timer "Start" "Symmetric Multiprocessing (SMP) Extract"
	BASECORES=0
	BASECORE=$(echo "$@" | grep -i "BASECORE")
	if [[ "${BASECORE}" ]]; then
		BASECORES=1
	fi
	# Snatch the number of CPU Core(s) / threads the end user has.
	CORES=$(grep -i "processor" "/proc/cpuinfo" | sed '/model/d' | wc -l)
	(( ACTUALCORES = ${CORES} -1 ))
	FullBar
	#CORES=$(("${CORES}" +3))
	CONTAINS=$(echo "$@" | grep -i 'threads')
	if [[ "${CONTAINS}" ]]; then
		THREADS=$(echo "$@" | grep -i "threads=" | sed "s/^.*threads=//g" | cut -d" " -f1)
		Encapsulate "Threads Specified as: ${THREADS}"
		CALCULATE=$(( "${THREADS}" + 3 + "${BASECORES}" ))
		CORES="${CALCULATE}"
	fi
	shopt -s dotglob
	shopt -s nullglob
	FOLDERS=(./*tar.zst ./*tar.xz)
	ARCHPACKAGE=();
	DEBPACKAGE=();
	declare -i INDEX;
	declare -i AINDEX;
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	INDEX=0
	AINDEX=0
	INSTANCE=1
	for EACH in "${FOLDERS[@]}"
	do
		if [[ -f "${EACH}" ]]; then
			AINDEX=$(( AINDEX + 1 ))
			ARCHPACKAGE[${AINDEX}]+="${EACH}"
		fi
	done
	if [[ "${AINDEX}" -ge "${CORES}" ]]; then
		USECORES="${CORES}"
	else
		USECORES="${AINDEX}"
	fi
	Encapsulate "Number of CPU Core(s) / threads(s) detected: ${CORES}"
	Encapsulate "Launching ${USECORES} threads to accelerate the extraction process, please wait."
	AINDEX=0
	USECORES=$(( USECORES + 3 ))
	THREADS=1
	for EACH in "${ARCHPACKAGE[@]}"
	do
		AINDEX=$(( AINDEX + 1 ))
		RUNNINGINSTANCES=$(ps -C repostorm | wc -l)
		# EXPELL all cores, let's go to work, if we have maxed out, wait for one core to finish.

		while [[ "${RUNNINGINSTANCES}" -ge "${USECORES}" ]] ;
		do
			RUNNINGINSTANCES=$(ps -C repostorm | wc -l)
		done
		# Yee HAW we have an open core, let's put it to work.
		if [[ "${RUNNINGINSTANCES}" -lt "${USECORES}" ]]; then
			INSTANCE=$(( "${RUNNINGINSTANCES}" + 1 ))
			Encapsulate "Launching thread #${THREADS}: Extracting: ${ARCHPACKAGE[${AINDEX}]} (RUNNING INSTANCES: ${RUNNINGINSTANCES} Internal processes: 2)"
			THREADS=$(( THREADS + 1 ))
			repostorm --extract "${ARCHPACKAGE[${AINDEX}]}" --suppress -YES & #& allows that to process and continue running through current software hence why the not equal 3 below
		fi
	done
	FullBar
	if [[ "${RUNNINGINSTANCES}" -ne "3" ]]; then
		INSTANCE=$(ps -C repostorm | wc -l)
		PCOMP=$((100*INDEX / INSTANCE))
		ProgressBar "${PCOMP}" "Waiting for threads to die: ${INDEX} of ${INSTANCE}"
	fi
	Timer "Stop" "Symmetric Multiprocessing (SMP) Extract"
}

# Extraction subroutine
Extract () {
	Timer "Start" "Extraction Function"
	CURRENT="${PWD}"
	ZSTD=$(type -p zstd)
	TAR=$(type -p tar)
	AR=$(type -p ar)
	GZIP=$(type -p gzip)
	XZIP=$(type -p xz)
	USAGE=$(type -p du)
	FOLDER=""
	BUILDIT=0
	shopt -s dotglob
	shopt -s nullglob
	FOLDERS=(*/)
	DEBS=();

	declare -i NARCH
	declare -i NDEBS
	declare -i INDEX
	declare -i AINDEX
	declare -a ARCHPACKAGES=();

	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	NDEBS="${#DEBS[@]}"
	NARCH="${#ARCHPACKAGES[@]}"
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			EXTENSION="${EACH##*.}"
			if [[ "${EXTENSION}" == "deb" ]]; then
				DEBS="${EACH}"
				SINGLE=1
			fi
			if [[ "${EXTENSION}" == "zst" ]]; then
				SINGLE=1
				ARCHPACKAGES="${EACH}"
			fi
		fi
	done
	if ! [[ "${SINGLE}" ]]; then
		ARCHPACKAGES=(./*tar.zst ./*tar.xz)
		DEBS=(./*deb)
	fi
	NDEBS="${#DEBS[@]}"
	NARCH="${#ARCHPACKAGES[@]}"
	if ! [[ "${NDEBS}" && "${NARCH}" ]]; then
		Error "ERROR: No deb(s) or Arch packages found."
		Encapsulate "${APPNAME} --help for help or man ${APPNAME} for further Information."
		exit 1;
	fi
	#tar --use-compress-program=unzstd -xvf ultimate-edition-repostorm-2.0.9-1-any.pkg.tar.zst -C ultimate-edition-repostorm-2.0.9/
	#Clean up in case.
	if [[ -f "ar.log" ]]; then
		rm "ar.log" 2> /dev/null
	fi
	if ! [[ "${SUPPRESS}" ]]; then
		Center "Repostorm ${REPOVERSION} is entering extraction mode."
	fi
	#Prompt the end user?
	if ! [[ "${PROMPTSUPPRESSION}" ]]; then
		INDEX=0
		if [[ "${#DEBS[@]}" -gt 0 ]]; then
			for EACH in "${DEBS[@]}"
			do
				INDEX=$((INDEX + 1))
				FNAME=$(echo "${EACH/./}" | sed "s/\///g")
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "${INDEX}. Deb Package: ${FNAME}"
				fi
			done
		else
			ZIP=0
		fi
	fi
	if ! [[ "${PROMPTSUPPRESSION}" ]]; then
		INDEX=0
		if [[ "${#ARCHPACKAGES[@]}" -gt 0 ]]; then
			ZIP=1
			for EACH in "${ARCHPACKAGES[@]}"
			do
				INDEX=$((INDEX + 1))
				FNAME=$(echo "${EACH/./}" | sed "s/\///g")
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "${INDEX}. Arch Package: ${FNAME}"
				fi
			done
			FullBar
		else
			ZIP=0
		fi
		if [[ "${ZIP}" -gt 0 ]]; then
			if ! [[ "${SUPPRESS}" ]]; then
				PromptYN "${WARNING}WARNING: ${BRIGHT}${TXTGRN}this will extract all the above ${NDEBS} deb(s) & ${NARCH} Arch packages to their own folder. (Y/N)? "
			fi
		else
			Error "No Packages found for Arch or Debian / Ubuntu."
			exit 0;
		fi
			# echo -en "\033[1A\033[2K"
			# echo -e "\033[${COLUMNZ}G▒" # Close Encapsulation.
			case "${YN}" in
				[Nn]* ) exit 0;;
				[Yy]* ) if ! [[ "${SUPPRESS}" ]]; then Center "Beginning extraction..."; fi;;
				* ) if ! [[ "${SUPPRESS}" ]]; then Encapsulate "Please answer y or n.";fi;;
			esac
	else
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "${WARNING}WARNING: ${BRIGHT}${TXTGRN}extracting ${NDEBS} deb(s) & ${NARCH} Arch packages to their own folder."
		fi
	fi
	if [[ "${NARCH}" -gt 1 ]]; then
		UnArchSMP "$@"
	else
		UnArch "$@"
	fi
	# They answered yes, Let's Rock

	declare -i TCOUNT;
	TCOUNT=0
	for FILE in "${DEBS[@]}"
	do
		TARGET=$(echo "${FILE}" | sed -e "s/ /_/")
		DEB="${TARGET%/}.deb"
		FOLDER="${FILE%%.deb}"
		FS=$(type -p stat)
		if [[ "${FS}" ]]; then
			FILESIZE=$(stat --printf="%s" "${FILE}")
		fi
		#Toss a little eye candy
		TCOUNT=$(( TCOUNT +1 ))
		if ! [[ "${SUPPRESS}" ]]; then
			Timer "Start" "Extracting ${FILE}"
			FormatNUM " ${TCOUNT} of" "${#DEBS[@]}"
			Thousands "${FILESIZE}"
			FILESIZE="${FORMATTED}"
			Encapsulate "Beginning extraction of ${FILE}. (${FILESIZE} bytes)"
			Encapsulate "to ${FOLDER/.\//}/"
		fi
		if [[ "${AR}" ]]; then
			ar x "${FILE}" >> "${CURRENT}/ar.log" 2>&1
		else
			if ! [[ "${ISARCH}" ]]; then
				Error "ar is not istalled exiting: sudo apt-get install ar"
				exit 1;
			else
				Error "ar is not istalled exiting: sudo pacman -Syuu ar"
				exit 1;
			fi
		fi
		mkdir -p "${FOLDER}/DEBIAN/"
		if [[ -f "control.tar.gz" ]]; then
			Encapsulate "Compression detected: tarball (Tape Archive) - GZip"
			if [[ "${TAR}" ]]; then
				mv "control.tar.gz" "${FOLDER}/DEBIAN/"
			else
				if ! [[ "${ISARCH}" ]]; then
					Error "tar is not installed exiting: sudo apt-get install tar"
					exit 1;
				else
					Error "tar is not installed exiting: sudo pacman -Syuu tar"
					exit 1;
				fi
			fi
		elif [[ -f "control.tar.xz" ]]; then
			Encapsulate "Compression detected: tarball (Tape Archive) - XZip"
			if [[ "${XZIP}" ]]; then
				mv "control.tar.xz" "${FOLDER}/DEBIAN/"
			else
				if ! [[ "${ISARCH}" ]]; then
					Error "xz is not istalled exiting: sudo apt-get install xz"
					exit 1;
				else
					Error "xz is not istalled exiting: sudo pacman-Syuu xz"
					exit 1;
				fi
			fi
		elif [[ -f "control.tar.zst" ]]; then
			if ! [[ "${SUPPRESS}" ]]; then
				Encapsulate "Compression detected: tarball (Tape Archive) - Zstd (FaceBook Compression)"
			fi
			if [[ "${ZSTD}" ]]; then
				mv "control.tar.zst" "${FOLDER}/DEBIAN/"
			else
				if ! [[ "${ISARCH}" ]]; then
					Error "Zstd compression is not installed exiting: sudo apt-get install zstd"
					exit 1;
				else
					Error "Zstd compression is not installed exiting: sudo pacman -Syuu zstd"
					exit 1;
				fi
			fi
		fi

		if [[ -d "${FOLDER}/DEBIAN/" ]]; then
			cd "${FOLDER}/DEBIAN/" || exit 1;
		else
			Error "No folder: ${FOLDER}/DEBIAN/ extraction error?"
			exit 1;
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Extracting Control files from ${FILE}"
			echo "Extracting Control files from ${FILE}" >> "${CURRENT}/tar.log"
		fi
		if [[ -f "control.tar.gz" ]]; then
			tar xfv "control.tar.gz" >> "${CURRENT}/tar.log" 2>&1
			rm "control.tar.gz" 2>/dev/null
			cd "${CURRENT}" || exit 1;
		fi
		if [[ -f "control.tar.xz" ]]; then
			tar xfv "control.tar.xz" >> "${CURRENT}/tar.log" 2>&1
			rm "control.tar.xz" 2>/dev/null
			cd "${CURRENT}" || exit 1;
		fi
		if [[ -f "control.tar.zst" ]]; then
			zstd -d "control.tar.zst" >> "${CURRENT}/tar.log" 2>&1
			if [[ -f "control.tar" ]]; then
				tar xfv "control.tar" >> "${CURRENT}/tar.log" 2>&1
			fi
			if [[ -f "control" ]]; then
				if [[ -f "control.tar" ]]; then
					rm "control.tar" 2>/dev/null
				fi
				if [[ -f "control.tar.zst" ]]; then
					rm "control.tar.zst" 2>/dev/null
				fi
			else
				Error "Exiting Error(s) in extraction using Zstd compression."
			fi
		fi
		if [[ -d "${CURRENT}" ]]; then
			cd "${CURRENT}" || exit 1;
		else
			Error "${CURRENT} was deleted while processing, exiting."
			exit 1;
		fi

		if [[ -f "data.tar.gz" ]]; then
			mv "data.tar.gz" "${FOLDER}/"
		fi

		if [[ -f "data.tar.xz" ]]; then
			mv "data.tar.xz" "${FOLDER}/"
		fi

		if [[ -f "data.tar.zst" ]]; then
			mv "data.tar.zst" "${FOLDER}/"
		fi

		if ! [[ -f "${FOLDER}/data.tar.gz" || "${FOLDER}/data.tar.xz" || "${FOLDER}/data.tar.zst" ]]; then
			Error "No data files in deb exiting: ${FILE}"
			exit 1;
		fi
		if [[ -d "${FOLDER}" ]]; then
			cd "${FOLDER}" || exit 1;
		else
			Error "Folder ${FOLDER} does not exist. Malformed archive?"
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Extracting data files from ${FILE}"
		fi
			echo "Extracting data files from ${FILE}" >> "${CURRENT}/tar.log"
		if [[ -f "data.tar.gz" ]]; then
			tar xfv "data.tar.gz" >> "${CURRENT}/tar.log" 2>&1 & Spinner "Extracting data files from ${FILE}"
			rm "data.tar.gz" 2>/dev/null
		elif [[ -f "data.tar.xz" ]]; then
			tar xfv "data.tar.xz" >> "${CURRENT}/tar.log" 2>&1 & Spinner "Extracting data files from ${FILE}"
			rm "data.tar.xz" 2>/dev/null
		elif [[ -f "data.tar.zst" ]]; then
			tar xfv "data.tar.zst" >> "${CURRENT}/tar.log" 2>&1 & Spinner "Extracting data files from ${FILE}"
			rm "data.tar.zst" 2>/dev/null
		fi

		cd "${CURRENT}" || exit 1;
		if ! [[ "${SUPPRESS}" ]]; then
			VersionControl "${FILE}"
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			if [[ "${USAGE}" ]]; then
				if [[ -d "${FOLDER}" ]]; then
					FullBar
					EXTRACTEDFOLDER=$(du -hs "${FOLDER}")
					FOLDERSIZE=$(echo "${EXTRACTEDFOLDER}" | awk '{print $1}')
					EXTRACTEDFOLDER=$(echo "${EXTRACTEDFOLDER}" | awk '{print $2}')
					NUMFILES=$(find "${EXTRACTEDFOLDER}" -type f | wc -l)
					Thousands "${NUMFILES}"
					NUMFILES="${FORMATTED}"
					Thousands "${FILESIZE}"
					FILESIZE="${FORMATTED}"
					Columnize -t "FILENAME" "FILESIZE BYTES" "FOLDER" "DISKSIZE" "# FILES"
					DEBIANFOLDER=$(echo "${EXTRACTEDFOLDER}" | sed "s/.\///g")
					THEFILE=$(echo "${FILE}" | sed "s/.\///g")
					Columnize "${THEFILE}" "${FILESIZE}" "${DEBIANFOLDER}/" "${FOLDERSIZE}" "${NUMFILES}"
					Timer "Stop" "Extracting ${FILE}"
				fi
			fi
		fi
	done
	if [[ -s "ar.log" ]]; then
		if ! [[ "${SUPPRESS}" ]]; then
			Notification 'Extraction complete. Error(s) in extraction: please review ar.log.'
			cat ar.log
		fi
	else
		if ! [[ "${SUPPRESS}" ]]; then
			TOTALFILES=$(find "." -type f  -not -path ".debs/*|.arch/*" | wc -l)
			Thousands "${TOTALFILES}"
			TOTALFILES="${FORMATTED}"
			Notification "Extraction of ${#DEBS[@]} deb(s) ${#ARCHPACKAGES[@]} Arch package(s) complete. No errors detected in extraction."
			FileSize "-d" "${PWD}"
			for dir in *; do
			# Check if the item is a directory
				if [ -d "$dir" ]; then
					# Calculate disk usage in kilobytes (-s for summary, -k for KB)
					# and extract only the size using 'cut' or 'awk'
					size_kb=$(du -sk "$dir" | cut -f1)
					# Append the size to the array
					folder_sizes_kb+=("$size_kb")
				fi
			done
			Thousands "${folder_sizes_kb}"
			TRUESIZE="${FORMATTED}"
			Encapsulate "Size: ${TRUESIZE}. Total files: ${TOTALFILES}"
		fi
		if [[ -f "ar.log" ]]; then
			rm "ar.log" 2>/dev/null
		fi
	fi
	if [[ -f "tar.log" ]]; then
		rm "tar.log"
	fi
	if ! [[ "${SUPPRESS}" ]]; then
		Timer "Stop" "Extraction Function"
	fi
}

# Clear logs - this subroutine is called internally when necessary.
ClearLogs () {
	CheckRoot "$@"
	if ! [[ "${SUPPRESS}" ]]; then
		Center "Repostorm ${REPOVERSION} is clearing log files."
	fi
	shopt -s nullglob
	ERRORFILES=(*.errors)
	CONTAINS=$(echo "$@" | grep "ALL")
	if [[ "${CONTAINS}" ]]; then
		if [[ "${#ERRORFILES[@]}" -gt 0 ]]; then
			for EACH in "${ERRORFILES[@]}"
			do
				rm "${EACH}" 2>/dev/null
			done
		fi
	fi
	DEB="${2}"
	FOLDER="${DEB%.*}/"
	declare -a SCRAP=( "all_errors.txt" "all_warnings.txt" "build.log" "ar.log" "tar.log" "all_information.txt" "column" "session.txt" "tmp.txt" "test.txt" );
	# RIP ALL LOGS
	# User is wild-carding it. Scrap all error logs.
	for EACH in "${SCRAP[@]}"
	do
		if [[ -s "${EACH}" ]]; then
			rm "${EACH}" 2>/dev/null
		fi
		if [[ -e "${EACH}" ]];then
			rm "${EACH}" 2>/dev/null
		fi
		done
	CONTAINS=$(echo "$@" | grep -i "all")
	#MAINLOG?
	if [[ "${CONTAINS}" ]]; then
		if [[ -e "/var/log/${APPNAME}_errors.log" ]]; then
			PromptYN "Clear Main Logs (Y/N)? "
			case "${YN}" in
				[Nn]* ) exit 0;;
				[Yy]* ) sudo rm "/var/log/${APPNAME}_errors.log" 2>/dev/null;
				sudo touch "/var/log/${APPNAME}_errors.log" 2>/dev/null;;
				* ) Encapsulate "Please answer y or n.";;
			esac
		else
			Encapsulate "No main Logs exist, creating an empty one."
			sudo touch "/var/log/${APPNAME}_errors.log" 2>/dev/null
		fi
	fi
}

# Clean subroutine - scraps build folder.  Specifying no folder name will prompt
# and scrap all sub-folders recursively.
Clean () {
	CheckRoot "$@"
	FOLDER=""
	BUILDIT=0
	shopt -s dotglob
	shopt -s nullglob
	FOLDERS=(*/)
	DEBS=();
	declare -i NUMFOLDERS;
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	for EACH in "$@"
	do
		if [[ -d "${EACH}" ]]; then
			FOLDER="${EACH}"
			EXISTS=1
		fi
	done
	if [[ "${FOLDERS[@]}" ]]; then
		EXISTS=1
	fi
	if ! [[ "${EXISTS}" -gt 0 ]]; then
		Error "No Folder(s) to process. Have you extracted it yet?"
		Encapsulate "${APPNAME} --help or man ${APPNAME} for assistance."
		ClearLogs "--suppress"
		exit 1;
	fi
	if ! [[ "${FOLDERS[@]}" ]]; then
		Encapsulate "No folders to clean."
		ClearLogs "--suppress"
		exit 1;
	fi
	Center "Repostorm ${REPOVERSION} is entering clean mode."
	CONTAINS=$(echo "$@" | grep "YES")
	NUMFOLDERS="${#FOLDERS[@]}"
	INDEX=0
	if ! [[ "${CONTAINS}" ]]; then
		if [[ "${FOLDER}" ]]; then
			Encapsulate "${FOLDER}"
			while true; do
				FullBar
				PromptYN "${WARNING}WARNING: ${TXTRED}Recursively delete all of the above ${NUMFOLDERS} folder(s). (Y/N)? "
				case "${YN}" in
					[Nn]* ) exit 0;;
				[Yy]* ) echo "Scraping...";
					INDEX=$((INDEX + 1))
					PCOMP=$((100*INDEX / NUMFOLDERS))
					ProgressBar "${PCOMP}" "Removing folder ${FOLDER}: ${INDEX} of ${NUMFOLDERS}"
					sudo rm -R "${FOLDER}"
				Encapsulate "Removing all error and build logs."
				ClearLogs "ALL" "--suppress"
				Encapsulate "Process complete."
				FullBar
				exit 0;;
				* ) Encapsulate "Please answer y or n.";;
				esac
			done
		else
			for EACH in "${FOLDERS[@]}"
			do
				Encapsulate "${EACH}"
			done
				FullBar
				PromptYN "${WARNING} WARNING${TXTRED}: Recursively delete all of the above ${NUMFOLDERS} folder(s). (Y/N)? "
				case "${YN}" in
					[Nn]* ) exit 0;;
				[Yy]* ) Center "Recursively deleting all of the above ${NUMFOLDERS} folder(s).";
					for EACH in "${FOLDERS[@]}"
					do
						if [[ "${EACH}" != "" ]]; then
							INDEX=$((INDEX + 1))
							PCOMP=$((100*INDEX / NUMFOLDERS))
							ProgressBar "${PCOMP}" "Removing folder ${EACH}: ${INDEX} of ${NUMFOLDERS}"
							sudo rm -R "${EACH}"
						fi
					done;
					Encapsulate "Removing all error and build logs."
					ClearLogs "ALL" "--suppress"
					Encapsulate "Process complete."
					FullBar
					exit 0;;
				* ) Encapsulate "Please answer y or n.";;
				esac
		fi
	else
		for EACH in "${FOLDERS[@]}"
		do
			if [[ "${EACH}" != "" ]]; then
				Encapsulate "Recursively Deleting: ${EACH}"
				sudo rm -R "${EACH}"
			fi
		done;
		Encapsulate "Removing all error and build logs."
		ClearLogs "$@"
		Encapsulate "Process complete."
		FullBar
	fi
}

Report () {
	FILE="${2}"
	if [[ "${2}" ]]; then
		#echo "DEBUGGING: ${1}"
		#strip trailing slash(s) aggressively, we only care about ${1}.errors.deb
		DIR=$(echo "${FILE}" | tr -s /)
		DIR="${DIR%/}"
		FILE="${DIR}"
		#Gone, lets start adding data. verify a deb was not called, or a vaild switch.
		GREPIT=$(echo "${FILE}" | grep '.deb.errors')
		if [[ "${GREPIT}" ]]; then
			FILE="${FILE}"
		else
			GREPIT=$(echo "${FILE}" | grep 'deb')
			#USER has reqested a deb, we are looking for errors modifify input.
			if [[ "${GREPIT}" ]]; then
				FILE="${FILE}.errors"
			fi
		fi
		if [[ "${FILE}" && -f "${FILE}" ]]; then
			#Version
			Center "Repostorm ${REPOVERSION} is entering report mode."
			FullBar
		else
			Error "Error: ${FILE} does not exist."
		fi
	fi
	DEB="${FILE}"
	FOLDER=$(echo "${DEB}" | sed 's/\.deb//g')
	FOLDER=$(echo "${FOLDER}" | sed 's/\.errors//g')
	ERR=0
	WARNINGS=0
	INFORMATION=0
	ERRORS=$((ls *.errors) 2>/dev/null)
	if [[ "${ERRORS}" ]]; then
		DEB="${FILE}"
		if [[ -s "${FILE}" ]]; then
			Center "Build results of: ${DEB}"
			# pre-process errors / warnings.
			ERRORS=$(cat "${DEB}" | grep 'E:' | wc -l)
			WARNINGS=$(cat "${DEB}" | grep 'W:' | wc -l)
			INFORMATION=$(cat "${DEB}" | grep 'N:' | wc -l)
			if [[ "${ERRORS}" != 0 ]]; then
				echo -e -n "${TXTRED}"
				cat "${DEB}" | grep 'E:' >> all_errors.txt
				cat "${DEB}" | grep 'E:'
			fi
			if [[ "${WARNINGS}" != 0 ]]; then
				echo -e -n "${TXTYLW}"
				cat "${DEB}" | grep 'W:' >> all_warnings.txt
				cat "${DEB}" | grep 'W:'
			fi
			if [[ "${INFORMATION}" != 0 ]]; then
				echo -e -n "${TXTWHT}"
				cat "${DEB}" | grep 'N:' >> all_information.txt
				cat "${DEB}" | grep 'N:'
			fi
			echo -e -n "${TXTGRN}"
			FullBar
			Encapsulate "Error(s): ${ERRORS} ${WARNING}Warning(s): ${WARNINGS} | Info: ${INFO}${INFORMATION} has been recorded."
			FullBar
			Encapsulate "nano ${DEB} for more information or"
			Encapsulate "${APPNAME} -f ${FOLDER} to autofix."
			return 1
		# else
			# WriteLogs "--suppress"
		fi
	else
		Encapsulate "No error(s) have been logged in current folder."
	fi
}

EmptyBinary () {
	#empty-binary-package
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIP=$(echo "${ERRORS}" | grep "empty-binary-package")
		if [[ "${STRIP}" ]]; then
			GREPIT=$(grep "metapackage" "${CONTROL}")
			if ! [[ "${GREPIT}" ]]; then
				Encapsulate "Adding metadata to description in control file."
				sed -i "/Description:/ s/$/ metapackage/" "${CONTROL}"
			fi
		fi
	done
}

PriorityOptional () {
	# priority-extra-is-replaced-by-priority-optional
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIP=$(echo "${ERRORS}" | grep "priority-extra-is-replaced-by-priority-optional")
		if [[ "${STRIP}" ]]; then
			GREPIT=$(grep "optional" "${CONTROL}")
			if ! [[ "${GREPIT}" ]]; then
				Encapsulate "Replacing: extra with optional in Priority of the control file."
				sed -i "/Priority:/ s/$/ metapackage/" "${CONTROL}"
			fi
		fi
	done
}

#THEME BASED FUNCTIONS...
Icon_Resize () {
	EXISTS=$(type -p convert)
	# icon-size-and-directory-name-mismatch
	# Example:
	# Warning: W: ultimate-edition-icons-dark-glass: icon-size-and-directory-name-mismatch usr/share/icons/Ultimate Edition Dark Glass/128x128/apps/blender.png 128x106 Logged to all_warnings.txt,
	# We want 128x128 as expected.  Let's resize the image in QUEStion.
	# NOSPACES=$(echo "${ERRORS}" | sed "s/ raster-image-in-scalable-directory //g" | cut -d: -f3 | awk -F'[ ]' '{print NF}')
	# NOSPACES=$(( NOSPACES -1))
	# FILENANDPATH=$(echo "${ERRORS}" | sed "s/ raster-image-in-scalable-directory //g" | cut -d: -f3 | cut -d' ' -f1-"${NOSPACES}")
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIP=""
		STRIP=$(echo "${ERRORS}" | grep "icon-size-and-directory-name-mismatch" | cut -d: -f3 | cut -d" " -f3)
		if [[ "${STRIP}" != "" ]]; then
			PACKAGE=$(echo "${ERRORS}" | grep "icon-size-and-directory-name-mismatch" | cut -d ":" -f2 | cut -d " " -f2)
			OUTSIZE=$(echo "${ERRORS}" | grep "icon-size-and-directory-name-mismatch" | cut -d ":" -f3 | sed s"/\ icon-size-and-directory-name-mismatch\ //g" | cut -d "x" -f1)
			SIZE=$(basename "${OUTSIZE}")
			FILETP=$(echo "${ERRORS}" | grep "icon-size-and-directory-name-mismatch"| cut -d ":" -f3 | sed s"/\ icon-size-and-directory-name-mismatch\ //g")
			FTP="${FILETP% *}"
			if [[ -f "${FILE}/${FTP}" ]]; then
				if [[ "${EXISTS}" ]]; then
					Encapsulate "Fixing Error: icon-size-and-directory-name-mismatch. Resizing image: ${FILE}/${FTP} to !${SIZE}x${SIZE}."
					TOPROCESS="${FILE}/${FTP}"
					TSIZE="!${SIZE}x${SIZE}"
					shopt -s nullglob
					shopt -s dotglob
					convert -resize "${TSIZE}" "${TOPROCESS}" "${TOPROCESS}"
				fi
			else
				Error "File does not exist: ${FILE}/${FTP} or imagemagik is not installed, unable to modify it, this error / warning will remain."
			fi
		fi
	done

}

RasterImage () {
	EXISTS=$(type -p convert)
	# raster-image-in-scalable-directory
	# Example:
	# Warning: W: revolt: raster-image-in-scalable-directory usr/share/icons/revolt/scalable/status/task-due.png Logged to all_warnings.txt.
	# We want SVG images as expected.  Let's convert the image in QUEStion to vector graphics.
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIP=""
		STRIP=$(echo "${ERRORS}" | grep "raster-image-in-scalable-directory" | sed "s/ raster-image-in-scalable-directory //g" | cut -d: -f3)
		if [[ "${STRIP}" != "" ]]; then
			FILETP=$(echo "${ERRORS}" | grep "raster-image-in-scalable-directory" | cut -d ":" -f3 | sed s"/\ raster-image-in-scalable-directory\ //g")
			FTP="${FILETP% *}"
			FILENAME=$(basename "${FTP}")
			EXTENSION="${FILENAME##*.}"
			FILENAME="${FILENAME%.*}"
			DIR=$(dirname "${FTP}")
			if [[ "${EXISTS}" ]]; then
				TOPROCESS="${FILE}/${FTP}"
				OUTFILE="${FILE}/${DIR}/${FILENAME}.svg"
				Encapsulate "Fixing Error: raster-image-in-scalable-directory. Converting image: ${TOPROCESS} to SVG (Vector Graphics)."
				convert "${TOPROCESS}" "${OUTFILE}"
				if [[ -f "${OUTFILE}" ]]; then
					if [[ -f "${TOPROCESS}" ]]; then
						Encapsulate "Removing processed file: ${TOPROCESS}"
						rm "${TOPROCESS}"
					else
						Encapsulate "Processing image has failed, not doing anything."
					fi
				fi
			fi
		fi
	done

}

FullReport () {
	ERR=0
	WARN=0
	INFOFORMATION=0
	ERRORS=0
	TERRORS=0
	TWARN=0
	TINFO=0
	CURRENTDEBS=();
	INFOLDER="${PWD}"
	shopt -s nullglob
	shopt -s dotglob
	if [[ -s "all_errors.txt" ]]; then
		ERRORS=$(cat "all_errors.txt" | wc -l)
	fi
	if [[ -s "all_warnings.txt" ]]; then
		WARNINGS=$(cat "all_warnings.txt" | wc -l)
	fi
	if [[ -s "all_information.txt" ]]; then
		INFORMATION=$(cat "all_information.txt" | wc -l)
	fi
	shopt -s nullglob
	ERRORFILES=(*.errors)
	if [[ "${#ERRORFILES[@]}" -gt 0 || "${WARNINGS}" -gt 0 || "${INFORMATION}" -gt 0 ]]; then
		Center "Repostorm ${REPOVERSION} is generating a full report in ${PWD}."
		Center "SESSION RESULTS"
		FullBar
		EColumnize -t "FILE" "ERROR(s)" "WARNING(s)" "INFO(s)"
		#FullBar
		#printf '%-1s %-118s %-5s %-5s %-5s %s\n' \
		#	"▒" "FILE" "ERROR" "WARN" "INFO" "▒"
		declare -a PERFECTDEBS=();
		if [[ -d ".debs/" ]]; then
			cd ".debs/" || exit 1;
			PERFECTDEBS=(*.deb)
			cd "${INFOLDER}" || exit 1;
		fi
		if [[ "${#ERRORFILES[@]}" -gt 0 ]]; then
			for EACH in "${ERRORFILES[@]}"
			do
				TARGET=$(echo "${EACH}" | sed -e "s/.deb.errors//")
				DEB="${TARGET%/}.deb"
				if [[ -s "${DEB}.errors" ]]; then
					ERRORS=$(grep -o 'E:' "${DEB}.errors" | wc -l)
					TERRORS=$((${TERRORS} + ${ERRORS}))
					WARNINGS=$(grep -o 'W:' "${DEB}.errors" | wc -l)
					TWARN=$(($TWARN+${WARNINGS}))
					INFORMATION=$(grep -o 'N:' "${DEB}.errors" | wc -l)
					TINFO=$((${TINFO} + ${INFORMATION}))
					#echo "${DEB}" "${ERRORS}" "${WARNING}" "${INFO}"
					#printf '%-1s %-58s %-5s %-5s %-5s %s\n' \
					EColumnize "${DEB}" "${ERRORS}" "${WARNINGS}" "${INFORMATION}"
				fi

			done
		else
			Encapsulate "All 100% perfect deb(s)."
		fi
		TTP="Error(s): ${TERRORS} | Warning(s): ${TWARN} | Info: ${TINFO}"
		Error "${TTP}"
		ERRORFILES=(./*.errors)
		if [[ -d ".debs" ]]; then
			cd ".debs" || exit 1;
			shopt -s nullglob
			PERFECTDEBS=(*)
			cd .. || exit 1;
		else
			PERFECTDEBS=0
		fi
		Encapsulate "Errored deb(s): ${#ERRORFILES[@]} | Perfect deb(s): ${#PERFECTDEBS[@]}"
		# WriteLogs "--suppress"
		Notification "${PROGNAME}: All operations complete."
	else
		if [[ -d ".debs" ]]; then
			cd ".debs" || exit 1;
			shopt -s nullglob
			PERFECTDEBS=(*)
			cd .. || exit 1;
		else
			PERFECTDEBS=0
		fi
		if ! [[ -d ".debs" ]]; then
			Encapsulate "No Error(s), Warning(s) or INFO detected.  Have you --analyzed yet?"
		else
			Encapsulate "Congradulations 0 error(s) | Perfect deb(s): ${#PERFECTDEBS[@]}"
		fi
	fi
}

# shlib-with-executable-bit
ShlibExecutable () {
	if [[ -f "${FILE}.deb.errors" ]]; then
		cat "${FILE}.deb.errors" | while read ERRORS
		do
			SCRIPT=$(echo "${ERRORS}" | grep "shlib-with-executable-bit" | cut -d":" -f3 | sed "s/ shlib-with-executable-bit //g" | cut -d " " -f1)
			if [[ "${SCRIPT}" ]]; then
				FTP="${FILE}/${SCRIPT}"
				if [[ -f "${FTP}" ]]; then
					Encapsulate "Fixing Error: shlib-with-executable-bit: ${FTP} to 644 permissions."
					chmod 644 "${FTP}"
					#sed -i "s/Priority:.*/Priority: optional/g" "${CONTROL}"
				else
					Encapsulate "File not found: ${FTP}"
				fi
			fi
		done
	fi
}

CreateNFO () {
	EXISTS="${1}"
	PROVIDER="${2}"
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	OVERRIDE="${FILE}/usr/share/lintian/overrides/"
	INFOLDER="${PWD}"
	if [[ -d "${OVERRIDE}" ]]; then
		cd "${OVERRIDE}" || exit 1;
	else
		mkdir -p "${OVERRIDE}"
		cd "${OVERRIDE}" || exit 1;
	fi
	if [[ -f "${PACKAGENAME}" ]]; then
		GREPIT=$(grep "${PACKAGENAME}: ${PROVIDER} *" "${PACKAGENAME}")
		if ! [[ "${GREPIT}" ]]; then
			Encapsulate "Creating override file: ${PACKAGENAME}: ${PROVIDER} * Found in ${EXISTS}"
			echo "${PACKAGENAME}: ${PROVIDER} *" >> "${PACKAGENAME}"
		fi
	else
		echo "# See Debian policy 12.1. Manual pages" > "${PACKAGENAME}"
		echo "${PACKAGENAME}: ${PROVIDER} *" >> "${PACKAGENAME}"
	fi
	cd "${INFOLDER}" || exit 1;
}

ArchBuild () {
shopt -s nullglob
shopt -s dotglob
shopt -s extglob
INFOLDER="${PWD}"
Timer "Start" "Build Arch Packages Function"
NARCH="${#ARCHPACKAGE[@]}"
AINDEX=0
for EACH in "${ARCHPACKAGE[@]}"
do
	if [[ -d "${EACH}" ]]; then
		sed -i '/^makepkgopt/d' "${EACH}/.PKGINFO"
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Setting ownership to root in ${EACH}"
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			sudo chown -R "root:root" "${EACH}" & Spinner "Setting ownership to root in ${EACH}."
		else
			sudo chown -R "root:root" "${EACH}"
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Setting individual folder permissions to 755."
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			find "${EACH}" -type d -exec chmod 755 {} \; & Spinner "Setting individual folder permissions to 755."
		else
			find "${EACH}" -type d -exec chmod 755 {} \;
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Scanning for executables in ${EACH} Stage 1."
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			find "${EACH}" -name "DEBIAN" -prune -o -type f -exec sh -c 'test "$(head -c 2 "$1")" = "#!"' sh {} \; -print -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 1."
		else
			find "${EACH}" -name "DEBIAN" -prune -o -type f -exec sh -c 'test "$(head -c 2 "$1")" = "#!"' sh {} \; -print -exec chmod 755 {} &> /dev/null \;
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Scanning for executables in ${EACH} Stage 2."
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			find "${EACH}" -type f -exec sh -c "file -i '{}' | grep 'x-executable; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 2."
		else
			find "${EACH}" -type f -exec sh -c "file -i '{}' | grep 'x-executable; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Scanning for executables in ${EACH} Stage 3."
		fi
		if ! [[ "${SUPPRESS}" ]]; then
			find "${EACH}" -type f ! -name "*.so*" -exec sh -c "file -i '{}' | grep 'application/x-sharedlib; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 3."
		else
			find "${EACH}" -type f ! -name "*.so*" -exec sh -c "file -i '{}' | grep 'application/x-sharedlib; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;
		fi
		# shlib-with-executable-bit
		FILE=$(basename -- "${EACH}")
		#echo "${PWD}"
		ShlibExecutable "${FILE}"
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "Calculating Installed size & inserting into .PKGINFO if necessary."
		fi
		DEBSIZE=$(du -s --block-size=1 "${EACH}" | cut -f1 | sed 's/ //g')
		ISIZE=$(grep "size" "${EACH}/.PKGINFO" | cut -d= -f2 | sed 's/ //g')
		if ! [[ "${SUPPRESS}" ]]; then
			Encapsulate "${EACH} is ${DEBSIZE}. PKGINFO file reporting: ${ISIZE}"
		fi
		if [[ "${ISIZE}" == "" ]]; then
			if ! [[ "${SUPPRESS}" ]]; then
				Encapsulate "No installed size in the .PKGINFO inserting: ${DEBSIZE}"
			fi
			echo "size = ${DEBSIZE}" >> "${EACH}/.PKGINFO"
		else
			if [[ "${ISIZE}" != "${DEBSIZE}" ]]; then
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Size Mismatch, replacing with ${DEBSIZE}."
				fi
				sed -i "s/size.*/size = ${DEBSIZE}/g" "${EACH}.PKGINFO"
			else
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Size indicated in .PKGINFO is correct."
				fi
			fi
		fi
		cd "${EACH}"
		PACKAGENAME="${EACH%/}"
		AINDEX=$(( AINDEX + 1 ))
		if ! [[ "${SUPPRESS}" ]]; then
			Center "Beginning build of ${PACKAGENAME}.pkg.tar.zst (${AINDEX} of ${NARCH})"
			Encapsulate "Generating .MTREE file... in ${PWD}"
		fi
		bsdtar -czf .MTREE --format=mtree --options='!all,use-set,type,uid,gid,mode,time,size,md5,sha256,link' * .PKGINFO .INSTALL 2> /dev/null
		tar --zstd -cf ../${PACKAGENAME}.pkg.tar.zst *
		cd "${INFOLDER}" || exit 1;
		if [[ -f "${PACKAGENAME}.pkg.tar.zst" ]]; then
			SUCCESS=$(( SUCCESS + 1 ))
			if ! [[ "${SUPPRESS}" ]]; then
				Encapsulate "We have built an Arch package: ${PACKAGENAME}.pkg.tar.zst."
			fi
			if [[ -d "${EACH}" ]]; then
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Recursively removing ${EACH} since we have a perfect package."
				fi
				SCRAPIT=$(sudo rm -R "${EACH}" 2>/dev/null)
			fi
			if ! [[ "${SUPPRESS}" ]]; then
				Encapsulate "Moving ${PACKAGENAME}.pkg.tar.zst to .arch/"
			fi
			mkdir -p ".arch"
			if [[ -d ".arch/" ]]; then
				sudo mv "${PACKAGENAME}.pkg.tar.zst" ".arch/" 2>/dev/null
				if [[ -f ".arch/${PACKAGENAME}.pkg.tar.zst" ]]; then
					if ! [[ "${SUPPRESS}" ]]; then
						Encapsulate "Success moving file: ${PACKAGENAME}.pkg.tar.zst to .arch/${PACKAGENAME}.pkg.tar.zst"
						FullBar
					fi
				else
					Error "Failure moving file: ${PACKAGENAME}.pkg.tar.zst to .arch/${PACKAGENAME}.pkg.tar.zst. Permission issue? Exiting."
					exit 1;
				fi
			fi
		fi
	fi
done
Timer "Stop" "Build Arch Packages Function"
}

# Build ARCH SMP
BuildArchSMP (){
	Timer "Start" "Symmetric Multiprocessing (SMP) Build"
	BASECORES=0
	BASECORE=$(echo "$@" | grep -i "BASECORE")
	if [[ "${BASECORE}" ]]; then
		BASECORES=1
	fi
	# Snatch the number of CPU Core(s) / threads the end user has.
	CORES=$(grep -i "processor" "/proc/cpuinfo" | sed '/model/d' | wc -l)
	(( ACTUALCORES = ${CORES} -1 ))
	FullBar
	#CORES=$(("${CORES}" +3))
	CONTAINS=$(echo "$@" | grep -i 'threads')
	if [[ "${CONTAINS}" ]]; then
		THREADS=$(echo "$@" | grep -i "threads=" | sed "s/^.*threads=//g" | cut -d" " -f1)
		Encapsulate "Threads Specified as: ${THREADS}"
		CALCULATE=$(( "${THREADS}" + 3 + "${BASECORES}" ))
		CORES="${CALCULATE}"
	fi
	shopt -s dotglob
	shopt -s nullglob
	FOLDERS=(*/)
	ARCHPACKAGE=();
	DEBPACKAGE=();
	declare -i INDEX;
	declare -i AINDEX;
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	INDEX=0
	AINDEX=0
	INSTANCE=1
	for EACH in "${FOLDERS[@]}"
	do
		if [[ -d "${EACH}" ]]; then
			if [[ -f "${EACH}/.PKGINFO" ]]; then
				AINDEX=$(( AINDEX + 1 ))
				ARCHPACKAGE[${AINDEX}]+="${EACH}"
			fi
		fi
	done
	if [[ "${AINDEX}" -ge "${CORES}" ]]; then
		USECORES="${CORES}"
	else
		USECORES="${AINDEX}"
	fi
	Encapsulate "Number of CPU Core(s) / threads(s) detected: ${CORES}"
	Encapsulate "Launching ${USECORES} threads to accelerate the building process, please wait."
	AINDEX=0
	USECORES=$(( USECORES + 2 ))
	THREADS=1
	for EACH in "${ARCHPACKAGE[@]}"
	do
		AINDEX=$(( AINDEX + 1 ))
		RUNNINGINSTANCES=$(ps -C repostorm | wc -l)
		# EXPELL all cores, let's go to work, if we have maxed out, wait for one core to finish.

		while [[ "${RUNNINGINSTANCES}" -ge "${USECORES}" ]] ;
		do
			RUNNINGINSTANCES=$(ps -C repostorm | wc -l)
		done
		# Yee HAW we have an open core, let's put it to work.
		if [[ "${RUNNINGINSTANCES}" -lt "${USECORES}" ]]; then
			INSTANCE=$(( "${RUNNINGINSTANCES}" + 1 ))
			Encapsulate "Launching thread #${THREADS}: Building: ${ARCHPACKAGE[${AINDEX}]} (RUNNING INSTANCES: ${RUNNINGINSTANCES} Internal processes: 2)"
			THREADS=$(( THREADS + 1 ))
			sudo repostorm --build "${ARCHPACKAGE[${AINDEX}]}" -YES --suppress & #& allows that to process and continue running through current software hence why the not equal 3 below
		fi
	done
	FullBar
	while [[ "${RUNNINGINSTANCES}" -ne "3" ]] ;
	do
		RUNNINGINSTANCES=$(ps -C repostorm | wc -l)
		Spinner "Instances: ${RUNNINGINSTANCES} waiting for them to die."
	done
	mkdir -p .arch/
	if [[ -d ".arch/" ]]; then
		chown "${IUSER}:${IUSER}" .arch/
	fi
	Timer "Stop" "Symmetric Multiprocessing (SMP) Build"
}

# Build Deb (s)
Build () {
	CheckRoot "$@"
	#shopt -s nullglob
	#ERRORFILES=(*.errors)
	#if [[ "${#ERRORFILES[@]}" -gt 0 ]]; then
	#	for EACH in "${ERRORFILES[@]}"
	#	do
	#		rm "${EACH}"
	#	done
	#	ERRORFILES=(*.errors)
	#fi
	FOLDER=""
	BUILDIT=0
	shopt -s dotglob
	shopt -s nullglob
	FOLDERS=(*/)
	ARCHPACKAGE=();
	DEBPACKAGE=();
	declare -i INDEX;
	declare -i AINDEX;
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	if [[ "${DEBUG}" ]]; then
		echo "DEBUG: $@: 1:${1} 2:${2} 3:$3"
	fi
	#set internal workings of -YES switch used in service mode.
	for EACH in "$@"
	do
		if [[ -d "${EACH}" ]]; then
			#echo "FOLDER DETECTED as ${EACH}"
			FOLDER="${EACH}"
			FOLDERS="${FOLDER}"
			BUILDIT=1
		fi
	done
	#ClearLogs on multi-builds
	#if ! [[ "${FOLDER}" ]]; then
	#	ClearLogs "suppress" #No Prompt
	#fi
	if [[ "${FOLDER}" ]]; then
		if ! [[ "${SUPPRESS}" ]]; then
			Center "Repostorm ${REPOVERSION} is entering single build mode."
		fi
	else
		for EACH in "${FOLDERS[@]}"
		do
			if [[ -f "${EACH}.deb" ]]; then
				BUILDIT=1
			fi
			if [[ -d "${EACH}" ]]; then
				BUILDIT=1
			fi
		done
		if ! [[ "$BUILDIT" ]]; then
			Encapsulate "Nothing to build. ${APPNAME} --help or man ${APPNAME} for assistance."
			exit 0;
		fi
	fi
	# Check to see if end user is in for multiple to build. If so prompt.
	CONTAINS=$(echo "$@" | grep -i "YES")
	if ! [[ "${CONTAINS}" ]]; then
		if [[ -d "${FOLDER}" ]]; then
			INDEX=1
			Encapsulate "${FOLDER}"
			while true; do
				FullBar
				if ! [[ -f "${FOLDER}/.PKGINFO" ]]; then
					PromptYN "Build the above deb (Y/N)? "
				else
					AINDEX=$(( AINDEX + 1 ))
					ARCHPACKAGE[${AINDEX}]+="${FOLDER}"
					PromptYN "Build the above arch package (Y/N)? "
				fi
				case "${YN}" in
					[Nn]* ) exit 0;;
					[Yy]* ) break;;
					* ) Encapsulate "Please answer y or n.";;
				esac
			done
		else
			INDEX=0
			AINDEX=0
			for EACH in "${FOLDERS[@]}"
			do
				if [[ -d "${EACH}" ]]; then
					if [[ -f "${EACH}/.PKGINFO" ]]; then
						AINDEX=$(( AINDEX + 1 ))
						ARCHPACKAGE[${AINDEX}]+="${EACH}"
						Encapsulate "${AINDEX}: Arch Package: ${ARCHPACKAGE[${AINDEX}]}"
					elif [[ -d "${EACH}/DEBIAN" ]]; then
						INDEX=$(( INDEX + 1 ))
						DEBPACKAGE[${INDEX}]+="${EACH}"
						Encapsulate "${INDEX}: Deb Package: ${DEBPACKAGE[${INDEX}]}"
					fi
				fi
			done
			while true; do
				FullBar
				PromptYN "Build the above ${INDEX} deb(s) & ${AINDEX} Arch package(s) (Y/N)? "
				case "${YN}" in
					[Nn]* ) exit 0;;
					[Yy]* ) break;;
					* ) Encapsulate "Please answer y or n.";;
				esac
			done
		fi
	else
		# Test single folder or service called
		if ! [[ "${BUILDIT}" == 1 ]]; then
			if [[ -d "/var/cache/apt/archives/" ]]; then
				# Service call
				cd "/var/cache/apt/archives/" || exit 1;
				CURRENT="${PWD}"
			fi
		fi
	fi
	# The user answered yes or -YES switch was used.
	declare -i TOTALCOUNT;
	TOTALCOUNT=0
	#AINDEX=$(( AINDEX + 1 ))
	ARCHPACKAGE[${AINDEX}]+="${FOLDER}"
	if [[ "${AINDEX}" -gt 1 ]]; then
		BuildArchSMP "$@"
	else
		ArchBuild "$@"
	fi
	if [[ "${INDEX}" ]]; then
		for EACH in "${DEBPACKAGE[@]}"
		do
			if ! [[ "${EACH}" == "" ]]; then
				#target=${EACH// /}
				if [[ "${INDEX}" -lt 1 ]]; then
					if [[ -d ".debs" ]]; then
						INDEX="${#FOLDERS[@]}"
						let "INDEX=INDEX-1"
					else
						INDEX="${#FOLDERS[@]}"
					fi
				fi
				let "TOTALCOUNT=TOTALCOUNT+1"
				#target=$(echo "${EACH}" | sed -e "s/ /_/")
				FormatNUM "${INDEX}"
				FULLAMOUNT="${OUTPUTNUM}"
				FormatNUM "${TOTALCOUNT}"
				CURRENTAMOUNT="${OUTPUTNUM}"
				if ! [[ "${SUPPRESS}" ]]; then
					Center "Beginning build of ${EACH}: ${CURRENTAMOUNT} of ${FULLAMOUNT}"
					Encapsulate "Relaxing permissions of ${EACH}"
				fi
				sudo chmod -R 777 "${EACH}/"
				if [[ -f "/etc/passwd" ]]; then
					USEREXIST=$(awk -F: '{ print $1}' /etc/passwd | grep -i "${USER}")
				fi
				if [[ "${USEREXIST}" ]]; then
					TRUEUSER="${USER}"
				else
					TRUEUSER="root"
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Setting owner to: ${TRUEUSER}"
				fi
				sudo chown -R "${TRUEUSER}:${TRUEUSER}" "${EACH}/"
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Cleaning up any tmp or backup files."
				fi
				find "${EACH}/" -type f -name "*~" -exec rm -f {} \;
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Setting individual file permissions to 644."
				fi
				find "${EACH}/" -type f -exec chmod 644 {} \; & Spinner "Setting individual file permissions to 644."
				find "${EACH}/" -name "*.ali" -type f -exec chmod 0444 {} \; 2>/dev/null
				# etc/sudoers.d/
				find "${EACH}/etc/sudoers.d/" -name "*" -type f -exec chmod 0440 {} \; 2>/dev/null
				if [[ -d "${EACH}/etc/" ]]; then
					if ! [[ "${SUPPRESS}" ]]; then
						Encapsulate "Scanning /etc to build conffiles."
					fi
					cd "${EACH}" || exit 1;
					shopt -s nullglob
					shopt -s dotglob
					COUNT=$(find "etc/" -name "*" -type f)
					if [[ -f "DEBIAN/conffiles" ]]; then
						rm -f "DEBIAN/conffiles" 2>/dev/null
					fi
					if [[ "${#COUNT}" -gt 0 ]]; then
						find "etc/" -name '*' -type f > "DEBIAN/conffiles"
					fi
					#search and replace etc/ with /etc/
					if [[ -f "DEBIAN/conffiles" ]]; then
						sed -i 's/etc/\/etc/g' "DEBIAN/conffiles"
					fi
					cd .. || exit 1;
				else
					if ! [[ "${SUPPRESS}" ]]; then
						Encapsulate "No /etc/ so need to build conffiles."
					fi
				fi
				# TODO write routine to build shlibs a call to Build-libs?
				if [[ -d "${CURRENT}" ]]; then
					cd "${CURRENT}" || exit 1;
				fi
				# Test for executables & make naming conventions apply spaces etc.
				# /usr/share/screenlets/Lyrics/Quodlibet plugin/LyricsScreenletInformator.py becomes /usr/share/screenlets/Lyrics/Quodlibet\ plugin/LyricsScreenletInformator.py to set the executable bit.
				# Sed is hardcore, also handles many other nonstandard characters all in one line.Why?  Because I sed so ;)
				# first find executables and set executable.
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Scanning for executables in ${EACH} Stage 1."
				fi
				find "${EACH}" -name "DEBIAN" -prune -o -type f -exec sh -c 'test "$(head -c 2 "$1")" = "#!"' sh {} \; -print -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 1."
				# No header, no problem
				# find ${FILE} -name "*.sh" -exec chmod 755 {} \;
				# find ${FILE} -name "*.py" -exec chmod 755 {} \;
				# Nonstandard? spaces ( " etc.sed 's/\([ "(){}$#\&~'"'"']\)/\\\1/g'
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Scanning for executables in ${EACH} Stage 2."
				fi
				find "${EACH}" -type f -exec sh -c "file -i '{}' | grep 'x-executable; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 2."
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Scanning for executables in ${EACH} Stage 3."
				fi
				find "${EACH}" -type f ! -name "*.so*" -exec sh -c "file -i '{}' | grep 'application/x-sharedlib; charset=binary'" \; -exec chmod 755 {} &> /dev/null \;& Spinner "Scanning for executables in ${EACH} Stage 3."
				# shlib-with-executable-bit
				FILE=$(basename -- "${EACH}")
				#echo "${PWD}"
				ShlibExecutable "${FILE}"
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Calculating Installed size & inserting into control file if necessary."
				fi
				DEBSIZE=$(du -sx --exclude DEBIAN "${EACH}" | cut -f1 | sed 's/ //g')
				ISIZE=$(grep "Installed-Size: " "${EACH}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "${EACH} is ${DEBSIZE}. Control file reporting: ${ISIZE}"
				fi
				if [[ "${ISIZE}" == "" ]]; then
					if ! [[ "${SUPPRESS}" ]]; then
						Encapsulate "No installed size in the control file inserting: ${DEBSIZE}"
					fi
					echo "Installed-Size: ${DEBSIZE}" >> "${EACH}/DEBIAN/control"
				else
					if [[ "${ISIZE}" != "${DEBSIZE}" ]]; then
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Size Mismatch, replacing with ${DEBSIZE}."
						fi
						sed -i "s/Installed-Size:.*/Installed-Size: ${DEBSIZE}/g" "${EACH}/DEBIAN/control"
					else
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Size indicated in control file is correct."
						fi
					fi
				fi
				if [[ -d "${EACH}" ]]; then
					cd "${EACH}" || exit 1;
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Calculating MD5SUMS in ${EACH}"
				fi
				find -name "DEBIAN" -prune -o -type f -exec md5sum {} + > "DEBIAN/md5sums"
				if [[ -d "${CURRENT}" ]]; then
					cd "${CURRENT}" || exit 1;
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Setting ownership to root in ${EACH}"
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					sudo chown -R "root:root" "${EACH}" & Spinner "Setting ownership to root in ${EACH}."
				else
					sudo chown -R "root:root" "${EACH}"
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Setting individual folder permissions to 755."
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					sudo find "${EACH}/" -type d -exec chmod 755 {} \; & Spinner "Setting individual folder permissions to 755."
				else
					sudo find "${EACH}/" -type d -exec chmod 755 {} \;
				fi
				if [[ -d "${EACH}/DEBIAN/" ]]; then
					cd "${EACH}/DEBIAN/" || exit 1;
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Setting permissions rights for control etc."
				fi
				sudo chmod 755 "*" 2>/dev/null
				sudo chmod 644 "control" 2>/dev/null
				sudo chmod 644 "md5sums" 2>/dev/null
				sudo chmod 644 "conffiles" 2>/dev/null
				sudo chmod 644 "shlibs" 2>/dev/null
				sudo chmod 644 "symbols" 2>/dev/null
				sudo chmod 644 "templates" 2>/dev/null
				sudo chmod 755 "postinst" 2>/dev/null
				sudo chmod 755 "preinst" 2>/dev/null
				sudo chmod 755 "prerm" 2>/dev/null
				sudo chmod 755 "postrm" 2>/dev/null
				if [[ -d "${CURRENT}" ]]; then
					cd "${CURRENT}" || exit 1;
				fi
				if ! [[ "${SUPPRESS}" ]]; then
					Encapsulate "Building ${EACH%/}.deb"
				fi
				BUILDIT=$(dpkg --build "${EACH}" 2>>build.log) & Spinner "Building ${EACH%/}.deb"
				DEB="${EACH%/}"
				DEB+=".deb"
				VERBOSE=$(echo "$@" | grep -- '-V\|verbose')
				QUICK=$(echo "$*" | grep "quick")
				if ! [[ "${QUICK}" ]]; then
					if [[ "${VERBOSE}" ]]; then
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Lintian resulting package ${DEB} in verbose mode."
						fi
						ERRORS=$(lintian --profile=ubuntu -i "${DEB}" 1> "${DEB}.errors" 2>/dev/null)
					else
						if ! [[ "${SUPPRESS}" ]]; then
							Encapsulate "Lintian resulting package ${DEB}."
						fi
						lintian --profile=ubuntu "${DEB}" 1> "${DEB}.errors" 2>/dev/null & Spinner "Lintian resulting package ${DEB}."
					fi
				fi
				# shlib-with-executable-bit
				#FILE=$(basename -- "${EACH}")
				#echo "${PWD}"
				#ShlibExecutable "${FILE}"
				# ERROR / Warning Test mini subroutine.
				# Size = 0 perfect / else pipe appropriately to all_errors.txt / all_warnings.txt (for eventual processing.)
				ERR=0
				WARNINGS=0
				INFORMATION=0
				AERROR=0
				if ! [[ -s "${DEB}.errors" ]]; then
					if [[ -f "${DEB}.errors" ]]; then
						if [[ "${DEBUG}" ]]; then
							echo "DEBUGGING REMOVAL OF FILE: ${DEB}.errors"
							cat "${DEB}.errors"
						fi
						rm "${DEB}.errors"
					fi
				fi
				if [[ "${DEBUG}" ]]; then
					echo "DEBUGGING deb.errors: ${DEB}.errors"
					cat "${DEB}.errors"
				fi

				if [[ -s "${DEB}.errors" ]]; then
					# pre-process errors / warnings
					AERROR=$(grep -o "E: " "${DEB}.errors" | wc -l)
					if [[ "${AERROR}" == 0 ]]; then
						AERROR=$(grep -o "W: " "${DEB}.errors" | wc -l)
					fi
				fi
				if [[ "${AERROR}" == "0" ]]; then
					if [[ -f "${DEB}.errors" ]]; then
						Encapsulate "NFO: tags overridden"
						Encapsulate "No errors or warnings. We will treat this as a perfect deb, we have to trust the programmer."
						Encapsulate "This file will not be reported."
						rm "${DEB}.errors"
					fi
				fi
				if [[ -s "${DEB}.errors" && "${AERROR}" ]]; then
					# pre-process errors / warnings.
					Encapsulate "Processing Error logs for ${DEB}.errors."
					cat "${DEB}.errors" | while read ERRORS
					do
						PREPROCESS=""
						PREPROCESS=$(echo "${ERRORS}" | grep 'E:')
						if [[ "$PREPROCESS" != "" ]]; then
							echo "${ERRORS}" >> "all_errors.txt"
							Error "Error: ${ERRORS} Logged to all_errors.txt."
						fi
						PREPROCESS=""
						PREPROCESS=$(echo "${ERRORS}" | grep 'W:')
						if [[ "$PREPROCESS" != "" ]]; then
							echo "${ERRORS}" >> "all_warnings.txt"
							Encapsulate "Warning: ${ERRORS} Logged to all_warnings.txt."
						fi
					done
				else
					if [[ -f "${DEB}" ]]; then
						Encapsulate "We have built a totally perfect deb."
						Encapsulate "Recursively removing ${EACH} since we have a perfect deb."
						SUCCESS=$(( SUCCESS + 1 ))
						SCRAPIT=$(sudo rm -R "${EACH}" 2>/dev/null)
						Encapsulate "Moving ${DEB} to .debs/"
						if [[ -d "./debs/" ]]; then
							mv "${DEB}" ".debs/" 2>/dev/null
							if [[ -f "${DEB}.errors" ]]; then
								rm "${DEB}.errors"
							fi
						else
							mkdir -p ".debs/"
							mv "${DEB}" ".debs/" 2>/dev/null
							if [[ -f "${DEB}.errors" ]]; then
								rm "${DEB}.errors"
							fi
						fi
						if [[ -f ".debs/${DEB}" ]]; then
							Encapsulate "Success moving file: ${DEB} to .debs/${DEB}"
						else
							Error "Failure moving file: ${DEB} to .debs/${DEB}.  Permission issue? Exiting."
							exit 1;
						fi
					fi
				fi
			fi
		done
	fi

	if [[ -s "all_errors.txt" ]]; then
		TERRORS=$(echo $(wc -l < all_errors.txt))
	fi
	if [[ -s "all_warnings.txt" ]]; then
		TWARN=$(echo $(wc -l < all_warnings.txt))
	fi
	if [[ "${TERRORS}" == "" ]]; then
		TERRORS=0
	fi
	if [[ "${TWARN}" == "" ]]; then
		TWARN=0
	fi
	if [[ "${TERRORS}" || "${TWARN}" ]]; then
		ERRORFILES=(*.errors)
		if [[ "${ERRORFILES[*]}" ]]; then
			FullReport "--suppress"
		else
			if ! [[ "${SUPPRESS}" ]]; then
				Center "We have had 100% error / warning free deb(s) built this session."
			fi
			ClearLogs "--suppress"
		fi
	fi
	if [[ -d ".arch" ]]; then
		chown -R "${IUSER}:${IUSER}" .arch/
	fi
	if [[ -d ".deb" ]]; then
		chown -R "${IUSER}:${IUSER}" .deb/
	fi
}

Homepage () {
	# Parse the control file to set the proper homepage. Programmer set homepage in description.
	# We will put it where it belongs.
	Encapsulate "Striping and setting homepage from the control file."
	CONTROL="${FILE}/DEBIAN/control"
	# the below does not work currently.  We need to strip the url.
	#sed action for urls /[a-zA-Z][a-zA-Z]*:\/\/[a-zA-Z0-9][a-zA-Z0-9\.]*.*/
	HOMEPAGE=$(grep --max-count=1 "http://" "${CONTROL}")
	# Homepage in extended desc a no-no, there is a Homepage: Section for it scrap it from description.
	sed -i '/ Homepage:/d' "${CONTROL}"
	HOMEPAGES=$(grep "Homepage: " "${CONTROL}")
	if [[ "${HOMEPAGES}" != "" ]]; then
		Encapsulate "Homepage is already set as: ${HOMEPAGES}"
	else
		if [[ "$HOMEPAGE" != "" ]]; then
			Encapsulate "No homepage set in control file."
			Encapsulate "Homepage is being set as: ${HOMEPAGE}"
			echo "${HOMEPAGE}" >> "${CONTROL}"
		else
			Encapsulate "There is no way to obtain the homepage from the control file."
			# Perhaps scan manpages / copy-write etc. to try to obtain this INFO automatically.
			# I don't have time for this right now.I may come back to address this later.
			# I love future jobs as you will read in my code ;)Does it mean I will do so?
			# A war will wage in my department.Progression or regression.Fundamentals
			# step in to say yay or neigh.
		fi
	fi
}

Interpreter () {
	# echo "Debugging FILE: ${FILE}"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FTP=$(echo "${ERRORS}" | grep "unusual-interpreter" | cut -d " " -f4)
		if [[ "${FTP}" ]]; then
			SCODE=$(echo "${ERRORS}" | cut -d " " -f5)
			GREPPED=$(echo "${SCODE}" | grep -i '#!')
			if [[ "${GREPPED}" ]]; then
				SCODE=$(echo "${SCODE}" | sed 's/#!//g')
			fi
			if [[ "${DEBUG}" ]]; then
				echo "Debugging: FILE TO PROCESS: ${FTP}"
				echo "Debugging: SCODE: ${SCODE}"
			fi
			sed -i "/${SCODE}/d" "${FILE}/${FTP}"
		fi
	done
}

MimeType () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FTP=$(echo "${ERRORS}" | grep "desktop-mime-but-no-exec-code" | cut -d " " -f4)
		if [[ "${FTP}" && "${FILE}" ]]; then
			SCODE=$(cat "${FILE}/${FTP}" | grep -i 'exec')
			GREPPED=$(echo "${SCODE}" | grep '#!')
			if [[ "${GREPPED}" ]]; then
				SCODE=$(echo "${SCODE}" | sed 's/#!//g')
			fi
			if [[ "${DEBUG}" ]]; then
				echo "Debugging: FILE TO PROCESS: ${FILE}/${FTP}"
				echo "Debugging: SCODE: ${SCODE} %f"
			fi
			sed -i '/^Exec/ s/$/ \%f/' "${FILE}/${FTP}"
		fi
	done
}

Libs () {
	if [[ -f "${FILE}/DEBIAN/shlibs" ]]; then
		rm "${FILE}/DEBIAN/shlibs"
	fi
}

Copyright () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	DATA=$(date -R)
	FOOTER=$(date +"%Y")
	LOCATION="${FILE}/usr/share/doc/${PACKAGENAME}/copyright"
	if [[ "$HOMEPAGE" != "" ]];then
		A="http:$HOMEPAGE"
		HOMEPAGE="$A"
		Encapsulate "Setting homepage as: ${HOMEPAGE}"
	else
		Encapsulate "Setting generic homepage please edit this file: ${LOCATION}"
		HOMEPAGE="<http://please-edit-me.com>"
	fi

	if [[ -f "${LOCATION}" ]]; then
		Encapsulate "Copywrite file exists full of errors?"
	else
		mkdir -p "${FILE}/usr/share/doc/${PACKAGENAME}/"
	fi

	Encapsulate "Creating generic copy-write file: ${LOCATION}, please review & correct."
	sudo echo "This package as well as this file was debianized and autogenerated by ${APPNAME} <${APPNAME}@${APPNAME}.com> on" > "${LOCATION}"
	echo "$DATA" >> "${LOCATION}"
	echo "
	It was downloaded from ${HOMEPAGE}

	Upstream Author:
	" >> "${LOCATION}"
	echo "${MAINTAINER}" >> "${LOCATION}"
	echo "
	Copyright:

	< Copyright (C) ${FOOTER} < ${USERSNAME} >" >> "${LOCATION}"
	echo "

	License:

	This package is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This package is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this package; if not, write to the Free Software
	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA02110-1301 USA

	On Debian systems, the complete text of the GNU General
	Public License can be found in '/usr/share/common-licenses/GPL'.

	The Debian packaging is (C) ${FOOTER}, ${USERSNAME} <${MAINTAINER}> and
	is licensed under the GPL, see above." >> "${LOCATION}"
}

PyScrap () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIP=""
		STRIP=$(echo "${ERRORS}" | grep "package-installs-python-bytecode" | cut -d: -f3 | cut -d" " -f3)
		if [[ "${STRIP}" != "" ]]; then
			Encapsulate "Fixing Error: package-installs-python-bytecode. Removing ${FILE}/${STRIP} which is a unecessary file."
			rm -f "${FILE}/${STRIP}"
		fi
	done
}

Stripcontrol () {
	#This function is not perfect, work needs to be done here.
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "depends-on-obsolete-package depends: " | cut -d: -f4)
		if [[ "${STRIPNAME}" != "" ]]; then
			Encapsulate "Fixing Error: depends-on-obsolete-package ${STRIPNAME}. Removing from control file."
			# Read control file searching for pattern deleting requires ${STRIPNAME}
			# pipe it 3 times first in case it is not the only "requires"
			# second in case no space was used after the comma
			# third a catch all.IE the only requires.
			sed -i "s/, ${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/,${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/${STRIPNAME},//g" "${CONTROL}"
			sed -i '/^$/d' "${CONTROL}"
		fi
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "package-relation-with-perl-modules")
		if [[ "${STRIPNAME}" != "" ]]; then
			Encapsulate "Fixing Error: package-relation-with-perl-modules ${STRIPNAME}. Removing perl-modules from control file."
			# Read control file searching for pattern deleting requires ${STRIPNAME}
			# pipe it 3 times first in case it is not the only "requires"
			# second in case no space was used after the comma
			# third a catch all.IE the only requires.
			STRIPNAME="perl-modules"
			sed -i "s/, ${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/,${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/${STRIPNAME}//g" "${CONTROL}"
			sed -i "s/${STRIPNAME},//g" "${CONTROL}"
			sed -i '/^$/d' "${CONTROL}"
		fi
	done
}

SpellCheck () {
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		STRIPNAME=$(echo "${ERRORS}" | grep "spelling-error-in-description" | cut -d: -f3 | cut -d" " -f3)
		REPLACE=$(echo "${ERRORS}" | grep "spelling-error-in-description" | cut -d: -f3 | cut -d" " -f4)
		if [[ "${STRIPNAME}" ]]; then
			Encapsulate "Replacing word: ${STRIPNAME} with ${REPLACE} in ${CONTROL}"
			sed -i "s|${STRIPNAME}|${REPLACE}|g" "${CONTROL}"
		fi
	done
}

Addcontrol () {
	#This function is not perfect, work needs to be done here.
	CONTROL="${FILE}/DEBIAN/control"
	sed -i '/^$/d' "${CONTROL}"
	ORIGINAL=$(grep "^Depends:" "${CONTROL}" | sed "s/^Depends://g")
	DEPENDS=$(grep "^Depends:" "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
	CHECKIT=$(echo "${ORIGINAL}" | grep ", ${2}")
	if [[ "${CHECKIT}" == "" ]]; then
		if [[ "${DEPENDS}" != "" ]]; then
			STRIPNAME="${ORIGINAL}, ${2}"
			Encapsulate "Original Depends section: ${ORIGINAL}"
			SS="^Depends:.*"
			REPLACEMENT="Depends: ${STRIPNAME}"
			Encapsulate "New dependancy list: ${REPLACEMENT}"
			Encapsulate "Adding dependancy: ${2} to ${CONTROL}"

			sed -i "s/${SS}/${REPLACEMENT}/g" "${CONTROL}"
		else
			Encapsulate "No Depends: section in control file creating section and adding ${2} to the depenancy list."
			echo "Depends: ${2}" >> "${FILE}/DEBIAN/control"
		fi
	else
		Encapsulate "${2} is already in the dependancy list, nothing done. Did you run the fix switch twice w/o re-building?"
	fi
}

Manpages () {
	# Set varibles no matter how many binarys in the package.
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	HOMEPAGE=$(grep --max-count=1 "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	DESCRIPTION=$(grep "Description: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	LOCATION="${FILE}/usr/share/man/man1"
	if [[ "${HOMEPAGE}" != "" ]];then
		A="http:${HOMEPAGE}"
		HOMEPAGE="${A}"
		Encapsulate "Setting homepage as: ${HOMEPAGE}"
	else
		HOMEPAGE="<http://PLEASECHANGEME.COM>"
	fi

	Encapsulate "Scanning for manpages errors."
	grep 'binary-without-manpage' "${FILE}.deb.errors" | while read ERRORS
	do
		# Set Filename for manpage.
		Encapsulate "Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "binary-without-manpage"| cut -d: -f3 | cut -d' ' -f3)
		BASE=$(basename "${STRIPNAME}")
		STRIPNAME="${BASE}"
		APTFILE=$(type -p apt-file)
		if [[ "${APTFILE}" ]]; then
			Encapsulate "Scanning other packages to see if the Author mistakenly placed ${STRIPNAME}.1.gz in another package."
			EXISTS=$(apt-file search ^"${STRIPNAME}.1.gz")
		else
			if [[ "${OSNAME}" ]]; then
				Error "apt-file is not installed: sudo apt-get install apt-file if you want this error type fixed."
			fi
		fi
		if [[ "${EXISTS}" ]]; then
			Encapsulate "FOUND: ${EXISTS}, please report this warning(s) to: ${MAINTAINER}"
			CreateNFO "${FILE}" "${EXISTS}"
		fi
		if [[ -f "${LOCATION}/${STRIPNAME}.gz" ]]; then
			Encapsulate "Manpage ${STRIPNAME} exists full of errors?"
		else
			mkdir -p "${LOCATION}"
		fi
		# Check for man pages if non existent fix it with a generic
		# manpage
		if ! [[ "${EXISTS}" ]]; then
			Encapsulate "Processing: ${STRIPNAME}"
			echo '.\"									  Hey, EMACS: -*- nroff -*-' > "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" First parameter, NAME, should be all caps' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" other parameters are allowed: see man(7), man(1)' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\"' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Some roff macros, for reference:' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .nh		disable hyphenation' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .hy		enable hyphenation' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .ad l	  left justify' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .ad b	  justify to both left and right margins' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .nf		disable filling' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .fi		enable filling' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .br		insert line break' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .sp <n>	insert n+1 empty lines' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" for manpage-specific macros, see man(7)' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Process this file with' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" groff -man -Tascii '${STRIPNAME}'.1' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\"' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.TH '${STRIPNAME}' 1 "'`date +"%B %Y"`'" "Debian/GNU Linux" ""' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH NAME' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${STRIPNAME} - Please edit this file." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH SYNOPSIS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.B '${STRIPNAME} >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH DESCRIPTION' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo ".B ${DESCRIPTION}" >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo ".B ${STRIPNAME} - This manpage was auto-generated using ${APPNAME} <http://${APPNAME}.com/>. Please edit this file." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH OPTIONS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.IP -v' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'Display version number.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.IP -h' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'Show help.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH BUGS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${STRIPNAME} Homepage: ${HOMEPAGE}." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'E-mail bug reports to: '${MAINTAINER}' including this bug.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH AUTHOR' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${MAINTAINER}" >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			gzip -9n "${FILE}/usr/share/man/man1/${STRIPNAME}.1" 2>/dev/null
		fi
	done
	grep 'no-manual-page' "${FILE}.deb.errors" | while read ERRORS
	do
		# Set Filename for manpage.
		Encapsulate "Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "no-manual-page"| cut -d: -f3 | cut -d' ' -f3)
		BASE=$(basename "${STRIPNAME}")
		STRIPNAME="${BASE}"
		APTFILE=$(type -p apt-file)
		if [[ "${APTFILE}" ]]; then
			Encapsulate "Scanning other packages to see if the Author mistakenly placed ${BASE}.1.gz in another package."
			EXISTS=$(apt-file search ^"${STRIPNAME}.1.gz")
		else
			Error "apt-file is not installed: sudo apt-get install apt-file if you want this error type fixed."
		fi
		if [[ "${EXISTS}" ]]; then
			Encapsulate "FOUND: ${EXISTS}, please report this warning(s) to: ${MAINTAINER}"
			CreateNFO "${FILE}" "${EXISTS}"
		fi
		if [[ -f "${LOCATION}/${BASE}.gz" ]]; then
			Encapsulate "Manpage ${BASE} exists full of errors?"
		else
			mkdir -p "${LOCATION}"
		fi
		# Check for man pages if non existent fix it with a generic
		# manpage
		if ! [[ "${EXISTS}" ]]; then
			Encapsulate "Processing: ${BASE}"
			echo '.\"									  Hey, EMACS: -*- nroff -*-' > "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" First parameter, NAME, should be all caps' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" other parameters are allowed: see man(7), man(1)' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\"' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Some roff macros, for reference:' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .nh		disable hyphenation' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .hy		enable hyphenation' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .ad l	  left justify' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .ad b	  justify to both left and right margins' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .nf		disable filling' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .fi		enable filling' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .br		insert line break' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" .sp <n>	insert n+1 empty lines' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" for manpage-specific macros, see man(7)' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" Process this file with' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\" groff -man -Tascii '${STRIPNAME}'.1' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.\"' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.TH '${STRIPNAME}' 1 "'`date +"%B %Y"`'" "Debian/GNU Linux" ""' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH NAME' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${STRIPNAME} - Please edit this file." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH SYNOPSIS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.B '${STRIPNAME} >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH DESCRIPTION' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo ".B ${DESCRIPTION}" >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo ".B ${STRIPNAME} - This manpage was auto-generated using ${APPNAME} <http://${APPNAME}.com/>. Please edit this file." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH OPTIONS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.IP -v' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'Display version number.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.IP -h' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'Show help.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH BUGS' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${STRIPNAME} Homepage: ${HOMEPAGE}." >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo 'E-mail bug reports to: '${MAINTAINER}' including this bug.' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo '.SH AUTHOR' >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			echo "${MAINTAINER}" >> "${FILE}/usr/share/man/man1/${STRIPNAME}.1"
			gzip -9n "${FILE}/usr/share/man/man1/${STRIPNAME}.1" 2>/dev/null
		fi
	done
}

# Compress all manpages.
ManComp () {
	Encapsulate "Extracting all manpages..."
	MANPAGES=$(find "${FILE}/usr/share/man/" -not -name '*.gz' -type f ; 2>/dev/null)
	shopt -s nullglob
	shopt -s dotglob
	SAVEIFS=$IFS
	# Change IFS to new line.
	IFS=$'\n'
	MANPAGES=($MANPAGES)
	IFS="$SAVEIFS"
	for EACH in "${MANPAGES[@]}"
	do
		NONEXT=$(basename -- "${EACH}")
		FILENAME="${NONEXT%.*}"
		PATHTOFILE=$(dirname "${EACH}")
		Encapsulate "FOUND: ${EACH} | BASE: ${PATHTOFILE}/${NONEXT}.gz"
		if [[ -f "${PATHTOFILE}/${NONEXT}.gz" ]]; then
			Encapsulate "${PATHTOFILE}/${NONEXT}.gz exists, removing and re-compressing."
			rm "${PATHTOFILE}/${NONEXT}.gz"
		fi
	done
	Encapsulate "Re-compressing all manpages with maximum compression..."
	find "${FILE}/usr/share/man/" -name '*' -type f -exec gzip -9n '{}' \; 2>/dev/null
	Encapsulate "Cleaning up any straglers."
	find "${FILE}/usr/share/man/" -name '*.1' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.2' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.3' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.4' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.5' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.6' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.7' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.8' -type f -exec rm '{}' \; 2>/dev/null
	find "${FILE}/usr/share/man/" -name '*.9' -type f -exec rm '{}' \; 2>/dev/null
}

Scrap () {
	# Set varibles no matter how many binarys in package.
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	cat "${FILE}.deb.errors" | grep 'extra-license-file' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		FIQ=$(echo "${ERRORS}" | grep "extra-license-file" | cut -d: -f3 | sed 's/extra-license-file//g')
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "extra-license-file"| cut -d: -f2 | sed 's/ //g')
		BASE=$(basename "${STRIPNAME}")
		STRIPNAME="${BASE}"
		Encapsulate "Deleting... ${FILE}/${FIQ}"
		rm "${FILE}/${FIQ}" 2>/dev/null
		ERR=$(( ERR + 1 ))
		Encapsulate "extra-license-file warning(s) fixed."
	done
	#Extra control files.
	cat "${FILE}.deb.errors" | grep 'unknown-control-file' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "unknown-control-file"| cut -d: -f3 | sed 's/unknown-control-file//g' | sed 's/ //g')
		Encapsulate "Deleting... ${FILE}/DEBIAN/${STRIPNAME}"
		rm "${FILE}/DEBIAN/${STRIPNAME}" 2>/dev/null
		ERR=$(( ERR + 1 ))
		Encapsulate "unknown-control-file(s) warning fixed."
	done
	#Extra git svn file(s).
	cat "${FILE}.deb.errors" | grep 'package-contains-vcs-control-file' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "package-contains-vcs-control-file"| cut -d: -f3 | sed 's/package-contains-vcs-control-file//g' | sed 's/ //g')
		Encapsulate "Deleting... ${FILE}/${STRIPNAME}"
		rm "${FILE}/${STRIPNAME}" 2>/dev/null
		ERR=$(( ERR + 1 ))
		Encapsulate "package-contains-vcs-control-file(s) warning fixed."
	done
	#Extra git svn folder(s).
	cat "${FILE}.deb.errors" | grep 'package-contains-vcs-control-dir' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "package-contains-vcs-control-dir"| cut -d: -f3 | sed 's/package-contains-vcs-control-dir//g' | sed 's/ //g')
		Encapsulate "Deleting folder ${FILE}/${STRIPNAME}"
		rm -R "${FILE}/${STRIPNAME:?}" 2>/dev/null
		ERR=$(( ERR + 1 ))
		Encapsulate "package-contains-vcs-control-dir warning(s) fixed."
	done
	#Windows Thumbnail file(s).
	cat "${FILE}.deb.errors" | grep 'windows-thumbnail-database-in-package' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "windows-thumbnail-database-in-package"| cut -d: -f3 | sed 's/windows-thumbnail-database-in-package//g' | sed 's/ //g')
		Encapsulate "Deleting... ${FILE}/${STRIPNAME}"
		rm "${FILE}/${STRIPNAME}" 2>/dev/null
		find "${FILE}/" -name 'Thumbs.db' -type f -exec rm -f {} \;
		ERR=$(( ERR + 1 ))
		Encapsulate "windows-thumbnail-database-in-package warning (s) fixed."
	done
	#Mac Thumbnail file(s).
	cat "${FILE}.deb.errors" | grep 'macos-ds-store-file-in-package' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "macos-ds-store-file-in-package"| cut -d: -f3 | sed 's/macos-ds-store-file-in-package//g' | sed 's/ //g')
		Encapsulate "Deleting... ${FILE}/${STRIPNAME}"
		rm "${FILE}/${STRIPNAME}" 2>/dev/null
		#find ${FILE}/ -name '.DS_Store' -type f -exec rm -f {} \;
		ERR=$(( ERR + 1 ))
		Encapsulate "macos-ds-store-file-in-package warning(s) fixed."
	done
	#Empty Control file(s).
	cat "${FILE}.deb.errors" | grep 'control-file-is-empty' | while read ERRORS
	do
		# Find file in QUEStion.
		Encapsulate "Fixing Warning: ${ERRORS}"
		STRIPNAME=""
		STRIPNAME=$(echo "${ERRORS}" | grep "control-file-is-empty"| cut -d: -f3 | sed 's/control-file-is-empty//g' | sed 's/ //g')
		Encapsulate "Deleting... ${FILE}/DEBIAN/${STRIPNAME}"
		rm "${FILE}/DEBIAN/${STRIPNAME}" 2>/dev/null
		ERR=$(( ERR + 1 ))
		Encapsulate "control-file-is-empty warning(s) fixed."
	done

}

TarRecompress () {
	FILETYPES=( "gzip" "tar");
	ARCHIVE=();
	INFOLDER="${PWD}"
	if [[ -f "${FILE}/DEBIAN/control" ]]; then
		PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
		Encapsulate "Packagename found: ${PACKAGENAME}"
	fi
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FTP=$(echo "${ERRORS}" | grep "package-contains-timestamped-gzip" | cut -d " " -f4)
		if [[ -f "${FILE}/${FTP}" ]]; then
			DIR=$(dirname "${FTP}")
			FILENAME=$(basename "${FTP}")
			FILENAME=$(basename -- "${FTP}")
			EXTENSION="${FILENAME##*.}"
			FILENAME="${FILENAME%.*}"
			TYPEFILE=$(echo "${FILENAME}" | grep ".tar")
			if ! [[ "${TYPEFILE}" ]]; then
				TYPEFILE="gz"
			fi
			if ! [[ "${TYPEFILE}" ]]; then
				TYPEFILE="tar"
			fi
			if [[ "${DEBUG}" ]]; then
				echo "DEBUG DIR: ${DIR}"
				echo "DEBUG FILENAME: ${FILENAME}"
				echo "DEBUG EXTENSION: ${EXTENSION}"
				echo "DEBUG TYPEFILE: ${TYPEFILE}"
			fi
			if [[ -d "${FILE}/${DIR}/" ]]; then
				Encapsulate "Changing directory to: ${FILE}/${DIR}/"
				cd "${FILE}/${DIR}/" || exit 1;
			fi
			Encapsulate "Extracting: ${FILENAME}.${EXTENSION} in ${PWD}"
			if [[ "${TYPEFILE}" == "gz" ]]; then
				ARCHIVE=$(gunzip "${FILENAME}.${EXTENSION}") 2>/dev/null
				if [[ -f "${FILENAME}.${EXTENSION}" ]]; then
					Encapsulate "Removing old Gzipped Manual."
					rm "${FILENAME}.${EXTENSION}"
				fi
				if [[ -f "${FILENAME}" ]]; then
					Encapsulate "Compressng ${FILENAME}"
					gzip -9n "${FILENAME}"
				else
					Error "File not found ${FILENAME} in ${PWD}".
				fi
			else
				if [[ -f "${FILENAME}.${EXTENSION}" ]]; then
					Encapsulate "Removing old Tar based file."
					rm "${FILENAME}.${EXTENSION}"
					Encapsulate "Recompressing: ${FILENAME}.${EXTENSION}"
					tar xfv "${FILENAME}.${EXTENSION}"
				fi
			fi
			cd "${INFOLDER}" || exit 1;
		fi
	done
}

ChangeCompress () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	if [[ "${CURRENT}" ]]; then
		cd "${CURRENT}" || exit 1;
	fi
	if [[ "${PACKAGENAME}" ]]; then
		LOCATION="${FILE}/usr/share/doc/${PACKAGENAME}/"
	else
		Error "ERROR: No packagename detected."
		exit 1;
	fi
	if [[ -d "${LOCATION}" ]]; then
		cd "${LOCATION}" || exit 1;
	fi
	#Changelog
	declare -a VALIDCLOGS=("changelog" "changelog.Debian");
	SUCCESS=""
	for EACH in "${VALIDCLOGS[@]}"
	do
		CHANGELOG="${EACH}"
		Encapsulate "Scanning for Changelog: ${EACH}"
		if [[ -f "${CHANGELOG}" ]]; then
			if [[ -f "${CHANGELOG}.gz" ]]; then
				rm "${CHANGELOG}.gz" 2>/dev/null
			fi
			if [[ "${CHANGELOG}" == "changelog.Debian" ]]; then
				Encapsulate "Renaming ${CHANGELOG} to changelog"
				mv "${CHANGELOG}" "changelog"
			fi
			Encapsulate "Found changelog, compressing."
			SUCCESS=$(gzip -9n -f "changelog") 2>/dev/null
			CHANGE=1
			# Encapsulate "Renaming changelog.gz to changelog.Debian.gz"
			# mv "changelog.gz" "changelog.Debian.gz"
		else
			Encapsulate "${CHANGELOG} not found."
		fi
	done
	if [[ "${SUCCESS}" ]]; then
		Encapsulate "Changelog compression fixed."
	fi
	if [[ -d "${CURRENT}" ]]; then
		cd "${CURRENT}" || exit 1;
	fi
}

Gameit () {
	CONTROL="${FILE}/DEBIAN/control"
	SECTION=$(grep "Section: " "${CONTROL}" | cut -d: -f2)
	if [[ "${SECTION}" != "" ]]; then
		NEWSECTION="games"
		Encapsulate "Original section: ${SECTION}"
		Encapsulate "New Section: ${NEWSECTION}"
		Encapsulate "Replacing: ${SECTION} to ${NEWSECTION}"
		sed -i "s|${SECTION}|${NEWSECTION}|g" "${CONTROL}"
		ERR=$(( ERR + 1 ))
	fi
}

ScrapChangeLog () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	#Changelog
	declare -a VALIDCLOGS=("${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian.gz");
	for EACH in "${VALIDCLOGS[@]}"
	do
		CHANGELOG="${EACH}"
		Encapsulate "Scanning for existing ${CHANGELOG}:"
		if [[ -f "${CHANGELOG}" ]]; then
			Encapsulate "Found, ${CHANGELOG} deleting..."
			rm -f "${CHANGELOG}" 2>/dev/null
		fi
	done
}

ExtractChangeLog () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	#Changelog
	declare -a VALIDCLOGS=("${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian.gz");
	for EACH in "${VALIDCLOGS[@]}"
	do
		CHANGELOG="${EACH}"
		Encapsulate "Scanning for existing ${CHANGELOG}:"
		if [[ -f "${CHANGELOG}" ]]; then
			Encapsulate "Found, ${CHANGELOG} extracting..."
			SUCCESS=$(gunzip "${CHANGELOG}")
		fi
	done
}

Changelog () {
	THEDATE=$(date -R)
	# Create a Generic changelog & prompt user to please review / fix.
	# Set varibles no matter how many binarys in package.
	# Strip trailing slash if necessary and replace it, we must be sure.
	cd "${CURRENT}" || exit 1;
	FOLDER="${FILE%%/}"
	FILE="${FOLDER}"
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	if [[ -d "${FILE}/usr/share/doc/${PACKAGENAME}/" ]]; then
		Encapsulate "Directory exists."
	else
		Encapsulate "Creating documentation folder: ${FILE}/usr/share/doc/${PACKAGENAME}/"
		Encapsulate "Populating package with Generic documentation, please review folder above."
		mkdir -p "${FILE}/usr/share/doc/${PACKAGENAME}/"
	fi
	# TODO add checking for existance - either correct or destroy and create new.
	# amazing, how many 1000's of errors disapear because of this short sub-routine.
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/^[ \t]*//;s/[ \t]*$//')
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	LOCATION="${FILE}/usr/share/doc/${PACKAGENAME}"
	if ! [[ "${LOCATION}" ]]; then
		mkdir -p "${LOCATION}"
	fi
	if [[ "${HOMEPAGE}" != "" ]];then
		A="http:${HOMEPAGE}"
		HOMEPAGE="${A}"
		Encapsulate "Setting homepage as: ${HOMEPAGE}"
	else
		HOMEPAGE="<http://PLEASECHANGEME.COM>"
	fi

	echo "${PACKAGENAME}"' ('$PVERSION') unstable; urgency=low' > "${LOCATION}/changelog.Debian"
	echo "" >> "${LOCATION}/changelog.Debian"
	echo "  * Initial Release." >> "${LOCATION}/changelog.Debian"
	echo -n "  * Changelog missing: " >> "${LOCATION}/changelog.Debian"
	if [[ "${MAINTAINER}" ]]; then
		echo " ${MAINTAINER}." >> "${LOCATION}/changelog.Debian"
	else
		echo "." >> "${LOCATION}/changelog.Debian"
	fi
	echo "  * ${MAINTAINER}." >> "${LOCATION}/changelog.Debian"
	echo "  * This file was auto generated via ${APPNAME}." >> "${LOCATION}/changelog.Debian"
	echo "  * Please review http://${APPNAME}.com/ for more information." >> "${LOCATION}/changelog.Debian"
	echo "  * Closes: Bug#99999." >> "${LOCATION}/changelog.Debian"
	echo "" >> "${LOCATION}/changelog.Debian"
	echo " -- ${MAINTAINER}  ${THEDATE}" >> "${LOCATION}/changelog.Debian"
	if [[ -d "${CURRENT}}" ]]; then
		cd "${CURRENT}" || exit 1;
	fi
	ERR=$(( ERR + 1 ))
	ChangeCompress
}

Description () {
	#Description of package Starts with packagename example frostwire's description:
	#FrostWire is a high quality, FREE peer-to-peer application.
	#Should be: High quality, FREE peer-to-peer application.
	#Parse and replace, this function will probably a large section of programming to catch all.
	#I will be using many debs to bring a means to an end.
	CONTROL="${FILE}/DEBIAN/control"
	ODESC=$(cat "${CONTROL}" | grep --max-count=1 "Description: " | cut -d: -f2)
	NDESC=$(cat "${CONTROL}" | grep --max-count=1 "Description: " | cut -d: -f2 | tr 'A-Z' 'a-z')
	PACKAGENAME=$(cat "${CONTROL}" | grep "Package: " | cut -d: -f2 | tr 'A-Z' 'a-z' | sed 's/ //g')
	Encapsulate "Original Description: ${ODESC}"
	#echo "FILE EFFECTED:${FILE}" >> DESC.TXT
	#echo "DESCRIPTION:$DESC" >> DESC.TXT
	#echo "PACKAGENAME:${PACKAGENAME}" >> DESC.TXT
	#echo "=========================" >> DESC.TXT
	#perhaps a case statement would simplfiy / accelerate this section.
	#DESC=$(echo $NDESC | sed 's/ ${PACKAGENAME}/${PACKAGENAME}/g')
	#REPLACEMENT=$(echo $DESC | sed "s/${PACKAGENAME} - //g")
	#REPLACEMENT=$(echo $DESC | sed "s/${PACKAGENAME} is an //g")
	#REPLACEMENT=$(echo $NDESC | sed "s/${PACKAGENAME} is a //g")
	ISSUE=""
	if [[ "${#ODESC}" != "${#REPLACEMENT}" && "${#REPLACEMENT}" != "0" ]];then
		#if [[ ${REPLACEMENT} != $DESC ]]; then
		Encapsulate "Replacing with: ${REPLACEMENT}"
		sed -i "s|${ODESC}|${REPLACEMENT}|" "${CONTROL}"
		ISSUE=1
	fi
	# is an
	REPLACEMENT=$(echo "${NDESC}" | sed "s/${PACKAGENAME} is an //g")
	if [[ "${#ODESC}" != "${#REPLACEMENT}" && "${#REPLACEMENT}" != "0" ]];then
		#if [[ ${REPLACEMENT} != $DESC ]]; then
		ISSUE=1
		Encapsulate "Replacing with: ${REPLACEMENT}"
		sed -i "s|${ODESC}|${REPLACEMENT}|" "${CONTROL}"
	fi
	if [[ "${ISSUE}" != "" ]]; then
		Encapsulate "This issue can be fixed by manually editing"
		Encapsulate "nano ${CONTROL} Description: section"
		Encapsulate "Please do not start the description with ${PACKAGENAME}."
	fi
}

ExtendDescription () {
	CONTROL="${FILE}/DEBIAN/control"
	DESC=$(grep --max-count=1 "Description: " "${CONTROL}" | cut -d: -f2)
	PACKAGENAME=$(grep "Package: " "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${CONTROL}" | cut -d: -f2)
	PVERSION=$(grep --max-count=1 "Version: " "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
	Encapsulate "Original description: ${DESC}"
	#sed -i "s/^ /d" ${CONTROL}
	sed -i '/^ /d' "${CONTROL}"
	sed -i '/^$/d' "${CONTROL}"
	Encapsulate "New Description: This package contained no extended or errored description"
	Encapsulate "this was inserted by the ${APPNAME} to bring"
	Encapsulate "to ${MAINTAINER} attention."
	Encapsulate "Please contact the above to report this error."
	#sed -i '/^Description:/d' "${CONTROL}"
	#echo "Description:$DESC" >> "${CONTROL}"
	echo " This package contained no extended or errored description" >> "${CONTROL}"
	echo " this was inserted by ${APPNAME} to bring" >> "${CONTROL}"
	echo " to ${MAINTAINER} attention." >> "${CONTROL}"
	echo " Please contact the above to report this error." >> "${CONTROL}"
}

Maintainer () {
	CONTROL="${FILE}/DEBIAN/control"
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	LOCATION="${FILE}/usr/share/doc/${PACKAGENAME}/"
	Encapsulate "Original Maintainer: ${USERSNAME}"
	REPLACEMENT="${USERSNAME} Unknown"
	Encapsulate "Replaced by ${REPLACEMENT}"
	sed -i "s|${USERSNAME}|${REPLACEMENT}|" "${CONTROL}"
}

AddEntry () {
	THEDATE=$(date -R)
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
	PVERSION=$(grep --max-count=1 "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	LOCATION="${FILE}/usr/share/doc/${PACKAGENAME}/"
	echo "Extracting changlog: ${LOCATION}/changelog.gz"
	gzip -d "${LOCATION}/changelog.gz"
	echo "Re-writing changelog."
	echo "${PACKAGENAME} (${PVERSION}) unstable; urgency=low" > "${LOCATION}/cl.log"
	echo "
	* Package built by ${APPNAME} please contact author listed below it has errors / warnings.

	-- ${MAINTAINER} ${THEDATE}." >> "${LOCATION}/cl.log"
	#cat "${LOCATION}/cl.log"
	echo "

	" >> "${LOCATION}/cl.log"
	Encapsulate "Removing to original changelog."
	rm "${LOCATION}/changelog" 2>/dev/null
	Encapsulate "Moving new changelog into place and re-compressing."
	mv "${LOCATION}/cl.log" "${LOCATION}/changelog"
	gzip -9nc "${LOCATION}/changelog" 2>/dev/null
	Encapsulate "Homepage: ${HOMEPAGE}"
	Encapsulate "Version: ${PVERSION}"
	Encapsulate "Username:${USERSNAME}"
	Encapsulate "Location: ${LOCATION}"
}

UnknownSection () {
	CONTROL="${FILE}/DEBIAN/control"
	SECTION=$(grep "Section: " "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
	Encapsulate "Original Section: ${SECTION}"
	REPLACEMENT="gnome"
	Encapsulate "Replaced by: ${REPLACEMENT}"
	sed -i "s|${SECTION}|${REPLACEMENT}|" "${CONTROL}"
}

#Version scan debs prior to extraction ensure we are not processing
#extras
Scan () {
	shopt -s nullglob
	declare -a DEBS=();
	declare -a SCRAP=();
	declare -a SUBFOLDERS=();
	declare -i NDEBS
	INFOLDER="${PWD}"
	echo -e -n "${TXTGRN}"
	Center "Repostorm ${REPOVERSION} is entering scan mode."
	echo -e -n "${TXTRST}"
	if ! [[ -d "${2}" ]]; then
		Error "Error: Please provide folder to process. Example: ${APPNAME} -s wip/"
		Help scan
		exit 0;
	fi
	if [[ "${2}" == "" ]]; then
		Error "Please provide folder to process. Example: ${APPNAME} -s wip/"
		Help scan
		exit 0;
	else
		if [[ -d "${2}" ]]; then
			cd "${2}" || exit 1;
			DEBS=(./*.deb)
			NDEBS="${#DEBS[@]}"
			Encapsulate "DEB(s) Detected: ${NDEBS}"
			FullBar
			Encapsulate "Version scanning packages in ${2}.This may take a few minutes, depending"
			Encapsulate "on how many deb(s) are involved and speed of your computer. This process"
			Encapsulate "may cycle many times depending on errors in debs. It will fix them"
			Encapsulate "individually and begin scanning again until zero control errors are met."
			Encapsulate "${APPNAME} will then proceed to stage 2: Error scanning / Version scanning X 2."
			Encapsulate "In case multiple versions of the same app exist, only one will be left behind."
			Encapsulate "Entering Stage 1: Version Scanning."
			FullBar
			cd "${INFOLDER}" || exit 1;
		else
			Error "No debs in folder to process. Example: ${APPNAME} -s wip/"
			Encapsulate "Folder: ${2} does not contain any debs to process."
			exit 1;
		fi
		FOLDER="${2%%/}"
		SCRAP=$(scanpackages "${2}/" 2>&1 | grep "is repeat;" | cut -d ":" -f3 | cut -d "(" -f2 | cut -d " " -f2 | sed "s/)//g" > "${2}/scrap.txt")
		if [[ -s "${2}/scrap.txt" ]]; then
			while read FILEZ; do
				if [[ -f "${FILEZ}" ]]; then
					Encapsulate "Removing: ${FILEZ}, newer version of deb detected."
					rm "${FILEZ}" 2>&1
				else
					Error "Does not exist: ${FILEZ}."
				fi
			done < "${2}/scrap.txt"
			rm "${2}/scrap.txt" 2>&1
			FullBar
		else
			Encapsulate "Congradulations, singular version at stage 1 of each deb rectified."
			FullBar
		fi
		Encapsulate "Entering Stage 2: Error scanning / version scanning(2), please wait..."
		SCRAP=$(scanpackages "${2}/" 2>&1 | grep "ignored data from" | cut -d ":" -f3 | cut -d " " -f9 | sed "s/\!//g" > "${2}/scrap.txt")
		if [[ -s "${2}/scrap.txt" ]]; then
			while read FILEZ; do
				if [[ -f "${FILE}Z" ]]; then
					Encapsulate "Removing: ${FILEZ}, newer version of deb detected."
					rm "${FILEZ}" 2>&1
				else
					Error "Does not exist: ${FILEZ}."
				fi
			done < "${2}/scrap.txt"
			rm "${2}/scrap.txt" 2>&1
			FullBar
		else
			Encapsulate "Congradulations, singular version at stage 2 of each deb(s) rectified."
			FullBar
		fi
		exit 0;
		BIGERROR=$(scanpackages "${FOLDER}" 2>&1 | cut -d: -f3 | sed '/^ Package/d' | sed '/^ ignored/d' | sed '/^ used that one and/d' | sed 's/ syntax error in //g' | sed 's/ at line /:/g' | awk -F "/" '{ print ${2} }')
		if [[ "$BIGERROR" == "" ]]; then
			Encapsulate "No errors in debs continuing to stage 2."
			Encapsulate "Stage 2: Version control scanning.${TXTRED}"
			#scanpackages ${2} 2>&1 | cut -d: -f3 | sed "s/) is repeat;//g" | sed "/!/d" | sed "s/Package //g" | sed "s/*\/\///g" | awk -F"filename ${2}/" '{ print ${2} }' > ${2}/scrap.txt
			scanpackages "${2}/" 2>&1 | cut -d: -f3 | sed "/^ ignored and deleted that one and using data from*/d" | sed "/ Package is repeat but newer version;/d" | sed "s/ used that one and ignored data from //g" | awk -F "${2}" '{ print ${2} }' | sed "s/) is repeat;//g" | sed 's/!//g' | sed '/^$/d' > ${2}/scrap.txt
			cat "${FOLDER}/scrap.txt" | while read ERRORS
			do
				rm "${FOLDER}/${ERRORS}"
				Encapsulate "Deleting older package: ${2}/${ERRORS}."
			done
			rm "${FOLDER}/scrap.txt" 2>/dev/null
			Encapsulate "Please Change directory to ${FOLDER}/ so you can begin extraction."
			Encapsulate "Version control function complete. Please execute ${APPNAME} -e [DEB]"
			Encapsulate "man ${APPNAME} for more information."
			rm "${FOLDER}/tmp.txt" 2>/dev/null
			rm "${FOLDER}/all_errors.txt" 2>/dev/null
			rm "${FOLDER}/all_warnings.txt" 2>/dev/null
			rm "${FOLDER}/*.errors" 2>/dev/null
			rm "${FOLDER}/tar.log" 2>/dev/null
			exit 0;
		else
			declare -i SLEN
			declare -i RLEN
			SLEN=$(echo "${#BIGERROR}")
			SS=$(echo "${BIGERROR}" | sed "s/.deb //g")
			RLEN=$(echo "${#SS}")
			if [ "${SLEN}" == "${RLEN}" ]; then
				EFILE=$(echo "${BIGERROR}" | cut -d: -f1)
				ELINE=$(echo "${BIGERROR}" | cut -d: -f2)
				Encapsulate "Error in deb: ${EFILE} at line ${ELINE}."
				echo "Attempting to autofix ${EFILE}: Extracting deb, deleting line ${ELINE} and rebuilding."
				REVERT="${PWD}"
				echo "Entering ${FOLDER}/ for extraction, fix and build."
				cd "${FOLDER}/" || exit 1;
				Extract -e "${EFILE}"
				BUILDD=$(echo "${EFILE}" | sed 's/.deb//g')
				echo "Deleting line ${ELINE} from ${BUILDD}/DEBIAN/control."
				ZLINE=$(echo "${ELINE}")
				sed -i "${ZLINE}" "${BUILDD}/DEBIAN/control"
				echo "Rebuilding. We can ignore errors at this stage -f or"
				echo "--fix routine will fix them later."
				Build -b "${BUILDD}/"
				echo "Scraping folder: ${BUILDD}"
				sudo rm -R "${BUILDD}/"
				echo "Reverting to ${REVERT} for further examination."
				cd "${REVERT}" || exit 1;
				Scan -s "${2}"
			fi
			Encapsulate "No errors in debs continuing to stage 2."
			Encapsulate "Stage 2: Version control scanning.${TXTRED}"
			#scanpackages ${2} 2>&1 | cut -d: -f3 | sed "s/) is repeat;//g" | sed "/!/d" | sed "s/Package //g" | sed "s/*\/\///g" | awk -F"filename ${2}/" '{ print ${2} }' > ${2}/scrap.txt
			scanpackages "${2}/" 2>&1 | cut -d: -f3 | sed "/^ ignored and deleted that one and using data from*/d" | sed "/ Package is repeat but newer version;/d" | sed "s/ used that one and ignored data from //g" | awk -F "${FOLDER}" '{ print ${2} }' | sed "s/) is repeat;//g" | sed 's/!//g' | sed '/^$/d' > "${2}/scrap.txt"
			cat "${FOLDER}/scrap.txt" | while read ERRORS
			do
				rm "${FOLDER}/${ERRORS}"
				Encapsulate "Deleting older package: ${FOLDER}/${ERRORS}."
			done
			rm "${FOLDER}/scrap.txt" 2>/dev/null
			Encapsulate "Please Change directory to ${FOLDER}/ so you can begin extraction."
			Encapsulate "Version control function complete. Please execute ${APPNAME} -e [DEB]"
			Encapsulate "man ${APPNAME} for more information."
			rm "${FOLDER}/tmp.txt" 2>/dev/null
			rm "${FOLDER}/all_errors.txt" 2>/dev/null
			rm "${FOLDER}/all_warnings.txt" 2>/dev/null
			rm "${FOLDER}/*.errors" 2>/dev/null
			rm "${FOLDER}/tar.log" 2>/dev/null
			exit 0;
		fi
	fi
	Encapsulate "Please Change directory to ${FOLDER}/ so you can begin extraction."
	Encapsulate "Version control function complete. Please execute ${APPNAME} -e [DEB]"
	Encapsulate "man ${APPNAME} for more information."
	rm "${FOLDER}/tmp.txt" 2>/dev/null
	rm "${FOLDER}/all_errors.txt" 2>/dev/null
	rm "${FOLDER}/all_warnings.txt" 2>/dev/null
	rm "${FOLDER}/*.errors" 2>/dev/null
	rm "${FOLDER}/tar.log" 2>/dev/null
}

WrongName () {
	STRIPNAME=$(grep "wrong-name-for-upstream-changelog" "${FILE}.deb.errors" | cut -d: -f3 | sed 's/wrong-name-for-upstream-changelog//g' | sed 's/ //g')
	PACKAGENAME=$(grep "Package: " "${FILE}.deb.errors" | cut -d: -f2 | sed 's/ //g')
	FILENAME=$(basename -- "${STRIPNAME}")
	EXTENSION="${FILENAME##*.}"
	if [[ "${EXTENSION}" ]]; then
		CHANGELOG="${FILE}/usr/share/doc/${PACKAGENAME}/changelog.${EXTENSION}"
		GREPIT=$(echo "${EXTENSION}" | grep "gz")
		if [[ "${GREPIT}" ]]; then
			ExtractChangeLog "${FILE}"
		fi
	else
		CHANGELOG="${FILE}/usr/share/doc/${PACKAGENAME}/changelog"
	fi
	if [[ -f "${FILE}/usr/share/doc/changelog.gz" ]]; then
		Encapsulate "Changelog exists. Scraping unnecessary file."
		rm "${STRIPNAME}"
	else
		if [[ "${EXTENSION}" == "" && -f "${STRIPNAME}" ]];then
			Encapsulate "Renaming ${STRIPNAME} to changelog and recompressing."
			mv "${FILE}/${STRIPNAME}" "${CHANGELOG}"
			ChangeCompress "${FILE}"
		fi
	fi
}

ChangeRename () {
	STRIPNAME=$(grep "wrong-name-for-changelog-of-native-package" "${FILE}.deb.errors" | cut -d: -f3 | sed 's/wrong-name-for-changelog-of-native-package//g' | sed 's/ //g')
	PACKAGENAME=$(grep "Package: " "${FILE}.deb.errors" | cut -d: -f2 | sed 's/ //g')
	CHANGELOG="${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz"
	if [[ -f "${FILE}/${STRIPNAME}" ]]; then
		Encapsulate "Renaming ${STRIPNAME} to changelog.gz"
		mv "${FILE}/${STRIPNAME}" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz"
	fi
}

InvalidEmail () {
	FILE="${1}"
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	PVERSION=$(grep "Version: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
	USERSNAME=$(echo "${MAINTAINER}" | sed -e 's/<[^>]*>//g')
	STRIPNAME=$(grep "debian-changelog-file-contains-invalid-email-address" "${FILE}.deb.errors" | cut -d: -f3 | sed 's/debian-changelog-file-contains-invalid-email-address//g' | sed 's/ //g')
	# Control file
	AT=$(echo "${STRIPNAME}" | grep '@')
	GT=$(echo "${STRIPNAME}" | grep '>')
	LT=$(echo "${STRIPNAME}" | grep '<')
	if ! [[ "${LT}" ]]; then
		LT="<"
		REPLACE="<${STRIPNAME}"
		Encapsulate "Inserting less then symbol: ${REPLACE}"
	fi

	if [[ "${AT}" && "${GT}" && "${LT}" ]]; then
		Encapsulate "No .com / .net etc. in address assuming .com entry."
		REPLACE=$(echo "${STRIPNAME}" | sed "s/\>/.com\>/g" )
		#sed -i "s/${STRIPNAME}/${REPLACE}/g"${FILE}/DEBIAN/control
	fi
	GREPIT=$(echo "${REPLACE}" | grep "\.")
	if ! [[ "${GREPIT}" ]]; then
		Encapsulate "No .com / .net etc. in address assuming .com entry."
		REPLACE="${REPLACE}.com"
	fi
	if ! [[ "${GT}" ]]; then
		GT=">"
		REPLACE="${REPLACE}>"
		Encapsulate "Inserting greater then symbol: ${REPLACE}"
	fi
	if [[ "${STRIPNAME}" ]]; then
		#Changelog
		declare -a VALIDCLOGS=("${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian.gz");
		for EACH in "${VALIDCLOGS[@]}"
		do
			CHANGELOG="${EACH}"
			Encapsulate "Scanning for existing ${CHANGELOG}:"
			if [[ -f "${CHANGELOG}" ]]; then
				Encapsulate "Found, extracting..."
				SUCCESS=$(gzip -d "${CHANGELOG}")
				if [[ -f "${FILE}/usr/share/doc/${PACKAGENAME}/changelog" ]]; then
					Encapsulate "Processing: ${CHANGELOG}"
					Encapsulate "SEARCH:${STRIPNAME} | REPLACE:${REPLACE} in ${CHANGELOG}"
					sed -i "s|${STRIPNAME}|${REPLACE}|g" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog"
					Encapsulate "DEBUGGING: Resulting Changelog"
					cat "${FILE}/usr/share/doc/${PACKAGENAME}/changelog"
					Encapsulate "Recompressing Changelog."
					ChangeCompress "${FILE}"
				fi
				if [[ -f "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian" ]]; then
					Encapsulate "Processing: ${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian"
					if [[ "${DEBUG}" ]]; then
						echo "SEARCH:${STRIPNAME} | REPLACE:${REPLACE}"
					fi
					sed -i "s|${STRIPNAME}|${REPLACE}|g" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian"
					Encapsulate "DEBUGGING: Resulting Changelog"
					cat "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian"
					ChangeCompress "${FILE}"
				fi
			else
				Error "Changelog:${CHANGELOG} not found."
			fi
		done
	fi
}

UseLess () {
	FILE="${1}"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		#echo "PROCESSING LINE: ${ERRORS}"
		STRIPNAME=$(echo "${ERRORS}" | grep "non-empty-dependency_libs-in-la-file" | cut -d: -f3 | sed 's/non-empty-dependency_libs-in-la-file//g' | sed 's/ //g')
		if [[ "${STRIPNAME}" ]]; then
			if [[ -f "${FILE}/${STRIPNAME}" ]]; then
				Encapsulate "Scrapping useless file ${FILE}/${STRIPNAME}"
				rm -f "${FILE}/${STRIPNAME}"
			else
				Error "ERROR: File ${FILE}/${STRIPNAME} does not exist, already repaired?"
			fi
		fi
	done
}

REGZIP () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		#echo "PROCESSING LINE: ${ERRORS}"
		STRIPNAME=$(echo "${ERRORS}" | grep "package-contains-timestamped-gzip" | cut -d: -f3 | sed 's/package-contains-timestamped-gzip//g' | sed 's/ //g')
		if [[ "${STRIPNAME}" ]]; then
			if [[ -f "${FILE}/${STRIPNAME}" ]]; then
				Encapsulate "Decompressing: ${FILE}/${STRIPNAME}:"
				gzip -d "${FILE}/${STRIPNAME}"
				Encapsulate "Done."
				Encapsulate "Re-compressing Changelog: ${FILE}/${STRIPNAME}"
				ChangeCompress
			else
				Error "ERROR: File ${FILE}/${STRIPNAME} does not exist, already repaired?"
			fi
		fi
	done
}

FSF () {
	CONTROL="${FILE}/DEBIAN/control"
	PACKAGENAME=$(grep "Package: " "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
	REPLACEMENT="51 Franklin St, Fifth Floor, Boston, MA  02110-1301"
	SS="59 Temple Place, Suite 330, Boston, MA 02111-1307"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "old-fsf-address-in-copyright-file")
		if [[ "${SCRIPT}" ]]; then
			GREPIT=$(grep "${SS}" "${FILE}/usr/share/doc/${PACKAGENAME}/copyright")
			if [[ "${GREPIT}" ]]; then
				Encapsulate "Searching for ${SS} Replacing Address: ${REPLACEMENT}"
				sed -i "s/${SS}/${REPLACEMENT}/g" "${FILE}/usr/share/doc/${PACKAGENAME}/copyright"
			else
				Encapsulate "Not found. Already fixed?"
			fi
		fi
	done
}

PathScript () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "command-with-path-in-maintainer-script" | cut -d ":" -f3 | cut -d " " -f3)
		if [[ "${SCRIPT}" ]]; then
			ERROREDLINE=$(echo "${ERRORS}" | grep "command-with-path-in-maintainer-script" | cut -d ":" -f4 | cut -d " " -f1)
			CURRENTERROR=$(echo "${ERRORS}" | grep "command-with-path-in-maintainer-script" | cut -d ":" -f4 | cut -d " " -f2)
			STRIPPEDPATH=$(basename -- "${CURRENTERROR}")
			DOCTORFILE="${FILE}/DEBIAN/${SCRIPT}"
			Encapsulate "The File: ${DOCTORFILE} on line: ${ERROREDLINE} has ${CURRENTERROR} / Replacing with: ${STRIPPEDPATH}."
			sed -i "s|${CURRENTERROR}|${STRIPPEDPATH}|g" "${DOCTORFILE}"
		fi
	done
}

SassCache () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "package-contains-sass-cache-directory" | cut -d ":" -f3 | cut -d " " -f3)
		if [[ "${SCRIPT}" ]]; then
			find "${FILE}/" -name "*.sass-cache" -print0 | xargs -0 rm -R 2>/dev/null
		fi
	done
}

DayOfWeek () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "debian-changelog-has-wrong-day-of-week" | cut -d ":" -f4 | sed "s/ debian-changelog-has-wrong-day-of-week //g")
		if [[ "${SCRIPT}" ]]; then
			find "${FILE}/" -name "*.sass-cache" -print0 | xargs -0 rm -R 2>/dev/null
		fi
	done
}

# priority-extra-is-replaced-by-priority-optional
PriorityOptional () {
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "priority-extra-is-replaced-by-priority-optional")
		if [[ "${SCRIPT}" ]]; then
			GREPIT=$(grep "extra" "${CONTROL}" | grep -i "Priority:")
			if [[ "${GREPIT}" ]]; then
				Encapsulate "Fixing Warning: Setting package priority to optional."
				sed -i "s/Priority:.*/Priority: optional/g" "${CONTROL}"
			else
				Encapsulate "Priority is not extra.  Already fixed?"
			fi
		fi
	done
}

# missing-dep-for-interpreter - an Error
MissingDep () {
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "missing-dep-for-interpreter" | cut -d " " -f6)
		if [[ "${SCRIPT}" ]]; then
			GREPIT=$(grep "${SCRIPT}" "${CONTROL}")
			if ! [[ "${GREPIT}" ]]; then
				Encapsulate "Fixing Error: adding dependancy ${SCRIPT} to control file."
				Addcontrol "${FILE}" "${SCRIPT}"
				#sed -i "s/Priority:.*/Priority: optional/g" "${CONTROL}"
			else
				Encapsulate "Dependancy on ${SCRIPT} is already in the control file.  Already fixed or multiple issues?"
			fi
		fi
	done
}

# empty-field - a warning
EmptyField () {
	CONTROL="${FILE}/DEBIAN/control"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "empty-field" | cut -d ":" -f3 | sed "s/ empty-field //g")
		if [[ "${SCRIPT}" ]]; then
			GREPIT=$(grep "${SCRIPT}" "${CONTROL}")
			if [[ "${GREPIT}" ]]; then
				Encapsulate "Fixing Warning: Stripping empty field ${SCRIPT} from control file."
				sed -i "/^${SCRIPT}/d" "${CONTROL}"
				#sed -i "s/Priority:.*/Priority: optional/g" "${CONTROL}"
			else
				Encapsulate "Not found: ${SCRIPT}. Already fixed or multiple issues?"
			fi
		fi
	done
}

# unknown-control-interpreter - an error
UnknownControlInterpreter () {
	CONTROLFOLDER="${FILE}/DEBIAN"
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "unknown-control-interpreter" | cut -d ":" -f3 | sed "s/ unknown-control-interpreter //g")
		if [[ "${SCRIPT}" ]]; then
			REPLACE=$(echo "${SCRIPT}" | cut -d " " -f2)
			REPLACEMENT="#!/bin/bash"
			FTP=$(echo "${SCRIPT}" | cut -d "/" -f2 | cut -d " " -f1)
			# echo "DEBUGGING: ${SCRIPT} FTP=${FTP} REPLACE=${REPLACE} with REPLACEMENT=${REPLACEMENT}."
			GREPIT=$(grep "${REPLACE}" "${CONTROLFOLDER}/${FTP}")
			if [[ "${GREPIT}" ]]; then
				Encapsulate "Fixing Error(s): Replacing: ${REPLACE} with ${REPLACEMENT} from file: ${FTP} from control ${CONTROLFOLDER}/${FTP} file."
				sed -i "s|${REPLACE}|${REPLACEMENT}|g" "${CONTROLFOLDER}/${FTP}"
				#sed -i "s/Priority:.*/Priority: optional/g" "${CONTROL}"
			else
				Encapsulate "Not found: ${SCRIPT}. Already fixed or multiple issues?"
			fi
		fi
	done
}

# wrong-path-for-interpreter E: eekboek: wrong-path-for-interpreter usr/share/perl5/EB.pm (#!perl != /usr/bin/perl)
WrongPathForInterpreter () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "wrong-path-for-interpreter")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			SEARCHSTRING=$(echo "${ERRORS}" | grep "wrong-path-for-interpreter" | cut -d":" -f3 | sed "s/ wrong-path-for-interpreter //g" | cut -d "(" -f2 | sed "s/!=.*//g" | cut -d " " -f1)
			REPLACESTRING=$(echo "${ERRORS}" | grep "wrong-path-for-interpreter" | cut -d":" -f3 | sed "s/ wrong-path-for-interpreter //g" | cut -d "(" -f2 | sed "s|${SEARCHSTRING}||g" | sed "s/!= //g" | sed "s/)//g" | cut -d " " -f2)
			FTP=$(echo "${ERRORS}" | grep "wrong-path-for-interpreter"| cut -d":" -f3 | sed "s/ wrong-path-for-interpreter //g" | cut -d "(" -f1 | cut -d " " -f1)
			Encapsulate "Fixing Error(s): Replacing: #!.* with #!${REPLACESTRING} from file: ${FILE}/${FTP}."
			REPLACE="#!${REPLACESTRING}"
			sed -i "s|#!.*|${REPLACE}|g" "${FILE}/${FTP}"
		fi
	 done
}

# incorrect-path-for-interpreter
IncorrectPathForInterpreter () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "incorrect-path-for-interpreter")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			SEARCHSTRING=$(echo "${ERRORS}" | grep "incorrect-path-for-interpreter" | cut -d":" -f3 | sed "s/ incorrect-path-for-interpreter //g" | cut -d "(" -f2 | sed "s/!=.*//g" | cut -d " " -f1)
			REPLACESTRING=$(echo "${ERRORS}" | grep "incorrect-path-for-interpreter" | cut -d":" -f3 | sed "s/ incorrect-path-for-interpreter //g" | cut -d "(" -f2 | sed "s|${SEARCHSTRING}||g" | sed "s/!= //g" | sed "s/)//g" | cut -d " " -f3)
			FTP=$(echo "${ERRORS}" | grep "incorrect-path-for-interpreter"| cut -d":" -f3 | sed "s/ incorrect-path-for-interpreter //g" | cut -d "(" -f1 | cut -d " " -f1)
			Encapsulate "Fixing Error(s): Replacing: #!.* with #!${REPLACESTRING} from file: ${FILE}/${FTP}."
			REPLACE="#!${REPLACESTRING}"
			sed -i "s|#!.*|${REPLACE}|g" "${FILE}/${FTP}"
		fi
	 done
}

# package-relation-with-perl-modules
PackageRelationWithPerlModules () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "package-relation-with-perl-modules" | cut -d ":" -f3 | sed "s/ //g")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			Encapsulate "Fixing: ${FILE}/DEBIAN/control removing ${FOUND}."
			Stripcontrol "${FILE}" "${FOUND}"
		fi
	 done
}

# package-installs-python-pycache-dir
PackageInstallsPythonPycacheDir () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		SCRIPT=$(echo "${ERRORS}" | grep "package-installs-python-pycache-dir" | cut -d ":" -f3 | sed "s/ package-installs-python-pycache-dir //g")
		if [[ "${SCRIPT}" ]]; then
			if [[ -d "${FILE}/${SCRIPT}" ]]; then
			   Encapsulate "Fixing Error: removing error: ${FILE}/${SCRIPT}."
			   rm -R "${FILE}/${SCRIPT}"
			else
			   Encapsulate "Folder does not exist: ${FILE}/${SCRIPT}. Already fixed?"
			fi
		fi
 	done
}

AddRecommends () {
	CONTROL="${FILE}/DEBIAN/control"
	CURRENTRECOMMENDS=$(grep "^Recommends:" "${CONTROL}" | sed "s/Recommends://g")
	ADDTOCONTROL="${1}"
	GREPIT=$(grep "${ADDTOCONTROL}" "${CONTROL}")
	if [[ "${DEBUG}" ]]; then
		echo "DEBUGGING: ADDCONTROL=${ADDTOCONTROL} CURRENTRECOMMENDS=${CURRENTRECOMMENDS} | GREPIT: ${GREPIT}"
	fi
	if ! [[ "${GREPIT}" ]]; then
		if [[ "${CURRENTRECOMMENDS}" ]]; then
			Encapsulate "Current Recommends: ${CURRENTRECOMMENDS}"
			ADDIT+="Recommends: ${CURRENTRECOMMENDS}, ${ADDTOCONTROL}"
			Encapsulate "Fixing: ${FILE}/DEBIAN/control adding into recommends: ${ADDTOCONTROL}"
			Encapsulate "Replacing with: ${ADDIT}"
			SS="^Recommends:.*"
			sed -i "s/${SS}/${ADDIT}/g" "${CONTROL}"
		else
			echo "Recommends: ${ADDTOCONTROL}" >> "${CONTROL}"
		fi
	else
		Encapsulate "Already in the control file: ${ADDTOCONTROL}. Already fixed?  Not doing anything."
	fi
}

# php-script-but-no-php-cli-dep
PhpScriptButNoPhpCliDep () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "php-script-but-no-php-cli-dep")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			FOUND="php-cli"
			AddRecommends "${FOUND}"
		fi
	done
}

# init.d-script-needs-depends-on-lsb-base
InitScriptNeedsDependsOnLsbBase () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "init.d-script-needs-depends-on-lsb-base")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			FOUND="lsb-base"
			Addcontrol "${FILE}" "${FOUND}"
		fi
	done
}

ParseChangelog () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	declare -a VALIDCLOGS=("${FILE}/usr/share/doc/${PACKAGENAME}/changelog.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog" "${FILE}/usr/share/doc/${PACKAGENAME}/changelog.Debian");
		for EACH in "${VALIDCLOGS[@]}"
		do
			if [[ -f "${EACH}" ]]; then
				LOCATION="${EACH}"
				WRONG="${1}"
				RIGHT="${2}"
			fi
		done
		if [[ "${LOCATION}" ]]; then
			ExtractChangeLog "${FILE}"
			Encapsulate "Fixing Spelling error replacing: ${WRONG} with ${RIGHT} in: ${LOCATION}"
			sed -i "s|${WRONG}|${RIGHT}|g" "${LOCATION}"
			ChangeCompress "${FILE}"
		else
			Encapsulate "Changelog not found or already fixed."
		fi
}

ParseReadme () {
	PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
	declare -a VALIDREADME=("${FILE}/usr/share/doc/${PACKAGENAME}/README.Debian.gz" "${FILE}/usr/share/doc/${PACKAGENAME}/README.Debian");
	for EACH in "${VALIDREADME[@]}"
	do
		Encapsulate "Scanning for ${EACH}"
		LOCATION="${EACH}"
		if [[ -f "${EACH}" ]]; then
			Encapsulate "Found: ${EACH}"
			if ! [[ "${GREP}" ]]; then
				GREP=$(echo "${EACH}" | grep ".gz")
			fi
			if [[ "${GREP}" ]]; then
				if [[ -f "${FILE}/usr/share/doc/${PACKAGENAME}/README.Debian.gz" ]]; then
					Encapsulate "Decompressing README: ${FILE}/usr/share/doc/${PACKAGENAME}/README.Debian.gz"
					gunzip "${FILE}/usr/share/doc/${PACKAGENAME}/README.Debian.gz"
				fi
			fi
		fi
	done
	WRONG="${1}"
	RIGHT="${2}"
	if [[ -f "${LOCATION}" ]]; then
		GREPIT=$(grep "${WRONG}" "${LOCATION}")
		if [[ "${GREPIT}" ]]; then
			Encapsulate "Fixing Readme Spelling error replacing: ${WRONG} with ${RIGHT} in: ${LOCATION}"
			sed -i "s/${WRONG}/${RIGHT}/g" "${LOCATION}"
			if [[ "${GREP}" ]]; then
				Encapsulate "Re-compressing to orignal state, with maximum compression."
				gzip -9n "${LOCATION}"
			fi
		else
			Encapsulate "Readme Spelling error already fixed in: ${LOCATION}?"
		fi
	else
		Encapsulate "File not found: ${LOCATION}"
	fi
}
# spelling-error-in-changelog
SpellingErrorInChangelog () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "spelling-error-in-changelog")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			ExtractChangeLog "${FILE}"
			WRONG=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ spelling-error-in-changelog //g" | cut -d " " -f1)
			RIGHT=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ spelling-error-in-changelog //g" | cut -d " " -f2)
			ParseChangelog "${WRONG}" "${RIGHT}"
			ChangeCompress
		fi
	done
}
# bad-permissions-for-ali-file
BadPermissionsForAliFile () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "bad-permissions-for-ali-file")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			FILENAME=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ bad-permissions-for-ali-file //g")
			FTP="${FILE}/${FILENAME}"
			if [[ -f "${FTP}" ]]; then
				Encapsulate "Setting permissions of ${FTP} to 0444."
				chmod 0444 "${FTP}"
			fi
		fi
	done
}

PythonCheck () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "python-script-but-no-python-dep")
		if [[ "${FOUND}" ]]; then
			INTERP=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ python-script-but-no-python-dep //g" | cut -d "!" -f2)
			INTERPRETER=$(basename -- "${INTERP}")
			if [[ "${INTERPRETER}" ]]; then
				Encapsulate "Interpreter detected as: ${INTERPRETER} adding dependancy to control file."
				Addcontrol "${FILE}" "${INTERPRETER}"
			else
				GREPIT=$(echo "${INTERP}" | grep "python" )
				if [[ "${GREPIT}" ]]; then
					Encapsulate "Interpreter detected as: python adding dependancy to control file."
					Addcontrol "${FILE}" "python"
				fi
			fi
		fi
	done
}

# incorrect-libdir-in-la-file
IncorrectLibdirInLaFile () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "incorrect-libdir-in-la-file")
		if [[ "${FOUND}" ]]; then
			FTP=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ incorrect-libdir-in-la-file //g" | cut -d " " -f1)
			SEARCH=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ incorrect-libdir-in-la-file //g" | cut -d " " -f2)
			REPLACE=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ incorrect-libdir-in-la-file //g" | cut -d " " -f4)
			GREPIT=$(grep "${SEARCH}" "${FILE}/${FTP}")
			if ! [[ "${GREPIT}" ]]; then
				Encapsulate "Search: ${SEARCH} Replace: ${REPLACE} is already in ${FILE}/${FTP}.  Already fixed?"
			else
				Encapsulate "Searching for: ${SEARCH} Replacing with: ${REPLACE} in ${FILE}/${FTP}."
				sed -i "s|${SEARCH}|${REPLACE}|g" "${FILE}/${FTP}"
			fi
		fi
	done
}

# spelling-error-in-readme-debian
SpellingErrorInReadmeDebian () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "spelling-error-in-readme-debian")
		# echo "FOUND: $FOUND"
		if [[ "${FOUND}" ]]; then
			WRONG=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ spelling-error-in-readme-debian //g" | cut -d " " -f1)
			RIGHT=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ spelling-error-in-readme-debian //g" | cut -d " " -f2)
			ParseReadme "${WRONG}" "${RIGHT}"
		fi
	done
}

# missing-depends-on-sensible-utils
MissingDependsOnSensibleUtils () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "missing-depends-on-sensible-utils")
		if [[ "${FOUND}" ]]; then
			UTIL="sensible-utils"
			AddRecommends "${UTIL}"
		fi
	done
}

# command-in-menu-file-and-desktop-file
# The command is listed both in a menu file and a desktop file
# Per the tech-ctte decision on #741573, this is now prohibited.
# Please remove the menu file from the package.
# command-in-menu-file-and-desktop-file
# Not Called - fixes 1 Warning and creates 2 warnings via calls from postinst, postrm
CommandInMenuFileAndDesktopFile () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "command-in-menu-file-and-desktop-file")
		if [[ "${FOUND}" ]]; then
			 SCRAP=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ command-in-menu-file-and-desktop-file //g" | cut -d " " -f2)
			 if [[ -f "${FILE}/${SCRAP}" ]]; then
				Encapsulate "Removing menu file, since we have a desktop file."
				rm "${FILE}/${SCRAP}"
			 else
				Encapsulate "File does not exist: ${SCRAP}. Already fixed?"
			 fi
		fi
	done
}

# interpreter-not-absolute
InterpreterNotAbsolute () {
	echo "Not implemented yet."
}

# doc-base-file-references-missing-file
DocBaseFileReferencesMissingFile () {
	if ! [[ "${NOAPTFILE}" ]]; then
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "doc-base-file-references-missing-file")
		if [[ "${FOUND}" ]]; then
			PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
			SCRAP=$(echo "${ERRORS}" | cut -d ":" -f4 | cut -d " " -f2)
			APTFILE=$(type -p apt-file)
			if [[ "${APTFILE}" ]]; then
				SCAN=$(apt-file search "${SCRAP}" | cut -d ":" -f1) 2>/dev/null
				if [[ "${SCAN}" ]]; then
					OVERRIDE="${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
					if [[ -f "${OVERRIDE}" ]]; then
						GREPIT=$(grep -i "${PACKAGENAME}: doc-base-file-references-missing-file *" "${OVERRIDE}")
						if ! [[ "${GREPIT}" ]]; then
							Encapsulate "Fixing Error: ${SCRAP} is provided by package: ${SCAN}, please wait if there are multiple."
							CreateNFO "${SCAN}" "doc-base-file-references-missing-file"
						fi
					else
						CreateNFO "${SCAN}" "doc-base-file-references-wrong-path"
					fi
				else
					MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
					HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
					Encapsulate "This is truely an error in ${FILE}, please report this error to ${MAINTAINER}."
					Encapsulate "${APPNAME}, refuses to fix it."
					if [[ "${HOMEPAGE}" ]]; then
						Encapsulate "Please visit: ${HOMEPAGE} & contact the maintainer: ${MAINTAINER}"
					fi
				fi
			 else
				Encapsulate "Apt-file is not installed. Not attempting to fix the error."
			 fi
		fi
	done
	else
		Encapsulate "No apt-file switch detected. Not fixing error: doc-base-file-references-missing-file"
	fi
}

# doc-base-file-references-wrong-path
DocBaseFileReferencesWrongPath () {
	if ! [[ "${NOAPTFILE}" ]]; then
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "doc-base-file-references-wrong-path")
		if [[ "${FOUND}" ]]; then
			PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
			SCRAP=$(echo "${ERRORS}" | cut -d ":" -f4 | cut -d " " -f2)
			APTFILE=$(type -p apt-file)
			if [[ "${APTFILE}" ]]; then
				SCAN=$(apt-file search "${SCRAP}" | cut -d ":" -f1) 2>/dev/null
				if [[ "${SCAN}" ]]; then
					OVERRIDE="${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
					if [[ -f "${OVERRIDE}" ]]; then
						GREPIT=$(grep -i "${PACKAGENAME}: doc-base-file-references-wrong-path *" "${OVERRIDE}")
						if ! [[ "${GREPIT}" ]]; then
							Encapsulate "Fixing Error: ${SCRAP} is provided by package: ${SCAN}, please wait if there are multiple."
							CreateNFO "${SCAN}" "doc-base-file-references-wrong-path"
						fi
					else
						CreateNFO "${SCAN}" "doc-base-file-references-wrong-path"
					fi
				else
					MAINTAINER=$(grep "Maintainer: " "${FILE}/DEBIAN/control" | cut -d: -f2)
					HOMEPAGE=$(grep "Homepage: " "${FILE}/DEBIAN/control" | cut -d: -f3)
					Encapsulate "This is truely an error in ${FILE}, please report this error to ${MAINTAINER}."
					Encapsulate "${APPNAME}, refuses to fix it."
					if [[ "${HOMEPAGE}" ]]; then
						Encapsulate "Please visit: ${HOMEPAGE} & contact the maintainer: ${MAINTAINER}"
					fi
				fi
			 else
				Encapsulate "Apt-file is not installed. Not attempting to fix the error."
			 fi
		fi
	done
	else
		Encapsulate "No apt-file switch detected. Not fixing error: doc-base-file-references-wrong-path"
	fi
}

EmptyManualPage () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "empty-manual-page")
		if [[ "${FOUND}" ]]; then
			 SCRAP=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ empty-manual-page //g" | cut -d " " -f2)
			 if [[ -f "${FILE}/${SCRAP}" ]]; then
				Encapsulate "Removing empty manual page file."
				rm "${FILE}/${SCRAP}"

			 else
				Encapsulate "File does not exist: ${SCRAP}. Already fixed?"
			 fi
		fi
	done
}

Appstream-Metadata-In-Legacy-Location () {
	cat "${FILE}.deb.errors" | while read ERRORS
	do
		FOUND=$(echo "${ERRORS}" | grep "appstream-metadata-in-legacy-location")
		if [[ "${FOUND}" ]]; then
			 SCRAP=$(echo "${ERRORS}" | cut -d ":" -f3 | sed "s/ appstream-metadata-in-legacy-location //g" | cut -d " " -f2)
			 if [[ -f "${FILE}/${SCRAP}" ]]; then
				Encapsulate "Moving ${SCRAP} to proper folder: ${FILE}/usr/share/metainfo/."
				if [[ -d "${FILE}/usr/share/metainfo/" ]]; then
					mv "${FILE}/${SCRAP}" "${FILE}/usr/share/metainfo/"
					rm -R "${FILE}/usr/share/appdata/"
				else
					mkdir -p "${FILE}/usr/share/metainfo/"
					mv "${FILE}/${SCRAP}" "${FILE}/usr/share/metainfo/"
				fi
				Encapsulate "Appstream-Metadata-In-Legacy-Location fixed."
			 else
				Encapsulate "File does not exist: ${SCRAP}. Already fixed?"
			 fi
		fi
	done
}

Fix () {
	CheckRoot "$@"
	if ! [[ "${NOAPTFILE}" ]]; then
	APTFILE=$(type -p apt-file)
	if [[ "${APTFILE}" ]]; then
		Encapsulate "Refreshing apt-file database."
		SUPPRESS=$(sudo apt-file update 2>/dev/null) & Spinner "Refreshing apt-file database."
		FullBar
	else
		Encapsulate "apt-file is not installed, many errors / warnings will not be fixed. sudo apt-get install apt-file"
	fi
	else
		Encapsulate "No apt-file switch detected. Not refreshing apt-file database"
	fi
	EXISTS=""
	FOLDER=""

	CONTAINS=$(echo "$@" | grep -i "errors") # Fix errors only, ignore warnings & Info's

	#ERRZ=0 #set if we wish to calculate number of errors per session, unset to count all across the board.This feature is currently not implemented.
	CONTAINS=$(echo "$@" | grep -i "yes")
	if [[ "${CONTAINS}" ]]; then
		for EACH in "$@"
		do
			INDEX=$(( INDEX + 1 )) #Curently unneccessary
			if [[ -d "${EACH}" ]]; then
				EXISTS="${EACH}"
			fi
		done
		if [[ "${EXISTS}" ]]; then
			FOLDER="$EXISTS" # Set in case end user reQUESted a folder
		fi
		FOLDER="${EXISTS%%/}"
		if [[ -f "${FOLDER}.deb.errors" ]]; then
			FILENAME="${FOLDER}.deb.errors"
			if ! [[ -f "${FILENAME}" ]]; then
				Error "Nothing to fix. Have you ran the build switch to find errors?"
				Encapsulate "Please type: ${APPNAME} --help fix for assistance."
				exit 0;
			fi
		else
			# add trailing slash, we are handling a slew.
			shopt -s nullglob
			ERRORFILES=(*.errors)
			if [[ "${#ERRORFILES[@]}" -gt 0 ]]; then
				Center "Repostorm ${REPOVERSION} is entering fix mode."
				for EACH in "${ERRORFILES[@]}"
				do
					if [[ "${DEBUG}" ]]; then
						echo "Error File DETECTED: ${EACH}"
					fi
				done
			else
				Error "Nothing to fix. Have you ran the build switch to find errors?"
				Encapsulate "Please type: ${APPNAME} --help fix for assistance."
				exit 0;
			fi
		fi
	else
		shopt -s nullglob
		ERRORFILES=(*.errors)

		if [[ "${#ERRORFILES[@]}" -gt 0 ]]; then
			Center "${PROGNAME} ${REPOVERSION} is entering fix mode."
			DEB="${ERRORFILES//.errors}" # Singular mode - non-extracted?  We will find out in a micro-second.
			FOLDER="${DEB//.deb}"
			if ! [[ -d "${FOLDER}" ]]; then
				Encapsulate "Folder not found: ${FOLDER}.  Have you extracted? ${APPNAME} --extract"
				exit 1;
			fi
		else
			Error "Nothing to fix. Have you ran the build switch to find errors?"
			Encapsulate "Please type: ${APPNAME} --help fix for assistance."
			exit 1;
		fi
	fi
	# Check to see if end user is in for multiple to build.If not prompt.
	CONTAINS=$(echo "$@" | grep "YES")
	if ! [[ "${CONTAINS}" ]]; then
		INDEX=0
		for FILE in "${ERRORFILES[@]}"
		do
			if [[ "${FILE}" ]]; then
				INDEX=$(( INDEX + 1 ))
				Encapsulate "${INDEX}. ${FILE}"
			fi
		done
			FullBar
			PromptYN "Repair the above ${INDEX} deb(s) (Y/N)? "
			case "${YN}" in
				[Nn]* ) exit 0;;
				[Yy]* ) Center "Beginning Repair...";
						Relax2 "${FILE}";;
				* ) Encapsulate "Please answer y or n.";;
			esac

	else
		Center "Beginning Repair..."
		Relax2
	fi
	for FILES in "${ERRORFILES[@]}"
	do
		Y="${FILE%.deb.errors}"
		#Test for errors to fix
		FOLDER="${FILES%.deb.errors}"
		FOLDER+="/"
		FILE="${FILES%.deb.errors}"
		if [[ "${DEBUG}" ]]; then
			echo "DEBUGGING: 1:${1} 2:${2}: 3:$3 4:$4"
			echo "DEBUGGING: y: ${Y} FILE: ${FILE} FOLDER: ${FOLDER} FILES:${FILES}"
		fi
		if [[ -f "${FILE}.deb.errors" ]]; then
			FILES="${FILE}.deb.errors"
			# FILE="${FILE}"
			# relax permissions w/o asking permissions - Relax2 is internal.  They asked to fix errors.  Errors exist
			# at this point in this subroutine.  Let's attempt to fix them, without bugging them every other second.
			# we will be logging.  We are scanning for errors to fix.
			# This program will be huge when complete.This section will be larger then the entire program when I am
			# done.  Once I get 100% error free code we will log for the end user. Prior to final release.
			# if ${APPNAME} -f ultamatix-1.9.1_all/ will handle the individual deb otherwise, ${APPNAME} -f
			# we will handle all.
			# 2=${FILE} currently unnecessary


			Center "Scanning for errors / warnings to fix in ${FILES}"
			# python-package-missing-depends-on-python
			ERRORCONTROL=$(grep 'python-package-missing-depends-on-python' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Dependancy on python - Adding python dependancy to the control file."
				Addcontrol "${FILE}" python
				Center "Dependancy on python package issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# script-with-language-extension - a warning, it is unnecessary. If I strip the extension the app will still work, however a link pointing to the file will fail.  Unsure if I will fix it.
			#  php-script-but-no-php-cli-dep
			ERRORCONTROL=$(grep 'php-script-but-no-php-cli-dep' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Dependancy on php-cli - Adding php-cli dependancy to the control file."
				Addcontrol "${FILE}" php-cgi
				Center "Dependancy on php-cgi package issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# uncompressed-manual-page - a Error... Did we forget to compress the Manual Page?
			ERRORCONTROL=$(grep 'uncompressed-manual-page' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: uncompressed-manual-page."
				ManComp "${FILES}"
				Center "Uncompressed-manual-page fixed."
				ERR=$(( ERR + 1 ))
			fi

			# appstream-metadata-in-legacy-location - a warning... file Hierarchy has changed.
			ERRORCONTROL=$(grep 'appstream-metadata-in-legacy-location' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: appstream-metadata-in-legacy-location."
				Appstream-Metadata-In-Legacy-Location "${FILES}"
				Center "Appstream-Metadata-In-Legacy-Location fixed."
				ERR=$(( ERR + 1 ))
			fi

			# package-name-defined-in-config-h
			ERRORCONTROL=$(grep 'package-name-defined-in-config-h' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: package-name-defined-in-config-h."
				Scrap "${FILES}"
				Center "Package Name Defined In Config Header fixed."
				ERR=$(( ERR + 1 ))
			fi

			# binary-package-depends-on-toolchain-package - this should never happen, but does force my hand to write software.
			ERRORCONTROL=$(grep 'binary-package-depends-on-toolchain-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: binary-package-depends-on-toolchain-package."
				Stripcontrol "${FILES}"
				Center "Binary Package Depends On Toolchain Package fixed."
				ERR=$(( ERR + 1 ))
			fi

			# empty-manual-page - Why?  Let's build them a manual page.
			ERRORCONTROL=$(grep 'empty-manual-page' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: empty-manual-page."
				EmptyManualPage "${FILES}"
				Center "Empty Manual Page fixed."
				ERR=$(( ERR + 1 ))
			fi

			# changelog-news-debian-mismatch
			ERRORCONTROL=$(grep 'changelog-news-debian-mismatch' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Changelog News Debian Mismatch."
				ScrapChangeLog "${FILES}"
				Changelog "${FILES}"
				Center "Changelog News Debian Mismatch fixed."
				ERR=$(( ERR + 1 ))
			fi

			# latest-changelog-entry-without-new-date
			ERRORCONTROL=$(grep 'latest-changelog-entry-without-new-date' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Latest Changelog Entry without new date."
				ScrapChangeLog "${FILES}"
				Changelog "${FILES}"
				Center "Latest Changelog Entry without new date fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Shared librarys fix - easy fix, sign of a lazy or unknowlegeable programmer. 1 Error gone or
			# 100's of errors in the case of ${APPNAME} -f
			ERRORCONTROL=$(grep 'pkg-has-shlibs-control-file-but-no-actual-shared-libs' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Removing Shared library dependancies."
				Libs "${FILES}"
				Center "Shared library dependancies fixed."
				ERR=$(( ERR + 1 ))
			fi

			# No Changelogeasy fix, sign of a lazy or unknowlegeable programmer. 1 Error gone or
			# 100's of errors in the case of ${APPNAME} -f
			ERRORCONTROL=$(grep 'no-changelog' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: no-changelog."
				Changelog "${FILE}"
				Center "no-changelog fixed."
				ERR=$(( ERR + 1 ))
			fi

			#old-fsf-address-in-copyright-file
			ERRORCONTROL=$(grep 'old-fsf-address-in-copyright-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: old-fsf-address-in-copyright-file."
				FSF "${FILE}"
				Center "old-fsf-address-in-copyright-file warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# wrong-name-for-upstream-changelog too many windows
			# users in my Linux world ;)
			ERRORCONTROL=$(grep 'wrong-name-for-upstream-changelog' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: wrong-name-for-upstream-changelog."
				WrongName "${FILE}"
				Center "wrong-name-for-upstream-changelog error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# invalid-date-in-debian-changelog
			ERRORCONTROL=$(grep 'invalid-date-in-debian-changelog' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: invalid-date-in-debian-changelog. Writing GPL generic copy-write file. Please review and change if necessary."
				Changelog "${FILE}"
				Center  "invalid-date-in-debian-changelog error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# Copywrite missing?  Lazy / unknowlegeable?
			ERRORCONTROL=$(grep 'no-copyright-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: no-copyright-file. Writing GPL generic copy-write file. Please review and change if necessary."
				Copyright "${FILE}"
				Center "Copyright fixed."
				ERR=$(( ERR + 1 ))
			fi
			# Boiler plate issues gone.
			ERRORCONTROL=$(grep 'copyright-contains-dh_make-todo-boilerplate' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: copyright-contains-dh_make-todo-boilerplate.Writing GPL generic copy-write file. Please review and change if necessary."
				Copyright "${FILE}"
				Center "Copyright fixed."
				ERR=$(( ERR + 1 ))
			fi
			# Copywrite issues gone?  No I have not wrote a subroutine for those that want thier money.
			ERRORCONTROL=$(grep 'copyright-should-refer-to-common-license-file-for-gpl' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: copyright-should-refer-to-common-license-file-for-gpl. Writing GPL generic copy-write file. Please review and change if necessary."
				Copyright "${FILE}"
				Center "Copyright fixed."
				ERR=$(( ERR + 1 ))
			fi

			ERRORCONTROL=$(grep 'copyright-without-copyright-notice' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: copyright-without-copyright-notice. Writing GPL generic copy-write file. Please review and change if necessary."
				Copyright "${FILE}"
				Center "Copyright fixed."
				ERR=$(( ERR + 1 ))
			fi

			ERRORCONTROL=$(grep 'debian-changelog-file-missing' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Writing Generic changelog in ${FILE}. Please review and change if necessary."
				Changelog "${FILE}"
				Center "Changelog fixed."
				ERR=$(( ERR + 1 ))
			fi

			ERRORCONTROL=$(grep 'wrong-name-for-changelog-of-native-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: wrong-name-for-changelog-of-native-package Renaming changelog in ${FILE}. please review and change if necessary."
				ChangeRename "${FILE}"
				Center "Changelog issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			ERRORCONTROL=$(grep 'changelog-file-missing-in-native-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Writing Generic changelog in ${FILE}. please review and change if necessary."
				Changelog "${FILES}"
				Center "Changelog fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Manpage not found? A warning.Eventually, divide and conquer.
			ERRORCONTROL=$(grep 'no-manual-page' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: No Manpage - Writing Generic manpage. please review and change if necessary."
				Manpages "${FILE}"
				Center "Manpage issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Manpage not found? A warning.Eventually, divide and conquer.
			ERRORCONTROL=$(grep 'binary-without-manpage' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: No Manpage - Writing Generic manpage. please review and change if necessary."
				Manpages "${FILE}"
				Center "Manpage issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Obsolete packages? Typically, not the programmers fault.
			ERRORCONTROL=$(grep 'depends-on-obsolete-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Obsolete Packages - Striping the control file."
				Stripcontrol "${FILE}"
				Center "Obsolete package(s) issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Missing Dependancy?
			ERRORCONTROL=$(grep 'python-script-but-no-python-dep' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Dependancy on python - Adding Python dependancy to the control file."
				PythonCheck "${FILE}"
				Center "Dependancy on Python package issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Extra License file?
			ERRORCONTROL=$(grep 'extra-license-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: extra-license-file."
				Scrap "${FILE}"
				Center "extra-license-file issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Extra License file?
			ERRORCONTROL=$(grep 'unknown-control-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: unknown-control-file."
				Scrap "${FILE}"
				Center "unknown-control-file(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Missing latest Changelog entry?
			ERRORCONTROL=$(grep 'latest-debian-changelog-entry-without-new-date' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: latest-debian-changelog-entry-without-new-date."
				AddEntry "${FILE}"
				Center "latest-debian-changelog-entry-without-new-date issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Reminents, like backup files for python.
			ERRORCONTROL=$(grep 'package-installs-python-bytecode' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-installs-python-bytecode."
				PyScrap "${FILE}"
				Center "package-installs-python-bytecode(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Did not use the -9 switch with gzip a common error.
			ERRORCONTROL=$(grep 'changelog-not-compressed-with-max-compression' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: changelog-not-compressed-with-max-compression."
				ChangeCompress "${FILE}"
				Center "changelog-not-compressed-with-max-compression(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Extra file?
			ERRORCONTROL=$(grep 'package-contains-vcs-control-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-contains-vcs-control-file."
				Scrap "${FILE}"
				Center "package-contains-vcs-control-file(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Compress manpage
			ERRORCONTROL=$(grep 'manpage-not-compressed' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: manpage-not-compressed."
				ManComp "${FILE}"
				Center "manpage-not-compressed(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Unstripped binary
			ERRORCONTROL=$(grep 'unstripped-binary-or-object' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				StripBin "${FILE}"
				Encapsulate "unstripped-binary-or-object(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Homepage in description?
			ERRORCONTROL=$(grep 'description-contains-homepage' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Homepage "${FILE}"
				Center "description-contains-homepage(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Missing Dependancy on libc?
			ERRORCONTROL=$(grep 'missing-dependency-on-libc' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: Dependancy on libc - Adding libc dependancy to the control file."
				Addcontrol "${FILE}" libc6
				Center "Dependancy on libc package issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Windows user build the deb?
			ERRORCONTROL=$(grep 'windows-thumbnail-database-in-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: windows-thumbnail-database-in-package."
				Scrap "${FILE}"
				Center "windows-thumbnail-database-in-package(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Extra folder?
			ERRORCONTROL=$(grep 'package-contains-vcs-control-dir' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-contains-vcs-control-dir."
				Scrap "${FILE}"
				Center "package-contains-vcs-control-dir(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Did not use the -9 switch with gzip a common error.
			ERRORCONTROL=$(grep 'changelog-file-not-compressed' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: changelog-file-not-compressed."
				ChangeCompress "${FILE}"
				Encapsulate "changelog-file-not-compressed error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Programmer or maintainer set the wrong section in control file.
			ERRORCONTROL=$(grep 'games-package-should-be-section-games' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: games-package-should-be-section-games."
				Gameit "${FILE}"
				Center "games-package-should-be-section-games(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Programmer or maintainer set the wrong section in control file.
			ERRORCONTROL=$(grep 'extended-description-is-empty' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: extended-description-is-empty."
				ExtendDescription "${FILE}"
				Center "extended-description-is-empty error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Programmer or maintainer set the wrong section in control file.
			ERRORCONTROL=$(grep 'description-starts-with-package-name' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: description-starts-with-package-name."
				Description "${FILE}"
				Center "description-starts-with-package-name(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Maintainer does not use last name.
			ERRORCONTROL=$(grep 'maintainer-not-full-name' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: maintainer-not-full-name."
				Maintainer "${FILE}"
				Center "maintainer-not-full-name(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Are we writing a book describing the program?
			ERRORCONTROL=$(grep 'extended-description-line-too-long' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: extended-description-line-too-long."
				ExtendDescription "${FILE}"
				Center "extended-description-line-too-long(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Set Gnome since there is no true way to know if the deb
			# is a game a graphics program etc. I may revisit this and parse
			# the manpages readme etc.To see if I can set it properly.
			ERRORCONTROL=$(grep 'section-is-dh_make-template' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: section-is-dh_make-template."
				UnknownSection "${FILE}"
				Center "section-is-dh_make-template fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Mac user build the deb?
			ERRORCONTROL=$(grep 'macos-ds-store-file-in-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: macos-ds-store-file-in-package."
				Scrap "${FILE}"
				Center "macos-ds-store-file-in-package(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Empty Control file(s)?
			ERRORCONTROL=$(grep 'control-file-is-empty' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: control-file-is-empty."
				Scrap "${FILE}"
				Center "control-file-is-empty warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# symlink-contains-spurious-segments
			# end user linked files using period(s)
			ERRORCONTROL=$(grep 'symlink-contains-spurious-segments' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				#Encapsulate "Fixing Error: symlink-contains-spurious-segments."
				Symlink "${FILE}"
				#Center "symlink-contains-spurious-segments error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# Set Gnome since there is no true way to know if the deb
			# is a game a graphics program etc. I may revisit this and parse
			# the manpages readme etc.To see if I can set it properly.
			# For now Gnome will have to do.
			ERRORCONTROL=$(grep 'package-section-games-but-contains-no-game' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-section-games-but-contains-no-game."
				UnknownSection "${FILE}"
				Center "package-section-games-but-contains-no-game warning fixed."
				ERR=$(( ERR + 1 ))
			fi

			# symlink-ends-with-slash - a rough one to fix chunk of programming will be involved.
			ERRORCONTROL=$(grep 'symlink-ends-with-slash' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: symlink-ends-with-slash."
				Symlink "${FILE}"
				#Center "symlink-ends-with-slash(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# copyright-has-url-from-dh_make-boilerplate
			ERRORCONTROL=$(grep 'copyright-has-url-from-dh_make-boilerplate' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: copyright-has-url-from-dh_make-boilerplate."
				Copyright "${FILE}"
				Center "Copyright issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			# unknown-section
			ERRORCONTROL=$(grep 'unknown-section' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: unknown-section."
				UnknownSection "${FILE}"
				Center "unknown-section warning fixed."
				ERR=$(( ERR + 1 ))
			fi

			# debian-changelog-file-contains-invalid-email-address
			ERRORCONTROL=$(grep 'debian-changelog-file-contains-invalid-email-address' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: debian-changelog-file-contains-invalid-email-address."
				InvalidEmail "${FILE}"
				Center "debian-changelog-file-contains-invalid-email-address error fixed."
				ERR=$(( ERR + 1 ))
			fi

			# icon-size-and-directory-name-mismatch
			ERRORCONTROL=$(grep 'icon-size-and-directory-name-mismatch' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: icon-size-and-directory-name-mismatch."
				Icon_Resize "${FILE}"
				Center "icon-size-and-directory-name-mismatch error fixed."
				ERR=$(( ERR + 1 ))
			fi

			# package-contains-hardlink
			ERRORCONTROL=$(grep 'package-contains-hardlink' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-contains-hardlink."
				SoftLink "${FILE}"
				Center "package-contains-hardlink error fixed."
				ERR=$(( ERR + 1 ))
			fi

			# postinst-has-useless-call-to-ldconfig: an error
			ERRORCONTROL=$(grep 'postinst-has-useless-call-to-ldconfig' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: postinst-has-useless-call-to-ldconfig."
				LdConfig "${FILE}" postinst
				Center "postinst-has-useless-call-to-ldconfig."
				ERR=$(( ERR + 1 ))
			fi

			# postrm-has-useless-call-to-ldconfig: an error
			ERRORCONTROL=$(grep 'postrm-has-useless-call-to-ldconfig' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: postrm-has-useless-call-to-ldconfig."
				LdConfig "${FILE}" postrm
				Center "postrm-has-useless-call-to-ldconfig fixed."
				ERR=$(( ERR + 1 ))
			fi

			# non-empty-dependency_libs-in-la-file: an error
			ERRORCONTROL=$(grep 'non-empty-dependency_libs-in-la-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: non-empty-dependency_libs-in-la-file."
				UseLess "${FILE}"
				Center "non-empty-dependency_libs-in-la-file issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			# unusual-interpreter: a warning
			ERRORCONTROL=$(grep 'unusual-interpreter' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: unusual-interpreter."
				Interpreter "${FILE}"
				Center "unusual-interpreter issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			# desktop-mime-but-no-exec-code: a warning
			ERRORCONTROL=$(grep 'desktop-mime-but-no-exec-code' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: desktop-mime-but-no-exec-code."
				MimeType "${FILE}"
				Center "desktop-mime-but-no-exec-code issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			# package-contains-timestamped-gzip: a warning
			ERRORCONTROL=$(grep 'package-contains-timestamped-gzip' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: package-contains-timestamped-gzip."
				TarRecompress "${FILE}"
				Encapsulate "package-contains-timestamped-gzip issue fixed."
				ERR=$(( ERR + 1 ))
			fi

			# spelling-error-in-description: a warning
			ERRORCONTROL=$(grep 'spelling-error-in-description' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: spelling-error-in-description."
				SpellCheck "${FILE}"
				Encapsulate "spelling-error-in-description issue fixed."
				ERR=$(( ERR + 1 ))
			fi
			# command-with-path-in-maintainer-script
			ERRORCONTROL=$(grep 'command-with-path-in-maintainer-script' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: command-with-path-in-maintainer-script."
				PathScript "${FILE}"
				Encapsulate "command-with-path-in-maintainer-script issue fixed."
				ERR=$(( ERR + 1 ))
			fi
			# package-contains-sass-cache-directory
			ERRORCONTROL=$(grep 'package-contains-sass-cache-directory' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: package-contains-sass-cache-directory."
				SassCache "${FILE}"
				Encapsulate "package-contains-sass-cache-directory issue fixed."
				ERR=$(( ERR + 1 ))
			fi
			# raster-image-in-scalable-directory
			ERRORCONTROL=$(grep 'raster-image-in-scalable-directory' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: raster-image-in-scalable-directory."
				RasterImage "${FILE}"
				Encapsulate "raster-image-in-scalable-directory issue(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# raster-image-in-scalable-directory
			ERRORCONTROL=$(grep 'empty-binary-package' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: empty-binary-package."
				EmptyBinary "${FILE}"
				Encapsulate "empty-binary-package issue fixed."
				ERR=$(( ERR + 1 ))
			fi
			# priority-extra-is-replaced-by-priority-optional
			ERRORCONTROL=$(grep 'priority-extra-is-replaced-by-priority-optional' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: priority-extra-is-replaced-by-priority-optional."
				PriorityOptional "${FILE}"
				Encapsulate "priority-extra-is-replaced-by-priority-optional fixed."
				ERR=$(( ERR + 1 ))
			fi
			# missing-dep-for-interpreter
			ERRORCONTROL=$(grep 'missing-dep-for-interpreter' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: missing-dep-for-interpreter."
				MissingDep "${FILE}"
				Encapsulate "missing-dep-for-interpreter fixed."
				ERR=$(( ERR + 1 ))
			fi
			# shlib-with-executable-bit
			ERRORCONTROL=$(grep 'shlib-with-executable-bit' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: shlib-with-executable-bit."
				ShlibExecutable "${FILE}"
				Encapsulate "shlib-with-executable-bit error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# empty-field
			ERRORCONTROL=$(grep 'empty-field' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: empty-field."
				EmptyField "${FILE}"
				Encapsulate "empty-field warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# unknown-control-interpreter - an error
			ERRORCONTROL=$(grep 'unknown-control-interpreter' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: unknown-control-interpreter."
				UnknownControlInterpreter "${FILE}"
				Encapsulate "unknown-control-interpreter error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# package-installs-python-pycache-dir
			ERRORCONTROL=$(grep 'package-installs-python-pycache-dir' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-installs-python-pycache-dir."
				PackageInstallsPythonPycacheDir "${FILE}"
				Encapsulate "package-installs-python-pycache-dir error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# incorrect-path-for-interpreter
			ERRORCONTROL=$(grep 'incorrect-path-for-interpreter' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: incorrect-path-for-interpreter."
				IncorrectPathForInterpreter "${FILE}"
				Encapsulate "incorrect-path-for-interpreter warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# package-relation-with-perl-modules
			ERRORCONTROL=$(grep 'package-relation-with-perl-modules' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: package-relation-with-perl-modules."
				PackageRelationWithPerlModules "${FILE}"
				Encapsulate "package-relation-with-perl-modules error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# php-script-but-no-php-cli-dep
			ERRORCONTROL=$(grep 'php-script-but-no-php-cli-dep' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: php-script-but-no-php-cli-dep."
				PhpScriptButNoPhpCliDep "${FILE}"
				Encapsulate "php-script-but-no-php-cli-dep error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# init.d-script-needs-depends-on-lsb-base
			ERRORCONTROL=$(grep 'init.d-script-needs-depends-on-lsb-base' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: init.d-script-needs-depends-on-lsb-base."
				InitScriptNeedsDependsOnLsbBase "${FILE}"
				Encapsulate "init.d-script-needs-depends-on-lsb-base error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# spelling-error-in-changelog
			ERRORCONTROL=$(grep 'spelling-error-in-changelog' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: spelling-error-in-changelog."
				SpellingErrorInChangelog "${FILE}"
				Encapsulate "spelling-error-in-changelog warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# bad-permissions-for-ali-file
			ERRORCONTROL=$(grep 'bad-permissions-for-ali-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: bad-permissions-for-ali-file."
				BadPermissionsForAliFile "${FILE}"
				Encapsulate "bad-permissions-for-ali-file warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# incorrect-libdir-in-la-file
			ERRORCONTROL=$(grep 'incorrect-libdir-in-la-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: incorrect-libdir-in-la-file."
				IncorrectLibdirInLaFile "${FILE}"
				Encapsulate "incorrect-libdir-in-la-file error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# spelling-error-in-readme-debian
			ERRORCONTROL=$(grep 'spelling-error-in-readme-debian' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Warning: spelling-error-in-readme-debian."
				SpellingErrorInReadmeDebian "${FILE}"
				Encapsulate "spelling-error-in-readme-debian warning(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# missing-depends-on-sensible-utils
			ERRORCONTROL=$(grep 'missing-depends-on-sensible-utils' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: missing-depends-on-sensible-utils."
				MissingDependsOnSensibleUtils "${FILE}"
				Encapsulate "missing-depends-on-sensible-utils error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# wrong-path-for-interpreter
			ERRORCONTROL=$(grep 'wrong-path-for-interpreter' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: wrong-path-for-interpreter."
				WrongPathForInterpreter "${FILE}"
				Encapsulate "wrong-path-for-interpreter error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# doc-base-file-references-missing-file
			ERRORCONTROL=$(grep 'doc-base-file-references-missing-file' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: doc-base-file-references-missing-file."
				DocBaseFileReferencesMissingFile "${FILE}"
				Encapsulate "doc-base-file-references-missing-file error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi
			# doc-base-file-references-wrong-path
			ERRORCONTROL=$(grep 'doc-base-file-references-wrong-path' "${FILES}")
			if [[ "${ERRORCONTROL}" ]]; then
				Encapsulate "Fixing Error: doc-base-file-references-wrong-path."
				DocBaseFileReferencesWrongPath "${FILE}"
				Encapsulate "doc-base-file-references-wrong-path error(s) fixed."
				ERR=$(( ERR + 1 ))
			fi

			# command-in-menu-file-and-desktop-file - fixes 1 warning & creates 2 - un-implemented.
			#ERRORCONTROL=$(grep 'command-in-menu-file-and-desktop-file' "${FILES}")
			#if [[ "${ERRORCONTROL}" ]]; then
			#	Encapsulate "Fixing Warning: command-in-menu-file-and-desktop-file."
			#	CommandInMenuFileAndDesktopFile "${FILE}"
			#	Encapsulate "command-in-menu-file-and-desktop-file warning(s) fixed."
			#	ERR=$(( ERR + 1 ))
			#fi

			# manpages not implemented a warning, none the less will be fixed generically using my manpage as a template
			# we will not quit until errors = 0; warnings are QUEStionable.  I do not want to spend the rest of my life
			# writing this program.  A huge benifit to all programmers if I did. Eventually piping necessary INFOrmation
			# to generate as so the Copywrite subroutine.  I have not sed'd yet to make perfect.  Eliminate human error.
			# Counting errors & warnings fixed acurately is not currently implemented. One Error type fixed I have seen
			# it fix thousands of errors in one clean sweep.

			Center "Types of errors / warnings fixed: ${ERR}"
		else
			Encapsulate "No errors in ${FILE} to fix."
		fi
		#find . ${FILE}/usr/share/man/ $PACKAGE.gz
		#exit 0
	done
}

NegateRoot () {
	if [[ "${EUID}" == 0 ]]; then
		Error "Please run as NON-root or NON sudo privilages."
		exit 1;
	fi
}

Prepare () {
	# CheckRoot "$@"
	NegateRoot "$@"
	shopt -s dotglob
	shopt -s nullglob
	DEBS=();
	SMALLDEBS=();
	MEDIUMDEBS=();
	LARGEDEBS=();
	#Set Returning Directory
	RTD="${PWD}"
	declare -a ARCHITECTURES=("i386" "amd64" "armhf")
	CONTAINS=$(echo "$@" | grep -i "suppress")
	if [[ "${2}" != "" ]]; then
		if [[ -d ".debs/" ]]; then
			Center "Repostorm ${REPOVERSION} is entering prepare mode."
			Encapsulate "Scaning good packages in ./debs."
			Encapsulate "Entering Version control function."
			#ADD VERSION CONTROL FUNCTION AND CALL IT HERE.
			Encapsulate "Please wait."
		else
			Encapsulate "No .debs/ folder. Please build your debs first. ${APPNAME} -b <FOLDERNAME> or ${APPNAME} -b to build all debs."
			Encapsulate "Please review man ${APPNAME} or ${APPNAME} --help for more information."
			Encapsulate "More specifically: ${APPNAME} --help prepare"
			exit 0;
		fi
	fi
	if [[ -d "${2}/" ]]; then
		Encapsulate "${2} folder already exists. Attempting to scan ${2}, have you already ran ${APPNAME} --prepare function?"
	else
		#DIST="$(lsb_release --short --codename)" #Future reference for adding additional distros case statment
		# or nested case function here.
		for RELEASES in "${ARCHITECTURES[@]}"
		do
			mkdir -p "dists/${2}/all/binary-${RELEASES}/"
			mkdir -p "${2}/${2}/all/binary-${RELEASES}/"
		done
	fi
	shopt -s nullglob
	shopt -s dotglob
	INFOLDER="${PWD}"
	declare -a PERFECTDEBS=();
	if [[ -d ".debs/" ]]; then
		cd ".debs/" || exit 1;
		PERFECTDEBS=(*.deb)
		cd "${INFOLDER}" || exit 1;
	fi
	NUMBER="${#PERFECTDEBS}"
	if [[ "${NUMBER}" != 0 ]]; then
		FileSize -d ".debs/"
		Encapsulate "Moving debs to approriate folder via architecture: ${FORMATTED} bytes (${TRUESIZE})."
		#test existence of each arch only preform what is necessary.
		cd ".debs/" || exit 1;

		LARGEDEBS=(./*amd*.deb)
		if [[ "${#LARGEDEBS[@]}" -gt 0 ]]; then
			Center "Processing ARCH: AMD64"
			CDEB=1
			NUMBEROFDEBS="${#LARGEDEBS[@]}"
			Encapsulate "Processing ARCH: AMD64"
			for EACH in "${LARGEDEBS[@]}"
			do
				PCOMP=$((100*CDEB / NUMBEROFDEBS))
				ProgressBar "${PCOMP}" "Processing AMD64 DEB(s): ${CDEB} of ${NUMBEROFDEBS}"
				# Encapsulate "Moving ${EACH} to ${RTD}/${2}/${2}/all/binary-amd64/"
				mv "${EACH}" "${RTD}/${2}/${2}/all/binary-amd64/"
				((CDEB++))
				#sudo mv ".debs/*arm*" "${2}/all/binary-armhf/"
			done
			Encapsulate "Files moved: ${NUMBEROFDEBS}, done."
			FullBar
		else
			Encapsulate "No AMD64 deb(s) found."
		fi
		SMALLDEBS=(./*86*.deb)
		if [[ "${#SMALLDEBS[@]}" -gt 0 ]]; then
			Center "Processing ARCH: i386"
			CDEB=1
			NUMBEROFDEBS="${#SMALLDEBS[@]}"
			Encapsulate "Processing ARCH: i386"
			for EACH in "${SMALLDEBS[@]}"
			do
				PCOMP=$((100*CDEB / NUMBEROFDEBS))
				ProgressBar "${PCOMP}" "Processing i386 DEB(s): ${CDEB} of ${NUMBEROFDEBS}"
				# Encapsulate "Moving ${EACH} to ${RTD}/${2}/${2}/all/binary-amd64/"
				mv "${EACH}" "${RTD}/${2}/${2}/all/binary-i386/"
				#sudo mv ".debs/*arm*" "${2}/all/binary-armhf/"
				((CDEB++))
			done
			Encapsulate "Files moved: ${NUMBEROFDEBS}, done."
			FullBar
		else
		   Encapsulate "No i386 deb(s) found."
		fi
		ARMDEBS=(./*arm*.deb)
		if [[ "${#ARMDEBS[@]}" -gt 0 ]]; then
			Center "Processing ARCH: ARM"
			CDEB=1
			NUMBEROFDEBS="${#ARMDEBS[@]}"
			Encapsulate "Processing ARCH: ARM"
			for EACH in "${ARMDEBS[@]}"
			do
				PCOMP=$((100*CDEB / NUMBEROFDEBS))
				# Encapsulate "Moving ${EACH} to ${RTD}/${2}/${2}/all/binary-armhf/"
				ProgressBar "${PCOMP}" "Processing ARM DEB(s): ${CDEB} of ${NUMBEROFDEBS}"
				mv "${EACH}" "${RTD}/${2}/${2}/all/binary-armhf/"
				#sudo mv ".debs/*arm*" "${2}/all/binary-armhf/"
				((CDEB++))
			done
			Encapsulate "Files moved: ${NUMBEROFDEBS}, done."
			FullBar
		else
			Encapsulate "No ARM deb(s) found."
		fi
		MEDIUMDEBS=(./*.deb)
		if [[ "${#MEDIUMDEBS[@]}" -gt 0 ]]; then
			CDEB=1
			NUMBEROFDEBS="${#MEDIUMDEBS[@]}"
			Encapsulate "Processing ARCH: Independant"
			#Process "all" independent architecture.
			for EACH in "${MEDIUMDEBS[@]}"
			do
				PCOMP=$((100*CDEB / NUMBEROFDEBS))
				ProgressBar "${PCOMP}" "Processing architecturally independent DEB(s): ${CDEB} of ${NUMBEROFDEBS}"
				# Encapsulate "Moving ${EACH} to ${RTD}/${2}/${2}/all/binary-amd64/"
				mv "${EACH}" "${RTD}/${2}/${2}/all/binary-amd64/"
				((CDEB++))
				#sudo mv ".debs/*arm*" "${2}/all/binary-armhf/"
			done
			Encapsulate "Files moved: ${NUMBEROFDEBS}, done."
			FullBar
		else
			Encapsulate "No ARCH independant deb(s) found."
		fi
		Center "Creating Symbolic Link(s) via architecture. For ${NUMBEROFDEBS} deb(s)."
		#for each deb symlink on all arch, no sense in uploading twice
		for RELEASES in "${ARCHITECTURES[@]}"
		do
			if [[ "${RELEASES}" != "amd64" ]]; then
				if [[ -d "${RTD}/${2}/${2}/all/binary-${RELEASES}/" ]]; then
					cd "${RTD}/${2}/${2}/all/binary-${RELEASES}/" || exit 1;
					Encapsulate "Creating ${NUMBEROFDEBS} Symbolic link(s) for ${RELEASES} in: ${PWD}"
					CDEB=1
					for EACH in "${MEDIUMDEBS[@]}"
					do
						PCOMP=$((100*CDEB / NUMBEROFDEBS))
						ProgressBar "${PCOMP}" "Processing symlink: ${CDEB} of ${NUMBEROFDEBS}"
						ln -s "../binary-amd64/${EACH}"
						((CDEB++))
					done
					cd "${RTD}" || exit 1;
				else
					Error "No folder: ${2}/${2}/all/binary-${EACH}/"
				fi
			fi
		done
		cd "${RTD}" || exit 1;
	else
		Error "No debs found."
		exit 1;
	fi
	cd "${RTD}" || exit 1;
	Encapsulate "Setting permissions and chowning files to ${USER} in ${PWD}."
	sudo mv "dists" "${2}/"
	sync;
	sudo chown -R "${USER}:${USER}" "${RTD}/${2}/"
	sudo chmod -R 644 "${RTD}/${2}/"
	sudo find "${RTD}/${2}/" -type d -exec chmod 755 {} \;
	Encapsulate "GPG Key signing phase initiating."
	#set -x

	GPGHOME="~/.gnupg/"
	MAINDIR="${2}"
	cd "${2}" || exit 1;
	for ARCH in "${ARCHITECTURES[@]}"
	do
		DIR="${2}/all/binary-${ARCH}"
		OUTDIR="${MAINDIR}/dists/${2}/all/binary-${ARCH}"
		# create index
		Encapsulate "Generating index for ${ARCH}, please wait..."

		apt-ftparchive packages "${DIR}" > "${RTD}/${OUTDIR}/Packages" & Spinner "Generating index for ${ARCH}, please wait..."
		cat "${RTD}/${OUTDIR}/Packages" | gzip -9c > "${RTD}/${OUTDIR}/Packages.gz"
		cat "${RTD}/${OUTDIR}/Packages" | bzip2 > "${RTD}/${OUTDIR}/Packages.bz2"
		#apt-ftparchive packages "${DIR}" > "${MAINDIR}/${2}/all/binary-${ARCH}/Packages"
		#cat "${DIR}/Packages" | gzip -9c > "${MAINDIR}/${2}/all/binary-${ARCH}/Packages.gz"
		#cat "${DIR}/Packages" | bzip2 > "${MAINDIR}/${2}/all/binary-${ARCH}/Packages.bz2"
	done
	cd "${RTD}" || exit 1;
	# create Release file
	Encapsulate "Generating Release file."
	if [[ -f "${MAINDIR}/dists/${2}/Release*" ]]; then
		Encapsulate "Removing old Release files, we will build new ones."
		rm -f "${MAINDIR}/dists/${2}/Release*"
	fi
	Date=$(date)
	echo "Origin: Ultimate Edition" >> "${MAINDIR}/dists/${2}/Release"
	echo "Label: ${2}" >> "${MAINDIR}/dists/${2}/Release"
	echo "Suite: ${2}" >> "${MAINDIR}/dists/${2}/Release"
	echo "Version: 1.0" >> "${MAINDIR}/dists/${2}/Release"
	echo "Codename: ${2}" >> "${MAINDIR}/dists/${2}/Release"
	echo "Date: $Date" >> "${MAINDIR}/dists/${2}/Release"
	BUILDSTRING="Architectures:"
	for RELEASES in "${ARCHITECTURES[@]}"
	do
		BUILDSTRING="${BUILDSTRING} ${RELEASES}"
	done
	echo "$BUILDSTRING" >> "${MAINDIR}/dists/${2}/Release"
	if [[ "${3}" ]]; then
		echo "Components: ${3}" >> "${MAINDIR}/dists/${2}/Release"
	else
		echo "Components: all" >> "${MAINDIR}/dists/${2}/Release"
	fi
	echo "Description: ${2} Repository automatically generated via Repostorm http://${APPNAME}.com" >> "${MAINDIR}/dists/${2}/Release"

	apt-ftparchive release "${MAINDIR}/dists/${2}" >> "${MAINDIR}/dists/${2}/Release"

	# sign Release file
	Encapsulate "Signing release file."
	gpg --sign --homedir="${GPGHOME}" -ba -o "${MAINDIR}/${2}/Release.gpg" "${MAINDIR}/dists/${2}/Release"
	#cp "${MAINDIR}/Release.gpg" "${MAINDIR}/InRelease"
	#cd "${MAINDIR}/" || exit 1;
	gpg --clearsign -o "${MAINDIR}/dists/${2}/InRelease" "${MAINDIR}/dists/${2}/Release"
	cd "${RTD}" || exit 1;
	#set +x
	FullBar
	Encapsulate "Repository is ready for publishing."
	Encapsulate "Moving all folders involved to Distribution folder."
	if [[ -f "${2}/Release.gpg" ]]; then
		Encapsulate "Moving gpg keys for distribution."
		mv "${2}/Release.gpg" "${2}/dists/${2}/"
		#mv "${2}/Release" "${2}/dists/${2}/"

	else
		Encapsulate "Warning: No GPG key found. Deb(s) will not be signed."
		Encapsulate "Please import your GPG key. Example:"
		Encapsulate "gpg --allow-secret-key-import --import private.key"
		Encapsulate "You can still publish w/o a secret key, however the end user will be prompted with:"
		Encapsulate "${WARNING}WARNING: The following packages cannot be authenticated!"
		Encapsulate "Install these packages without verification [y/N]?"
		Encapsulate "E: Some packages could not be authenticated"
		if [[ "${DEBUG}" ]]; then
			echo "DEBUGGING: WE ARE IN ${PWD}"
		fi
	fi
	FullBar
	cd "${RTD}" || exit 1;
	if [[ -d "/usr/share/ultimate_edition/htaccesss/" ]]; then
		SAVEIFS=$IFS
		IFS=$'\n'
		declare -a THEFILEZ=();
		shopt -s nullglob
		THEFILEZ=$(find "/usr/share/ultimate_edition/htaccesss/" -type f -printf '%P\n') 2>/dev/null
		THEFILEZ=(${THEFILEZ})
		declare -a REPOFOLDERS=();

		# Change IFS to new line.

		REPOFOLDERS=$(find ${2}/ -maxdepth 6 -type d -printf '%P\n')
		REPOFOLDERS=(${REPOFOLDERS})
		IFS=$SAVEIFS

		for EACH in "${REPOFOLDERS[@]}"
		do
			for THEFILE in "${THEFILEZ[@]}"
			do
				Encapsulate "Populating: ${EACH} with ${THEFILE} for htaccess."
				cp "/usr/share/ultimate_edition/htaccesss/${THEFILE}" "${2}/${EACH}"
			done
		done
	fi
	sudo chown -R "${USER}:${USER}" "${RTD}/${2}/"
	sudo chmod -R 644 "${RTD}/${2}/"
	sudo find "${RTD}/${2}/" -type d -exec chmod 755 {} \;
	Encapsulate "Please initiate Publish mode when you are ready to publish:${APPNAME} -P USERNAME@ADDRESS_TO_RSYNC_TO"
	if [[ -d "${2}" ]]; then
		#cd ${2}
		EXISTANT=$(grep "${PWD}" "/etc/apt/sources.list")
		if ! [[ "${EXISTANT}" ]]; then
			PromptYN "Would you like ${PROGNAME} to insert ${2}'s local repository into your sources.list to test(Y/N)? "
			case "${YN}" in
				[Nn]* ) exit 0;;
				[Yy]* ) echo "deb file://${PWD} ${2} all" | sudo tee -a "/etc/apt/sources.list" 1>/dev/null; Encapsulate "Please sudo apt-get update for changes to reflect.";;
				* ) Encapsulate "Please answer y or n.";;
			esac
		else
			Encapsulate "Repository detected, not prompting to re-add."
		fi
	fi
}

Publish () {
	if [[ "${DEBUG}" ]]; then
		echo "DEBUGGING PUBLISH FUNCTION: 1: ${1} 2:${2} 3:$3"
	fi
	if [[ "${2}" ]]; then
		GREPPED=$(echo "${2}" | grep "@")
		if [[ "${GREPPED}" ]]; then
			echo "Contains name and address."
			ssh "${2}"
		fi
	else
		Help publish
	fi
	exit 0;
}

Help () {
	#CONTAINS=$(echo "$*" | grep -w '\-h\|\-\-help')
	if [[ "${DEBUG}" ]]; then
		echo "DEBUGGING HELP FUNCTION: 1:${1} 2:${2} 3:${3} CONTAINS:${CONTAINS}"
	fi
	if ! [[ "${2}" == "" && "${CONTAINS}" ]]; then
		if [[ "${2}" != "" ]]; then
			PRAM="${2}"
		else
			PRAM="ALL"
		fi
	fi
	case "${PRAM}" in
		ALL)
		Encapsulate "Usage: ${PROGNAME} -<-COMMAND> [OPTION]"
		FullBar
		Encapsulate "Mandatory arguments to long options are identical for short options."
		Encapsulate "  possible commands..."
		Encapsulate " "
		Encapsulate "  -a       --analyze       pre-scan deb(s) for error(s)"
		Encapsulate "  -b       --build         builds deb(s)"
		Encapsulate "  -e       --extract       extract debian archive"
		Encapsulate "  -C       --convert       converts deb(s) to Arch Linux"
		Encapsulate "  -C       --cleanfolder   removes folder(s)"
		Encapsulate "  -d       --dummy         builds empty dummy package"
		Encapsulate "  -f       --fix           attempts to fix error(s)"
		Encapsulate "  -h       --help          this help message"
		Encapsulate "  -l       --log           view or clean logs"
		Encapsulate "  -o       --override      suppresses all known warnings per package"
		Encapsulate "  -p       --prepare       prepare good .debs/ for publishing"
		Encapsulate "  -P       --publish       publishes them to address specified"
		Encapsulate "  -R       --relax         relax permissions"
		Encapsulate "  -r       --report        examine reported errorlog(s)"
		Encapsulate "  -r       --release       releases file for download."
		Encapsulate "  -s       --scan          version scans deb(s)"
		Encapsulate "  -S       --service       installs or removes ${APPNAME} as a service"
		Encapsulate "  -V       --verbose       reports errors verbosly and instructs how to fix"
		Encapsulate "  -v       --version       dump version info and exit."
		Encapsulate "  -z       --repository    build Arch based reposiroty and exit."
		Encapsulate " "
		FullBar
		Center "${PROGNAME} --help [COMMAND] for further information."
		FullBar;;
		a|analyze)
		FullBar
		Encapsulate "Usage analyze;"
		Encapsulate "${APPNAME} -a [DEB(s)]"
		FullBar
		FormatText "Analyses packages for error(s) and warnings. Specifying no [DEB] will analyze all debs in current directory for error(s) and warning(s) prompting first.  All error free deb(s) are moved to a hidden folder called .debs/ in the current folder. If non-existant the .debs/ folder will be created for you."
		FullBar
		Encapsulate "Example: ${APPNAME} -a ultimate-edition-${APPNAME}_1.8.5_all.deb"
		Encapsulate "Will analyze ${APPNAME} itself looking for error(s) and warning(s)."
		FullBar;;
		b|build)
		FullBar
		Encapsulate "Usage build;"
		Encapsulate "${APPNAME} -b [FOLDERNAME]"
		FullBar
		FormatText "Builds Debian package. Specifying no [FOLDERNAME] will build all folders in current directory prompting first.  All error free deb(s) are moved to a hidden folder called .debs/ in the current folder.  If non-existant the .debs/ folder will be created for you."
		FullBar
		Encapsulate "Example: ${APPNAME} -b ultimate-edition-${APPNAME}_1.8.5_all/"
		Encapsulate "Will build ${APPNAME} into a Debian package."
		FullBar;;
		C|cleanfolder)
		FullBar
		Encapsulate "Usage cleanfolder;"
		Encapsulate "${APPNAME} -C [FOLDERNAME]"
		FullBar
		FormatText "Will erase specified folder ignoring permissions. Specifying no folder name will erase all sub-folders in the curent folder. It will display the folders to be effected and prompt you. Please use with extreme caution and care. ${APPNAME} will prompt you of the folders to be effected."
		FullBar
		Encapsulate "Example: ${APPNAME} -C ultimate-edition-${APPNAME}_1.8.5_all/"
		Encapsulate "Will remove the folder ultimate-edition-${APPNAME}_1.8.5_all/"
		Encapsulate "Ignoring permissions."
		FullBar;;
		e|extract)
		FullBar
		Encapsulate "Usage extract;"
		Encapsulate "${APPNAME} -d [DEBIANFILENAME]"
		FullBar
		Encapsulate "Will extract [DEBIANFILENAME]. Specifying no deb file name will extract"
		Encapsulate "all debs in current directory prompting first."
		FullBar
		Encapsulate "Example: ${APPNAME} -e ultimate-edition-${APPNAME}_1.8.5_all.deb"
		Encapsulate "Will extract the deb to the folder ultimate-edition-${APPNAME}_1.8.5_all/"
		FullBar;;
		d|dummy)
		FullBar
		Encapsulate "Usage dummy;"
		Encapsulate "${APPNAME} -e <DEBIANFILENAME> <VERSION"
		FullBar
		FormatText "Will create an empty <DEBIANFILENAME> at <VERSION>. Useful for wiping a Requirement of a dependancy or getting rid of malware such as Zeitgeist.  Leaving the Operating System thinking the pre-requsite has been installed.  The resulting package is empty and preforms nothing."
		FullBar
		Encapsulate "Example: ${APPNAME} -d zeitgeist 3.0.0"
		Encapsulate "Will build an empty package of zeitgeist at version 3.0.0."
		FullBar;;
		f|fix)
		FullBar
		Encapsulate "Usage fix;"
		Encapsulate "${APPNAME} -f [FOLDER]"
		FullBar
		FormatText "Will attempt to fix all errors in the specified folder to be lintian, debian complient. Specifying no folder name will process all folders with a [FOLDER].deb.errors. This will take a long time to be fully implemented."
		FullBar
		Encapsulate "Example: ${APPNAME} -f ultimate-edition-${APPNAME}_1.8.5_all/"
		Encapsulate "Will attempt repair in the folder ultimate-edition-${APPNAME}_1.8.5_all/"
		FullBar;;
		h|help)
		FullBar
		Encapsulate "${APPNAME} -h [COMMAND]"
		Encapsulate "Display help for <COMMAND>"
		Encapsulate "	possible commands...\n"
		Encapsulate "	-b	--build		builds deb(s)"
		Encapsulate "	-e	--extract	extract debian archive"
		Encapsulate "	-C	--cleanfolder	removes folder(s)"
		Encapsulate "	-d	--dummy		builds empty dummy package"
		Encapsulate "	-f	--fix		attempts to fix error(s)"
		Encapsulate "	-h	--help		this help message"
		Encapsulate "	-l	--log		view or clean logs"
		Encapsulate "   -o  --overwrite suppresses all known warnings per package"
		Encapsulate "	-p	--prepare	prepare good .debs/ for publishing"
		Encapsulate "	-P	--publish	publishes repository to address specified"
		Encapsulate "	-R	--relax		relax permissions"
		Encapsulate "	-r	--report	examine reported errorlog(s)"
		Encapsulate "	-s	--scan		version scans debs"
		Encapsulate "	-S	--service	installs or removes ${APPNAME} as a service"
		Encapsulate "	-V	--verbose	reports errors verbosly and instructs how to fix"
		Encapsulate "	-v	--version	dump version info"
		Encapsulate "  -z       --repository    build Arch based reposiroty and exit.";;
		l|log)
		FullBar
		Encapsulate "Usage log;"
		Encapsulate "${APPNAME} -l <view/clean/logfilename>"
		FullBar
		Encapsulate "Usage log;"
		Encapsulate "${APPNAME} -l <view/clean/logfilename>"
		Encapsulate "View, clear global or individual logging activity."
		FullBar
		Encapsulate "Example: ${APPNAME} -l view"
		Encapsulate "Will load up the error log into your default text viewer."
		FullBar;;
		o|override)
		FullBar
		Encapsulate "Usage override;"
		Encapsulate "${APPNAME} -o <WARNING>"
		FullBar
		FormatText "Overrides all warning(s).  ${PROGNAME} will strip package by package all warnings.  I highly suggest you do not use this switch until ${PROGNAME} has exhusted all options (typically 3 passes of the fix option) before invoking this switch.  What will remain is solidly Error(s). Warning(s) will become a thing of the past.  I have written this switch (was undocumented) so I can solely concentrate on errors and quit building packages that for example have a spelling error in them.  The optional <WARNING> will seek and destroy only that warning.  Specifing no option will do the same on a * based system. Previously Undocumented switch used for working all warnings out of debs / folders, repetitive processing.  Allows me to concentrate solely on errors."
		FullBar
		Encapsulate "Example: ${APPNAME} -o no-manual-page"
		Encapsulate "Will prepare all the debs that had a warning for no-manual-page.  Which should never happen ${APPNAME} will to the best of it's knowledge make that for you, similar to help2man does."
		FullBar;;
		p|prepare)
		FullBar
		Encapsulate "Usage prepare;"
		Encapsulate "${APPNAME} -p <DISTNAME>"
		FullBar
		FormatText "Prepares known good .debs/ for publishing. Builds the directory structure in a folder called <DISTNAME>. ${PROGNAME} then GPG key signs the deb(s) as well the release key for distribution. This command switch also auto generates packages.gz for repository management. Knowledge of how a repository works is highly recommended when using this command switch."
		FullBar
		Encapsulate "Example: ${APPNAME} -P Themes"
		Encapsulate "Will prepare all the debs in Themes/ for publishing a repo online."
		FullBar;;
		P|publish)
		FullBar
		Encapsulate "Usage publish;"
		Encapsulate "${APPNAME} -P <USERNAME@URL/DISTNAME>"
		FullBar
		FormatText "Will scan good debs from .debs/ folder automatically creating structure for repository management and rsync the files to address ie ${APPNAME} -P USER@http://themelinux.com/themes/ themes it will prompt for the password for your server."
		FullBar
		Encapsulate "Example: ${APPNAME} -P USER@http://themelinux.com/themes/ themes"
		Encapsulate "Will publish all the debs in Themes/ for a repo online."
		FullBar;;
		r|relax)
		FullBar
		Encapsulate "Usage relax;"
		Encapsulate "${APPNAME} -r [FOLDERNAME]"
		FullBar
		FormatText "Will relax the permissions on a given folder allowing you to edit or delete files within the folder.  The proper permissions will automatically be reset when you goto build.  Not specifying a folder will reset permissions on all sub-folders.  Please be careful where you execute this tool. It will display the folders to be effected and prompt you."
		FullBar
		Encapsulate "Example: ${APPNAME} -r ultimate-edition-${APPNAME}_1.8.5_all/"
		Encapsulate "Will relax all permissions to 777 in given folder."
		FullBar;;
		R|report)
		FullBar
		Encapsulate "Usage report;"
		Encapsulate "${APPNAME} -R [FOLDERNAME]"
		FullBar
		Encapsulate "Will display error and build reports for all debs in previous session, or"
		Encapsulate "results from [FOLDERNAME] specific deb."
		FullBar
		Encapsulate "Example: ${APPNAME} -R ultimate-edition-${APPNAME}_1.8.5_all/"
		FormatText "Will report any error or warning involved in the building in this case ${APPNAME} itself.  You will never see one there ;)"
		FullBar;;
		S|service)
		FullBar
		FullBar
		Encapsulate "${APPNAME} -S <on|off> [--autofix] [#]"
		FullBar
		FormatText "Installs or removes based on second switch to set Repostorm as a service. Once set as a service Repostorm will monitor any package being installed and scan for error(s) and warning(s) optionally [--autofix] them via end users discretion.  This powerful feature will allow the end user to make the decision if or not error(s) and warning(s) enter their system prior to the package even being installed.  Similar to what anti-virus software does.  Optional [#] number of attempts ${PROGNAME} will re-build / fix an errored debian archive, before moving on.  I highly suggest setting this no higher then 3.  If ${PROGNAME} does not fix it in 3 passes, I have yet to write a function to auto-correct the error in question."
		FullBar
		Encapsulate "Example: ${APPNAME} --service on autofix 3"
		FormatText "Will install ${PROGNAME} as a service, and autoscan for error(s) and warning(s) attempting repair 3 times before allowing the error(s) if any to go through. ${PROGNAME} will currently catch and repair in the high 90 percentile of all known errors and warnings."
		FullBar;;
		s|scan)
		FullBar
		Encapsulate "Usage scan;"
		Encapsulate "${APPNAME} -s [FOLDER]"
		FullBar
		FormatText "Version scans all deb(s) to be processed. This should be the first step you take when dealing with large amounts of debs. When processing a single deb this switch is useless. There is no sense in building 2 seperate versions of debs. On the large scale this is not a required, but recommended base of first action."
		FullBar
		Encapsulate "Example: ${APPNAME} -scan debs/"
		Encapsulate "Will version scan the entire folder at debs/"
		FullBar;;
		V|verbose)
		FullBar
		Encapsulate "Usage verbose;"
		Encapsulate "${APPNAME} -V [FOLDER]"
		FullBar
		FormatText "Specifying no folder name will build all folders in current directory; prompting first. Verbosely displaying how to fix error(s) in given deb. All error free debs are copied to a hidden folder called .debs/ in the current folder. The .debs/ folder will be created for you.";;
		v|version)
		FullBar
		Encapsulate "Usage version;"
		Encapsulate "${APPNAME} -v$"
		FullBar
		Encapsulate "Displays ${APPNAME}s version number and exits.";;
		h|help|\?)
		FullBar
		Encapsulate "Usage help;"
		Encapsulate "${APPNAME} -h [COMMAND]"
		FullBar
		Encapsulate "Displays this message. For futher information ${APPNAME} --help <COMMAND>"
		Encapsulate "or refer to the manpages."
		Encapsulate "man ${APPNAME}"
		FullBar
		Encapsulate "Example: ${APPNAME} -h service"
		Encapsulate "Will display help for service function.";;
		*)
		Encapsulate "Usage: ${PROGNAME} -<-COMMAND> [OPTION]"
		FullBar
		Encapsulate "Mandatory arguments to long options are identical for short options."
		Encapsulate "  possible commands..."
		Encapsulate " "
		Encapsulate "  -a       --analyze       pre-scan deb(s) for error(s)"
		Encapsulate "  -b       --build         builds deb(s)"
		Encapsulate "  -e       --extract       extract debian archive"
		Encapsulate "  -C       --cleanfolder   removes folder(s)"
		Encapsulate "  -d       --dummy         builds empty dummy package"
		Encapsulate "  -f       --fix           attempts to fix error(s)"
		Encapsulate "  -h       --help          this help message"
		Encapsulate "  -l       --log           view or clean logs"
		Encapsulate "  -o       --override      suppresses all known warnings per package"
		Encapsulate "  -p       --prepare       prepare good .debs/ for publishing"
		Encapsulate "  -P       --publish       publishes them to address specified"
		Encapsulate "  -R       --relax         relax permissions"
		Encapsulate "  -r       --report        examine reported errorlog(s)"
		Encapsulate "  -r       --release       releases files for download."
		Encapsulate "  -s       --scan          version scans deb(s)"
		Encapsulate "  -S       --service       installs or removes ${APPNAME} as a service"
		Encapsulate "  -V       --verbose       reports errors verbosly and instructs how to fix"
		Encapsulate "  -v       --version       dump version info and exit."
		Encapsulate "  -z       --repository    build Arch based reposiroty and exit."
		Encapsulate " ";;
	esac
	exit 0
}

PreScan () {
	# Break out the TOYS!, err what toys do we have?
	CORES=$(grep -i "processor" "/proc/cpuinfo" | sed '/model/d' | wc -l)
	(( ACTUALCORES = ${CORES} -1 ))
	Encapsulate "Number of CPU Core(s) / threads(s) detected: ${CORES}"
	Encapsulate "Launching ${CORES} instances to accelerate the analitical process, please wait."
	# How many core do we have running currently?
   	RUNNINGINSTANCES=$(ps -C ${APPNAME} | wc -l)
	shopt -s nullglob
	declare -a ERRORLOGS=();
	declare -a ISFOLDERS=();
	declare -a PERFECTDEBS=();
	declare -a DEBS=();
	FTP=""
	ISFOLDERS=(/*)
	NFOLDERS="${#ISFOLDERS[@]}"
	DEBS=(./*.deb)
	TOTALDEBS="${#DEBS[@]}"
	ERRORLOGS=(./*.errors)
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			FTP="${EACH}"
		fi
	done
	if ! [[ -d ".debs/" ]]; then
		mkdir ".debs/"
	fi
	if [[ "${#DEBS[@]}" -gt 0 ]]; then
		Center "${PROGNAME} ${REPOVERSION} is pre-scanning for error(s)."
		FormatNUM "Processing deb(s): 1 of " "${TOTALDEBS}"
		for EACH in "${DEBS[@]}"
		do
			TARGET=${EACH// /_}
			DEB="${TARGET%/}"
			# How many core do we have running currently?
	   	   	RUNNINGINSTANCES=$(ps -C lintian | wc -l)
			while [[ "${RUNNINGINSTANCES}" -ge "${CORES}" ]] ;
		   	do
				RUNNINGINSTANCES=$(ps -C lintian | wc -l)
			done

			ERRORFILE="${DEB}.errors"
			if ! [[ -s "${ERRORFILE}" ]]; then
				if [[ "${RUNNINGINSTANCES}" -lt "${CORES}" ]]; then
					Encapsulate "Launching thread #${RUNNINGINSTANCES}: Scanning ${EACH} for errors."
					THREAD=$(lintian --profile=ubuntu "${EACH}" 1> "${EACH}.errors" 2>/dev/null &)
				fi
   			fi
		done
		while [[ "${RUNNINGINSTANCES}" -gt 1 ]] ;
		do
			if [[ "${CHANGED}" -eq 0 ]]; then
				CHANGED=1
				Encapsulate "Waiting for thread(s) to complete."
			else
				Encapsulate "Thread(s) Running: ${RUNNINGINSTANCES}"
			fi
			RUNNINGINSTANCES=$(ps -C lintian | wc -l)
		done
		# I hate this command, but ensures all files are there before continuing.
		Encapsulate "Sycronising data, please wait."
		sync;
   		AERROR=0
		ERRORFILES=(*.errors)
		for EACH in "${ERRORFILES[@]}"
		do
		#ERRORS?? - let's start ignoring NFO's
		if [[ -s "${EACH}" ]]; then
			# pre-process errors / warnings
			AERROR=$(grep -o "E: " "${EACH}" | wc -l)
			if [[ "${AERROR}" == 0 ]]; then
				AERROR=$(grep -o "W: " "${EACH}" | wc -l)
			fi
		fi
		if [[ "${AERROR}" == "0" ]]; then
		   	if [[ -s "${EACH}" ]]; then
		   		Encapsulate "NFO: tags overridden, we hope they overwote the tag because does no apply to them."
				Encapsulate "No errors or warnings. We will treat this as a perfect deb, we have to trust the programmer."
				Encapsulate "This file will not be reported."
			fi
		if [[ -f "${EACH}" ]]; then
			rm "${EACH}"
		fi
	fi

	if [[ -s "${EACH}" ]]; then
		Encapsulate "Errors detected in ${EACH}."
	else
		Encapsulate "${EACH//.errors} is a perfect deb. Moving to ./debs/"
		mv "${EACH//.errors}" ".debs/"
		if [[ -f "${EACH}" ]]; then
			# Let's clean up.
			rm "${EACH}"
		fi
	fi
	done
	sync;
	#Delete non-error reports
	find . -name "*.errors" -size 0 -delete
	# WriteLogs "--suppress" # Let's not bloat the log file.
	FullReport "--suppress"

			Error "No files to process?"
			exit 0;
		fi
	#Clean up
	Notification "${PROGNAME}: Analitical process complete."
	shopt -s nullglob
	shopt -s dotglob
	INFOLDER="${PWD}"
	declare -a PERFECTDEBS=();
	if [[ -d ".debs/" ]]; then
		cd ".debs/" || exit 1;
		PERFECTDEBS=(*.deb)
		cd "${INFOLDER}" || exit 1;
	fi
	Center "Total deb(s) analyzed: ${TOTALDEBS} Perfect deb(s):${#PERFECTDEBS[@]}"
	FullBar
}

Service () {
	SS="${APPNAME}"
	RETURND="$CWD"
	Center "${PROGNAME} ${REPOVERSION} service function invoked."
	if [[ "${2}" == "" ]]; then
		Error "Missing parameter(s)"
		Help service
		exit 0;
	fi
	AUTOFIX=$(echo "$*" | grep -i "autofix")
	ENGAGE=$(echo "$*" | grep -i "engage")

	# echo "DEBUGGING: $*"
	# CLEANUP=$(apt-get clean)
	sudo touch /etc/apt/apt.conf.d/triggers
	if ! [[ "${ENGAGE}" ]]; then
		if [[ "${2}" == "on" ]]; then
			SERVICE=$(grep -i "/bin/${APPNAME}" "/etc/apt/apt.conf.d/triggers")
			if [[ "${SERVICE}" == "" ]]; then
				Encapsulate "Installing ${PROGNAME} as a service. To remove the service ${APPNAME} --service off."
				GREPIT=$(echo "$@" | grep -i 'autofix')
				if [[ "${GREPIT}" ]]; then

					Encapsulate "${PROGNAME} autofix switch engaged, ${APPNAME} will autorepair packages before they enter your system."
				fi
				if ! [[ -f "/etc/apt/apt.conf.d/triggers" ]]; then
					sudo touch "/etc/apt/apt.conf.d/triggers"
				fi
				if [[ "${AUTOFIX}" ]]; then
					echo 'DPkg::Pre-Install-Pkgs:: "/bin/repostorm --service on autofix 3 engage";'| sudo tee -a "/etc/apt/apt.conf.d/triggers" >/dev/null
				else
					echo 'DPkg::Pre-Install-Pkgs:: "/bin/repostorm --service on engage";'| sudo tee -a "/etc/apt/apt.conf.d/triggers" >/dev/null
				fi
				echo 'DPkg::Post-Invoke {"/bin/rm -f /var/cache/apt/archives/*.deb || true";};' | sudo tee "/etc/apt/apt.conf.d/clean" 1>/dev/null
				if [[ -e "/etc/apt/apt.conf.d/10periodic" ]]; then
					sudo rm "/etc/apt/apt.conf.d/10periodic"
					sudo touch "/etc/apt/apt.conf.d/10periodic"
				fi
				echo 'APT::Periodic::Download-Upgradeable-Packages "1";
				APT::Periodic::AutocleanInterval "1";
				APT::Periodic::Unattended-Upgrade "1";'| sudo tee -a "/etc/apt/apt.conf.d/10periodic" >/dev/null
				sudo apt-get clean
				exit 0;
			else
				if [[ "${AUTOFIX}" ]]; then
					Error "${PROGNAME} is already set as a service. To remove the service ${APPNAME} --service off."
					exit 0;
				fi
			fi
		fi
		if [[ "${2}" == "off" ]]; then
			SERVICE=$(grep -i "/bin/${APPNAME}" "/etc/apt/apt.conf.d/triggers")
			if [[ "${SERVICE}" == "" ]]; then
				Error "${APPNAME} is not currently set as a service. Use ${APPNAME} --service on."
				exit 0;
			else
				Encapsulate "Removing ${PROGNAME} as a service. To add the service ${APPNAME} --service on."
				#sed -i '/'$SS'/d' /etc/apt/apt.conf.d/triggers
				sudo sed -i "/${SS}/d" /etc/apt/apt.conf.d/triggers
				if [[ -e "/etc/apt/apt.conf.d/10periodic" ]]; then
					sudo rm "/etc/apt/apt.conf.d/10periodic"
					sudo rm "/etc/apt/apt.conf.d/clean"
				fi
				sudo touch "/etc/apt/apt.conf.d/10periodic"
				echo 'APT::Periodic::Update-Package-Lists "1";
				APT::Periodic::Download-Upgradeable-Packages "0";
				APT::Periodic::AutocleanInterval "0";'| sudo tee -a "/etc/apt/apt.conf.d/10periodic" >/dev/null
				sudo apt-get clean
				exit 0;
			fi
		fi
	else
		LITERATIONS=$(echo "$*" | grep -i "engage" | cut -d " " -f6 | sed "s/ //g")
	fi
	if [[ -f "/etc/apt/apt.conf.d/triggers" ]]; then
		LITERATIONS=$(grep -i "autofix" "/etc/apt/apt.conf.d/triggers" | cut -d " " -f6 | sed "s/ //g")
	fi
	Encapsulate "Pre-scanning deb file(s)."
	cd "/var/cache/apt/archives/" || exit 1;

	# Prescan debs for error(s) - move good ones no sense in repairing a deb that is not broken.
	PreScan "--suppress" #works perfectly now.
	# FullReport "--suppress" # PreScan Generates a full Report, why do it twice?
	if [[ "${LITERATIONS}" -gt 1 ]]; then
		Center "${PROGNAME} has detected autofix has been set to re-building each errored package(s) ${LITERATIONS} time(s)."
	fi
	# Extract debs with error(s) w/o prompting maximize computer resources while doing so.
	FILESTOEXTRACT=(./*.deb)
	NUMFILESTOEXTRACT="${#FILESTOEXTRACT}"
	if [[ "${NUMFILESTOEXTRACT}" -gt 0 ]]; then
		Encapsulate "Extracting ${NUMFILESTOEXTRACT} package(s) at a time using ${CORES} CPU core(s)."
	else
		Encapsulate "No files to extract.  All perfect?"
	fi
	RUNNINGINSTANCES=$(ps -C ${APPNAME} | wc -l)
	Encapsulate "Debugging: Current running processes: ${RUNNINGINSTANCES}"
	#exit 0; # we are still debugging.
	if [[ "${NUMFILESTOEXTRACT}" -gt 0 ]]; then
		for EACH in "${FILESTOEXTRACT[@]}"
		do
			# How many core do we have running currently?
		   	RUNNINGINSTANCES=$(ps -C ${APPNAME} | wc -l)
			# EXPELL all core, let's go to work, if we have maxed out, wait for one core to finish.
			while [[ "${RUNNINGINSTANCES}" -ge "${CORES}" ]] ;
		   	do
				RUNNINGINSTANCES=$(ps -C ${APPNAME} | wc -l)
			done
			# Yee HAW we have an open core, let's put it to work.
		   	if [[ "${RUNNINGINSTANCES}" -lt "${CORES}" ]]; then
				INSTANCE=$(( "${RUNNINGINSTANCES}" + 1 ))
		   	   	Encapsulate "Launching thread #${INSTANCE}: Extracting ${EACH} (RUNNING INSTANCES: ${RUNNINGINSTANCES})"
				repostorm -e "${EACH}" -YES --suppress & #& allows that to process and continue running through current software hence why the not equal 3 below
			fi
		done
		while [[ "${RUNNINGINSTANCES}" -ne "3" ]] ;
			do
				Encapsulate "Waiting for threads to complete: ${RUNNINGINSTANCES}"
				RUNNINGINSTANCES=$(ps -C ${APPNAME} | wc -l)
			done
			# I hate this command, but ensures all files are there before continuing.
			Encapsulate "Sycronising data, please wait."
			sync;
			#exit 1;  #we are still debugging, bail out, before even fixing.
	fi
	# if autofix is set fix errors and re-build w/o prompting.
	DEBFILES=(*.deb)
	NUMDEBS="${#DEBFILES}"
	if [[ "${NUMDEBS}" -gt 0 ]]; then
		EACH=0
		if [[ "${LITERATIONS}" ]]; then
			while [[ "${EACH}" -lt "${LITERATIONS}" ]]
			do
				EACH=$(( EACH + 1 ))
				Center "Processing autofix ${EACH} of ${LITERATIONS}"
				repostorm -f -YES --suppress
				repostorm -b -YES --suppress
			done
		else
			repostorm -f -YES --suppress
			repostorm -b -YES --suppress
		fi
	else
		Center "All Deb(s) are perfect, moving back for installation."
		#mv .debs/* .
	fi
	INFLD="${PWD}"
	if [[ -d "/var/cache/apt/archives/.debs/" ]]; then
		cd "/var/cache/apt/archives/.debs/" || exit 1;
		shopt -s nullglob
		DEBFILES=(*.deb)
		if [[ "${#DEBFILES[@]}" -gt 0 ]]; then
			Encapsulate "Moving known good ${#DEBFILES[@]} deb(s) back for installation."
			for EACH in "${DEBFILES[@]}"
			do
				mv "${EACH}" "/var/cache/apt/archives/"
			done
			sync
			cd "${INFLD}" || exit 1;
			rm -R "/var/cache/apt/archives/.debs/"
			ClearLogs "--suppress"
		fi
	fi
	if [[ -d "/var/cache/apt/archives/" ]]; then
		Encapsulate "${PROGNAME} is cleaning up, before installing."
		cd "/var/cache/apt/archives/" || exit 1;
		find . -type d ! -regex '^./partial\(/.*\)?' | xargs rm -rf 2>/dev/null
	fi
	# WriteLogs "--suppress"
	Encapsulate "Clearing session build logs."
	#CleanService
	ClearLogs "--suppress"
	#Clean --YES
	cd "${RETURND}" || exit 1;
	Center "${PROGNAME} service complete."
}

ViewLog () {
	IFILE="${3}"
	if ! [[ -f "${IFILE}" ]]; then
		IFILE="/var/log/${APPNAME}_errors.log"
	fi
	XVIEW=$(type -p xdg-open)
	if ! [[ "${XVIEW}" ]]; then
		declare -a VIEWER=('gedit' 'nano' 'vi');
		for VIEW in "${VIEWER[@]}"
		do
			if ! [[ "${XVIEW}" ]]; then
				XVIEW=$(type -p "${VIEW}")
			fi
		done
	fi
	if [[ "${XVIEW}" ]]; then
		if [[ -f "${IFILE}" ]]; then
			Encapsulate "To Open log file with default viewer:"
			COMMAND="${XVIEW} ${IFILE}"
			Encapsulate "${COMMAND}"
			xdg-open "${IFILE}"
		else
			echo "No logs are availiable."
		fi
	else
		Error "Error: No text editor detected."
		exit 0;
	fi
}

Empty () {
	if ! [[ -d "${2}-${3}" ]]; then
		mkdir -p "${2}-${3}/DEBIAN"
	fi
	if ! [[ -f "${2}-${3}/DEBIAN/control" ]]; then
		echo "Package: ${2}" > "${2}-${3}/DEBIAN/control"
		echo "Priority: optional" >> "${2}-${3}/DEBIAN/control"
		echo "Section: gnome" >> "${2}-${3}/DEBIAN/control"
		echo "Architecture: all" >> "${2}-${3}/DEBIAN/control"
		echo "Version: ${3}" >> "${2}-${3}/DEBIAN/control"
		echo "Installed-Size: 21120" >> "${2}-${3}/DEBIAN/control"
		echo "Homepage: http://${APPNAME}.com/" >> "${2}-${3}/DEBIAN/control"
		echo "Maintainer: Repostorm <${APPNAME}@${APPNAME}.com>" >> "${2}-${3}/DEBIAN/control"
		echo "Replaces: ${2}" >> "${2}-${3}/DEBIAN/control"
		echo "Description: Dumby package" >> "${2}-${3}/DEBIAN/control"
		echo " A dumby package used to squash dependencies." >> "${2}-${3}/DEBIAN/control"
		echo " ." >> "${2}-${3}/DEBIAN/control"
		echo " For information please visit http://forumubuntusoftware.info/" >> "${2}-${3}/DEBIAN/control"
	fi
	repostorm --build "${2}-${3}"
	repostorm --fix "${2}-${3}"
	repostorm --build "${2}-${3}"
	repostorm --fix "${2}-${3}"
	repostorm --build "${2}-${3}"
	repostorm --fix "${2}-${3}"
}

# Internal, undocumented function.
WorkIt () {
	# See if we have analyzed the debs prior, if not analyze data & kick out the perfect ones.
	# If it is not broken, don't fix it.
	# Push inmaterial data off to null in case there are no error logs
	# IE user has not scanned for errors etc.
	shopt -s nullglob
	declare -a ERRORLOGS=();
	declare -a ISFOLDERS=();
	ISFOLDERS=(/*)
	NFOLDERS="${#ISFOLDERS[@]}"
	ISDEBS=(./*.deb)
	ERRORLOGS=(./*.errors)
	# No errorlogs? Have we analzyed the deb(s) for errors? Let's make that happen.
	if ! [[ "${ERRORLOGS[*]}" ]]; then
		repostorm --analyze
		repostorm --report
	fi

	# DEBUG at this point in programming...
	Error "${PROGNAME} ${VERSION} IS DEBUGGING ${USER}'s INPUT: 1:${1} 2:${2} 3:$3"
	Center "${PROGNAME}: (Work it) internal, undocumented function invoked."
	Encapsulate "${PROGNAME}, has detected ${NFOLDERS} folders and ${NDEBS} debian archives to process. ${PROGNAME} will scan / repair ${PWD}'s contents ${2} times, before giving up."

	#BEGIN Full automation and the flow to perfection...
	if [[ "${ISDEBS[*]}" ]]; then
			for EACH in "${ISDEBS[@]}"
			do
				FOLDER="${EACH%%.deb}"
				if [[ -d "${FOLDER}" ]]; then
					repostorm --build "${FOLDER}/"
					if [[ -f "${FOLDER}.deb.errors" ]]; then
						repostorm --fix "${FOLDER}"
					fi
				else
					repostorm --extract "${EACH}"
				fi
			done
	else
		if [[ "${ISFOLDERS[*]}" ]]; then
			for EACH in "${ISFOLDERS[@]}"
			do
				if [[ -d "${EACH}/DEBIAN" ]]; then
					Encapsulate "Un-built Debian package detected at ${EACH}:"
					repostorm --build "${EACH}"
					ERROR=$(echo "${EACH}" | sed 's/\///g')
					if [[ -f "${ERROR}.deb.errors" ]]; then
						Error "ERRORS DETECTED IN ${EACH}, Fixing aforesaid error(s)."
						repostorm --fix --YES "${FOLDER}"
					fi
				fi
			done
		else
			Error "Error: No debian archives or debian folders found in current folder."
		fi
	fi
}

ClearErrors () {
	#enable for debugging...
	#echo "Switches : 1:${1} 2:${2} 3:$3"
	Timer "Start" "Lintian OverRides"
	ETYPE="${2}" # Allow closing a single type of error / warning.
	shopt -s nullglob
	declare -a ERRORLOGS=();
	declare -a ISFOLDERS=();
	declare -a PERFECTDEBS=();
	declare -a DEBS=();
	declare -a FTCP=();
	TWARN=0
	ISFOLDERS=(/*)
	NFOLDERS="${#ISFOLDERS[@]}"
	DEBS=(*.deb)
	TOTALDEBS="${#DEBS[@]}"
	ERRORLOGS=(*.errors)
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			FTCP="${EACH//.deb}"
		fi
		if [[ -d "${EACH}" ]]; then
			FTCP="${EACH}"
		fi
	done
	if ! [[ "${FTCP[*]}" ]]; then
		FTCP=(*.errors)
	fi
	if ! [[ "${FTCP[*]}" ]]; then
		Error "Nothing to process, ${PROGNAME} will exit graciously."
		exit 0;
	fi
	FColumnize -t "FOLDER" "WARNING/ERROR" "INSERT" "DEB"
	for EACH in "${FTCP[@]}"
	do
		FILE="${EACH//.deb.errors}"  # Set the standard.  Already loaded Array.
		if [[ -f "${FILE}.deb.errors" ]]; then # Individual file check - Smash it now, do not build a known good file.
	   		cat "${FILE}.deb.errors" | while read ERRORS  # Here comes the hammer, strip errors?
			do
	   			if [[ -d "${FILE}" ]]; then # check for existance of "extracted" deb.
					CONTROL="${FILE}/DEBIAN/control" # Pull the data of the package we are processing.
					PACKAGENAME=$(grep -i "Package: " "${CONTROL}" | cut -d: -f2 | sed 's/ //g')
					if ! [[ "${ETYPE}" ]]; then
						DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.
						ETYPE="${DROPSTRING}"
					fi
					ISWARNING=$(echo "${ERRORS}" | grep "^[W]") # Is it a Warning or an error?
					ISERROR=$(echo "${ERRORS}" | grep "^[E]") # Is it a Warning or an error?
					DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.
					if [[ "${ISWARNING}" ]]; then # We only want to suppress warning(s) not error(s)
						if [[ -f "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then # Has errors been reported before?
							EXISTS=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}")
							if ! [[ "${EXISTS}" && "${ISERROR}" ]]; then
					   	   		DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.
								GREPIT=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}") # Has it previously been fixed?
								if ! [[ "${GREPIT}" ]] ; then # I bet not.
									FColumnize "${FILE}/" "Warning  " "${ETYPE}" "${FILE}.deb" # Override it.
									if [[ -w "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then
										echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # It is gone from reporting.
										(( TWARN + 1 ))
									else
										Error "Insuficient privilages to write to: ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}."
										exit 1;
									fi
								fi
							fi
						else
							# What we know is the folder does not exist. we are still in the second if loop.  Ignoring the for loop or the Array.
							# DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.  Why again? It never seen the code above.
							# Encapsulate "Creating Lintian overrides folder: ${FILE}/usr/share/lintian/overrides/" # Create a folder specific for the "Packagename"
							mkdir -p "${FILE}/usr/share/lintian/overrides/"
							touch "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # Set it in stone
							FColumnize "${FILE}/" "${ETYPE}" "*" "${FILE}.deb" # Override it.
							echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
						fi
					fi
					if [[ "${ISERROR}" ]]; then # We only want to suppress error(s)
						if [[ -f "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then # Has errors been reported before?
							EXISTS=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}")
							if ! [[ "${EXISTS}" && "${ISERROR}" ]]; then
					   	   		DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.
								GREPIT=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}") # Has it previously been fixed?
								if ! [[ "${GREPIT}" ]] ; then # I bet not.
									FColumnize "${FILE}/" "Error	" "${ETYPE}" "*" "${FILE}.deb" # Override it.
									if [[ -w "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then
										echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # It is gone from reporting.
										(( TWARN + 1 ))
									else
										Error "Insuficient privilages to write to: ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}."
										exit 1;
									fi
								fi
							fi
						else
							# What we know is the folder does not exist. we are still in the second if loop.  Ignoring the for loop or the Array.
							# DROPSTRING=$(echo "${ERRORS}" | cut -d ":" -f3 | cut -d " " -f2) # Pull the error to fix.  Why again? It never seen the code above.
							# Encapsulate "Creating Lintian overrides folder: ${FILE}/usr/share/lintian/overrides/" # Create a folder specific for the "Packagename"
							mkdir -p "${FILE}/usr/share/lintian/overrides/"
							touch "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # Set it in stone
							FColumnize "${FILE}/" "${ETYPE}" "*" "${FILE}.deb" # Override it.
							echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
						fi
					fi
				else
					Error "Folder: ${FILE} does not exist, did you extract the deb(s)?"
					Encapsulate "Please use: ${APPNAME} --extract"
					exit 5;
				fi
			done
		fi
	done
	Encapsulate "Folder(s) processed: ${#FTCP[@]} Warning Type(s) supressed: ${TWARN}"
	Timer "Stop" "Lintian OverRides"
}

ProcessLogs () {
	if [[ "${2}" == "view" ]]; then
		ViewLog "$@"
	fi
	if [[ "${2}" == "clear" ]]; then
		ClearLogs "$@"
		if ! [[ -w "/var/log/${APPNAME}_errors.log" ]]; then
			CheckRoot "$@"
			sudo rm "/var/log/${APPNAME}_errors.log"
			sudo touch "/var/log/${APPNAME}_errors.log"
		fi
	fi
	if [[ "${2}" != "view" && "${2}" != "clean" ]]; then
		Error "ERROR: Invalid secondary log switch ${2}, retriving help system for log function:"
		repostorm -h log
	fi
	exit 0;
}

NeverFIX () {
	Timer "Start" "Error Suppression"
	# Unsure if I will fix:
	# Warning: W: libgtkmm-2.4-doc: embedded-javascript-library usr/share/doc/libgtkmm-2.4-doc/reference/html/jquery.js please use libjs-jquery Logged to all_warnings.txt. - tons of these warnings.  Instad of setting a dependancy on the file they included it thier package.  No way for me tell if it is a modified version.  I doubt I fix it.
	# Warning: W: libguestfs-tools: manpage-has-errors-from-man usr/share/man/man1/guestfish.1.gz 1388: warning [p 16, 8.8i]: can't break line Logged to all_warnings.txt. - require me to extact it, fix it and recompress.
	# Error: E: libhfstdc++6-8-dbg-armel-cross: unstripped-binary-or-object usr/arm-linux-gnueabi/libhf/debug/libstdc++.so.6.0.25 Logged to all_errors.txt. - Already have software for that, why does it not get stripped?  ARM.
	# pkg-config-unavailable-for-cross-compilation - results Unknown.
	# Error: E: libjas-java: privacy-breach-w3c-valid-html usr/share/doc/libjas-java/intro.html (http://www.w3.org/icons/valid-xhtml10) Logged to all_errors.txt. - this one bothers me, I just fixed this error today in repostorm.
	# I do not want to track you why should they?
	# Error: E: libjavatuples-java: description-too-short javatuples Logged to all_errors.txt. - if you are too lazy to write a description, should I do it for you?
	# Error: E: libjazzy-java: privacy-breach-logo usr/share/doc/libjazzy-java/index.html (http://sourceforge.net/sflogo.php?group_id=34472&amp;type=4) Logged to all_errors.txt.  Tracking, I do know how to fix it and remove you tracking users in a few mill-iseconds.
	# debian-news-entry-has-unknown-version (can be bothered to update your news)?  I do not even use it, but can fix it.
	# EZ FIX: helper-templates-in-copyright.  But I do not know if it is copywritten, IGNORE!. I would bet this individual is a Windows User. Example:
	# Error: E: libjcode-pm-perl: helper-templates-in-copyright Logged to all_errors.txt.
	# Error: E: libjcode-pm-perl: manpage-not-compressed-with-gzip usr/share/man/man3/--exclude=Jcode.3pm.gz Logged to all_errors.txt.
	# Warning: W: libjcode-pm-perl: broken-gz usr/share/doc/libjcode-pm-perl/--exclude=changelog.Debian.gz Logged to all_warnings.txt.
	# Warning: W: libjcode-pm-perl: broken-gz usr/share/man/man3/--exclude=Jcode.3pm.gz Logged to all_warnings.txt.
	# Warning: W: libjcode-pm-perl: manpage-has-bad-whatis-entry usr/share/man/man3/--exclude=Jcode.3pm.gz Logged to all_warnings.txt.
	# Warning: W: libjcode-pm-perl: syntax-error-in-debian-changelog line 0 "found eof where expected first heading" Logged to all_warnings.txt.
	# Warning: W: libjcode-pm-perl: wrong-name-for-upstream-changelog usr/share/doc/libjcode-pm-perl/Changes Logged to all_warnings.txt.
	# Warning: W: libjcode-pm-perl: zero-byte-file-in-doc-directory usr/share/doc/libjcode-pm-perl/changelog.Debian.gz Logged to all_warnings.txt.
	# If Repostorm does not know if it is copywritten does not fix SHIT!
	# HISTORY Bar almost none
	# The following Error(s) / Warning(s) I have zero intention of ever fixing...  It would require me to download the source code & build them properly.  Evidently the Author is incapable of doing.
	# all the following conditions would require me to download the source core re-build it properly, then re-build the deb.  NOT HAPPENING Captain.
	declare -a NEVER=();
	NEVER=( 'description-too-short' 'appstream-metadata-legacy-format' 'depends-on-essential-package-without-using-version' 'description-contains-invalid-control-statement' 'extended-description-is-empty' 'possible-gpl-code-linked-with-openssl' 'description-is-pkg-name' 'package-contains-file-in-etc-skel' 'arch-dependent-file-in-usr-share' 'init.d-script-not-included-in-package' 'privacy-breach-donation' 'privacy-breach-logo' 'ocaml-dangling-cmx' 'privacy-breach-google-cse' 'apache2-module-does-not-ship-load-file' 'privacy-breach-google-adsense' 'copyright-file-contains-full-apache-2-license' 'copyright-not-using-common-license-for-apache2' 'binary-from-other-architecture' 'arch-independent-package-contains-binary-or-object' 'license-problem-font-adobe-copyrighted-fragment' 'doc-base-file-references-wrong-path' 'privacy-breach-statistics-website' 'doc-base-file-references-missing-file' 'custom-library-search-path' 'privacy-breach-w3c-valid-html' 'package-installs-java-bytecode' 'embedded-javascript-library' 'shared-library-lacks-prerequisites' 'hardening-no-pie' 'embedded-library' 'debian-changelog-file-contains-invalid-email-address' 'binary-or-shlib-defines-rpath' 'non-dev-pkg-with-shlib-symlink' 'privacy-breach-uses-embedded-file' 'privacy-breach-generic' 'manpage-has-errors-from-man' 'wrong-path-for-interpreter' 'missing-dep-for-interpreter' 'transitional-package-should-be-oldlibs-optional' 'statically-linked-binary' 'hardening-no-relro' 'manpage-has-bad-whatis-entry' 'privacy-breach-uses-embedded-file' 'shlib-without-PT_GNU_STACK-section' 'shlib-with-executable-stack' 'symbols-file-contains-current-version-with-debian-revision' 'package-name-doesnt-match-sonames' 'gir-missing-typelib-dependency' 'library-not-linked-against-libc' 'pkg-config-multi-arch-wrong-dir' 'old-style-config-script-multiarch-path' 'helper-templates-in-copyright' 'shared-lib-without-dependency-information' 'package-must-activate-ldconfig-trigger' 'debian-revision-not-well-formed' 'debian-changelog-line-too-long' 'spelling-error-in-changelog') # The only exception is package-must-activate-ldconfig-trigger.  I can pull the data and modify the postinst.  I doubt, I go that far.
	NEVERS="${#NEVER[@]}"
	INDEX=0
	FINDEX=0
	TERRORS=0
	ERRORFILES=(*.errors)
	NUMFILES="${#ERRORFILES[@]}"
	if [[ "${NUMFILES}" -gt 1 ]]; then
		for EACH in "${NEVER[@]}"
		do
			INDEX=$((INDEX + 1))
			Center "FILES (${NUMFILES}) Scanning for error type ${EACH}: ${INDEX} of ${NEVERS}"
			FINDEX=0
			for ERROR in "${ERRORFILES[@]}"
			do
				FINDEX=$((FINDEX + 1))
				PROGRESS=$((100*FINDEX / NUMFILES))
				ProgressBar "${PROGRESS}" "Scanning file: ${FINDEX} of ${NUMFILES}"
				GREPIT=$(grep -i "${EACH}" "${ERROR}")
				if [[ "${GREPIT}" ]]; then
					FILE="${ERROR//.deb.errors}"
					PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
					Encapsulate "Found Error(s): ${EACH} in ${ERROR} FOLDER: ${FILE}/  Already suppressed?"
					if [[ -d "${FILE}" ]]; then
						ETYPE="${EACH}"
						if [[ -f "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then # Has errors been reported before?
							EXISTS=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}")
							if ! [[ "${EXISTS}" ]]; then
								GREPIT=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}") # Has it previously been fixed?
								if ! [[ "${GREPIT}" ]] ; then # I bet not.
									FullBar
									Encapsulate "Suppressed: No"
									Encapsulate "Suppressing Error in ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}:"
									Encapsulate "Error Type: ${ETYPE}" "*"
									Encapsulate "Deb file: ${FILE}.deb" # Override it.
									if [[ -w "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then
										echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # It is gone from reporting.
									else
										Error "Insuficient privilages to write to: ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}."
										exit 1;
									fi
								else
									FullBar
									Encapsulate "Suppressed: Yes"
									Encapsulate "Error Type: ${ETYPE}" "*"
									Encapsulate "Deb file: ${FILE}.deb"
								fi
							fi
						else
							# What we know is the folder does not exist. we are still in the second if loop.  Ignoring the for loop or the Array.
							# Encapsulate "Creating Lintian overrides folder: ${FILE}/usr/share/lintian/overrides/" # Create a folder specific for the "Packagename"
							mkdir -p "${FILE}/usr/share/lintian/overrides/"
							touch "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # Set it in stone
							FullBar
							Encapsulate "Suppressed: No"
							Encapsulate "Suppressing Error in ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}:"
							Encapsulate "Error Type: ${ETYPE}" "*"
							Encapsulate "Deb file: ${FILE}.deb" # Override it.
							echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
						fi
						TERRORS=$((TERRORS +1))
					else
						Error "Have you extracted the deb(s) yet?"
						exit 1;			#WipeErrors "${EACH}"
					fi
				fi
			done
		done
	else
		Encapsulate "No Error files found."
		exit 1;
	fi
	Encapsulate "Total Error(s) suppressed: ${TERRORS}"
	Timer "Stop" "Error Suppression"
}

Warnings () {
	Timer "Start" "Warning Suppression"
	INDEX=0
	FINDEX=0
	TERRORS=0
	ERRORFILES=(*.errors)
	NUMFILES="${#ERRORFILES[@]}"
	if [[ "${NUMFILES}" -gt 1 ]]; then
		for EACH in "${ERRORFILES[@]}"
		do
			INDEX=$((INDEX + 1))
			Center "FILES (${NUMFILES}) Scanning for Warnings in ${EACH}: ${INDEX} of ${NUMFILES}"
			FINDEX=0
			cat "${EACH}" | while read ERROR
			do
				FINDEX=$((FINDEX + 1))
				PROGRESS=$((100*FINDEX / NUMFILES))
				ProgressBar "${PROGRESS}" "Scanning file: ${FINDEX} of ${NUMFILES}"
				GREPIT=$(grep -i "${EACH}" "${ERROR}")
				if [[ "${GREPIT}" ]]; then
					FILE="${ERROR//.deb.errors}"
					PACKAGENAME=$(grep "Package: " "${FILE}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
					Encapsulate "Found Warning(s): ${EACH} in ${ERROR} FOLDER: ${FILE}/  Already suppressed?"
					if [[ -d "${FILE}" ]]; then
						ETYPE="${EACH}"
						if [[ -f "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then # Has errors been reported before?
							EXISTS=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}")
							if ! [[ "${EXISTS}" ]]; then
								GREPIT=$(grep -i "${ETYPE}" "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}") # Has it previously been fixed?
								if ! [[ "${GREPIT}" ]] ; then # I bet not.
									FullBar
									Encapsulate "Suppressed: No"
									Encapsulate "Suppressing Error in ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}:"
									Encapsulate "Error Type: ${ETYPE}" "*"
									Encapsulate "Deb file: ${FILE}.deb" # Override it.
									if [[ -w "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then
										echo "${ETYPE} * ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # It is gone from reporting.
										# echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # It is gone from reporting.
									else
										Error "Insuficient privilages to write to: ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}."
										exit 1;
									fi
								else
									FullBar
									Encapsulate "Suppressed: Yes"
									Encapsulate "Error Type: ${ETYPE}" "*"
									Encapsulate "Deb file: ${FILE}.deb"
								fi
							fi
						else
							# What we know is the folder does not exist. we are still in the second if loop.  Ignoring the for loop or the Array.
							# Encapsulate "Creating Lintian overrides folder: ${FILE}/usr/share/lintian/overrides/" # Create a folder specific for the "Packagename"
							#mkdir -p "${FILE}/usr/share/lintian/overrides/"
							#touch "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"  # Set it in stone
							FullBar
							Encapsulate "Suppressed: No"
							Encapsulate "Suppressing Error in ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}:"
							Encapsulate "Error Type: ${ETYPE}" "*"
							Encapsulate "Deb file: ${FILE}.deb" # Override it.
							echo "${ETYPE} * ${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
							# echo "${ETYPE} *" >> "${FILE}/usr/share/lintian/overrides/${PACKAGENAME}"
						fi
						TERRORS=$((TERRORS +1))
					else
						Error "Have you extracted the deb(s) yet?"
						exit 1;			#WipeErrors "${EACH}"
					fi
				fi
			done
		done
	else
		Encapsulate "No Error files found."
		exit 1;
	fi
	Encapsulate "Total Error(s) suppressed: ${TERRORS}"
	Timer "Stop" "Error Suppression"
}

Reset () {
	DESTINATIONFOLDER="${2}"
	if ! [[ "${DESTINATIONFOLDER}" ]]; then
		Encapsulate "Please specify destination folder. Ex: repostorm -z /home/${USER}/wip/"
		exit 0;
	fi
	if ! [[ -d "${DESTINATIONFOLDER}" ]]; then
		PromptYN "${WARNING}WARNING: Folder ${DESTINATIONFOLDER} does not exist. Create it (Y/N)? "
		case "${YN}" in
			[Nn]* ) Encapsulate "Exiting..."
			exit 0;;
			[Yy]* ) Encapsulate "Creating folder: ${DESTINATIONFOLDER}...";
				mkdir -p "${DESTINATIONFOLDER}";;
			* ) Encapsulate "Please answer y or n.";;
		esac
	fi
	SAVEIFS="${IFS}"
	declare -i NUMFILES
	declare -a THEDEBS=();
	shopt -s dotglob
	shopt -s nullglob
	Encapsulate "Scanning for deb(s)"
	#NUMFILES=$(find . -name \*.deb | wc -l)
	IFS=$'\n'
	THEDEBS=$(find . -name \*.deb)
	THEDEBS=("${THEDEBS[@]}")
	NUMFILES="${#THEDEBS[@]}"
	#Thousands "${NUMFILES}"
	if [[ "${NUMFILES}" -gt 0 ]]; then
		#NUMFILES="${FORMATTED}"
		FormatNUM "Found deb(s). Array loaded, Copying file(s):" "${NUMFILES}"
		INDEX=0
		for EACH in "${THEDEBS[@]}"
		do
			INDEX=$((INDEX + 1))
			PCOMP=$((100*INDEX / NUMFILES))
			ProgressBar "${PCOMP}" "Copying file : ${INDEX} of ${NUMFILES}"
			cp "${EACH}" "${DESTINATIONFOLDER}"
		done
		IFS="${SAVEIFS}"
	else
		Encapsulate "No debs found exiting."
		IFS="${SAVEIFS}"
		exit 0;
	fi

}

Unused () {
	Timer "Start" "Unused Lintian OverRides"
	Encapsulate "Enter Unused Lintian Override Switches."
	NegateRoot "$@"
	shopt -s dotglob
	shopt -s nullglob
	declare -a UNUSED=();
	FOLDERS=(*/)
	DEBS=();
	DEBS=(./*deb)
	declare -i NDEBS
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	NDEBS="${#DEBS[@]}"
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			DEBS="${EACH}"
		fi
	done
	if ! [[ "${DEBS}" ]]; then
		NDEBS="${#DEBS[@]}"
	fi
	if ! [[ "${NDEBS}" ]]; then
		Error "ERROR: No deb(s) found."
		Encapsulate "${APPNAME} --help for help or man ${APPNAME} for further Information."
		exit 1;
	fi
	for EACH in ${DEBS[@]}
	do
	if [[ -f "${EACH}" ]]; then
		Encapsulate "Scanning ${EACH} for unused Lintian overrides."
		SAVEIFS=$IFS
		# Change IFS to new line.
		IFS=$'\n'
		UNUSED=$(lintian -E -i -I --pedantic --no-tag-display-limit --color auto --verbose "${EACH}" | grep "I:" | grep "unused-override" | cut -d " " -f4)
		UNUSED=($UNUSED)
		IFS="$SAVEIFS"
		for USED in "${UNUSED[@]}"
		do
			FLDER="${EACH//.deb}"
			Encapsulate "Scanning for folder: ${FLDER}"
			if [[ -d "${FLDER}" ]]; then
				if [[ -f "${FLDER}/DEBIAN/control" ]]; then
					PACKAGENAME=$(grep "Package: " "${FLDER}/DEBIAN/control" | cut -d: -f2 | sed 's/ //g')
					Encapsulate "Found. Scanning for override: ${USED} in ${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}"
					FOUND=$(grep -i "${USED}" "${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}")
					if [[ "${FOUND}" ]]; then
						Encapsulate "Found. Stripping: ${USED} from ${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}"
						if [[ -w "${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}" ]]; then
							sed -i "/${USED}/d" "${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}"
						else
							Error "No write permissions to ${FLDER}/usr/share/lintian/overrides/${PACKAGENAME}, exiting..."
							exit 1;
						fi
					fi
				else
					Error "No control file found: ${FLDER}/DEBIAN/control, exiting..."
					exit 1;
				fi
			else
				Encapsulate "Extracting: ${EACH}"
			fi
		done
	fi
	done
	Timer "Stop" "Unused Lintian OverRides"
}

NOAPTFILE=$(echo "$@" | grep -i "aptfile")
if ! [[ "${SUPPRESS}" ]]; then
	VersionDump "$@"
	Timer "Start" "${APPNAME}"
	if ! [[ "${ISULTIMATE}" ]]; then
		Encapsulate "This software was written to work with Ultimate Edition. You are running ${OS_NAME}."
		Encapsulate "This means the software has NOT been tested for your O/S."
		Encapsulate "Run this at your own risk. The author takes no responsibily if you bork your O/S."
		FullBar
		Encapsulate "Press enter to continue or Ctrl+C to exit"
		FullBar
		read -rs key
	fi
fi
BuildRepo () {
	LANG=en_US.UTF-8
	Encapsulate "Repository name?: (No spaces or ASCII in repository name allowed. HIT space to confirm): "
	read -p '▒ Repository name: ' '-d ';
	echo -e "\033[${COLUMNZ}G▒" # Close Encapsulation.
	echo -en "\033[1A\033[2K"
	REPOSITORY="${REPLY}"
	Timer "Start" "Build Repository"
	LANG=en_US.UTF-8
	ZST=(./*zst)
	NZST="${#ZST[@]}"
	INDEX=0
	NUMBERFOLDERS="${NZST}"
	CLEN="${NUMBERFOLDERS} of ${NUMBERFOLDERS}"
	LONGESTFOLDERNAME=$(find . -maxdepth 1 -type f | awk 'function base(f){sub(".*/", "", f); return f;} {print length(base($0))}'| sort -nr | head -1)
	(( LONGESTFOLDERNAME = LONGESTFOLDERNAME + 10 )) # add 2 characters for the Encapsulation & Adding:
	Center "Building Arch repository: ${REPOSITORY} ${NZST} files, please wait."
	for EACH in "${ZST[@]}"
	do
		INDEX=$((INDEX + 1))
		FormatNUM "${INDEX}"
		PCOMP=$((100*INDEX / NUMBERFOLDERS))
		BigBarFolders "${LONGESTFOLDERNAME}" "Adding: ${EACH}:" "${#CLEN}" "${INDEX} of ${NUMBERFOLDERS}" "${PCOMP}"
		repo-add ${REPOSITORY}.db.tar.gz "${EACH}" >/dev/null 2>&1
	done
	Timer "Stop" "Build Repository"
	Encapsulate "Removing symbolic links"
	find . -type l -delete
	Encapsulate "Moving files for repository: ${REPOSITORY}"
	if [[ -f "${REPOSITORY}.files.tar.gz" ]]; then
		Encapsulate "Moving files for repository: ${REPOSITORY} ${REPOSITORY}.files.tar.gz to ${REPOSITORY}.files"
		mv "${REPOSITORY}.files.tar.gz"  "${REPOSITORY}.files"
	fi
	if [[ -f "${REPOSITORY}.db.tar.gz" ]]; then
		Encapsulate "Moving files for repository: ${REPOSITORY} ${REPOSITORY}.db.tar.gz to ${REPOSITORY}.db"
		mv "${REPOSITORY}.db.tar.gz" "${REPOSITORY}.db"
	fi
	if [[ -d "/usr/share/ultimate_edition/htaccesss/" ]]; then
		cp /usr/share/ultimate_edition/htaccesss/* .
	fi
	#sudo chown -R "${USER}:${USER}" "${RTD}/${2}/"
	#sudo chmod -R 644 "${RTD}/${2}/"
	#sudo find "." -type d -exec chmod 755 {} \;
	if [[ -f "${REPOSITORY}.db.tar.gz.old" ]]; then
		rm "${REPOSITORY}.db.tar.gz.old"
	fi
	if [[ -f "${REPOSITORY}.files.tar.gz.old" ]]; then
		rm "${REPOSITORY}.files.tar.gz.old"
	fi
	Encapsulate "Please add the following to test your repository as an example:"
	echo "[${REPOSITORY}]"
	echo "SigLevel = Optional TrustAll"
	echo "Server = https://os-builder.com/Arch/\$repo"
	Timer "Stop" "Build Repository"
}

Convert () {
	Timer "Start" "Conversion"
	if [[ ! $(ls /var/cache/pkgfile/*.files 2> /dev/null) ]] || [[ ! $(ls /var/cache/dconvert/*-packages-files 2> /dev/null) ]] || [[ ! -e /var/cache/dconvert/base-packages ]] || [[ ! -e /var/cache/dconvert/aur-packages ]] || [[ ! -e /var/cache/dconvert/virtual-packages ]]; then
		sudo dconvert -u
	fi
	BASECORES=0
	BASECORE=$(echo "$@" | grep -i "BASECORE")
	if [[ "${BASECORE}" ]]; then
		BASECORES=1
	fi
	# Snatch the number of CPU Core(s) / threads the end user has.
	CORES=$(grep -i "processor" "/proc/cpuinfo" | sed '/model/d' | wc -l)
	(( ACTUALCORES = ${CORES} -1 ))
	Encapsulate "Number of CPU Core(s) / threads(s) detected: ${CORES}"
	CORES=$(( "${CORES}" ))
	CONTAINS=$(echo "$@" | grep -i 'threads')
	if [[ "${CONTAINS}" ]]; then
		THREADS=$(echo "$@" | grep -i "threads=" | sed "s/^.*threads=//g" | cut -d" " -f1)
		Encapsulate "Threads Specified as: ${THREADS}"
		CALCULATE=$(( "${THREADS}" + 3 + "${BASECORES}" ))
		CORES="${CALCULATE}"
	fi
	DEBS=(./*deb)
	declare -i NDEBS
	DELETEELEMENT=(".debs/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Quotes when working with strings
	DELETEELEMENT=("partial/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" )
	DELETEELEMENT=(".arch/")
	FOLDERS=( "${FOLDERS[@]/$DELETEELEMENT}" ) #Implement Arch support
	NDEBS="${#DEBS[@]}"
	if [[ "${NDEBS}" -lt "${CORES}" ]]; then
		Encapsulate "Launching ${NDEBS} threads to accelerate the building process, please wait."
	else
		Encapsulate "Launching ${CORES} threads to accelerate the building process, please wait."
	fi
	for EACH in "$@"
	do
		if [[ -f "${EACH}" ]]; then
			DEBS="${EACH}"
		fi
	done
	if ! [[ "${DEBS}" ]]; then
		NDEBS="${#DEBS[@]}"
	fi
	#Prompt the end user?
	if ! [[ "${PROMPTSUPPRESSION}" ]]; then
		for EACH in "${DEBS[@]}"
		do
			FNAME=$(echo "${EACH/./}" | sed "s/\///g")
			Encapsulate "${FNAME}"
		done
			FullBar
			if ! [[ "${NDEBS}" == "0" ]]; then
				PromptYN "${WARNING}WARNING: ${BRIGHT}${TXTGRN}this will convert all the above ${NDEBS} deb(s) to Arch Linux. (Y/N)? "
				# echo -en "\033[1A\033[2K"
				# echo -e "\033[${COLUMNZ}G▒" # Close Encapsulation.
				case "${YN}" in
					[Nn]* ) exit 0;;
					[Yy]* ) Center "Beginning conversion...";;
					* ) Encapsulate "Please answer y or n.";;
				esac
			else
				TARGET=$(echo "${FILE}" | sed -e "s/ /_/")
				ZST="${TARGET%/}.zst"
				Encapsulate "${WARNING}WARNING: ${BRIGHT}${TXTGRN}build ${ZST} ZST(s) as a repository?"
				case "${YN}" in
					[Nn]* ) exit 0;;
					[Yy]* ) Center "Beginning building repository...";;
					* ) Encapsulate "Please answer y or n.";;
				esac
			fi
	fi
	declare -i TCOUNT;
	TCOUNT=0
	for FILE in "${DEBS[@]}"
	do
		TARGET=$(echo "${FILE}" | sed -e "s/ /_/")
		DEB="${TARGET%/}.deb"
		FOLDER="${FILE%%.deb}"
		FS=$(type -p stat)
		if [[ "${FS}" ]]; then
			FILESIZE=$(stat --printf="%s" "${FILE}")
		fi
		#Toss a little eye candy
		TCOUNT=$(( TCOUNT + 1 ))
		if ! [[ "${SUPPRESS}" ]]; then
			#Timer "Start" "Converting ${FILE}"
			FormatNUM " ${TCOUNT} of" "${#DEBS[@]}"
			Thousands "${FILESIZE}"
			FILESIZE="${FORMATTED}"
		fi
		# How many core do we have running currently?
		RUNNINGINSTANCES=$(ps -C dconvert | wc -l)
		# EXPELL all core, let's go to work, if we have maxed out, wait for one core to finish.
		while [[ "${RUNNINGINSTANCES}" -ge "${CORES}" ]] ;
		do
			RUNNINGINSTANCES=$(ps -C dconvert | wc -l)
		done
		if [[ "${RUNNINGINSTANCES}" -lt "${CORES}" ]]; then
			INSTANCE=$(( "${RUNNINGINSTANCES}" +  "${BASECORES}"))
			Encapsulate "Launching thread #${INSTANCE}: Converting file: ${FILE} (${FILESIZE}) bytes to ${FILE}.-1-any.pkg.tar.zst (RUNNING INSTANCES: ${RUNNINGINSTANCES})."
			dconvert -Q "${FILE}" >/dev/null 2>&1 &
		fi
	done
	RUNNINGINSTANCES=$(ps -C dconvert | wc -l)
	INSTANCE="${RUNNINGINSTANCES}"
	INDEX="1"
	while [[ "${RUNNINGINSTANCES}" -ne "1" ]] ;
	do
		RUNNINGINSTANCES=$(ps -C dconvert | wc -l)
		if [[ "${RUNNINGINSTANCES}" -lt "${INSTANCE}" ]]; then
			INSTANCE=$(ps -C dconvert | wc -l)
			PCOMP=$((100*INDEX / INSTANCE))
			ProgressBar "${PCOMP}" "Waiting for threads to die: ${INDEX} of ${INSTANCE}"
		fi
	done
	FullBar
	ZST=(./*zst)
	NZST="${#ZST[@]}"
	Timer "Stop" "Conversion"
	PromptYN "${BRIGHT}${TXTGRN}Would you like to create a repository based on the converted ${NZST} zst(s) for Arch Linux. (Y/N)? "
			# echo -en "\033[1A\033[2K"
			# echo -e "\033[${COLUMNZ}G▒" # Close Encapsulation.
	case "${YN}" in
		[Nn]* ) exit 0;;
		[Yy]* ) Center "Building repository...";;
		* ) Encapsulate "Please answer y or n.";;
	esac
	BuildRepo "$@"
}

TestMe () {
	Encapsulate "Repository name?: (No spaces or ASCII in repository name allowed. HIT space to confirm): "
	read -p '▒ Repository name: ' '-d ';
	echo -e "\033[${COLUMNZ}G▒" # Close Encapsulation.
	echo -en "\033[1A\033[2K"
	REPOSITORY="${REPLY}"
	Timer "Start" "Build Repository"
	LANG=en_US.UTF-8
	ZST=(./*zst)
	NZST="${#ZST[@]}"
	INDEX=0
	NUMBERFOLDERS="${NZST}"
	CLEN="${NUMBERFOLDERS} of ${NUMBERFOLDERS}"
	LONGESTFOLDERNAME=$(find . -maxdepth 1 -type f | awk 'function base(f){sub(".*/", "", f); return f;} {print length(base($0))}'| sort -nr | head -1)
	(( LONGESTFOLDERNAME = LONGESTFOLDERNAME + 10 )) # add 2 characters for the Encapsulation & Adding:
	Center "Building Arch repository: ${REPOSITORY} ${NZST} files, please wait."
}

case "${1}" in
	-h|--help|-\?) Help "$@";;
	-a|--analyze) PreScan "$@"; Report "$@";;
	-b|--build) Build "$@";;
	-c|--convert) Convert "$@";; # Undocumented switch, converts debian based packages to Arch Linux native packages.
	-C|--cleanfolder) Clean "$@";;
	-e|--extract) Extract "$@";;
	-d|--dummy) Empty "$@";;
	-f|--fix) Fix "$@";;
	-l|--log) ProcessLogs "$@"; exit 0;;
	-N|--NEVER) NeverFIX "$@"; exit 0;; # Undocumented switch used for working all errors out of debs / folders, repetitive processing.  Things I refuse to fix.
	-o|--override) ClearErrors "$@"; exit 0;; # Previously Undocumented switch used for working all warnings out of debs / folders, repetitive processing.  Allows me to concentrate solely on errors.
	-p|--prepare) Prepare "$@";;
	-P|--publish) Publish "$@";;
	-R|--relax) Relax "$@";;
	-z|--repository) BuildRepo "$@";;
	-r|--report) if [[ "${2}" ]]; then Report "$@"; else FullReport "$@"; fi;;
	-S|--service) Service "$@";;
	-s|--scan) Scan "$@";;
	-u|--unused) Unused "$@";; # Undocumented switch, strips unused Lintian overrides.
	-V|--verbose) Build "$@";;
	-v|--version) VersionDump "$@"; exit 0;;
	-W|--warnings) Warnings "$@";;
	-y|--testme) TestMe "$@"; exit 0;;
	-Z|--reset) Reset "$@";; # Undocumented switch, I will not tell you what this does.  Read my code.  Oh that's right you can't since I wrote that switch.
	*) Help "$@";;
esac
# ==============================================================================
# This code was automatically cleaned up using code-cleanup
# title			:code-cleanup
# description	:Bash code cleanup script
# Author		:root
# date			:10/23/2013
# version		:1.7.2-1
# http://ultimateedition.info/
# ==============================================================================

# To do:
# Error: E: libion-dev: description-contains-invalid-control-statement Logged to all_errors.txt.
# Timer Complete repostorm: 21h1m30s
# package-has-long-file-name
# doc-base-file-references-missing-file  Gone...
