2014-04-03 17:43:50 +02:00
|
|
|
#!/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()
|
|
|
|
{
|
2014-09-02 16:22:00 +02:00
|
|
|
FILE="$1"
|
|
|
|
MD5="$2"
|
|
|
|
ARCHIVE="${QPACKAGE_ROOT}/data/cache/$MD5"
|
|
|
|
if [[ -f "$ARCHIVE" ]]
|
2014-04-03 17:43:50 +02:00
|
|
|
then
|
2014-09-02 16:22:00 +02:00
|
|
|
if ! diff "$FILE" "${QPACKAGE_ROOT}/data/cache/$MD5" &> /dev/null
|
2014-04-03 17:43:50 +02:00
|
|
|
then
|
|
|
|
echo "Something went wrong. The file"
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "${QPACKAGE_ROOT}/data/cache/$MD5"
|
2014-04-03 17:43:50 +02:00
|
|
|
echo "is different from $FILE"
|
|
|
|
echo "Aborting"
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
else
|
2014-09-02 16:22:00 +02:00
|
|
|
cp "$FILE" "${QPACKAGE_ROOT}/data/cache/$MD5"
|
2014-04-03 17:43:50 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EZFIO_FILE=$(basename ${1})
|
|
|
|
|
|
|
|
if [[ -z ${EZFIO_FILE} ]]
|
|
|
|
then
|
|
|
|
echo "Usage: $(basename $0) <EZFIO_FILE>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2014-09-02 16:22:00 +02:00
|
|
|
cd "${QPACKAGE_ROOT}/EZFIO/src"
|
2014-04-03 17:43:50 +02:00
|
|
|
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
|
|
|
|
|
2014-09-02 16:22:00 +02:00
|
|
|
MD5_FILE=$(basename "${EZFIO_FILE}" .ezfio).md5
|
|
|
|
rm -f -- "${MD5_FILE}"
|
2014-04-03 17:43:50 +02:00
|
|
|
for FILE in ${FILES[@]}
|
|
|
|
do
|
2014-09-02 16:22:00 +02:00
|
|
|
FILE="${EZFIO_FILE}/${FILE}"
|
|
|
|
MD5=$(md5sum "${FILE}" 2>/dev/null | cut -d ' ' -f 1)
|
2014-04-03 17:43:50 +02:00
|
|
|
if [[ ! -z $MD5 ]]
|
|
|
|
then
|
2014-09-02 16:22:00 +02:00
|
|
|
if ! archive "$FILE" "$MD5"
|
2014-04-03 17:43:50 +02:00
|
|
|
then
|
2014-09-02 16:22:00 +02:00
|
|
|
rm -- "${MD5_FILE}"
|
2014-04-03 17:43:50 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-09-02 16:22:00 +02:00
|
|
|
echo "$MD5" "$FILE" >> "${MD5_FILE}"
|
2014-04-03 17:43:50 +02:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|