@@ -100,6 +100,8 @@ cook() {
100100 download_ib $target
101101 }
102102
103+ [ " $snapshots " -eq 1 ] && check_outdated " $target " " imagebuilder"
104+
103105 [ -n " $use_remote_pkgs " ] && {
104106 local arch=` get_arch_from_ib $target `
105107 echo " -> Using remote repository for ImageBuilder, architecture: $arch "
@@ -188,9 +190,11 @@ build_sdk() {
188190
189191 [ ! -d " $sdk " ] && {
190192 echo " -> SDK for target $target not found"
191- download_sdk $target
193+ download_sdk " $target "
192194 }
193-
195+
196+ [ " $snapshots " -eq 1 ] && check_outdated " $target " " sdk"
197+
194198 echo " -> Building $sdk "
195199
196200 [ -f " $feeds_file " ] || {
@@ -335,6 +339,30 @@ download_all() {
335339 cat $targets_list | while read t; do download_sdk $t ; download_ib $t ; done
336340}
337341
342+ check_outdated () {
343+ echo " -> Check if snapshot is outdated"
344+ local target=" $1 "
345+ local type=" $2 "
346+ local url=" $base_url /$target "
347+ local output=" $release /$target "
348+ local file_hash=" $( get_hash_filename $url $type ) "
349+ local file=" $( echo $file_hash | cut -d' *' -f 2) "
350+
351+ [ " $file_hash " != " $( cat $tmp_dir /${file} _checksum) " ] && {
352+ echo " -> Snapshot $type is outdated"
353+ echo " --> Removing and downloading again"
354+ rm " $tmp_dir /$file " *
355+ [ " $type " == " sdk" ] && download_sdk " $target "
356+ [ " $type " == " imagebuilder" ] && download_ib " $target "
357+ }
358+ }
359+
360+ get_hash_filename () {
361+ local url=" $1 "
362+ local type=" $2 "
363+ echo " $( wget -q -O- $url /sha256sums | grep ${brand_name} -$type ) "
364+ }
365+
338366download_sdk () {
339367 local target=" $1 "
340368 [ -z " $target " ] && {
@@ -346,12 +374,17 @@ download_sdk() {
346374 local output=" $release /$target "
347375 [ ! -d " $output " ] && mkdir -p " $output "
348376
349- local sdk_file=" $( wget -q -O- $url | grep ${brand_name} -sdk | grep href | awk -F\> ' {print $4}' | awk -F\< ' {print $1}' ) "
377+ local sdk_file_hash=" $( get_hash_filename $url sdk) "
378+ local sdk_file=" $( echo $sdk_file_hash | cut -d' *' -f 2) "
379+
350380 echo " -> Downloading $url /$sdk_file "
351381 wget -c " $url /$sdk_file " -O " $tmp_dir /$sdk_file " || {
352382 echo " -> Error, cannot download SDK $url /$sdk_file "
353383 exit 1
354384 }
385+
386+ echo " $sdk_file_hash " > " $tmp_dir /${sdk_file} _checksum"
387+
355388 unpack_sdk $tmp_dir /$sdk_file $output
356389}
357390
@@ -386,7 +419,9 @@ download_ib() {
386419 local url=" $base_url /$target "
387420 local output=" $release /$target "
388421 [ ! -d " $output " ] && mkdir -p " $output "
389- local ib_file=" $( wget -q -O- $url | grep ${brand_name} -imagebuilder | grep href | awk -F\> ' {print $4}' | awk -F\< ' {print $1}' ) "
422+
423+ local ib_file_hash=" $( get_hash_filename $url imagebuilder) "
424+ local ib_file=" $( echo $ib_file_hash | cut -d' *' -f 2) "
390425 echo " -> Downloading $url /$ib_file "
391426 wget -c " $url /$ib_file " -O " $tmp_dir /$ib_file " || {
392427 echo " -> Error, cannot download ImageBuilder $url /$ib_file "
0 commit comments