Added opsi-builder.cfg: CHECKSUM_AUTOCREATE: Every downloaded file is checked using SHA1 algorithm against a checksum file, if this file ist not available, it will be created on-the-fly, dependent on this setting.

This commit is contained in:
Daniel Schwager 2012-02-01 14:37:59 +01:00
parent e9754434bb
commit 2c21c221ff
4 changed files with 32 additions and 15 deletions

View File

@ -21,6 +21,12 @@ DEBUG_LEVEL=
# release : passed the testing and go's to productive
STATUS="integration"
# CHECKSUM_AUTOCREATE - Every downloaded file is checked using SHA1 algorithm
# against a checksum file, if this file ist not available, it will be created
# on-the-fly, dependent on this setting.
# Valid values: true|false, Default: false
CHECKSUM_AUTOCREATE=false
###############################
# CREATOR
###############################

View File

@ -96,13 +96,10 @@ builder_retrieve() {
if [ ! -z ${DIST_PRIVATE_REPOS} ]; then
urls="${DIST_PRIVATE_REPOS}/$basename;$urls"
fi
# check existence of CRC file only in non devel mode
if [ ! -z "${DEVEL}" ] ; then
if [ ! -e ${PRODUCT_DIR}/${basename}.sha1sum ] ; then
echo "You need to create the checksums with: sha1sum ${DIST_CACHE_DIR}/${basename} > ${PRODUCT_DIR}/${basename}.sha1sum"
exit 1
fi
if [ ! -e "${PRODUCT_DIR}/${basename}.sha1sum" ] && [ "$CHECKSUM_AUTOCREATE" != "true" ] ; then
fatal_error "You need to create the checksums with: sha1sum ${DIST_CACHE_DIR}/${basename} > ${PRODUCT_DIR}/${basename}.sha1sum"
fi
echo "Downloading $basename"
@ -110,6 +107,7 @@ builder_retrieve() {
for src in `echo $urls | sed -e 's/[;,]/\n/g'` ; do
if [ $downloaded == 1 ]; then continue; fi
# Download file
echo " Info: Downloding from $src"
local downloader=${DL_DOWNLOADER[$i]}
if [ -z $downloader ]; then downloader="wget" ; fi
@ -118,19 +116,32 @@ builder_retrieve() {
DL_DIST_FILE[$i]=${DIST_CACHE_DIR}/$arch/$basename
retrieve_file $downloader $src ${DL_DIST_FILE[$i]}
if [ $? == 0 ] ; then
if [ $? != 0 ] ; then
echo " Warning: Failed to download file - try next URL"
continue;
fi
# Check sha1
if [ ! -e "${PRODUCT_DIR}/${basename}.sha1sum" ] && [ "$CHECKSUM_AUTOCREATE" == "true" ] ; then
sha1sum ${DL_DIST_FILE[$i]} > ${PRODUCT_DIR}/${basename}.sha1sum
downloaded=1
echo " WARNING: SHA1 checksum (${DL_DIST_FILE[$i]}.sha1sum) was created dynamically because auf CHECKSUM_AUTOCREATE=$CHECKSUM_AUTOCREATE"
else
# testing the checksum of the downloaded files
local sha1sum_val=`cat ${PRODUCT_DIR}/${basename}.sha1sum | cut -d " " -f1`
local checksum_val=`sha1sum ${DL_DIST_FILE[$i]} | cut -d " " -f1`
if [ "$checksum_val" == "$sha1sum_val" ] ; then
downloaded=1
echo " Info: Downloaded successfully"
else
echo " Error: The checksums do not match - try next URL"
fi
else
echo " Warning: Failed to download file - try next URL"
fi
# Print result
if [ "$downloaded" == "1" ] ; then
echo " Info: Downloaded successfully"
else
echo " Error: The checksums do not match - try next URL"
fi
done
echo
@ -151,7 +162,7 @@ builder_create() {
# Copy files and convert text files to dos format
cp -Rv ${PRODUCT_DIR}/OPSI $INST_DIR
cp -Rv ${PRODUCT_DIR}/CLIENT_DATA $INST_DIR
find $INST_DIR/CLIENT_DATA -type f | xargs -n1 -iREP sh -c 'file -i $0 | grep "text/plain" && unix2dos $0' REP
find $INST_DIR/CLIENT_DATA -type f | xargs -n1 -iREP sh -c 'file -i $0 | grep "text/plain" && unix2dos $0 ' REP >/dev/null
# converting icon file
local iconfile_src=${DL_DIST_FILE[$ICON_DL_INDEX]}

View File

@ -89,7 +89,7 @@ function call_entry_point() {
###################
fatal_error() {
echo "FATAL: $1"
exit 0
exit 1
}
###################

View File

@ -112,7 +112,7 @@ ICON_DL_INDEX=0
#########################
# Setup additional, custom WINST variables
# which will be injected to the *.ins files
# which will be injected to the *.ins files (replaces token @@BUILDER_VARIABLES@@ )
#
# The following tokens inside the WINST_VALUE will be replaced dynamically
#