Build customized mate-themes from package source

Script updated to version 4.1 on 2024-08-19 17:42 EDT.

Here's a much more complex version of that script but ...

FAIR WARNING, you need to fully understand its logic (flow, conditionals, limitations) to ensure you have no surprises before committing to it !!!


Guide to logic flow:

Outline of Program Logic ― rebuildThemes.sh

<< Script Header >>

do_RefMirror()
{
Create a mirror duplicate of the initial package code tree after first download, using rsync. This is used for comparison to identify all changes applied to code under the “work” tree.
}

do_ReportDifferences()
{
Use rsync “dry run” option to generate list of items that would require extraction and collection as a tar bundle for later submission as a package feature request or for submitting a bug fix.  Generates both,
- a list of files to create the delta “snapshot” tar bundle, and
- a report by rsync of the flags indicative of the nature of the changes.
}

do_CreatePatchFiles()
{
Populate the code tree with patch files applicable for modified text files.
}

do_BuildSnapshotTar()
{
Create the “snapshot” tar bundle, to keep as refefence of a given internally-consistent set of files for a working configuration.
}

myLs()
{
Create customized version of ‘ls l’ to report on files during the progress of the script.  Key aspect is that, if the modification is older than 24 hours, it reports only the date; otherwise it reports only the time of the last change using the 24-hour clock.
}

sep()
{
This is just a function to improve visual separation of the reporting, in the terminal, from the various logical segments of the script.
}

parmError()
{
This is a function to standardize the error reporting when a command-line parameter is missing.
}

<< Code Segment 1 ― Initializing parameters and command line parsing >>

<< Code Segment 2 ― Logic and reporting triggered, based on version of code: specified default, detected extracted version or command-line specified.  Handling for an “upgrade” in version is not currently implemented, leaving that to manual intervention by the user himself. >>

<< Code Segment 3 ― Setup of commen referential parameters depending on version number and package name. >>

<< Code Segment 4 ― Logic prompting for code refresh (currently non-functional) and logic prompting for rebuild of “snapshot tar” containing customization changes, namely “${host}.0_reclaimCustom.tar”. >>

<< Code Segment 5 ― Logic for conditional download of the specified package for the specified version.  Create flag file “${host}.1_bundle.DONE” if process completed to indicate bypass at subsequent re-running of script. >>

<< Code Segment 6 ― Logic for conditional extraction of the specified package for the specified version into the required work tree.  Create flag file “${host}.2_unbundle.DONE” if process completed to indicate bypass at subsequent re-running of script. >>

<< Code Segment 7 ― Logic for conditional download and installation of build dependencies to ensure success of build process for specified package at the specified version.  Create flag file “${host}.3_dependencies.DONE” if process completed to indicate bypass at subsequent re-running of script. >>

<< Code Segment 8 ― Logic requesting confirmation to proceed with re-attempt of package build and install. >>

<< Code Segment 9 ― Perform “autogen” action. >>

<< Code Segment 10 ― Perform “build” action. >>

<< Code Segment 11 ― Perform “install” action. >>

<< Code Segment 12 ― Logic for conditional creation of code tree mirror to be used during later comparison for identification of changes that have been applied.  Create flag file “${host}.6_mirror.DONE” if process completed to indicate bypass at subsequent re-running of script. >>

<< Code Segment 13 ― Inactive code segments, retained for possible consideration for later additions to code logic. >>



Log of terminal session

  • after changes have been made in working code tree, build sequence applied and verified good, and updating previous snapshot bundle (of changes).
