Fix patching and unpacking of dependency packages.
This commit is contained in:
		
							
								
								
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -36,5 +36,7 @@ MasterPassword/C/mpw-*.tar.gz
 | 
				
			|||||||
MasterPassword/C/mpw
 | 
					MasterPassword/C/mpw
 | 
				
			||||||
MasterPassword/C/mpw-bench
 | 
					MasterPassword/C/mpw-bench
 | 
				
			||||||
MasterPassword/C/mpw-tests
 | 
					MasterPassword/C/mpw-tests
 | 
				
			||||||
MasterPassword/C/lib/*/*
 | 
					MasterPassword/C/lib/*/.unpacked
 | 
				
			||||||
!MasterPassword/C/lib/*/.source
 | 
					MasterPassword/C/lib/*/.patched
 | 
				
			||||||
 | 
					MasterPassword/C/lib/*/src
 | 
				
			||||||
 | 
					MasterPassword/C/lib/include
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -62,6 +62,14 @@ fetch() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
unpack() {
 | 
					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
 | 
					    if [[ $1 = *.tar.gz || $1 = *.tgz ]]; then
 | 
				
			||||||
        tar -xvzf "$1"
 | 
					        tar -xvzf "$1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -75,20 +83,11 @@ unpack() {
 | 
				
			|||||||
        echo 2>&1 "Don't know how to unpack: $1"
 | 
					        echo 2>&1 "Don't know how to unpack: $1"
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    printf 'Verifying package: %s, against digest: %s...' "$1" "$2"
 | 
					    files=( * )
 | 
				
			||||||
    [[ $(digest "$1") = $2 ]] || {
 | 
					 | 
				
			||||||
        printf ' mismatch!\n'
 | 
					 | 
				
			||||||
        echo 2>&1 "Downloaded package doesn't match digest."
 | 
					 | 
				
			||||||
        exit 1
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    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
 | 
				
			||||||
    touch .unpacked
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
fetchSource() (
 | 
					fetchSource() (
 | 
				
			||||||
    local name=${PWD##*/}
 | 
					    local name=${PWD##*/}
 | 
				
			||||||
@@ -98,11 +97,11 @@ fetchSource() (
 | 
				
			|||||||
        true
 | 
					        true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif [[ $pkg && -e "${pkg##*/}" ]]; then
 | 
					    elif [[ $pkg && -e "${pkg##*/}" ]]; then
 | 
				
			||||||
        files=( !("${pkg##*/}") )
 | 
					        [[ -e src ]] || {
 | 
				
			||||||
        [[ -e $files ]] || {
 | 
					 | 
				
			||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Unpacking: $name, using package..."
 | 
					            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
 | 
					    elif [[ $git ]] && hash git 2>/dev/null; then
 | 
				
			||||||
@@ -110,7 +109,7 @@ fetchSource() (
 | 
				
			|||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Fetching: $name, using git..."
 | 
					            echo "Fetching: $name, using git..."
 | 
				
			||||||
            git clone "$git" src
 | 
					            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
 | 
					    elif [[ $svn ]] && hash git 2>/dev/null && [[ -x "$(git --exec-path)/git-svn" ]]; then
 | 
				
			||||||
@@ -118,7 +117,7 @@ fetchSource() (
 | 
				
			|||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Fetching: $name, using git-svn..."
 | 
					            echo "Fetching: $name, using git-svn..."
 | 
				
			||||||
            git svn clone --prefix=origin/ --stdlayout "$svn" src
 | 
					            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
 | 
					    elif [[ $svn ]] && hash svn 2>/dev/null; then
 | 
				
			||||||
@@ -126,16 +125,16 @@ fetchSource() (
 | 
				
			|||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Fetching: $name, using svn..."
 | 
					            echo "Fetching: $name, using svn..."
 | 
				
			||||||
            svn checkout "$svn/trunk" src
 | 
					            svn checkout "$svn/trunk" src
 | 
				
			||||||
            printf 'r%s' "$(svn info | awk '/^Revision:/{ print $2 }')" > "$name-version"
 | 
					            touch .unpacked
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif [[ $pkg ]]; then
 | 
					    elif [[ $pkg ]]; then
 | 
				
			||||||
        files=( !("${pkg##*/}") )
 | 
					        [[ -e src ]] || {
 | 
				
			||||||
        [[ -e $files ]] || {
 | 
					 | 
				
			||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Fetching: $name, using package..."
 | 
					            echo "Fetching: $name, using package..."
 | 
				
			||||||
            fetch "$pkg"
 | 
					            fetch "$pkg"
 | 
				
			||||||
            ( mkdir src && cd src && unpack "${pkg##*/}" "$pkg_sha256" )
 | 
					            ( mkdir src && cd src && unpack "../${pkg##*/}" "$pkg_sha256" )
 | 
				
			||||||
 | 
					            touch .unpacked
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    else
 | 
					    else
 | 
				
			||||||
@@ -152,7 +151,7 @@ fetchSource() (
 | 
				
			|||||||
        for patch in "${patches[@]}"; do
 | 
					        for patch in "${patches[@]}"; do
 | 
				
			||||||
            echo
 | 
					            echo
 | 
				
			||||||
            echo "Patching: $name, for $patch..."
 | 
					            echo "Patching: $name, for $patch..."
 | 
				
			||||||
            patch -p0 < "../../$name-$patch.patch"
 | 
					            patch -p0 < "../$patch.patch"
 | 
				
			||||||
        done
 | 
					        done
 | 
				
			||||||
        popd
 | 
					        popd
 | 
				
			||||||
        touch .patched
 | 
					        touch .patched
 | 
				
			||||||
@@ -166,7 +165,7 @@ depend() {
 | 
				
			|||||||
    [[ -e "lib/include/$name" ]] && return
 | 
					    [[ -e "lib/include/$name" ]] && return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pushd "lib/$name"
 | 
					    pushd "lib/$name"
 | 
				
			||||||
    [[ -e "src" ]] || fetchSource
 | 
					    fetchSource
 | 
				
			||||||
    pushd "src"
 | 
					    pushd "src"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    echo
 | 
					    echo
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								MasterPassword/C/clean
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										7
									
								
								MasterPassword/C/clean
									
									
									
									
									
										Executable file
									
								
							@@ -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
 | 
				
			||||||
@@ -88,7 +88,7 @@ int main(int argc, char *const argv[]) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Start BCrypt
 | 
					    // Start BCrypt
 | 
				
			||||||
    int bcrypt_cost = 9;
 | 
					    int bcrypt_cost = 9;
 | 
				
			||||||
    iterations = 500;
 | 
					    iterations = 1000;
 | 
				
			||||||
    mpw_getTime( &startTime );
 | 
					    mpw_getTime( &startTime );
 | 
				
			||||||
    for (int i = 0; i < iterations; ++i) {
 | 
					    for (int i = 0; i < iterations; ++i) {
 | 
				
			||||||
        crypt( masterPassword, crypt_gensalt( "$2b$", bcrypt_cost, fullName, strlen( fullName ) ) );
 | 
					        crypt( masterPassword, crypt_gensalt( "$2b$", bcrypt_cost, fullName, strlen( fullName ) ) );
 | 
				
			||||||
@@ -100,8 +100,8 @@ int main(int argc, char *const argv[]) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    // Summarize.
 | 
					    // Summarize.
 | 
				
			||||||
    fprintf( stdout, "\n== SUMMARY ==\nOn this machine,\n" );
 | 
					    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 sha256 (reference: 320000 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 bcrypt (cost 9) (reference: 22 on an MBP Late 2013).\n", bcrypt9Speed / mpwSpeed );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user