#!/bin/sh
#----------------------------------------------------------------------------
# _do_update-2.8.8 - joblist to do before mktarball.sh work
#
# Creation   : 2018-08-13 holbru
# Last update: $Id$
#----------------------------------------------------------------------------

#exec 2> `pwd`/targz-trace$$.log
#set -x

# get current directory
call_dir=$(pwd)

# get start directory
start_dir=$(dirname $0)/../../..
cd ${start_dir}
start_dir=$(pwd)


system_folder='eisfair-1
               eisfair-64'

for s_folder in ${system_folder}
do
    if [ -f ${start_dir}/updates/update-2.8.8/common/tmp/${s_folder}.tar.gz ]
    then
        svn rm --force ${start_dir}/updates/update-2.8.8/common/tmp/${s_folder}.tar.gz
    fi

    file_list="${start_dir}/updates/update-2.8.8/common/_ADMIN/update-2.8.8-files.txt"

    sed -i "/${s_folder}.tar.gz/d" "${file_list}"
done


system_folder='eisfair-1'

for s_folder in ${system_folder}
do

    if $(grep -qE "^u|^b" ${start_dir}/updates/update-2.8.8/${s_folder}/_ADMIN/update-2.8.8-files.txt)
    then
        ${start_dir}/_ADMIN/create-targz.sh  \
       -from ${s_folder}                     \
       -to common/tmp                        \
       -tar ${s_folder}                      \
       -quiet                                \
        update-2.8.8                         \
        ${1}

        file_list_text="b 0644 root root update-2.8.8 tmp/${s_folder}.tar.gz"
        file_list="${start_dir}/updates/update-2.8.8/common/_ADMIN/update-2.8.8-files.txt"

        if ! grep -q "${file_list_text}" "${file_list}"
        then
            echo "${file_list_text}" >> "${file_list}"
        fi

        svn add ${start_dir}/updates/update-2.8.8/common/tmp/${s_folder}.tar.gz >/dev/null 2>&1

    fi
done