$ rebuildThemes.sh

	 Version for newest code tree currently on disk is:  3.22.26

	 NOTE:  Version specified is same as most recently worked version ...
	 Re-do attempt using same code version base as previously worked ...

	 Refresh (overwrite) previously downloaded code bundle file ? [y|N] => 
	 Continuing with previously downloaded code bundle file 'mate-themes-3.22.26.tar.xz' ...


	 Detected previously-created customization snapshot bundle 'Oasis.0_reclaimCustom.tar':
	   -rw-rw-r--  1          296960   17:34:04   Oasis.0_reclaimCustom.tar

	 Replace that with newer snapshot ? [y|N] => y

	 These patch files will be added to the snapshot tar file:
	   -rw-rw-r--  1            1272   17:36:07   desktop-themes/BlackMATE-border/metacity-1/metacity-theme-3.xml.patch

	 Will create tar file containing the following files:
	  | desktop-themes/BlackMATE-border/metacity-1/bar_unfocused.DISTRO.png
	  | desktop-themes/BlackMATE-border/metacity-1/bar_unfocused.Oasis.png
	  | desktop-themes/BlackMATE-border/metacity-1/bar_unfocused.png
	  | desktop-themes/BlackMATE-border/metacity-1/metacity-theme-3.DISTRO.xml
	  | desktop-themes/BlackMATE-border/metacity-1/metacity-theme-3.Oasis.xml
	  | desktop-themes/BlackMATE-border/metacity-1/metacity-theme-3.xml
	  | desktop-themes/BlackMATE-border/metacity-1/metacity-theme-3.xml.patch

	 No errors reported during tar file creation ...

	 Successfully created tar file containing only modified files:
	   -rw-rw-r--  1          296960   17:36:07   Oasis.0_reclaimCustom.tar

	 List of files impacted by all impacting changes:
	   -rw-rw-r--  1             471   17:36:07   Oasis.0_reclaimCustom.tar.list

	 Report [rsync] flagging attributes triggering inclusion in tar file:
	   -rw-rw-r--  1             473   17:36:07   Oasis.0_reclaimCustom.tar.details

	 [1] Downloading of 'mate-themes-3.22.26.tar.xz' ...			previously done ...
	 [2] Extract of files from 'mate-themes-3.22.26.tar.xz' ...		previously done ...
	 [3] Installation of build dependencies for 'mate-themes' package ...	previously done ...

	 Proceed with rebuild of MATE Themes ? [y/N] => 

	 Rebuild deferred as directed.
 Bye!

$ 

Script:

#!/bin/bash

####################################################################################################
###
###	Script to perform sequence necessary to have system apply
###	various customization changes to the installed OS
###
###	Version: 4.0 (major change, some inactive code segments)
###	Version: 4.1 (added logic to generate patch files and include those in snapshot tar)
###
###	REF:
###	https://ubuntu-mate.community/t/window-adjust-grab-zone-size-issues/28070/14
###	https://ubuntu-mate.community/t/window-adjust-grab-zone-size-issues/28070/16
###
####################################################################################################
#23456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+123456789+


do_RefMirror()
{
	#${doUpdate} \
	#${doCheckSum} \
	#${showProgress} \
	#--verbose --out-format=\"%t|%i|%M|%b|%f|\" \
	COM="ionice -c 2 -n 7 rsync \
	--one-file-system \
	--recursive \
	--outbuf=Line \
	--links \
	--perms \
	--times \
	--group \
	--owner \
	--devices \
	--specials \
	--verbose --out-format=%f \
	--delete-during \
	--whole-file \
	--human-readable \
	--protect-args \
	--ignore-errors \
	--msgs2stderr \
	./ ${PathMirror}/"

	${COM}
}


do_ReportDifferences()
{
	###	REF:
	###	https://superuser.com/questions/1624000/using-rsync-to-quickly-show-only-files-that-have-different-content

	#	-HPrl \
	COM="ionice -c 2 -n 7 rsync \
		--hard-links \
		--partial \
		--progress \
		--links \
		--recursive \
		--itemize-changes \
		--dry-run \
		./ ${PathMirror}/"
	#	./ ${START}/${buildDir_themes}"		###  Used for a reversed comparison

	${COM}	| grep -vF "f..T......"  | grep -vF "d..T......"  | grep '^>' | grep "${focus_string}" | grep -v '.patch | tee ../${host}.0_reclaimCustom.tar.details | cut -f2- -d" "
	#       ; no timediff on files   ; no timediff on dirs    
}


