-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create /proc/sys/kernel/spl/gitrev with git hash #7965
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, few nits
scripts/make_gitrev.sh
Outdated
# | ||
# Check if there are uncommitted changes | ||
# | ||
git diff-index --quiet HEAD -- || exit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we perhaps still generate a hash with "(modified)" appended to it, just so that people aren't too confused why it's suddenly "unknown"?
Also nit: --
looks unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For simplicity, I'm going to drop this (adding (modified)
) if that's OK with you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's up to you. That should be very easy to implement though.
How about adding |
gitrev: | ||
-${top_srcdir}/scripts/make_gitrev.sh | ||
|
||
BUILT_SOURCES = gitrev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should add a call to -${top_srcdir}/scripts/make_gitrev.sh
in dist-hook:
. This target is run at the end of make dist
and it let's you add additional files prior to the tar
. Right now it's used to ensure an updated META file is included in the the final tarball. This would ensure that tarball also includes the git hash if available, and a valid version of sys/zfs_gitrev.h
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a dependency on gitrev
, which I think will do the same thing without duplicating code. Let me know if you see a problem with this (I'm not a makefile expert).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works, that sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it does the same thing as what you suggested. However, zfs_gitrev.h doesn't end up in the tarball. I suspect that we would need to tell it to generate the file in an alternate location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out we copy the .c/.h files before doing dist-hook
. So I had to also add a line to dist-hook to copy zfs_gitrev.h into the distdir. Now I have:
$ make dist
...
make[2]: Entering directory '/export/home/delphix/zfs'
./scripts/make_gitrev.sh
cp ./include/zfs_gitrev.h zfs-0.8.0/include; \
sed -i 's/Release:[[:print:]]*/Release: rc1/' \
zfs-0.8.0/META
...
$ tar -tzf zfs-0.8.0.tar.gz |grep git
zfs-0.8.0/scripts/make_gitrev.sh
zfs-0.8.0/include/zfs_gitrev.h
Great idea. What would you think about replacing |
@behlendorf I'm getting the following errors, do you know how I should address them? I think I'm not using POSIX sh's echo, I'm using /bin/echo.
Incidentally, I don't get these errors when running |
@ahrens Yes, that's exactly what I was thinking. The existing "software version" thing doesn't seem very useful at all. |
Regarding the shellcheck errors, I noticed that several other scripts use |
I also see that the kernel.org build is not working, it seems that it isn't generating the new header or it's being put in the wrong place.
|
The existing mechanisms for determining what code is running in the kernel do not always correctly report the git hash. The versions reported there do not reflect changes made since `configure` was run (i.e. incremental builds do not update the version) and they are misleading if git tags are not set up properly. This applies to `modinfo zfs`, `dmesg`, and `/sys/module/zfs/version`. There are complicated requirements on how the existing version is generated. Therefore we are leaving that alone, and adding a new mechanism to record and retrieve the git hash: `cat /proc/sys/kernel/spl/gitrev` The gitrev is re-generated at compile time, when running `make` (including for incremental builds). The value is the output of `git describe` (or "unknown" if not in a git repo or there are uncommitted changes). We're also removing /proc/sys/kernel/spl/version, which was never very useful. Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Codecov Report
@@ Coverage Diff @@
## master #7965 +/- ##
==========================================
- Coverage 78.65% 78.48% -0.18%
==========================================
Files 377 377
Lines 114213 114213
==========================================
- Hits 89837 89642 -195
- Misses 24376 24571 +195
Continue to review full report at Codecov.
|
I believe I've addressed all the review feedback and this is now ready for final review and integration. Note that I moved the location of the new (generated) header to |
The existing mechanisms for determining what code is running in the kernel do not always correctly report the git hash. The versions reported there do not reflect changes made since `configure` was run (i.e. incremental builds do not update the version) and they are misleading if git tags are not set up properly. This applies to `modinfo zfs`, `dmesg`, and `/sys/module/zfs/version`. There are complicated requirements on how the existing version is generated. Therefore we are leaving that alone, and adding a new mechanism to record and retrieve the git hash: `cat /proc/sys/kernel/spl/gitrev` The gitrev is re-generated at compile time, when running `make` (including for incremental builds). The value is the output of `git describe` (or "unknown" if not in a git repo or there are uncommitted changes). We're also removing /proc/sys/kernel/spl/version, which was never very useful. Reviewed by: Pavel Zakharov <pavel.zakharov@delphix.com> Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed by: Tim Chase <tim@chase2k.com> Signed-off-by: Matthew Ahrens <mahrens@delphix.com> Closes openzfs#7931 Closes openzfs#7965
Motivation and Context
The existing mechanisms for determining what code is running in the kernel do not always correctly report the git hash. The versions reported there do not reflect changes made since
configure
was run (i.e. incremental builds do not update the version) and they are misleading if git tags are not set up properly. This applies tomodinfo zfs
,dmesg
, and/sys/module/zfs/version
.This is related to #7931. It doesn't directly fix it (existing version info can still be stale), but it provides an alternative which decreases the need for a fix.
Description
There are complicated requirements on how the existing version is generated. Therefore we are leaving that alone, and adding a new mechanism to record and retrieve the git hash:
cat /proc/sys/kernel/spl/gitrev
The gitrev is re-generated at compile time, when running
make
(including for incremental builds). The value is the output ofgit describe
(or "unknown" if not in a git repo or there are uncommitted changes).We're also removing /proc/sys/kernel/spl/version, which was never very useful.
How Has This Been Tested?
Check the contents of /proc/sys/kernel/spl/gitrev after full and incremental builds, and when there are uncommitted changes.
Types of changes
Checklist:
Signed-off-by
.