[+vadim]<br><br><div class="gmail_quote">On Fri, Aug 27, 2010 at 1:49 PM, David Hendricks <span dir="ltr"><<a href="mailto:dhendrix@google.com">dhendrix@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="gmail_quote">Looks pretty good so far!</div><div class="gmail_quote"><br></div><div class="gmail_quote">For the benefit of everyone who missed the excitement on IRC, there is one major caveat to this patch: Those using a git repository probably have stale SVN metadata, which means the upstream Flashrom SVN information in the version string will be incorrect.</div>


<div class="gmail_quote"><br></div><div class="gmail_quote">For example, if I clone the Chromium OS flashrom branch (git clone <a href="http://src.chromium.org/git/flashrom.git" target="_blank">http://src.chromium.org/git/flashrom.git</a>) and run "git svn info", I'll get a message saying "Unable to determine upstream SVN information from working tree history." After adding the upstream SVN repo as a remote repository and doing "git svn fetch", I'll get something like this:</div>


<div class="gmail_quote"><div class="gmail_quote"><font face="'courier new', monospace">dhendrix@thegates:flashrom$ git svn info</font></div><div class="gmail_quote"><font face="'courier new', monospace">Path: .</font></div>


<div class="gmail_quote"><font face="'courier new', monospace">URL: svn://<a href="http://coreboot.org/flashrom/trunk" target="_blank">coreboot.org/flashrom/trunk</a></font></div><div class="gmail_quote">
<font face="'courier new', monospace">Repository Root: svn://<a href="http://coreboot.org/flashrom" target="_blank">coreboot.org/flashrom</a></font></div><div class="gmail_quote"><font face="'courier new', monospace">Repository UUID: 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1</font></div>


<div class="gmail_quote"><font face="'courier new', monospace"><font color="#FF0000">Revision: 1011</font></font></div><div class="gmail_quote"><font face="'courier new', monospace">Node Kind: directory</font></div>


<div class="gmail_quote"><font face="'courier new', monospace">Schedule: normal</font></div><div class="gmail_quote"><font face="'courier new', monospace">Last Changed Author: uwe</font></div>
<div class="gmail_quote"><font face="'courier new', monospace">Last Changed Rev: 1011</font></div><div class="gmail_quote"><font face="'courier new', monospace">Last Changed Date: 2010-05-24 10:39:14 -0700 (Mon, 24 May 2010)</font></div>


</div><div class="gmail_quote"><br></div><div class="gmail_quote">In this example, r1011 is incorrect.</div><div class="gmail_quote"><br></div><div class="gmail_quote">Carl-Daniel root caused the issue and has a script that seems to workaround it. Here is his blogpost which summarizes the problem and workaround very well: <a href="http://blogs.coreboot.org/blog/2010/08/27/git-svn-info-unable-to-determine-upstream-svn-information-from-working-tree-history/" target="_blank">http://blogs.coreboot.org/blog/2010/08/27/git-svn-info-unable-to-determine-upstream-svn-information-from-working-tree-history/</a></div>


<div class="gmail_quote"><br></div><div class="gmail_quote">Using Carl-Daniel's script in the same repo, I get:</div><div class="gmail_quote"><div class="gmail_quote">
<font face="'courier new', monospace">dhendrix@thegates:flashrom$ sh /tmp/cdh.sh</font></div><div class="gmail_quote"><font face="'courier new', monospace">URL: svn://<a href="http://coreboot.org/flashrom/trunk" target="_blank">coreboot.org/flashrom/trunk</a></font></div>


<div class="gmail_quote"><font face="'courier new', monospace">Repository UUID: 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1</font></div><div class="gmail_quote"><font face="'courier new', monospace">Revision: 1145</font></div>


<div class="gmail_quote"><font face="'courier new', monospace">Last Changed Author: hailfinger</font></div><div class="gmail_quote"><br></div><div class="gmail_quote">which is (currently) correct.</div>
<div class="gmail_quote"><br></div><div class="gmail_quote">Now to figure out how best to integrate this... Can we put the script in util/ and have the Makefile invoke it when it detects we're using a git repo?</div>

<div class="gmail_quote">
<br></div></div><div><div></div><div class="h5"><div class="gmail_quote">On Sat, Aug 21, 2010 at 11:21 AM, Carl-Daniel Hailfinger <span dir="ltr"><<a href="mailto:c-d.hailfinger.devel.2006@gmx.net" target="_blank">c-d.hailfinger.devel.2006@gmx.net</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">flashrom relies on svn to export tarballs and only prints the last svn<br>
revision in the version message even if flashrom is in a git tree.<br>
<br>
Print extended version information (version, svn revision, git hash,<br>
repository URL).<br>
Allow exporting from git trees.<br>
<br>
This should make git users first-class citizens like svn users.<br>
<br>
Side note: If anyone has an idea how to make the export target more<br>
beautiful (80 column limit etc.), please tell me.<br>
<br>
Signed-off-by: Carl-Daniel Hailfinger <<a href="mailto:c-d.hailfinger.devel.2006@gmx.net" target="_blank">c-d.hailfinger.devel.2006@gmx.net</a>><br>
<br>
Index: flashrom-gitfriendly/Makefile<br>
===================================================================<br>
--- flashrom-gitfriendly/Makefile       (Revision 1145)<br>
+++ flashrom-gitfriendly/Makefile       (Arbeitskopie)<br>
@@ -97,13 +97,15 @@<br>
 # of the checked out flashrom files.<br>
 # Note to packagers: Any tree exported with "make export" or "make tarball"<br>
 # will not require subversion. The downloadable snapshots are already exported.<br>
-SVNVERSION := $(shell LC_ALL=C svnversion -cn . 2>/dev/null | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/" | grep "[0-9]" || LC_ALL=C svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || LC_ALL=C git svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || echo unknown)<br>



+SCMVERSION := $(shell LC_ALL=C svnversion -cn . 2>/dev/null | sed -e "s/.*://" -e "s/\([0-9]*\).*/\1/" | grep "[0-9]" || LC_ALL=C svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || LC_ALL=C git svn info . 2>/dev/null | awk '/^Revision:/ {print $$2 }' | grep "[0-9]" || echo unknown)<br>



+SCMEXTVERSION := $(shell LC_ALL=C git rev-parse HEAD 2>/dev/null | sed 's/^./-\0/')<br>
+SCMURL := $(shell LC_ALL=C svn info 2>/dev/null | grep URL: | sed 's/.*URL:[[:blank:]]*//' | grep ^. || LC_ALL=C git remote show origin 2>/dev/null |grep URL: | sed 's/.*URL:[[:blank:]]*//' | grep ^. || echo unknown )<br>



<br>
 RELEASE := 0.9.2<br>
-VERSION := $(RELEASE)-r$(SVNVERSION)<br>
+VERSION := $(RELEASE)-r$(SCMVERSION)$(SCMEXTVERSION)<br>
 RELEASENAME ?= $(VERSION)<br>
<br>
-SVNDEF := -D'FLASHROM_VERSION="$(VERSION)"'<br>
+SCMDEF := -D'FLASHROM_VERSION="$(VERSION)"' -D'FLASHROM_SCMURL="$(SCMURL)"'<br>
<br>
 # Always enable internal/onboard support for now.<br>
 CONFIG_INTERNAL ?= yes<br>
@@ -310,7 +312,7 @@<br>
 TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --group=root")<br>
<br>
 %.o: %.c .features<br>
-       $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SVNDEF) -o $@ -c $<<br>
+       $(CC) -MMD $(CFLAGS) $(CPPFLAGS) $(FEATURE_CFLAGS) $(SCMDEF) -o $@ -c $<<br>
<br>
 # Make sure to add all names of generated binaries here.<br>
 # This includes all frontends and libflashrom.<br>
@@ -420,9 +422,12 @@<br>
<br>
 export:<br>
        @rm -rf $(EXPORTDIR)/flashrom-$(RELEASENAME)<br>
-       @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME)<br>
-       @sed "s/^SVNVERSION.*/SVNVERSION := $(SVNVERSION)/" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile<br>
-       @LC_ALL=C svn log >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog<br>
+       @svn export -r BASE . $(EXPORTDIR)/flashrom-$(RELEASENAME) 2>/dev/null || git checkout-index -a -f --prefix=$(EXPORTDIR)/flashrom-$(RELEASENAME)/<br>
+       @# If SCMVERSION or SCMEXTVERSION contain a slash or SCMURL contains a hash, this will explode<br>
+       @sed "s/^SCMVERSION.*/SCMVERSION := $(SCMVERSION)/;s/^SCMEXTVERSION.*/SCMEXTVERSION := $(SCMEXTVERSION)/;s#^SCMURL.*#SCMURL := $(SCMURL)#" Makefile >$(EXPORTDIR)/flashrom-$(RELEASENAME)/Makefile<br>
+       @# ChangeLog should be in English, but we want UTF-8 for names.<br>
+       @( LC_ALL=en_US.UTF-8 svn log 2>/dev/null || LC_ALL=en_US.UTF-8 git log 2>/dev/null || echo "Unable to extract log from SCM" ) >$(EXPORTDIR)/flashrom-$(RELEASENAME)/ChangeLog<br>
+       @rm -f $(EXPORTDIR)/flashrom-$(RELEASENAME)/.gitignore $(EXPORTDIR)/flashrom-$(RELEASENAME)/.gitattributes $(EXPORTDIR)/flashrom-$(RELEASENAME)/.gitmodules<br>
        @echo Exported $(EXPORTDIR)/flashrom-$(RELEASENAME)/<br>