do_CreatePatchFiles()
{
	rm -f ${host}.0_reclaimCustom.patchfiles
	while read file
	do
		if [ -f "${buildDir_REF}/${file}" ]
		then
			testor=$( file "${buildDir_REF}/${file}" | cut -f2- -d\: | grep 'ASCII [Tt][Ee][Xx][Tt]' )
			if [ -n "${testor}" ]
			then
				#echo "$testor}" >&2
				#echo diff -Naru "${buildDir_REF}/${file}" "${buildDir_themes}${file}"
				diff -Naru "${buildDir_REF}/${file}" "${buildDir_themes}${file}" >"${buildDir_themes}${file}.patch"
				#echo "${file}.patch" >&2
				echo "${file}.patch" >>${host}.0_reclaimCustom.patchfiles
			fi
		fi
	done <${host}.0_reclaimCustom.list

	if [ -s "${host}.0_reclaimCustom.patchfiles" ]
	then
		printf "\n\t These patch files will be added to the snapshot tar file:\n"
		while read patch
		do
			test -n "${buildDir_themes}${patch}" && {
			( cd "${buildDir_themes}" ;
				myLs "${patch}" 2>&1 | awk '{ printf("\t   %s\n", $0 ) ; }'
			) ;
			}
			testor=$( grep "${patch}" ${host}.0_reclaimCustom.list )
			test -z "${testor}" && { echo "${patch}" >>${host}.0_reclaimCustom.list ; }
		done <${host}.0_reclaimCustom.patchfiles
	fi
}


do_BuildSnapshotTar()
{

	rm -f ${host}.0_reclaimCustom.list

	( cd "${buildDir_themes}" ; do_ReportDifferences >../${host}.0_reclaimCustom.list 2>../${host}.0_reclaimCustom.err )

	if [ -s ${host}.0_reclaimCustom.list ]
	then
		do_CreatePatchFiles

		printf "\n\t Will create tar file containing the following files:\n"
		awk '{ printf("\t  | %s\n", $0 ) ; }' ${host}.0_reclaimCustom.list

		( cd "${buildDir_themes}" ; tar cvf ../${host}.0_reclaimCustom.tar -T ../${host}.0_reclaimCustom.list ) >${host}.0_reclaimCustom.tar.list 2>${host}.0_reclaimCustom.tar.err

		test -s ${host}.0_reclaimCustom.tar.err && {
			printf "\n\t Errors reported during tar file creation:\n"
			awk '{ printf("\t  | %s\n", $0 ) ; }' <"${host}.0_reclaimCustom.tar.err"
		} || {
			printf "\n\t No errors reported during tar file creation ...\n" ;
			rm -f ${host}.0_reclaimCustom.tar.err
		}


		test -s ${host}.0_reclaimCustom.tar && {
			printf "\n\t Successfully created tar file containing only modified files:\n" ;
			myLs "${host}.0_reclaimCustom.tar" 2>&1 | awk '{ printf("\t   %s\n", $0 ) ; }'
		} || {
			printf "\n\t Empty file:  '${host}.0_reclaimCustom.tar' \n" ;
			rm -fv ${host}.0_reclaimCustom.tar 2>&1 | awk '{ printf("\t\t %s\n", $0 ) ; }' ;
			exit 1 ;
		}


		test -s ${host}.0_reclaimCustom.tar.list && {
			printf "\n\t List of files impacted by all impacting changes:\n" ;
			myLs "${host}.0_reclaimCustom.tar.list" 2>&1 | awk '{ printf("\t   %s\n", $0 ) ; }'
		} || {
			printf "\n\t Empty file:  '${host}.0_reclaimCustom.tar.list' \n" ;
			rm -fv ${host}.0_reclaimCustom.tar.list 2>&1 | awk '{ printf("\t\t %s\n", $0 ) ; }' ;
		}


		test -s ${host}.0_reclaimCustom.tar.details && {
			printf "\n\t Report [rsync] flagging attributes triggering inclusion in tar file:\n" ;
			myLs "${host}.0_reclaimCustom.tar.details" 2>&1 | awk '{ printf("\t   %s\n", $0 ) ; }'
		} || {
			printf "\n\t Empty file:  '${host}.0_reclaimCustom.tar.details' \n" ;
			rm -fv ${host}.0_reclaimCustom.tar.details 2>&1 | awk '{ printf("\t\t %s\n", $0 ) ; }' ;
		}
		echo ""
	else
		if [ ${force} -eq 0 ]
		then
			printf "\n\t WARNING:  No differences detected between 'Work Code tree' and 'Reference Code tree'.\n\t\t   Visual inspection is STRONGLY RECOMMENDED before adding the '--force' option to proceed beyond this step.\n" ; exit 1
		fi
	fi
}


