Skip to content

Instantly share code, notes, and snippets.

@pescobar
Created October 5, 2015 07:14
Show Gist options
  • Save pescobar/6ae5634f92d75d23c36a to your computer and use it in GitHub Desktop.
Save pescobar/6ae5634f92d75d23c36a to your computer and use it in GitHub Desktop.
compile git with openssl instead of gnutls
#!/usr/bin/env bash
# Clear out all previous attempts
rm -rf "/tmp/source-git/"
# Get the dependencies for git, then get openssl
sudo apt-get install build-essential fakeroot dpkg-dev -y
sudo apt-get build-dep git -y
sudo apt-get install libcurl4-openssl-dev -y
mkdir -p "/tmp/source-git/"
cd "/tmp/source-git/"
apt-get source git
# We need to actually go into the git source directory
# find -type f -name "*.dsc" -exec dpkg-source -x \{\} \;
cd $(find -mindepth 1 -maxdepth 1 -type d -name "git-*")
pwd
# This is where we actually change the library from one type to the other.
sed -i -- 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/' ./debian/control
# Compile time, itself, is long. Skips the tests. Do so at your own peril.
sed -i -- '/TEST\s*=\s*test/d' ./debian/rules
# Build it.
dpkg-buildpackage -rfakeroot -b
# Install
find .. -type f -name "git_*ubuntu*.deb" -exec sudo dpkg -i \{\} \;
@nepvec
Copy link

nepvec commented Mar 16, 2022

Works flawless. Used this to circumvent usage of gnutls which didn't work on servers that disabled TLS v1.0 and v1.1.
Now it uses SSLv3 instead, thanks to OpenSSL.

@nojiratz
Copy link

nojiratz commented May 18, 2022

Everything worked, except the very last command. On the very last command I get

find .. -type f -name "git_*ubuntu*.deb" -exec sudo dpkg -i \{\} \;
[sudo] password for noji:
Selecting previously unselected package git.
(Reading database ... 174287 files and directories currently installed.)
Preparing to unpack .../git_2.17.0-1ubuntu1_amd64.deb ...
Unpacking git (1:2.17.0-1ubuntu1) ...
dpkg: dependency problems prevent configuration of git:
 git depends on git-man (>> 1:2.17.0); however:
  Package git-man is not installed.
 git depends on git-man (<< 1:2.17.0-.); however:
  Package git-man is not installed.

dpkg: error processing package git (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 git

Anything I can do, to get around this error? Thanks.
I tried doing and got

sudo apt install git-man
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 git : Depends: git-man (< 1:2.17.0-.) but 1:2.17.1-1ubuntu0.11 is to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I even ran and got

apt --fix-broken install
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Thoughts?

@ddelange
Copy link

forked gist with fixes:

/bin/bash -c "$(curl -fsSL https://gist.github.com/ddelange/e4766e56d422881e061f8758a0ba8061/raw/build-git.sh)"

@niko-dunixi
Copy link

@nojiratz / @ddelange If you go to https://github.com/niko-dunixi/git-openssl-shellscript you will find the original script that this gist was from. I haven't had a chance to look at the problems you're facing (since I don't have ownership of this individual gist), but more people will benefit from raised Issues and Pull Requests at the originating repo.

@logust79
Copy link

logust79 commented Oct 5, 2023

@nojiratz I had exactly the same issue. In case if it is still relevant, I solved the issue by running apt install git -y && git remove git -y beforehand.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment