2010-04-09 00:40:53 +00:00
|
|
|
#!/bin/bash
|
2011-12-14 07:40:48 +00:00
|
|
|
# Use this script to build MegaGlest Data Diff Archive for a Version Release
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Written by Mark Vejvoda <mark_vejvoda@hotmail.com>
|
|
|
|
# Copyright (c) 2011 Mark Vejvoda under GNU GPL v3.0+
|
2010-04-09 00:40:53 +00:00
|
|
|
|
|
|
|
# This script compares two mega-glest data content folders for file differences,
|
|
|
|
# then creates an archive of ONLY the differences (including files ONLY in new version)
|
2013-05-26 02:16:01 +00:00
|
|
|
|
|
|
|
# Consider setting this for small packages if there's plenty of RAM and CPU available:
|
|
|
|
#export XZ_OPT="$XZ_OPT -9e"
|
|
|
|
|
2011-01-22 04:51:24 +00:00
|
|
|
OLD_VERSION=`./mg-version.sh --oldversion`
|
2011-05-07 07:36:10 +00:00
|
|
|
VERSION=`./mg-version.sh --version`
|
|
|
|
NEW_SUBFOLDER_PATH="megaglest-$VERSION"
|
2010-04-09 00:40:53 +00:00
|
|
|
|
2014-01-24 09:50:17 -08:00
|
|
|
CURRENTDIR="$(dirname $(readlink -f $0))"
|
|
|
|
RELEASEDIR_ROOT="$CURRENTDIR/../../../release/"
|
|
|
|
|
|
|
|
cd $RELEASEDIR_ROOT
|
|
|
|
CURDIR=$RELEASEDIR_ROOT
|
|
|
|
cd $CURRENTDIR
|
2011-05-07 07:36:10 +00:00
|
|
|
|
2010-04-09 00:40:53 +00:00
|
|
|
RELEASENAME=megaglest-data-updates-$VERSION
|
|
|
|
|
|
|
|
cd $CURDIR
|
|
|
|
|
|
|
|
echo "Creating data package $RELEASENAME (comparing against $OLD_VERSION)"
|
|
|
|
|
2011-01-22 02:02:49 +00:00
|
|
|
#if [ ! -e megaglest-data-$VERSION-changes.txt ]; then
|
2011-05-25 19:03:22 +00:00
|
|
|
diff --strip-trailing-cr --brief -r -x "*~" megaglest-data-$OLD_VERSION/megaglest-$OLD_VERSION megaglest-data-$VERSION/megaglest-$VERSION > megaglest-data-$VERSION-changes.txt
|
2011-01-22 02:02:49 +00:00
|
|
|
#fi
|
2010-04-09 00:40:53 +00:00
|
|
|
|
|
|
|
cd megaglest-data-$VERSION
|
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
[[ -f "../megaglest-data-$VERSION-fileslist.txt" ]] && rm "../megaglest-data-$VERSION-fileslist.txt"
|
2010-04-09 00:40:53 +00:00
|
|
|
|
|
|
|
cat ../megaglest-data-$VERSION-changes.txt | while read line;
|
|
|
|
do
|
|
|
|
|
|
|
|
#echo "$line" # Output the line itself.
|
|
|
|
#echo `expr match "$line" 'megaglest-data-$VERSION'`
|
|
|
|
#addfilepos=`expr match "$line" 'megaglest-data-$VERSION'`
|
|
|
|
|
|
|
|
#echo [$line]
|
|
|
|
#echo `awk "BEGIN {print index(\"$line\", \"megaglest-data-$VERSION\")}"`
|
|
|
|
|
|
|
|
addfilepos=`awk "BEGIN {print index(\"$line\", \"megaglest-data-$VERSION\")}"`
|
|
|
|
|
|
|
|
#echo [$addfilepos]
|
|
|
|
#echo [${line:$addfilepos-1}]
|
|
|
|
|
|
|
|
#echo [Looking for ONLY in: `expr match "$line" 'Only in '`]
|
2011-05-26 05:06:51 +00:00
|
|
|
onlyinpos=`expr match "$line" "Only in "`
|
2010-04-09 00:40:53 +00:00
|
|
|
#echo [$onlyinpos]
|
|
|
|
|
|
|
|
if [ "$onlyinpos" -eq "8" ]; then
|
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
echo **NOTE: Found ONLY IN string... original line [${line}]
|
2010-04-09 00:40:53 +00:00
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
onlyinpos=`expr match "$line" "Only in megaglest-data-$VERSION"`
|
|
|
|
if [ "$onlyinpos" -ge "24" ]; then
|
|
|
|
line=${line:$addfilepos-1}
|
|
|
|
line=${line/: //}
|
|
|
|
line=${line/megaglest-data-$VERSION\/}
|
2010-04-09 00:40:53 +00:00
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
echo New path: [$line]
|
|
|
|
else
|
|
|
|
echo **NOTE: skipping file since it is not in current version [${line}] match [$onlyinpos]
|
|
|
|
line=
|
|
|
|
echo New path: [$line]
|
|
|
|
fi
|
2010-04-09 00:40:53 +00:00
|
|
|
else
|
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
echo Section B ... original line [${line}]
|
|
|
|
|
2010-04-09 00:40:53 +00:00
|
|
|
line=${line:$addfilepos-1}
|
|
|
|
line=${line/ differ/}
|
2011-05-26 05:06:51 +00:00
|
|
|
line=${line/megaglest-data-$VERSION\/}
|
2010-04-09 00:40:53 +00:00
|
|
|
|
|
|
|
echo New path: [$line]
|
|
|
|
fi
|
|
|
|
|
|
|
|
#compress_files="${compress_files} ${line}"
|
|
|
|
|
|
|
|
#echo compress_files = [$compress_files]
|
|
|
|
#echo ${line##megaglest-data-$VERSION*}
|
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
if [ -n "${line}" ]; then
|
|
|
|
echo "${line} " >> ../megaglest-data-$VERSION-fileslist.txt
|
|
|
|
fi
|
2010-04-09 00:40:53 +00:00
|
|
|
|
|
|
|
done
|
|
|
|
#exit
|
|
|
|
|
|
|
|
files_list=`cat ../megaglest-data-$VERSION-fileslist.txt`
|
|
|
|
|
|
|
|
#echo compress_files = [$files_list]
|
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
[[ -f "../$RELEASENAME.tar.xz" ]] && rm "../$RELEASENAME.tar.xz"
|
2010-04-09 00:40:53 +00:00
|
|
|
|
2011-05-26 05:06:51 +00:00
|
|
|
echo Current Folder is [`pwd`]
|
2010-04-09 00:40:53 +00:00
|
|
|
#echo 7za a "../$RELEASENAME.7z" $files_list
|
2011-05-26 05:06:51 +00:00
|
|
|
#7za a -mx=9 -ms=on -mhc=on "../$RELEASENAME.7z" $files_list
|
2013-05-26 02:16:01 +00:00
|
|
|
tar -cf - --add-file $files_list | xz > ../$RELEASENAME.tar.xz
|
2010-04-09 00:40:53 +00:00
|
|
|
|
2014-01-24 09:50:17 -08:00
|
|
|
cd $CURRENTDIR
|
2010-04-09 00:40:53 +00:00
|
|
|
|