myLs()
{
	#eval stat --format=\"\|\%A\|\%h\|\%s\|\%y\|\%n\|\" \"${1}\"
	eval stat --format=\"\|\%A\|\%h\|\%s\|\%Y\|\%n\|\" \"${1}\" |
	awk -v now=${time_now} '{
		n=split( $0, vals, "|" ) ;

		#mult24=( (1.0*now) - vals[5] )/86400 ;
		#print mult24 ;
		# 86400 seconds in a 24 hour period

		if( ( (1.0*now) - vals[5] )/86400 > 1 ){
			printf("%s %2s %15s  %10s  %s\n", vals[2], vals[3], vals[4], strftime("%F", vals[5]), vals[6] ) ;
		}else{
			printf("%s %2s %15s  %9s   %s\n", vals[2], vals[3], vals[4], strftime("%R:%S", vals[5]), vals[6] ) ;
		} ;

	}'
}


sep()
{
	printf "\n\n====================================================================================================\n\n\n"
}


parmError()
{
	printf "\n\t ERROR: You must specify a ${msg} to proceed.\n" ; exit 1
}



version_worked=$(ls -d mate-themes-[0-9].[0-9][0-9].[0-9][0-9] | sort -nr | head -1 | awk '{ n=split($0, vars, "-") ; print vars[n] ; }' )

printf "\n\t Version for newest code tree currently on disk is:  ${version_worked}\n\n"


START=$(pwd)
host="Oasis"

packageName="mate-themes"
version="3.22.26"
focus_string="BlackMATE-border"

reclaim=0
snapshot=0
force=0
version_up=0

while [ $# -gt 0 ]
do
	testor=$(echo "${2}" | grep "\-\-" )
	case "${1}" in
		"--snapshot" )
			snapshot=1 ; shift
			;;
		"--force" )
			force=1 ; shift
			;;
		"--"* )
			case "${1}" in
				"--host" )
					msg="single-word host label"
					if [ -n "${testor}" -o -z "${2}" ] ; then  parmError ; fi
					host="${2}" ; shift ; shift
					;;
				"--package" )
					msg="single-word package name"
					if [ -n "${testor}" -o -z "${2}" ] ; then  parmError ; fi
					packageName="${2}" ; shift ; shift
					;;
				"--version" )
					msg="version number"
					if [ -n "${testor}" -o -z "${2}" ] ; then  parmError ; fi
					version="${2}" ; shift ; shift
					;;
				* )
					printf "\n\t ERROR: Invalid parameter used on the command line.\n" ; exit 1
					;;
			esac
			;;
		* )
			printf "\n\t ERROR: Invalid parameter used on the command line.\n" ; exit 1
			;;
	esac
done

time_now=$(date +%s) 			# echo ${time_now}

if [ "${version}" = "${version_worked}" ]
then
	printf "\t NOTE:  Version specified is same as most recently worked version ...\n"
	printf "\t Re-do attempt using same code version base as previously worked ...\n"
else
	newer=$( { echo "${version}" ; echo "${version_worked}" ; } | sort -nr | head -1 )
	if [ "${newer}" = "${version_worked}" ]
	then
		printf "\t WARNING:  Ignoring specification of older code version ...\n"
		printf "\t Re-do attempt using same code version base as previously worked ...\n"
	else
		printf "\t VERSION CHANGE:  Newer code version base specified, ${version} vs previous ${version_worked} ...\n"
		version_up=1
		
		echo "
		###
		###	FUTURES:
		###
		###	LOGIC for this condition needs to be defined.
		###	Until then, must intervene manually to ensure no loss of customization.
		###
		"
		exit
	fi
