Skip to content

Instantly share code, notes, and snippets.

@kiarafbickers
Last active October 8, 2016 19:33
Show Gist options
  • Select an option

  • Save kiarafbickers/d18782a751bbedff2a2c34caded96b3d to your computer and use it in GitHub Desktop.

Select an option

Save kiarafbickers/d18782a751bbedff2a2c34caded96b3d to your computer and use it in GitHub Desktop.

Revisions

  1. Kiara Robles revised this gist Oct 8, 2016. 1 changed file with 2 additions and 13 deletions.
    15 changes: 2 additions & 13 deletions git-validated-install.sh
    Original file line number Diff line number Diff line change
    @@ -38,7 +38,8 @@ git-validated-install()
    return 1
    fi

    openssl_update
    # Install openssl
    brew install openssl

    # Compare checksums
    cksum=$(shasum -a 256 ./git-$latest_git_version.tar.gz | cut -d" " -f1)
    @@ -75,16 +76,4 @@ git-validated-install()

    make
    fi
    }

    openssl_update()
    {
    path=$(type -p java)
    if [ "$path" ]; then
    # Updating OpenSSL
    brew install openssl
    else
    # nstalling OpenSSL
    brew install openssl
    fi
    }
  2. Kiara Robles created this gist Oct 8, 2016.
    90 changes: 90 additions & 0 deletions git-validated-install.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,90 @@
    git-validated-install()
    {
    # Pull the latest version of Git from https://git-scm.com html
    if [ -z "$latest_git_version" ]; then
    if [ "`uname`" == "Darwin" ]; then
    sed_regexp="-E";
    else
    sed_regexp="-r";
    fi
    latest_git_version=$(curl https://git-scm.com/ 2>&1 | grep '<span class="version">' -A 1 | tail -n 1 | sed $sed_regexp 's/ *//')
    fi

    # Get the version of Git locally
    local_git_version=$(git --version)
    local_git_version=$($local_git_version |cut -d " " -f3)

    echo "Latest Git Version: $latest_git_version"
    echo "Local Git Version: $local_git_version"

    if [[ "$local_git_version" == "$latest_git_version" ]]; then
    echo "Git is already up to date."
    else
    # Fetch tar
    curl -O https://kernel.org/pub/software/scm/git/git-2.10.1.tar.gz

    # Fetch checksums
    curl -O https://kernel.org/pub/software/scm/git/sha256sums.asc

    # Fetch GPG sig from keyserver network:
    gpg --keyserver keyserver.ubuntu.com --recv-keys 0x632D3A06589DA6B1

    # Fetch GPG sig from keyserver network:
    signature=$(gpg --verify sha256sums.asc | grep "Good signature")
    # *Caveat: this trusts the keyserver network and the provenance of the KeyID from the GPG signature

    if [ $signature -eq 0 ]; then
    echo "Signature failed!"
    return 1
    fi

    openssl_update

    # Compare checksums
    cksum=$(shasum -a 256 ./git-$latest_git_version.tar.gz | cut -d" " -f1)
    refsum=$(grep git-$latest_git_version.tar.gz ./sha256sums.asc | cut -d" " -f1)

    if [ "$refsum" != "$cksum" ]; then
    echo "Bad checksum"
    return 1
    fi

    # Uncompressing tar archive
    tar xzf "git-$latest_git_version.tar.gz"

    cd "git-$latest_git_version"

    # Downloading gettext
    brew install gettext

    # Add symlinks
    export LDFLAGS=-L/usr/local/opt/gettext/lib
    export CPPFLAGS=-I/usr/local/opt/gettext/include

    # Define two environment variables
    export CPATH="/usr/local/opt/openssl/include:/usr/local/opt/gettext/include"
    export LIBRARY_PATH="/usr/local/opt/openssl/lib:/usr/local/opt/gettext/lib"

    brew link gettext --force

    # Clean up files
    cd ..
    rm -r -f "git-$latest_git_version"
    rm "git-$latest_git_version.tar.gz"
    rm sha256sums.asc

    make
    fi
    }

    openssl_update()
    {
    path=$(type -p java)
    if [ "$path" ]; then
    # Updating OpenSSL
    brew install openssl
    else
    # nstalling OpenSSL
    brew install openssl
    fi
    }