<commit_before>#!/bin/bash

set -e
STARTTIME="$(date +%s)"
SCRIPTNAME=`basename $0`
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
FULLPATHSCRIPTNAME=$SCRIPTPATH/$SCRIPTNAME
COVERAGE="0"
RELEASE="0"
BUILDIRODS="1"
PORTABLE="0"
COVERAGEBUILDDIR="/var/lib/irods"
PREFLIGHT=""
PREFLIGHTDOWNLOAD=""
PYPREFLIGHT=""
IRODSPACKAGEDIR="./build"

USAGE="

Usage: $SCRIPTNAME [OPTIONS] <serverType> [databaseType]
Usage: $SCRIPTNAME docs
Usage: $SCRIPTNAME clean

Options:
-c      Build with coverage support (gcov)
-h      Show this help
-r      Build a release package (no debugging information, optimized)
-s      Skip compilation of iRODS source
-p      Portable option, ignores OS and builds a tar.gz

Examples:
$SCRIPTNAME icat postgres
$SCRIPTNAME resource
$SCRIPTNAME -s icat postgres
$SCRIPTNAME -s resource
"

# Color Manipulation Aliases
if [[ "$TERM" == "dumb" || "$TERM" == "unknown" ]] ; then
    text_bold=""      # No Operation
    text_red=""       # No Operation
    text_green=""     # No Operation
    text_yellow=""    # No Operation
    text_blue=""      # No Operation
    text_purple=""    # No Operation
    text_cyan=""      # No Operation
    text_white=""     # No Operation
    text_reset=""     # No Operation
else
    text_bold=$(tput bold)      # Bold
    text_red=$(tput setaf 1)    # Red
    text_green=$(tput setaf 2)  # Green
    text_yellow=$(tput setaf 3) # Yellow
    text_blue=$(tput setaf 4)   # Blue
    text_purple=$(tput setaf 5) # Purple
    text_cyan=$(tput setaf 6)   # Cyan
    text_white=$(tput setaf 7)  # White
    text_reset=$(tput sgr0)     # Text Reset
fi

# boilerplate
echo "${text_cyan}${text_bold}"
echo "+------------------------------------+"
echo "| RENCI iRODS Build Script           |"
echo "+------------------------------------+"
date
echo "${text_reset}"

# translate long options to short
for arg
do
    delim=""
    case "$arg" in
        --coverage) args="${args}-c ";;
        --help) args="${args}-h ";;
        --release) args="${args}-r ";;
        --skip) args="${args}-s ";;
        --portable) args="${args}-p ";;
        # pass through anything else
        *) [[ "${arg:0:1}" == "-" ]] || delim="\""
        args="${args}${delim}${arg}${delim} ";;
    esac
done
# reset the translated args
eval set -- $args
# now we can process with getopts
while getopts ":chrsp" opt; do
    case $opt in
        c)
        COVERAGE="1"
        TARGET=$2
        echo "-c detected -- Building iRODS with coverage support (gcov)"
        echo "${text_green}${text_bold}TARGET=[$TARGET]${text_reset}"
        if [ "$TARGET" == "icat" ] ; then
            echo "${text_green}${text_bold}TARGET is ICAT${text_reset}"
        fi
        ;;
        h)
        echo "$USAGE"
        ;;
        r)
        RELEASE="1"
        echo "-r detected -- Building a RELEASE package of iRODS"
        ;;
        s)
        BUILDIRODS="0"
        echo "-s detected -- Skipping iRODS compilation"
        ;;
        p)
        PORTABLE="1"
        echo "-p detected -- Building portable package"
        ;;
        \?)
        echo "Invalid option: -$OPTARG" >&2
        ;;
    esac
done
echo ""