fi


label="${packageName}-${version}"
buildDir_themes="${label}/"
buildDir_REF="${label}_REF"
buildDir_DIFF="${label}_DIFF"
packageBundle="${label}.tar.xz"
PathMirror="${START}/${buildDir_REF}"
#echo "${PathMirror}"


test "$(pwd | grep "/usr/share/themes" )" = "" ||  { printf "\n\t ERROR: This script should NOT be run within the OS installation libraries.  Start from within a 'development' workspace.\n" ; exit 1 ; }

test "$(pwd | grep "${label}" )" = "" ||  { printf "\n\t ERROR: This script should NOT be run within the extracted MATE Themes code branch.\n\t Instead, must start from directory containing the downloaded/extracted code branch, namely, the 'development' workspace.\n" ; exit 1 ; }

if [ -s "${packageBundle}" ]
then
	if [ ${snapshot} -eq 0 ]
	then
		printf "\n\t Refresh (overwrite) previously downloaded code bundle file ? [y|N] => " ; read ans
		if [ -z "${ans}" ]
		then
			ans="N"
		fi

		case "${ans}" in
			y* | Y* )
				snapshot=1
				reclaim=1

				###
				###	FUTURES:  logic for code refresh
				###
				#printf "\t Entering code refresh loop ...\n"
				#oldLogic
				#newLogic
				;;
			* )	printf "\t Continuing with previously downloaded code bundle file '${packageBundle}' ...\n"
				;;
		esac
	fi

	if [ -s ${host}.0_reclaimCustom.tar ]
	then
		overwrite="N"
		echo ""
		printf "\n\t Detected previously-created customization snapshot bundle '${host}.0_reclaimCustom.tar':\n"
		myLs "${host}.0_reclaimCustom.tar" 2>&1 | awk '{ printf("\t   %s\n", $0 ) ; }'
		printf "\n\t Replace that with newer snapshot ? [y|N] => " ; read overwrite
		if [ -z "${overwrite}" ]
		then
			overwrite="N"
		fi

		case "${overwrite}" in
			y* | Y* )
				snapshot=1
				;;
			* )	printf "\t CONFIRMED:  Preserving OLD customization snapshot bundle '${host}.0_reclaimCustom.tar' ...\n"
				snapshot=0
				;;
		esac
	fi

	if [ ${snapshot} -eq 1 ]
	then
		no_snap=0
		if [ ! -f "${host}.2_unbundle.DONE" ]	; then  no_snap=1 ; printf "\t\t Code tree create process not completed.\n" ; fi
		if [ ! -f "${host}.6_mirror.DONE" ]	; then  no_snap=1 ; printf "\t\t Code mirror tree create process not completed.\n" ; fi
		if [ ! -d "${START}/${buildDir_themes}" ]	; then  no_snap=1 ; printf "\t\t Code tree directory missing.\n" ; fi
		if [ ! -d "${START}/${build_Dir_REF}" ]		; then  no_snap=1 ; printf "\t\t Code mirror tree directory missing.\n" ; fi

		if [ ${no_snap} -eq 1 ]
		then
			printf "\n\t ERROR: Pre-conditions for creating requested snapshot are not met. Abandoning process.\n" ; exit 1
		else
			do_BuildSnapshotTar
		fi
	else
		echo ""
	fi
fi


if [ -f ${host}.1_bundle.DONE ]
then
	printf "\t [1] Downloading of '${packageBundle}' ...\t\t\tpreviously done ...\n"
else
	{
	wget https://github.com/mate-desktop/mate-themes/releases/download/v${version}/${packageBundle} 2>&1

	test $? -eq 0  || { printf "\n\t ERROR: Download of package file '${packageBundle}' failed.\n" >&2 ; exit 1 ; }
	} | tee ${host}.1_bundle.log

	test -s "${packageBundle}" || { printf "\n\t ERROR: Expected package file '${packageBundle}' was not downloaded.\n" ; exit 1 ; }
	touch ${host}.1_bundle.DONE
	sep
