From 537e7d86f913d80bdd5b25c65300fe2c368a9297 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Thu, 5 Nov 2015 11:07:49 -0500 Subject: [PATCH] Fix patching and unpacking of dependency packages. --- .gitignore | 6 ++- MasterPassword/C/build | 41 +++++++++---------- MasterPassword/C/clean | 7 ++++ .../{bcrypt-arm.patch => bcrypt/arm.patch} | 0 .../{scrypt-osx.patch => scrypt/osx.patch} | 0 MasterPassword/C/mpw-bench.c | 6 +-- 6 files changed, 34 insertions(+), 26 deletions(-) create mode 100755 MasterPassword/C/clean rename MasterPassword/C/lib/{bcrypt-arm.patch => bcrypt/arm.patch} (100%) rename MasterPassword/C/lib/{scrypt-osx.patch => scrypt/osx.patch} (100%) diff --git a/.gitignore b/.gitignore index 45a384f3..24c36219 100644 --- a/.gitignore +++ b/.gitignore @@ -36,5 +36,7 @@ MasterPassword/C/mpw-*.tar.gz MasterPassword/C/mpw MasterPassword/C/mpw-bench MasterPassword/C/mpw-tests -MasterPassword/C/lib/*/* -!MasterPassword/C/lib/*/.source +MasterPassword/C/lib/*/.unpacked +MasterPassword/C/lib/*/.patched +MasterPassword/C/lib/*/src +MasterPassword/C/lib/include diff --git a/MasterPassword/C/build b/MasterPassword/C/build index 9f1cecd8..e56a7dec 100755 --- a/MasterPassword/C/build +++ b/MasterPassword/C/build @@ -62,6 +62,14 @@ fetch() { fi } unpack() { + printf 'Verifying package: %s, against digest: %s...' "$1" "$2" + [[ $(digest "$1") = $2 ]] || { + printf ' mismatch!\n' + echo 2>&1 "Downloaded package doesn't match digest." + exit 1 + } + printf ' OK!\n' + if [[ $1 = *.tar.gz || $1 = *.tgz ]]; then tar -xvzf "$1" @@ -75,20 +83,11 @@ unpack() { echo 2>&1 "Don't know how to unpack: $1" fi - printf 'Verifying package: %s, against digest: %s...' "$1" "$2" - [[ $(digest "$1") = $2 ]] || { - printf ' mismatch!\n' - echo 2>&1 "Downloaded package doesn't match digest." - exit 1 - } - printf ' OK!\n' - - files=( !("$1") ) + files=( * ) if [[ -d $files ]] && (( ${#files[@]} == 1 )); then mv "$files"/* . rmdir "$files" fi - touch .unpacked } fetchSource() ( local name=${PWD##*/} @@ -98,11 +97,11 @@ fetchSource() ( true elif [[ $pkg && -e "${pkg##*/}" ]]; then - files=( !("${pkg##*/}") ) - [[ -e $files ]] || { + [[ -e src ]] || { echo echo "Unpacking: $name, using package..." - ( mkdir src && cd src && unpack "${pkg##*/}" "$pkg_sha256" ) + ( mkdir src && cd src && unpack "../${pkg##*/}" "$pkg_sha256" ) + touch .unpacked } elif [[ $git ]] && hash git 2>/dev/null; then @@ -110,7 +109,7 @@ fetchSource() ( echo echo "Fetching: $name, using git..." git clone "$git" src - printf '%s' "$(git describe --always)" > "$name-version" + touch .unpacked } elif [[ $svn ]] && hash git 2>/dev/null && [[ -x "$(git --exec-path)/git-svn" ]]; then @@ -118,7 +117,7 @@ fetchSource() ( echo echo "Fetching: $name, using git-svn..." git svn clone --prefix=origin/ --stdlayout "$svn" src - printf '%s' "$(git describe --always)" > "$name-version" + touch .unpacked } elif [[ $svn ]] && hash svn 2>/dev/null; then @@ -126,16 +125,16 @@ fetchSource() ( echo echo "Fetching: $name, using svn..." svn checkout "$svn/trunk" src - printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > "$name-version" + touch .unpacked } elif [[ $pkg ]]; then - files=( !("${pkg##*/}") ) - [[ -e $files ]] || { + [[ -e src ]] || { echo echo "Fetching: $name, using package..." fetch "$pkg" - ( mkdir src && cd src && unpack "${pkg##*/}" "$pkg_sha256" ) + ( mkdir src && cd src && unpack "../${pkg##*/}" "$pkg_sha256" ) + touch .unpacked } else @@ -152,7 +151,7 @@ fetchSource() ( for patch in "${patches[@]}"; do echo echo "Patching: $name, for $patch..." - patch -p0 < "../../$name-$patch.patch" + patch -p0 < "../$patch.patch" done popd touch .patched @@ -166,7 +165,7 @@ depend() { [[ -e "lib/include/$name" ]] && return pushd "lib/$name" - [[ -e "src" ]] || fetchSource + fetchSource pushd "src" echo diff --git a/MasterPassword/C/clean b/MasterPassword/C/clean new file mode 100755 index 00000000..e45bee28 --- /dev/null +++ b/MasterPassword/C/clean @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +# +# Clean all generated build files. +set -e +cd "${BASH_SOURCE%/*}" + +rm -vfr lib/*/{.unpacked,.patched,src} lib/include diff --git a/MasterPassword/C/lib/bcrypt-arm.patch b/MasterPassword/C/lib/bcrypt/arm.patch similarity index 100% rename from MasterPassword/C/lib/bcrypt-arm.patch rename to MasterPassword/C/lib/bcrypt/arm.patch diff --git a/MasterPassword/C/lib/scrypt-osx.patch b/MasterPassword/C/lib/scrypt/osx.patch similarity index 100% rename from MasterPassword/C/lib/scrypt-osx.patch rename to MasterPassword/C/lib/scrypt/osx.patch diff --git a/MasterPassword/C/mpw-bench.c b/MasterPassword/C/mpw-bench.c index a479b927..987d6b74 100644 --- a/MasterPassword/C/mpw-bench.c +++ b/MasterPassword/C/mpw-bench.c @@ -88,7 +88,7 @@ int main(int argc, char *const argv[]) { // Start BCrypt int bcrypt_cost = 9; - iterations = 500; + iterations = 1000; mpw_getTime( &startTime ); for (int i = 0; i < iterations; ++i) { crypt( masterPassword, crypt_gensalt( "$2b$", bcrypt_cost, fullName, strlen( fullName ) ) ); @@ -100,8 +100,8 @@ int main(int argc, char *const argv[]) { // Summarize. fprintf( stdout, "\n== SUMMARY ==\nOn this machine,\n" ); - fprintf( stdout, " - mpw is %f times slower than sha256 (reference: 414000 on an MBP Late 2013).\n", sha256Speed / mpwSpeed ); - fprintf( stdout, " - mpw is %f times slower than bcrypt (cost 9) (reference: 4.86 on an MBP Late 2013).\n", bcrypt9Speed / mpwSpeed ); + fprintf( stdout, " - mpw is %f times slower than sha256 (reference: 320000 on an MBP Late 2013).\n", sha256Speed / mpwSpeed ); + fprintf( stdout, " - mpw is %f times slower than bcrypt (cost 9) (reference: 22 on an MBP Late 2013).\n", bcrypt9Speed / mpwSpeed ); return 0; }