Support for pre-downloaded dependency packages and digest verification.
[UPDATED] Allow overriding of targets to build at command-line via target=X ./build [ADDED] Support pre-downloaded packages for integration with package managers. [ADDED] Support for package digest verification. [UPDATED] Skip fetching on in a method-specific way, more reliable.
This commit is contained in:
parent
c3474de2ff
commit
9d926be8ae
@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# TROUBLESHOOTING
|
# TROUBLESHOOTING
|
||||||
# - See the 'options' array. Comment/uncomment lines as you see fit.
|
# - To enable verbose algorithm/implementation debugging, use ./build -DDEBUG
|
||||||
# - If you see 'undefined reference to `clock_gettime'', try ./build -lrt instead.
|
# - If you see 'undefined reference to `clock_gettime'', try ./build -lrt instead
|
||||||
#
|
#
|
||||||
# BUGS
|
# BUGS
|
||||||
# masterpassword@lyndir.com
|
# masterpassword@lyndir.com
|
||||||
@ -14,15 +14,20 @@ cd "${BASH_SOURCE%/*}"
|
|||||||
shopt -s extglob
|
shopt -s extglob
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# optional features.
|
|
||||||
options=(
|
### CONFIGURATION
|
||||||
#-DDEBUG # Turn on debugging verbosity.
|
|
||||||
)
|
# Targets to build.
|
||||||
# available targets.
|
if [[ $targets ]]; then
|
||||||
|
read -ra targets <<< "$targets"
|
||||||
|
else
|
||||||
|
# Default targets.
|
||||||
|
# Modify here or override using targets='mpw mpw-bench' ./build
|
||||||
targets=(
|
targets=(
|
||||||
mpw # C CLI version of Master Password.
|
mpw # C CLI version of Master Password.
|
||||||
#mpw-bench # C CLI Master Password benchmark utility.
|
#mpw-bench # C CLI Master Password benchmark utility.
|
||||||
)
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
### DEPENDENCIES
|
### DEPENDENCIES
|
||||||
@ -34,52 +39,86 @@ fetch() {
|
|||||||
curl "$1" > "${1##*/}"
|
curl "$1" > "${1##*/}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
fetchSource() (
|
unpack() {
|
||||||
echo
|
if [[ $1 = *.tar.gz || $1 = *.tgz ]]; then
|
||||||
echo "Fetching dependency: ${PWD##*/}..."
|
tar -xvzf "$1"
|
||||||
source .source
|
|
||||||
|
|
||||||
if [[ $git ]] && hash git 2>/dev/null; then
|
elif [[ $1 = *.tar.bz2 || $1 = *.tbz2 ]]; then
|
||||||
echo
|
tar -xvjf "$1"
|
||||||
echo "Fetching: ${PWD##*/}, using git..."
|
|
||||||
git clone "$svn" .
|
|
||||||
printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
|
|
||||||
return
|
|
||||||
|
|
||||||
elif [[ $svn ]] && hash git 2>/dev/null && [[ -x "$(git --exec-path)/git-svn" ]]; then
|
elif [[ $1 = *.tar ]]; then
|
||||||
echo
|
tar -xvf "$1"
|
||||||
echo "Fetching: ${PWD##*/}, using git-svn..."
|
|
||||||
git svn clone --prefix=origin/ --stdlayout "$svn" .
|
|
||||||
printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
|
|
||||||
return
|
|
||||||
|
|
||||||
elif [[ $svn ]] && hash svn 2>/dev/null; then
|
else
|
||||||
echo
|
echo 2>&1 "Don't know how to unpack: $1"
|
||||||
echo "Fetching: ${PWD##*/}, using svn..."
|
fi
|
||||||
svn checkout "$svn/trunk" .
|
|
||||||
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > "${PWD##*/}-version"
|
|
||||||
return
|
|
||||||
|
|
||||||
elif [[ $pkg ]]; then
|
printf 'Verifying package: %s, against digest: %s...' "$1" "$2"
|
||||||
echo
|
[[ $(openssl sha < "$1") = $2 ]] || {
|
||||||
echo "Fetching: ${PWD##*/}, using package..."
|
printf ' mismatch!\n'
|
||||||
fetch "$pkg"
|
echo 2>&1 "Downloaded package doesn't match digest."
|
||||||
if [[ $pkg = *.tar.gz || $pkg = *.tgz ]]; then
|
exit 1
|
||||||
tar -xvzf "${pkg##*/}"
|
}
|
||||||
files=(!("${pkg##*/}"))
|
printf ' OK!\n'
|
||||||
|
|
||||||
|
files=( !("$1") )
|
||||||
if [[ -d $files ]] && (( ${#files[@]} == 1 )); then
|
if [[ -d $files ]] && (( ${#files[@]} == 1 )); then
|
||||||
mv "$files"/* .
|
mv "$files"/* .
|
||||||
rmdir "$files"
|
rmdir "$files"
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
return
|
fetchSource() (
|
||||||
fi
|
source .source
|
||||||
|
|
||||||
|
if [[ $pkg && -e "${pkg##*/}" ]]; then
|
||||||
|
files=( !("${pkg##*/}") )
|
||||||
|
[[ -e $files ]] || {
|
||||||
|
echo
|
||||||
|
echo "Unpacking: ${PWD##*/}, using package..."
|
||||||
|
unpack "${pkg##*/}" "$pkg_sha"
|
||||||
|
}
|
||||||
|
|
||||||
|
elif [[ $git ]] && hash git 2>/dev/null; then
|
||||||
|
[[ -e .git ]] || {
|
||||||
|
echo
|
||||||
|
echo "Fetching: ${PWD##*/}, using git..."
|
||||||
|
git clone "$svn" .
|
||||||
|
printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
|
||||||
|
}
|
||||||
|
|
||||||
|
elif [[ $svn ]] && hash git 2>/dev/null && [[ -x "$(git --exec-path)/git-svn" ]]; then
|
||||||
|
[[ -e .git ]] || {
|
||||||
|
echo
|
||||||
|
echo "Fetching: ${PWD##*/}, using git-svn..."
|
||||||
|
git svn clone --prefix=origin/ --stdlayout "$svn" .
|
||||||
|
printf '%s' "$(git describe --always)" > "${PWD##*/}-version"
|
||||||
|
}
|
||||||
|
|
||||||
|
elif [[ $svn ]] && hash svn 2>/dev/null; then
|
||||||
|
[[ -e .svn ]] || {
|
||||||
|
echo
|
||||||
|
echo "Fetching: ${PWD##*/}, using svn..."
|
||||||
|
svn checkout "$svn/trunk" .
|
||||||
|
printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > "${PWD##*/}-version"
|
||||||
|
}
|
||||||
|
|
||||||
|
elif [[ $pkg ]]; then
|
||||||
|
files=( !("${pkg##*/}") )
|
||||||
|
[[ -e $files ]] || {
|
||||||
|
echo
|
||||||
|
echo "Fetching: ${PWD##*/}, using package..."
|
||||||
|
fetch "$pkg"
|
||||||
|
unpack "${pkg##*/}" "$pkg_sha"
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
echo >&2 "error: Missing git-svn or svn."
|
echo >&2 "error: Missing git-svn or svn."
|
||||||
echo >&2 "error: Please install either or manually check out the sources"
|
echo >&2 "error: Please install either or manually check out the sources"
|
||||||
echo >&2 "error: from: $home"
|
echo >&2 "error: from: $home"
|
||||||
echo >&2 "error: into: $PWD"
|
echo >&2 "error: into: $PWD"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
)
|
)
|
||||||
depend() {
|
depend() {
|
||||||
|
|
||||||
@ -88,8 +127,7 @@ depend() {
|
|||||||
[[ -e "lib/$1/.built" ]] && return
|
[[ -e "lib/$1/.built" ]] && return
|
||||||
|
|
||||||
pushd "lib/$1"
|
pushd "lib/$1"
|
||||||
files=( * )
|
fetchSource
|
||||||
[[ -e $files ]] || fetchSource
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Configuring dependency: $1..."
|
echo "Configuring dependency: $1..."
|
||||||
@ -155,8 +193,8 @@ mpw() {
|
|||||||
"lib/scrypt/scrypt-scryptenc.o"
|
"lib/scrypt/scrypt-scryptenc.o"
|
||||||
)
|
)
|
||||||
|
|
||||||
cc "${CFLAGS[@]}" "${options[@]}" -c types.c -o types.o "$@"
|
cc "${CFLAGS[@]}" -c types.c -o types.o "$@"
|
||||||
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "${options[@]}" "types.o" mpw.c -o mpw "$@"
|
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "types.o" mpw.c -o mpw "$@"
|
||||||
echo "done! Now run ./install or use ./mpw"
|
echo "done! Now run ./install or use ./mpw"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,8 +231,8 @@ mpw-bench() {
|
|||||||
"lib/bcrypt/x86.o"
|
"lib/bcrypt/x86.o"
|
||||||
)
|
)
|
||||||
|
|
||||||
cc "${CFLAGS[@]}" "${options[@]}" -c types.c -o types.o "$@"
|
cc "${CFLAGS[@]}" -c types.c -o types.o "$@"
|
||||||
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "${options[@]}" "types.o" mpw-bench.c -o mpw-bench "$@"
|
cc "${CFLAGS[@]}" "${LDFLAGS[@]}" "types.o" mpw-bench.c -o mpw-bench "$@"
|
||||||
echo "done! Now use ./mpw-bench"
|
echo "done! Now use ./mpw-bench"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,7 +252,7 @@ cc() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Will build targets: ${targets[*]}${options:+, using options: ${options[*]}}..."
|
echo "Will build targets: ${targets[*]}..."
|
||||||
for target in "${targets[@]}"; do
|
for target in "${targets[@]}"; do
|
||||||
"$target" "$@"
|
"$target" "$@"
|
||||||
done
|
done
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
home=http://www.openwall.com/crypt/
|
home=http://www.openwall.com/crypt/
|
||||||
pkg=http://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz
|
pkg=http://www.openwall.com/crypt/crypt_blowfish-1.3.tar.gz
|
||||||
|
pkg_sha=7253c86c8fe890e67ec782749f95ce3f1517b065
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
home=https://code.google.com/p/scrypt/
|
home=https://code.google.com/p/scrypt/
|
||||||
svn=http://scrypt.googlecode.com/svn
|
svn=http://scrypt.googlecode.com/svn
|
||||||
|
pkg=http://masterpasswordapp.com/libscrypt-b12b554.tar.gz
|
||||||
|
pkg_sha=a86445c3e031392d20652f4163adfd3fb0b1994e
|
||||||
|
Loading…
Reference in New Issue
Block a user