fi


if [ -f ${host}.2_unbundle.DONE ]
then
	printf "\t [2] Extract of files from '${packageBundle}' ...\t\tpreviously done ...\n"
else
	{
	tar xvf ${packageBundle} 2>&1

	test $? -eq 0  || { printf "\n\t ERROR: Failed to extract files from package file '${packageBundle}'.\n" >&2 ; exit 1 ; }
	} | tee ${host}.2_unbundle.log

	touch ${host}.2_unbundle.DONE
	sep
fi


if [ -f ${host}.3_dependencies.DONE ]
then
	printf "\t [3] Installation of build dependencies for '${packageName}' package ...\tpreviously done ...\n"
else
	{
	sudo apt-get build-dep ${packageName} 2>&1

	test $? -eq 0  || { printf "\n\t ERROR: Failed to retrieve build dependencies for '${packageName}' package.\n" >&2 ; exit 1 ; }
	} | tee ${host}.3_dependencies.log

	touch ${host}.3_dependencies.DONE
	sep
fi


###
###	This is where the script would normally re-start on subsequent iterations
###	AFTER you have made the changes you wish to make in the 'source code tree'
###

printf "\n\t Proceed with rebuild of MATE Themes ? [y/N] => " ; read ans
if [ -z "${ans}" ]
then
	ans="N"
fi
case "${ans}" in
	y* | Y* ) continue ;;
	* ) printf "\n\t Rebuild deferred as directed.\n Bye!\n\n" ; exit 0 ;;
esac

cd "${buildDir_themes}"
test $? -eq 0  || { printf "\n\t ERROR: Failed to to set root of code tree, '${buildDir_themes}', as working directory.\n" ; exit 1 ; }

printf "\t [4] Performing 'autogen.sh' ...\n"
./autogen.sh --prefix=/usr | tee ../${host}.4_autogen.log
sep

printf "\t [5] Build stage 1 'make' ...\n"
make | tee ../${host}.5_make.log
sep

printf "\t [6] Build stage 2 'make install' ...\n"
sudo make install | tee ../${host}.6_install.log
sep

cd "${START}"
test $? -eq 0  || { printf "\n\t ERROR: Failed to to set root of code tree, '${buildDir_themes}', as working directory.\n" ; exit 1 ; }

if [ -f ${host}.6_mirror.DONE ]
then
	printf "\t [6b] 'Reference Mirror' of '${packageBundle}' already exists.  No need to create.\n"
else
	rm -f ${host}.6_dirset.FAIL

	test -d "${buildDir_themes}" || { printf "\n\t ERROR: Failed to locate '${buildDir_themes}' to set as work directory for creating comparison mirror.\n" >&2 ; exit 1 ; }

	if [ -d "${PathMirror}" ]
	then
		rm -fv ${host}.6_mirror.log ${host}.6_mirror.err
	else
		mkdir -v "${PathMirror}"
	fi
	test -d "${PathMirror}" || { printf "\n\t ERROR: Was unable to create directory '${PathMirror}' for mirroring code tree for later comparison.\n" >&2 ; exit 1 ; }

	(	cd "${buildDir_themes}"
		test $? -eq 0 || { touch ${host}.6_dirset.FAIL ; exit 1 ; }

		do_RefMirror >../${host}.6_mirror.log
	) 2>&1 | tee ${host}.6_mirror.err

	test -f ${host}.6_dirset.FAIL && { printf "\n\t ERROR: Failed to set '${buildDir_themes}' as work directory for creating comparison mirror.\n" >&2 ; rm -f ${host}.6_mirror.log ${host}.6_mirror.err ; exit 1 ; }

	printf "\t Code tree from '${buildDir_themes}' has been successfully mirrored under '${PathMirror}' ...\n"
	touch ${host}.6_mirror.DONE
fi


printf "\n	BUILD DONE -- Time to verify the deployment performs as expected.\n\n"


