Re: Getting /usr/src to match specific git hash?

From: Warner Losh <imp_at_bsdimp.com>
Date: Sun, 24 Jan 2021 15:22:18 -0700
On Sun, Jan 24, 2021, 12:14 PM Steve Kargl <sgk_at_troutmask.apl.washington.edu>
wrote:

> On Sun, Jan 24, 2021 at 09:00:45AM -0700, Warner Losh wrote:
> > On Sun, Jan 24, 2021, 6:05 AM Jeffrey Bouquet <jbtakk_at_iherebuywisely.com
> >
> > wrote:
> >
> > >
> > >
> > > On Sat, 23 Jan 2021 20:14:03 -0800, Steve Kargl <
> > > sgk_at_troutmask.apl.washington.edu> wrote:
> > >
> > > > On Sun, Jan 24, 2021 at 01:08:05PM +0900, Yasuhiro Kimura wrote:
> > > > > From: Steve Kargl <sgk_at_troutmask.apl.washington.edu>
> > > > > Subject: Getting /usr/src to match specific git hash?
> > > > > Date: Sat, 23 Jan 2021 19:58:52 -0800
> > > > >
> > > > > > Suppose one has an empty /usr/src.
> > > > > >
> > > > > > Suppose further that one had to re-install a 32-bit
> > > > > > i386-*-freebsd with the 24 Dec 2020 image available
> > > > > > from freebsd.org.
> > > > > >
> > > > > > uname -a for the booted kernel shows
> > > > > >
> > > > > > % uname -a
> > > > > > FreeBSD mobile 13.0-CURRENT FreeBSD 13.0-CURRENT #0 \
> > > > > > 3cc0c0d66a0-c255241(main)-dirty: Thu Dec 24 05:43:23 UTC 2020 \
> > > > > > root_at_releng1.nyi.freebsd.org:
> /usr/obj/usr/src/i386.i386/sys/GENERIC
> > > i386
> > > > > >
> > > > > > How does one use git to pull the exact sources that match
> > > > > > this specifc kernel?
> > > > >
> > > > > cd /usr
> > > > > git clone https://git.freebsd.org/src.git
> > > > > cd src
> > > > > git checkout 3cc0c0d66a0
> > > > >
> > > >
> > > > Thank you.
> > > >
> > >
> > > Can this be put in /usr/src/UPDATING with an explanation of precisely
> how
> > > each
> > > of the git commands populates or repopulated the directories in /usr???
> > >
> >
> > It is in the mini primer I wrote, along with how to bisect and other
> useful
> > things. This will migrate into the handbook once the doc tree converts to
> > asciidoc (happening this weekend).
> >
> > https://github.com/bsdimp/freebsd-git-docs/blob/main/mini-primer.md
> >
>
> Any advice on how to jump, say, 4 days ahead of the current
> date of the src/ tree?  That is, I have src/ that should
> correspond to 24 Dec 2020.  How do I jump to 28 Dec 2020?
>

You could use git bisect, but as you say, the laundry list is extensive.

Git doesn't offer checkout by date, alas. So here's some tools to help you
out.

First, let's get a count of how many commits behind main you are at the
moment. Use 'git log --oneline --first-parent HEAD..main | wc' to get a
count of the number of commits between what you have checked out and the
tip of current. My count is 994, but I just updated, so your count will
differ and that's OK.The --first-parent in the git log above is critical,
since otherwise a number of commits from vendor merges in the vendor
branches will appear in git log's output, throwing the count off).

Now, this is 1 month worth of -current. 4 days in the month is about 13%.
However, let's keep things simple and step forward 100 commits at a time
(which is 10% of 1000). The precise numbers don't matter, but it works out
well in this case.

So, your commit is:
% git log -1 3cc0c0d66a0
Author: Li-Wen Hsu <lwhsu_at_FreeBSD.org>
Date:   Sun Dec 20 02:59:44 2020 +0000

    Mark the repository as being converted to Git.

which is the last subversion commit. It's also head~994, you can do a 'git
log -1 main~900' to verify that. So, let's move forward 94 commits. This
would be:

% git log main~900
commit 8d405efd73d3991fe1647f91a2b7c9989dd5f18f
Author: Ulrich Sp<C3><B6>rlein <uqs_at_FreeBSD.org>
Date:   Wed Dec 23 22:29:34 2020 +0100

    Fix newvers.sh to no longer print an outdated SVN rev

which is 3 days newer and may be a good place to start:

% git checkout main~900

and that will move you forward 94 commits. Do it again with main~800, etc
to find a spot that's good for you. Not as convenient as giving dates, but
once you have a count of the number of commits between where you are and
head, you can use that number to decide how far forward to go.

You can adjust this as needed. If you don't do a git pull during this
process (and you likely shouldn't) these numbers will be stable, and a lot
easier to work with than hashes. I've found I like to move N commits rather
than N days.

Hope this is helpful. Sadly I found no way to say HEAD+50 commits directly
in git, but maybe one of the more knowledgeable folks on this list can give
a better hint there.

Warner


My past week experience with top-of-tree suggests doing
> a bisection would be frought with peril.  My laptop runs
> well with 24 Dec 2020 kernel/world.  Getting to top-of-tree,
> one has to deal with
> (1) infinite recursion in wpa_supplicant,
> (2) possible locking issue in UFS (30 second system freezes),
> (3) memory alignment messages from the kernel,
> (4) processes being killed with out-of-swapspace messages
>     even though I have 4 GB of untouched swap space.  Might
>     be associated with (3).
> (5) graphic console mess
> (6) pilot-error of using -march=core2, which matches the
>     processor in the laptop, to build kernel/world but
>     manifests a llvm bug
>
> I would like to creep up on the issues.
>
> --
> Steve
>
Received on Sun Jan 24 2021 - 21:22:32 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:26 UTC