10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-19 12:32:34 +01:00
quantum_package/scripts/archive_ezfio.sh

77 lines
1.4 KiB
Bash
Executable File

#!/bin/bash
#
# Computes the MD5 digest of an EZFIO file, and creates a tar.
# Thu Apr 3 16:55:50 CEST 2014
if [[ -z ${QPACKAGE_ROOT} ]]
then
print "The QPACKAGE_ROOT environment variable is not set."
print "Please reload the quantum_package.rc file."
fi
function archive()
{
FILE=$1
MD5=$2
ARCHIVE=${QPACKAGE_ROOT}/data/cache/$MD5
if [[ -f $ARCHIVE ]]
then
if ! diff $FILE ${QPACKAGE_ROOT}/data/cache/$MD5 &> /dev/null
then
echo "Something went wrong. The file"
echo ${QPACKAGE_ROOT}/data/cache/$MD5
echo "is different from $FILE"
echo "Aborting"
return 1
fi
else
cp $FILE ${QPACKAGE_ROOT}/data/cache/$MD5
fi
}
EZFIO_FILE=$(basename ${1})
if [[ -z ${EZFIO_FILE} ]]
then
echo "Usage: $(basename $0) <EZFIO_FILE>"
exit 1
fi
cd ${QPACKAGE_ROOT}/EZFIO/src
FILES=($(python << EOF | sort
from read_config import *
for group in groups:
if group == "ezfio":
continue
for d in groups[group]:
if d[2] == ():
suffix = ""
else:
suffix = ".gz"
print group+'/'+d[0]+suffix
print "ezfio/creation"
print "ezfio/library"
EOF
))
cd $OLDPWD
for FILE in ${FILES[@]}
do
FILE=${EZFIO_FILE}/${FILE}
MD5=$(md5sum ${FILE} 2>/dev/null | cut -d ' ' -f 1)
if [[ ! -z $MD5 ]]
then
if ! archive $FILE $MD5
then
rm ${EZFIO_FILE}.md5
exit 1
fi
echo $MD5 $FILE >> ${EZFIO_FILE}.md5
fi
done