Browse Source

Fixed MD5 checking

master
mid-kid 10 years ago
parent
commit
d9905874a7
  1. 15
      astronaut

15
astronaut

@ -13,7 +13,7 @@ Just describe what he's got to do in a satellite file.
Usage: $0 [-s <dir>] [-b <dir>] [-i <dir>] <satellite> Usage: $0 [-s <dir>] [-b <dir>] [-i <dir>] <satellite>
-s Set source directory -s Set source directory
-b Set build directory -b Set build directory [WARNING: Will be deleted before build]
-i Set install directory" -i Set install directory"
} }
@ -51,12 +51,16 @@ msg() {
echo "=> $@" echo "=> $@"
} }
mksum() {
echo $(md5sum "$@" 2> /dev/null | cut -d' ' -f1)
}
download() { download() {
local name=$(basename "$1") local name=$(basename "$1")
local path="$dir_source/$name" local path="$dir_source/$name"
local checksum="" local checksum=""
if [ "$2" -a -f "$path" ]; then if [ "$2" -a -f "$path" ]; then
checksum="$(md5sum ""$path"" 2> /dev/null | cut -d' ' -f1)" checksum=$(mksum "$path")
fi fi
if [ ! -f "$path" -o "$checksum" != "$2" ]; then if [ ! -f "$path" -o "$checksum" != "$2" ]; then
msg "Downloading $name" msg "Downloading $name"
@ -66,6 +70,12 @@ download() {
else else
curl -#L -o "$path" "$1" curl -#L -o "$path" "$1"
fi fi
checksum=$(mksum "$path")
if [ "$2" -a "$checksum" != "$2" ]; then
msg "Houston, we have a problem: Checksum failed."
msg "Checksum: $checksum"
exit 1
fi
fi fi
} }
@ -89,6 +99,7 @@ extrafile() {
} }
# Create the satellite # Create the satellite
rm -rf "$dir_build"
mkdir -p "$dir_source" mkdir -p "$dir_source"
mkdir -p "$dir_build" mkdir -p "$dir_build"
mkdir -p "$dir_install" mkdir -p "$dir_install"

Loading…
Cancel
Save