summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schwager <[email protected]>2012-02-01 13:37:59 (GMT)
committer Daniel Schwager <[email protected]>2012-02-01 13:37:59 (GMT)
commit2c21c221ffb9cf619c6204d9667781145a19989c (patch)
treecbc21235755441b03c5296e031f1a3a051ade796
parente9754434bb0eca9750d84059b1aac41525468da1 (diff)
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.
-rw-r--r--conf/opsi-builder.cfg6
-rw-r--r--lib/builder-targets.sh37
-rw-r--r--lib/builder-utils.sh2
-rw-r--r--sample/builder-product.cfg2
4 files changed, 32 insertions, 15 deletions
diff --git a/conf/opsi-builder.cfg b/conf/opsi-builder.cfg
index 74939ec..16f4914 100644
--- a/conf/opsi-builder.cfg
+++ b/conf/opsi-builder.cfg
@@ -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
###############################
diff --git a/lib/builder-targets.sh b/lib/builder-targets.sh
index 3df69ef..3e44626 100644
--- a/lib/builder-targets.sh
+++ b/lib/builder-targets.sh
@@ -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]}
diff --git a/lib/builder-utils.sh b/lib/builder-utils.sh
index 996a6f7..dfee2b0 100644
--- a/lib/builder-utils.sh
+++ b/lib/builder-utils.sh
@@ -89,7 +89,7 @@ function call_entry_point() {
###################
fatal_error() {
echo "FATAL: $1"
- exit 0
+ exit 1
}
###################
diff --git a/sample/builder-product.cfg b/sample/builder-product.cfg
index 89fc4a6..d6d08c8 100644
--- a/sample/builder-product.cfg
+++ b/sample/builder-product.cfg
@@ -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 @@[email protected]@ )
#
# The following tokens inside the WINST_VALUE will be replaced dynamically
#

Powered by Domaintechnik.at | Hosting - Domain - Webspace