Skip to content

Instantly share code, notes, and snippets.

@pescobar
Created October 5, 2015 07:14
Show Gist options
  • Star 58 You must be signed in to star a gist
  • Fork 24 You must be signed in to fork a gist
  • 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 \{\} \;
@sergey-suloev
Copy link

user@ubuntu:~$ sudo apt-get build-dep git -y
[sudo] password for user:
Reading package lists... Done
E: You must put some 'source' URIs in your sources.list

@xu48169172
Copy link

delete # berfore deb-src in /etc/apt/source.list, then run apt-get update

@chenhu66
Copy link

chenhu66 commented Feb 5, 2018

I came across a signature issue the first time i tried the build. After googling a while, i found a workaround and would like to share it with you:

dpkg-buildpackage -rfakeroot -b -uc -us

@niko-dunixi
Copy link

This looks like an old revision of my script! 😄
I've updated it recently, which means you can look here for the most recent fixes

https://github.com/paul-nelson-baker/git-openssl-shellscript

@siam1251
Copy link

It it throws error regarding signing, you may use the following command
sudo debuild -b -uc -us
It will create build for local use without signing.

@raja-ashok
Copy link

apt-get source git is not getting latest version of git, instead it gets 2.7.0 on ubuntu.16.04. But when I install git using sudo apt install git it installs 2.27.0 by adding the ppa:git-core/ppa repository.

I am not able to find, how to get latest version of git source code using apt-get source git.

@epalmans
Copy link

epalmans commented Dec 1, 2021

@paul-nelson-baker very helpful script! Much appreciated, thanks!

@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