# detect illogical combinations, and exit
if [ "$BUILDIRODS" == "0" -a "$RELEASE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -s   skip compilation" 1>&2
    echo "      :: -r   build for release" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi
if [ "$BUILDIRODS" == "0" -a "$COVERAGE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -s   skip compilation" 1>&2
    echo "      :: -c   coverage support" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi
if [ "$COVERAGE" == "1" -a "$RELEASE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -c   coverage support" 1>&2
    echo "      :: -r   build for release" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi

if [ "$COVERAGE" == "1" ] ; then
    if [ -d "$COVERAGEBUILDDIR" ] ; then
        echo "${text_red}#######################################################" 1>&2
        echo "ERROR :: $COVERAGEBUILDDIR/ already exists" 1>&2
        echo "      :: Cannot build in place with coverage enabled" 1>&2
        echo "      :: Try uninstalling the irods package" 1>&2
        echo "#######################################################${text_reset}" 1>&2
        exit 1
    fi
    if [ "$(id -u)" != "0" ] ; then
        echo "${text_red}#######################################################" 1>&2
        echo "ERROR :: $SCRIPTNAME must be run as root" 1>&2
        echo "      :: when building in place (coverage enabled)" 1>&2
        echo "#######################################################${text_reset}" 1>&2
        exit 1
    fi
fi



# remove options from $@
shift $((OPTIND-1))

# check arguments
if [ $# -ne 1 -a $# -ne 2 ] ; then
    echo "$USAGE" 1>&2
    exit 1
fi

# get into the correct directory
DETECTEDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DETECTEDDIR/../

# begin self-awareness
echo "${text_green}${text_bold}Detecting Build Environment${text_reset}"
echo "Detected Packaging Directory [$DETECTEDDIR]"
GITDIR=`pwd`
BUILDDIR=$GITDIR  # we'll manipulate this later, depending on the coverage flag
EPMCMD="external/epm/epm"
cd $BUILDDIR/iRODS
echo "Build Directory set to [$BUILDDIR]"
# read iRODS Version from file
source ../VERSION
echo "Detected iRODS Version to Build [$IRODSVERSION]"
echo "Detected iRODS Version Integer [$IRODSVERSIONINT]"
# detect operating system
DETECTEDOS=`../packaging/find_os.sh`
if [ "$PORTABLE" == "1" ] ; then
  DETECTEDOS="Portable"
fi
echo "Detected OS [$DETECTEDOS]"
DETECTEDOSVERSION=`../packaging/find_os_version.sh`
echo "Detected OS Version [$DETECTEDOSVERSION]"




############################################################
# FUNCTIONS
############################################################

# find number of cpus
detect_number_of_cpus_and_set_makejcmd() {
    if [ "$DETECTEDOS" == "MacOSX" ] ; then
        DETECTEDCPUCOUNT=`sysctl -n hw.ncpu`
    elif [ "$DETECTEDOS" == "Solaris" ] ; then
        DETECTEDCPUCOUNT=`/usr/sbin/psrinfo -p`
    else
        DETECTEDCPUCOUNT=`cat /proc/cpuinfo | grep processor | wc -l | tr -d ' '`
    fi
    if [ $DETECTEDCPUCOUNT -lt 2 ] ; then
        DETECTEDCPUCOUNT=1
    fi
    CPUCOUNT=$(( $DETECTEDCPUCOUNT + 3 ))
    MAKEJCMD="make -j $CPUCOUNT"

    # print out detected CPU information
    echo "${text_cyan}${text_bold}-------------------------------------"
    echo "Detected CPUs:    $DETECTEDCPUCOUNT"
    echo "Compiling with:   $MAKEJCMD"
    echo "-------------------------------------${text_reset}"
    sleep 1
}

# rename generated packages appropriately
rename_generated_packages() {

    # parameters
    if [ "$1" == "" ] ; then
        echo "rename_generated_packages() expected 1 parameter"
        exit 1
    fi
    TARGET=$1

    #################
    # extensions
    cd $BUILDDIR
    SUFFIX=""
    if   [ "$DETECTEDOS" == "RedHatCompatible" ] ; then
	EXTENSION="rpm"
	SUFFIX="-redhat"
	if [ "$epmosversion" == "CENTOS6" ] ; then
            SUFFIX="-centos6"
	fi
    elif [ "$DETECTEDOS" == "SuSE" ] ; then
	EXTENSION="rpm"
	SUFFIX="-suse"
    elif [ "$DETECTEDOS" == "Ubuntu" -o "$DETECTEDOS" == "Debian" ] ; then
	EXTENSION="deb"
    elif [ "$DETECTEDOS" == "Solaris" ] ; then
	EXTENSION="pkg"
    elif [ "$DETECTEDOS" == "MacOSX" ] ; then
	EXTENSION="dmg"
    elif [ "$DETECTEDOS" == "ArchLinux" ] ; then
	EXTENSION="tar.gz"
    elif [ "$DETECTEDOS" == "Portable" ] ; then
	EXTENSION="tar.gz"
    fi

    #################
    # icat and resource server packages
    RENAME_SOURCE="./linux*/irods-*$IRODSVERSION*.$EXTENSION"
    RENAME_SOURCE_DOCS=${RENAME_SOURCE/irods-/irods-docs-}
    RENAME_SOURCE_DEV=${RENAME_SOURCE/irods-/irods-dev-}
    RENAME_SOURCE_ICOMMANDS=${RENAME_SOURCE/irods-/irods-icommands-}
    SOURCELIST=`ls $RENAME_SOURCE`
    echo "EPM produced packages:"
    echo "$SOURCELIST"
    # prepare target build directory
    mkdir -p $IRODSPACKAGEDIR
    # vanilla construct
    RENAME_DESTINATION="$IRODSPACKAGEDIR/irods-$IRODSVERSION-64bit.$EXTENSION"
    # add OS-specific suffix
    if [ "$SUFFIX" != "" ] ; then
	RENAME_DESTINATION=${RENAME_DESTINATION/.$EXTENSION/$SUFFIX.$EXTENSION}
    fi
    # docs build
    RENAME_DESTINATION_DOCS=${RENAME_DESTINATION/irods-/irods-docs-}
    # release build (also building icommands)
    RENAME_DESTINATION_DEV=${RENAME_DESTINATION/irods-/irods-dev-}
    RENAME_DESTINATION_ICOMMANDS=${RENAME_DESTINATION/irods-/irods-icommands-}
    # icat or resource
    if [ "$TARGET" == "icat" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/irods-/irods-icat-}
    elif [ "$TARGET" == "resource" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/irods-/irods-resource-}
    fi
    # coverage build
    if [ "$COVERAGE" == "1" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/-64bit/-64bit-coverage}
    fi

    #################
    # database packages
    DB_SOURCE="./plugins/database/linux*/*database*.$EXTENSION"
    echo `ls $DB_SOURCE`
    DB_PACKAGE=`basename $DB_SOURCE`
    DB_DESTINATION="$IRODSPACKAGEDIR/$DB_PACKAGE"
    DB_DESTINATION=`echo $DB_DESTINATION | sed -e "s,\\(-[^-]*\\)\{3\}\\.$EXTENSION\$,.$EXTENSION,"`

    #################
    # rename and tell me
    if [ "$TARGET" == "docs" ] ; then
	echo ""
	echo "renaming    [$RENAME_SOURCE_DOCS]"
	echo "         to [$RENAME_DESTINATION_DOCS]"
	mv $RENAME_SOURCE_DOCS $RENAME_DESTINATION_DOCS
    else
	if [ "$RELEASE" == "1" ] ; then
	    echo ""
	    echo "renaming    [$RENAME_SOURCE_ICOMMANDS]"
	    echo "         to [$RENAME_DESTINATION_ICOMMANDS]"
	    mv $RENAME_SOURCE_ICOMMANDS $RENAME_DESTINATION_ICOMMANDS
	fi
	if [ "$TARGET" == "icat" ] ; then
	    echo ""
	    echo "renaming    [$RENAME_SOURCE_DEV]"
	    echo "         to [$RENAME_DESTINATION_DEV]"
	    mv $RENAME_SOURCE_DEV $RENAME_DESTINATION_DEV
	fi
        # icat or resource
        echo ""
        echo "renaming    [$RENAME_SOURCE]"
        echo "         to [$RENAME_DESTINATION]"
        mv $RENAME_SOURCE $RENAME_DESTINATION
        # database
        if [ "$BUILDIRODS" == "1" -a "$TARGET" == "icat" ] ; then
            echo ""
            echo "renaming    [$DB_SOURCE]"
            echo "         to [$DB_DESTINATION]"<commit_msg>[#1872] skip database listing on resource server build<commit_after>#!/bin/bash

set -e
STARTTIME="$(date +%s)"
SCRIPTNAME=`basename $0`
SCRIPTPATH=$( cd $(dirname $0) ; pwd -P )
FULLPATHSCRIPTNAME=$SCRIPTPATH/$SCRIPTNAME
COVERAGE="0"
RELEASE="0"
BUILDIRODS="1"
PORTABLE="0"
COVERAGEBUILDDIR="/var/lib/irods"
PREFLIGHT=""
PREFLIGHTDOWNLOAD=""
PYPREFLIGHT=""
IRODSPACKAGEDIR="./build"

USAGE="

Usage: $SCRIPTNAME [OPTIONS] <serverType> [databaseType]
Usage: $SCRIPTNAME docs
Usage: $SCRIPTNAME clean

Options:
-c      Build with coverage support (gcov)
-h      Show this help
-r      Build a release package (no debugging information, optimized)
-s      Skip compilation of iRODS source
-p      Portable option, ignores OS and builds a tar.gz

Examples:
$SCRIPTNAME icat postgres
$SCRIPTNAME resource
$SCRIPTNAME -s icat postgres
$SCRIPTNAME -s resource
"

# Color Manipulation Aliases
if [[ "$TERM" == "dumb" || "$TERM" == "unknown" ]] ; then
    text_bold=""      # No Operation
    text_red=""       # No Operation
    text_green=""     # No Operation
    text_yellow=""    # No Operation
    text_blue=""      # No Operation
    text_purple=""    # No Operation
    text_cyan=""      # No Operation
    text_white=""     # No Operation
    text_reset=""     # No Operation
else
    text_bold=$(tput bold)      # Bold
    text_red=$(tput setaf 1)    # Red
    text_green=$(tput setaf 2)  # Green
    text_yellow=$(tput setaf 3) # Yellow
    text_blue=$(tput setaf 4)   # Blue
    text_purple=$(tput setaf 5) # Purple
    text_cyan=$(tput setaf 6)   # Cyan
    text_white=$(tput setaf 7)  # White
    text_reset=$(tput sgr0)     # Text Reset
fi

# boilerplate
echo "${text_cyan}${text_bold}"
echo "+------------------------------------+"
echo "| RENCI iRODS Build Script           |"
echo "+------------------------------------+"
date
echo "${text_reset}"

# translate long options to short
for arg
do
    delim=""
    case "$arg" in
        --coverage) args="${args}-c ";;
        --help) args="${args}-h ";;
        --release) args="${args}-r ";;
        --skip) args="${args}-s ";;
        --portable) args="${args}-p ";;
        # pass through anything else
        *) [[ "${arg:0:1}" == "-" ]] || delim="\""
        args="${args}${delim}${arg}${delim} ";;
    esac
done
# reset the translated args
eval set -- $args
# now we can process with getopts
while getopts ":chrsp" opt; do
    case $opt in
        c)
        COVERAGE="1"
        TARGET=$2
        echo "-c detected -- Building iRODS with coverage support (gcov)"
        echo "${text_green}${text_bold}TARGET=[$TARGET]${text_reset}"
        if [ "$TARGET" == "icat" ] ; then
            echo "${text_green}${text_bold}TARGET is ICAT${text_reset}"
        fi
        ;;
        h)
        echo "$USAGE"
        ;;
        r)
        RELEASE="1"
        echo "-r detected -- Building a RELEASE package of iRODS"
        ;;
        s)
        BUILDIRODS="0"
        echo "-s detected -- Skipping iRODS compilation"
        ;;
        p)
        PORTABLE="1"
        echo "-p detected -- Building portable package"
        ;;
        \?)
        echo "Invalid option: -$OPTARG" >&2
        ;;
    esac
done
echo ""

# detect illogical combinations, and exit
if [ "$BUILDIRODS" == "0" -a "$RELEASE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -s   skip compilation" 1>&2
    echo "      :: -r   build for release" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi
if [ "$BUILDIRODS" == "0" -a "$COVERAGE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -s   skip compilation" 1>&2
    echo "      :: -c   coverage support" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi
if [ "$COVERAGE" == "1" -a "$RELEASE" == "1" ] ; then
    echo "${text_red}#######################################################" 1>&2
    echo "ERROR :: Incompatible options:" 1>&2
    echo "      :: -c   coverage support" 1>&2
    echo "      :: -r   build for release" 1>&2
    echo "#######################################################${text_reset}" 1>&2
    exit 1
fi

if [ "$COVERAGE" == "1" ] ; then
    if [ -d "$COVERAGEBUILDDIR" ] ; then
        echo "${text_red}#######################################################" 1>&2
        echo "ERROR :: $COVERAGEBUILDDIR/ already exists" 1>&2
        echo "      :: Cannot build in place with coverage enabled" 1>&2
        echo "      :: Try uninstalling the irods package" 1>&2
        echo "#######################################################${text_reset}" 1>&2
        exit 1
    fi
    if [ "$(id -u)" != "0" ] ; then
        echo "${text_red}#######################################################" 1>&2
        echo "ERROR :: $SCRIPTNAME must be run as root" 1>&2
        echo "      :: when building in place (coverage enabled)" 1>&2
        echo "#######################################################${text_reset}" 1>&2
        exit 1
    fi
fi



# remove options from $@
shift $((OPTIND-1))

# check arguments
if [ $# -ne 1 -a $# -ne 2 ] ; then
    echo "$USAGE" 1>&2
    exit 1
fi

# get into the correct directory
DETECTEDDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DETECTEDDIR/../

# begin self-awareness
echo "${text_green}${text_bold}Detecting Build Environment${text_reset}"
echo "Detected Packaging Directory [$DETECTEDDIR]"
GITDIR=`pwd`
BUILDDIR=$GITDIR  # we'll manipulate this later, depending on the coverage flag
EPMCMD="external/epm/epm"
cd $BUILDDIR/iRODS
echo "Build Directory set to [$BUILDDIR]"
# read iRODS Version from file
source ../VERSION
echo "Detected iRODS Version to Build [$IRODSVERSION]"
echo "Detected iRODS Version Integer [$IRODSVERSIONINT]"
# detect operating system
DETECTEDOS=`../packaging/find_os.sh`
if [ "$PORTABLE" == "1" ] ; then
  DETECTEDOS="Portable"
fi
echo "Detected OS [$DETECTEDOS]"
DETECTEDOSVERSION=`../packaging/find_os_version.sh`
echo "Detected OS Version [$DETECTEDOSVERSION]"




############################################################
# FUNCTIONS
############################################################

# find number of cpus
detect_number_of_cpus_and_set_makejcmd() {
    if [ "$DETECTEDOS" == "MacOSX" ] ; then
        DETECTEDCPUCOUNT=`sysctl -n hw.ncpu`
    elif [ "$DETECTEDOS" == "Solaris" ] ; then
        DETECTEDCPUCOUNT=`/usr/sbin/psrinfo -p`
    else
        DETECTEDCPUCOUNT=`cat /proc/cpuinfo | grep processor | wc -l | tr -d ' '`
    fi
    if [ $DETECTEDCPUCOUNT -lt 2 ] ; then
        DETECTEDCPUCOUNT=1
    fi
    CPUCOUNT=$(( $DETECTEDCPUCOUNT + 3 ))
    MAKEJCMD="make -j $CPUCOUNT"

    # print out detected CPU information
    echo "${text_cyan}${text_bold}-------------------------------------"
    echo "Detected CPUs:    $DETECTEDCPUCOUNT"
    echo "Compiling with:   $MAKEJCMD"
    echo "-------------------------------------${text_reset}"
    sleep 1
}

# rename generated packages appropriately
rename_generated_packages() {

    # parameters
    if [ "$1" == "" ] ; then
        echo "rename_generated_packages() expected 1 parameter"
        exit 1
    fi
    TARGET=$1

    #################
    # extensions
    cd $BUILDDIR
    SUFFIX=""
    if   [ "$DETECTEDOS" == "RedHatCompatible" ] ; then
	EXTENSION="rpm"
	SUFFIX="-redhat"
	if [ "$epmosversion" == "CENTOS6" ] ; then
            SUFFIX="-centos6"
	fi
    elif [ "$DETECTEDOS" == "SuSE" ] ; then
	EXTENSION="rpm"
	SUFFIX="-suse"
    elif [ "$DETECTEDOS" == "Ubuntu" -o "$DETECTEDOS" == "Debian" ] ; then
	EXTENSION="deb"
    elif [ "$DETECTEDOS" == "Solaris" ] ; then
	EXTENSION="pkg"
    elif [ "$DETECTEDOS" == "MacOSX" ] ; then
	EXTENSION="dmg"
    elif [ "$DETECTEDOS" == "ArchLinux" ] ; then
	EXTENSION="tar.gz"
    elif [ "$DETECTEDOS" == "Portable" ] ; then
	EXTENSION="tar.gz"
    fi

    #################
    # icat and resource server packages
    RENAME_SOURCE="./linux*/irods-*$IRODSVERSION*.$EXTENSION"
    RENAME_SOURCE_DOCS=${RENAME_SOURCE/irods-/irods-docs-}
    RENAME_SOURCE_DEV=${RENAME_SOURCE/irods-/irods-dev-}
    RENAME_SOURCE_ICOMMANDS=${RENAME_SOURCE/irods-/irods-icommands-}
    SOURCELIST=`ls $RENAME_SOURCE`
    echo "EPM produced packages:"
    echo "$SOURCELIST"
    # prepare target build directory
    mkdir -p $IRODSPACKAGEDIR
    # vanilla construct
    RENAME_DESTINATION="$IRODSPACKAGEDIR/irods-$IRODSVERSION-64bit.$EXTENSION"
    # add OS-specific suffix
    if [ "$SUFFIX" != "" ] ; then
	RENAME_DESTINATION=${RENAME_DESTINATION/.$EXTENSION/$SUFFIX.$EXTENSION}
    fi
    # docs build
    RENAME_DESTINATION_DOCS=${RENAME_DESTINATION/irods-/irods-docs-}
    # release build (also building icommands)
    RENAME_DESTINATION_DEV=${RENAME_DESTINATION/irods-/irods-dev-}
    RENAME_DESTINATION_ICOMMANDS=${RENAME_DESTINATION/irods-/irods-icommands-}
    # icat or resource
    if [ "$TARGET" == "icat" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/irods-/irods-icat-}
    elif [ "$TARGET" == "resource" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/irods-/irods-resource-}
    fi
    # coverage build
    if [ "$COVERAGE" == "1" ] ; then
        RENAME_DESTINATION=${RENAME_DESTINATION/-64bit/-64bit-coverage}
    fi

    #################
    # database packages
    if [ "$TARGET" == "icat" ] ; then
        DB_SOURCE="./plugins/database/linux*/*database*.$EXTENSION"
        echo `ls $DB_SOURCE`
        DB_PACKAGE=`basename $DB_SOURCE`
        DB_DESTINATION="$IRODSPACKAGEDIR/$DB_PACKAGE"
        DB_DESTINATION=`echo $DB_DESTINATION | sed -e "s,\\(-[^-]*\\)\{3\}\\.$EXTENSION\$,.$EXTENSION,"`
    fi

    #################
    # rename and tell me
    if [ "$TARGET" == "docs" ] ; then
	echo ""
	echo "renaming    [$RENAME_SOURCE_DOCS]"
	echo "         to [$RENAME_DESTINATION_DOCS]"
	mv $RENAME_SOURCE_DOCS $RENAME_DESTINATION_DOCS
    else
	if [ "$RELEASE" == "1" ] ; then
	    echo ""
	    echo "renaming    [$RENAME_SOURCE_ICOMMANDS]"
	    echo "         to [$RENAME_DESTINATION_ICOMMANDS]"
	    mv $RENAME_SOURCE_ICOMMANDS $RENAME_DESTINATION_ICOMMANDS
	fi
	if [ "$TARGET" == "icat" ] ; then
	    echo ""
	    echo "renaming    [$RENAME_SOURCE_DEV]"
	    echo "         to [$RENAME_DESTINATION_DEV]"
	    mv $RENAME_SOURCE_DEV $RENAME_DESTINATION_DEV
	fi
        # icat or resource
        echo ""
        echo "renaming    [$RENAME_SOURCE]"
        echo "         to [$RENAME_DESTINATION]"
        mv $RENAME_SOURCE $RENAME_DESTINATION
        # database
        if [ "$BUILDIRODS" == "1" -a "$TARGET" == "icat" ] ; then
            echo ""
            echo "renaming    [$DB_SOURCE]"
            echo "         to [$DB_DESTINATION]"
{'fraction_non_alphanumeric': 0.2172561032210155, 'fraction_numerical': 0.010489185927782418, 'mean_word_length': 2.8774518625157457, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2836572', 'n_tokens_mistral': 7594, 'n_tokens_neox': 7176, 'n_words': 1701}