Skip to content

Commit b09a2c0

Browse files
committed
add cache system for packages. You can move your packages directory with PACKAGES_PATH=~/.p4a-cache ./distribute.sh -m ...
1 parent 7fc6359 commit b09a2c0

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

distribute.sh

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RECIPES_PATH="$ROOT_PATH/recipes"
2424
BUILD_PATH="$ROOT_PATH/build"
2525
LIBS_PATH="$ROOT_PATH/build/libs"
2626
JAVACLASS_PATH="$ROOT_PATH/build/java"
27-
PACKAGES_PATH="$ROOT_PATH/.packages"
27+
PACKAGES_PATH="${PACKAGES_PATH:-$ROOT_PATH/.packages}"
2828
SRC_PATH="$ROOT_PATH/src"
2929
JNI_PATH="$SRC_PATH/jni"
3030
DIST_PATH="$ROOT_PATH/dist/default"
@@ -57,8 +57,10 @@ if [ "X$WGET" == "X" ]; then
5757
else
5858
WGET="$WGET -L -O -o"
5959
fi
60+
WHEAD="curl -L -I"
6061
else
6162
WGET="$WGET -O"
63+
WHEAD="wget --spider -q -S"
6264
fi
6365

6466
case $OSTYPE in
@@ -504,12 +506,17 @@ function run_get_packages() {
504506
fi
505507

506508
filename=$(basename $url)
509+
marker_filename=".mark-$filename"
507510
do_download=1
508511

509-
# check if the file is already present
510512
cd $PACKAGES_PATH
513+
514+
# check if the file is already present
511515
if [ -f $filename ]; then
512-
if [ -n "$md5" ]; then
516+
# if the marker has not been set, it might be cause of a invalid download.
517+
if [ ! -f $marker_filename ]; then
518+
rm $filename
519+
elif [ -n "$md5" ]; then
513520
# check if the md5 is correct
514521
current_md5=$($MD5SUM $filename | cut -d\ -f1)
515522
if [ "X$current_md5" == "X$md5" ]; then
@@ -525,10 +532,31 @@ function run_get_packages() {
525532
fi
526533
fi
527534

535+
# check if the file HEAD in case of, only if there is no MD5 to check.
536+
check_headers=0
537+
if [ -z "$md5" ]; then
538+
if [ "X$DO_CLEAN_BUILD" == "X1" ]; then
539+
check_headers=1
540+
elif [ ! -f $filename ]; then
541+
check_headers=1
542+
fi
543+
fi
544+
545+
if [ "X$check_headers" == "X1" ]; then
546+
debug "Checking if $url changed"
547+
$WHEAD $url &> .headers-$filename
548+
$PYTHON "$ROOT_PATH/tools/check_headers.py" .headers-$filename .sig-$filename
549+
if [ $? -ne 0 ]; then
550+
do_download=1
551+
fi
552+
fi
553+
528554
# download if needed
529555
if [ $do_download -eq 1 ]; then
530556
info "Downloading $url"
557+
try rm -f $marker_filename
531558
try $WGET $filename $url
559+
touch $marker_filename
532560
else
533561
debug "Module $module already downloaded"
534562
fi

0 commit comments

Comments
 (0)