<br>
 tarball: export<br>
Index: flashrom-gitfriendly/flashrom.c<br>
===================================================================<br>
--- flashrom-gitfriendly/flashrom.c     (Revision 1145)<br>
+++ flashrom-gitfriendly/flashrom.c     (Arbeitskopie)<br>
@@ -1355,6 +1355,7 @@<br>
 void print_version(void)<br>
 {<br>
        msg_ginfo("flashrom v%s", flashrom_version);<br>
+       msg_ginfo(" from " FLASHROM_SCMURL ",");<br>
        print_sysinfo();<br>
 }<br>
<br>
@@ -1362,7 +1363,6 @@<br>
 {<br>
        msg_ginfo("flashrom is free software, get the source code at "<br>
                    "<a href="http://www.flashrom.org" target="_blank">http://www.flashrom.org</a>\n");<br>
-       msg_ginfo("\n");<br>
 }<br>
<br>
 int selfcheck(void)<br>
<font color="#888888"><br>
<br>
--<br>
<a href="http://www.hailfinger.org/" target="_blank">http://www.hailfinger.org/</a><br>
<br>
<br>
_______________________________________________<br>
flashrom mailing list<br>
<a href="mailto:flashrom@flashrom.org" target="_blank">flashrom@flashrom.org</a><br>
<a href="http://www.flashrom.org/mailman/listinfo/flashrom" target="_blank">http://www.flashrom.org/mailman/listinfo/flashrom</a><br>
</font></blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>David Hendricks (dhendrix)<br>Systems Software Engineer, Google Inc.<br>