Please snap GIT

Hi,

I was testing ubuntu core 20 on a raspberry pi as a base system for docker/docker-compose, and one problem is, that ubuntu core does not come with git. Many docker images or docker-compose scenarios are not stand-alone to be run just as a docker container to be fetched, but are based on some repository containing sources, web pages, or the docker-compose.yaml itself, that are supposed to be mounted as a volume at runtime, not be part of the image.

Ubuntu core does not come with git, and there is no snap for git.

Of course, it is possible to install a docker image with git, use LXD to install a complete Ubuntu oder compile it, but that’s far too much overhead.

Would be nice, convenient, and useful for ubuntu core, to have git available as a snap.

2 Likes

I am actually surprised it isn’t a snap already. I believe doing a fully confined snap wouldn’t come with too many challenges. I might give that a try during the weekend

1 Like

Are you able to just build the docker image using docker’s built-in git directly? There is some support for this with i.e. docker build https://github.com/docker/rootfs.git#container:docker.

If that’s not enough however, since the docker snap is strict and has some git support, it includes git by just staging it with some special layouts:

and the layout setup for git to be able to run in confinement:

The main reason that I think folks have not built a strictly confined git snap is that many folks like to have git commit-hooks, etc. which call other programs, and also other editors that are not feasible to all be shipped inside a hypothetical git snap. So instead most folks treat git like an editor snap and request classic confinement instead. See https://snapcraft.io/git-cola and https://snapcraft.io/gitkraken and https://snapcraft.io/sublime-merge for graphical git snaps that are all classic.

I don’t recall at all the reasons why I did this, but I did build a strict git snap that I promptly abandoned, I don’t remember why I needed to build git from source (maybe this was before we had layouts in snapcraft.yaml), but if using stage-packages doesn’t just work for you, you might take some inspiration from https://github.com/anonymouse64/git-snap

2 Likes

To the best of my knowledge, that docker git implementation cannot checkin changes, and use only git over http(s), e.g. github, but not over ssh. I just tried, it does not even recognize the URL.

I would need to make my git repository available over https, and still would not have full functionality, e.g. checkin changes. And even if, it wouldn’t be able to cope with complex docker-compose scenarios.

In my eyes, there’s more uses for git on ubuntu core than just docker.

And the reason, why git has not been considered for a snap before, might be, that most Linux distributions supporting snapd already come with git, and git is quite stable, so there is no need to have the latest version as with other programs, which exist both as a regular ubuntu/debian/… package and a snap.

I am aware, that this request is rather ubuntu-core-specific.

However, if they want to bring ubuntu core forward, they need to improve usability, and a really good use case is to run docker or kubernetes/microk8s on it.

1 Like

There is actually a snap git-ubuntu , but it is not installable under ubuntu core since it requires classic confinement.

git-ubuntu is likely not what you expect it to be :slight_smile:

https://ubuntu.com/blog/developing-ubuntu-using-git

(spoiler: it is a tool to manage ubuntu package sources, automatically pointing to the right launchpad trees)

the more a regular git snap would be needed.

Note that git-ubuntu needs classic confinement to wrap git push. Users expect to use their existing ssh keys in ~/.ssh that are already registered in Launchpad, seamlessly switching between their system git command and git ubuntu. A confined snap wouldn’t have access to these without some additional setup and maintenance for git-ubuntu to keep a copy of their private keys somewhere it could access. A similar issue exists with cached Launchpad API credentials. Maybe personal-files would work, but there’s also /tmp - I often clone git repositories into there, and expect to be able to use my system git and git ubuntu interchangeably.

I found my own solution, and it is very simple. You can find additional information here: https://askubuntu.com/questions/1388050/whats-the-cleanest-way-to-get-git-onto-ubuntu-core