Re: /usr/src and /usr/ports not git directories ?
Date: Wed, 22 Jan 2025 16:30:09 UTC
On Wed, Jan 22, 2025 at 1:23 AM Dave Cottlehuber <dch@skunkwerks.at> wrote: > On Tue, 21 Jan 2025, at 21:29, Warner Losh wrote: > >> Do you mean have the "install src" checkbox invoke git clone? > >> That seems like a better idea, at least to me. > > This wouldn't be ideal for small systems or any area with lousy > internet. > > > I think we should replace the populate /usr/src from a tarball with.... > > populate it > > with a tarball that represents a 1-deep checkout tree at the rev we > > built the release > > from. This lets users have the source, has minimal overhead and also > > lets users update > > or turn the shallow checkout into a deep one, etc. A shallow checkout > > is quite a bit > > less than a full tree, though still more than just the raw files. I've > > not done poking to > > see size comparisons. > > Can we ship a working gitup config? I've not used this yet, but this > would be a good option. > > Another option is to ship src.txz as we do today, but include a minimal > git config, such that `git fetch origin releng/14.2` would work. I like > this because we're not really reliant on a specific version of git > packfiles, and it's still just src as usual. > > Another option, IIRC Kyle mentioned this last year, is to use `git bundle` > https://git-scm.com/book/en/v2/Git-Tools-Bundling but I don't really know > enough about that. Perhaps that would be a reasonable option to fetch over > network, in the installer? > > For the former, this seems to be sufficient: > > ``` > # /usr/src/ > .git/ > .git/branches/ > .git/objects/ > .git/refs/ > .git/HEAD ref: refs/heads/releng/14.2 > .git/description FreeBSD 14.2-RELEASE > .git/config see below > ``` > > ``` > # .git/config > [core] > repositoryformatversion = 0 > filemode = true > bare = false > logallrefupdates = true > > [remote "origin"] > url = https://git.freebsd.org/src.git > pushurl = git@gitrepo.freebsd.org:src.git > fetch = +refs/heads/releng/14.2:refs/remotes/origin/releng/14.2 > > [branch "releng/14.2"] > remote = origin > merge = refs/heads/releng/14.2 > ``` > > this yields ~ 350MiB raw, as txz its still 325MiB. > > ``` > $ git fetch --depth 1 --no-tags --jobs 32 --set-upstream origin > releng/14.2 > remote: Enumerating objects: 103451, done. > remote: Counting objects: 100% (103451/103451), done. > remote: Compressing objects: 100% (89088/89088), done. > remote: Total 103451 (delta 21659), reused 41475 (delta 10515), > pack-reused 0 (from 0) > Receiving objects: 100% (103451/103451), 344.67 MiB | 9.13 MiB/s, done. > Resolving deltas: 100% (21659/21659), done. > From https://git.freebsd.org/src > * branch releng/14.2 -> FETCH_HEAD > > $ du -chs .git > 348M .git > 348M total > ``` > > this isn't quite right, git switch / git reset --hard or similar might be > needed, > but its pretty close. > I think what you want is % git clone https://github.com/freebsd/freebsd-src --depth=1 -b releng/14.2 --single-branch fred --bare % cd fred % mkdir .git % mv * .git % git config --local core.bare false This will clone 1 deep into the directory 'fred' and won't checkout a copy. If we make this a package, it's 325MB, as you say. That can then be extracted and then you can recover the tree with: % git checkout releng/14.2 which could be done with the pkg file when extracting to /usr/src. I've not measured ports. This would give the user the sources to the release in a package that's fairly minimal. And it would let them fetch other branches more cheaply than having no git repo at all if they are internet connected. It's a good balance between giving everything and taking up too much space. And it's only a little bit larger than the src pkg today. Warner