exit
exit
exit

####################################################################################################
###
###	NON-FUNCTIONAL Code segments segregated for possible future use
###	to expand script functionality for advancing to newer versions "more intelligently"
###
####################################################################################################

oldLogic()
{
	###
	###	LOGIC currently disabled
	###

	if [ -d "${buildDir_REF}" -a -d "${buildDir_themes}" ]
	then
		if [ ! -f "${host}.2_reclaim.DONE" ]
		then
			do_Reclaim
		fi

		echo "past"
		exit

		if [ -f "${host}.2_reclaim.DONE" ]
		then
			echo "====  " rm -rf "${buildDir_REF}"
			echo "====  " mv -v "${buildDir_themes}" "${buildDir_REF}"
			printf "\n\t NOTE:  Previously downloaded code branch, containing modifications, has been preserved for reclaim of changes ...\n"
		else
			printf "\n\t PROBLEM:  Modified files have not yet been reclaimed from the previously downloaded code branch.\n\t Unable to proceed.\n" ; exit 1
		fi
	fi
}

newLogic()
{
	###
	###	LOGIC currently disabled
	###

	do_ReportDifferences

	echo "====  " rm -v ${packageBundle}
	echo "====  " rm -fv ${host}.1_bundle.DONE
	echo "====  " rm -fv ${host}.1_bundle.log
	echo "====  " rm -fv ${host}.2_unbundle.DONE
	echo "====  " rm -fv ${host}.2_unbundle.log
	echo "====  " rm -fv ${host}.3_dependencies.DONE
	echo "====  " rm -fv ${host}.3_dependencies.log
}


do_Reclaim()
{
	###
	###	LOGIC currently disabled
	###

	rm -f tmp.new tmp.old tmp.diff

	#( cd "${buildDir_themes}" ; find . -print | sort | cut -c3- ) >tmp.new
	( cd "${buildDir_REF}"   ; find . -print | sort | cut -c3- ) >tmp.old

	if [ -s tmp.old ]
	then
		while read line
		do
			testorT=$(find "$(dirname "${buildDir_REF}/${line}" )" -name "$(basename "${line}" )" -newer "${buildDir_themes}${line}" -print )
			if [ -n "${testorT}" ]
			then
				rm -f tmp.diff
				diff "${buildDir_themes}${line}" "${buildDir_REF}/${line}" >tmp.diff
				if [ -s tmp.diff ]
				then
					printf "${testorT}\n"
					awk '{ printf("\t| %s\n", $0 ) ; }' <tmp.diff
				else
					printf "${testorT}\t\t NO_DIFF\n"
				fi
			#	echo cp -pv "${testor}" "${buildDir_themes}${line}"
			fi
			read <&2
		done <tmp.old
		#touch ${host}.2_reclaim.DONE
	else
		printf "\n\t NOTE:  Both '${buildDir_REF}' and '${buildDir_themes}' contain the same files.\n\t\tCan proceed safely with purging of '${buildDir_REF}' ...\n"
	fi
}
#"${buildDir_themes}"
#"${buildDir_REF}"


do_Reclaim_OLD()
{
	###
	###	LOGIC currently disabled
	###

	rm -f tmp.new tmp.old tmp.diff

	( cd "${buildDir_themes}" ; find . -print | sort | cut -c3- ) >tmp.new
	( cd "${buildDir_REF}"   ; find . -print | sort | cut -c3- ) >tmp.old

	diff tmp.new tmp.old | grep '^>' | cut -c3- >tmp.diff
	#cat tmp.diff

	if [ -s tmp.diff ]
	then
		while read line
		do
			cp -pv "${buildDir_REF}/${line}" "${buildDir_themes}${line}"
		done <tmp.diff
		touch ${host}.2_reclaim.DONE
	else
		printf "\n\t NOTE:  Both '${buildDir_REF}' and '${buildDir_themes}' contain the same files.\n\t\tCan proceed safely with purging of '${buildDir_REF}' ...\n"
	fi
}
#"${buildDir_themes}"
#"${buildDir_REF}"
4 Likes