threads / patch / 8339

patchInfrastructure for tig rpm builds.

Subject: [PATCH (tig)] Infrastructure for tig rpm builds.

## tl;dr

12 messages between May 28, 2007 and Jun 3, 2007. Diffs are folded; open one to read it.

replies: 11people: 2as markdown or json

Jakub Narebski· May 28, 2007, 08:54 UTC · lore

Adds RPM_VERSION to Makefile and new make targets: tig.spec, dist, and rpm. A simple 'make rpm' will build the rpm. Also adds tig.spec.in which is used to generate tig.spec.

Accidentally VERSION (and adding -DVERSION=$(VERSION) to CFLAGS) is now defined always, even if we do not compile from the "live" tig repository.

Minimally tested (meaning "make rpm" from tig repository works).
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
'tig.spec.in' is based on 'git.spec.in' from git repository.

This is the initial, minimal version. For example it does not add TIG-VERSION-GEN file and the rest of versioning infrastructure that is used in git Makefile.

Commands used to get version string (in RPM_VERSION) suitable as a version field in the rpm can, most probably, be improved. Perhaps (with the new git-describe output) we should put closest version tag as version of tig in rpm, and distance from the tag (perhaps plus 1) as release number (in the rpm sense).

TODO: Change '--without docs' to '--with rebuild-docs' and use
pre-generated docs when creating rpm, instead of generating them (and
requiring asciidoc, xmlto and docbook2pdf to build rpm if we want tig
documentation).

P.S. I have build tig-0.6.4.g9eded37-1.i386.rpm using "make rpm" from tig repository, and installed it without problems, but when trying to build it again _without network_ it failed on building manual.pdf. Error log attached.

  asciidoc-7.1.2-2.fc3.rf
  docbook-dtds-1.0-26
  docbook-style-dsssl-1.79-1
  docbook-style-xsl-1.68.1-1
  docbook-utils-0.6.14-4
  docbook-utils-pdf-0.6.14-4
  jadetex-3.12-13
  openjade-1.3.2-16

I think we can skip generation of manual.pdf, and generate it only on request (e.g. "make doc-pdf"), or using doc-man and doc-html in place of doc in the spec file... but this is better left for the next commit.

By the way, why do you use xmlto and docbook2pdf, instead of a2x from asciidoc package?

 .gitignore  |    2 ++
 Makefile    |   34 ++++++++++++++++++++++++++++++++--
 tig.spec.in |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 2 deletions(-)
 create mode 100644 tig.spec.in
Show changes to 3 files +90 −2

.gitignore, Makefile, tig.spec.in

diff --git a/.gitignore b/.gitignore
index 8f6aa93..f7ab840 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ manual.html-chunked
 manual.pdf
 manual.toc
 tig
+tig.spec
+tig-*.tar.gz
diff --git a/Makefile b/Makefile
index 06a5d6a..45c833b 100644
--- a/Makefile
+++ b/Makefile
@@ -18,8 +18,16 @@ DOCS	= $(DOCS_MAN) $(DOCS_HTML) \
 ifneq (,$(wildcard .git))
 VERSION = $(shell git-describe)
 WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
-CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
+else
+GEN_VER="tig-0.6.TIG"
+VERSION = $(shell test -f version && cat version || echo "$(GEN_VER)")
 endif
+CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
+RPM_VERSION  = $(subst tig-,,$(VERSION))
+RPM_VERSION := $(subst -,.,$(RPM_VERSION))
+
+TARNAME=tig-$(RPM_VERSION)
+
 
 all: $(PROGS)
 all-debug: $(PROGS)
@@ -57,6 +65,9 @@ install-doc: install-doc-man install-doc-html
 clean:
 	rm -rf manual.html-chunked
 	rm -f $(PROGS) $(DOCS) core *.xml
+	rm -f *.spec
+	rm -rf $(TARNAME)
+	rm -f $(TARNAME).tar.gz
 
 spell-check:
 	aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
@@ -64,7 +75,7 @@ spell-check:
 strip: all
 	strip $(PROGS)
 
-.PHONY: all all-debug doc doc-man doc-html install install-doc install-doc-man install-doc-html clean spell-check
+.PHONY: all all-debug doc doc-man doc-html install install-doc install-doc-man install-doc-html clean spell-check dist rpm
 
 manual.html: manual.toc
 manual.toc: manual.txt
@@ -119,3 +130,22 @@ sync-docs:
 	make doc
 	cg commit -m "Sync docs"
 	cg switch master
+
+tig.spec: tig.spec.in
+	sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' < $< > $@+
+	mv $@+ $@
+
+dist: tig.spec
+	git-archive --format=tar \
+		--prefix=$(TARNAME)/ HEAD^{tree} > $(TARNAME).tar
+	@mkdir -p $(TARNAME)
+	@cp tig.spec $(TARNAME)
+	@echo $(VERSION) > $(TARNAME)/version
+	tar rf $(TARNAME).tar \
+	       $(TARNAME)/tig.spec \
+	       $(TARNAME)/version
+	@rm -rf $(TARNAME)
+	gzip -f -9 $(TARNAME).tar
+
+rpm: dist
+	rpmbuild -ta $(TARNAME).tar.gz
diff --git a/tig.spec.in b/tig.spec.in
new file mode 100644
index 0000000..2ce6cdb
--- /dev/null
+++ b/tig.spec.in
@@ -0,0 +1,56 @@
+# -*- mode: rpm-spec-mode; encoding: utf-8; -*-
+# Pass '--without docs' to rpmbuild if you don't want the documentation
+
+Summary: 	Tig: text-mode interface for git
+Name: 		tig
+Version: 	@@VERSION@@
+Release: 	1%{?dist}
+License: 	GPL
+Group: 		Development/Tools
+Vendor: 	Jonas Fonseca <fonseca@diku.dk>
+URL: 		http://jonas.nitro.dk/tig/
+Source: 	http://jonas.nitro.dk/tig/releases/%{name}-%{version}.tar.gz
+BuildRequires: 	ncurses-devel%{!?_without_docs:, xmlto, asciidoc > 6.0.3, /usr/bin/docbook2pdf}
+BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+Requires: 	git-core, ncurses
+
+%description
+Tig is a git repository browser that additionally can act as a pager
+for output from various git commands.
+
+When browsing repositories, it uses the underlying git commands to
+present the user with various views, such as summarized revision log
+and showing the commit with the log message, diffstat, and the diff.
+
+Using it as a pager, it will display input from stdin and colorize it.
+
+%prep
+%setup -q
+
+%build
+CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
+%{__make} %{_smp_mflags} \
+	prefix=%{_prefix} \
+	all %{!?_without_docs: doc}
+
+%install
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
+%{__make} %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT \
+	prefix=%{_prefix} bindir=%{_bindir} mandir=%{_mandir} \
+	install %{!?_without_docs: install-doc-man}
+
+%clean
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%{_bindir}/*
+%doc README COPYING INSTALL SITES BUGS TODO tigrc
+%{!?_without_docs: %{_mandir}/man1/*.1*}
+%{!?_without_docs: %{_mandir}/man5/*.5*}
+%{!?_without_docs: %doc *.html *.pdf}
+
+%changelog
+* Mon May 28 2007 Jakub Narebski <jnareb@gmail.com>
+- Initial tig spec file
-- 
1.5.2



docbook2pdf manual.xml
Using catalogs: /etc/sgml/xml-docbook-4.2-1.0-26.cat
Using stylesheet: /usr/share/sgml/docbook/utils-0.6.14/docbook-utils.dsl#print
Working on: /home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:2:118:E: could not resolve host "www.oasis-open.org" (try again later)
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:2:118:E: DTD did not contain element declaration for document type name
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:4:14:E: there is no attribute "lang"
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:4:18:E: element "article" undefined

[...]

jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:400:10:E: element "entry" undefined
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:401:172:E: element "emphasis" undefined
jade:/home/local/builddir/BUILD/tig-0.6.4.g9eded37/manual.xml:404:6:E: element "row" undefined
jade:I: maximum number of errors (200) reached; change with -E option
jade:/usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/../common/dbtable.dsl:224:13:E: 2nd argument for primitive "ancestor" of wrong type: "#<unknown object 152549536>" not a singleton node list
jade:/usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/../common/dbtable.dsl:224:13:E: 2nd argument for primitive "ancestor" of wrong type: "#<unknown object 152549536>" not a singleton node list
jade:/usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/../common/dbtable.dsl:224:13:E: 2nd argument for primitive "ancestor" of wrong type: "#<unknown object 152549536>" not a singleton node list

[...]

jade:/usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/../common/dbtable.dsl:224:13:E: 2nd argument for primitive "ancestor" of wrong type: "#<unknown object 152549536>" not a singleton node list
jade:/usr/share/sgml/docbook/dsssl-stylesheets-1.79/print/../common/dbtable.dsl:224:13:E: 2nd argument for primitive "ancestor" of wrong type: "#<unknown object 152549536>" not a singleton node list
make[1]: *** [manual.pdf] Błąd 8
rm manual.xml tigrc.5.xml tig.1.xml
make[1]: Leaving directory `/home/local/builddir/BUILD/tig-0.6.4.g9eded37'
Jonas Fonseca· May 29, 2007, 20:29 UTC · re: Jakub Narebski · lore

Re: [PATCH (tig)] Infrastructure for tig rpm builds.

Hej Jakub,
Jakub Narebski <jnareb@gmail.com> wrote Mon, May 28, 2007:
> Adds RPM_VERSION to Makefile and new make targets: tig.spec, dist, and
> rpm. A simple 'make rpm' will build the rpm. Also adds tig.spec.in
> which is used to generate tig.spec.
Thank you. :)
> Accidentally VERSION (and adding -DVERSION=$(VERSION) to CFLAGS) is
> now defined always, even if we do not compile from the "live" tig
> repository.

Yeah, this is probably a good idea; the same goes for moving version info to a file instead of having it in tig.c.

> Minimally tested (meaning "make rpm" from tig repository works).
Trying 'make rpm' on ubuntu 7.04 I get:
  $ rpmbuild -ta tig-0.6.g2463b4e.tar.gz
  error: Name field must be present in package: (main package)
  error: Version field must be present in package: (main package)
  error: Release field must be present in package: (main package)
  error: Summary field must be present in package: (main package)
  error: Group field must be present in package: (main package)
  error: License field must be present in package: (main package)
  $ ls -l /usr/src/rpm/SPECS/
  total 0
  -rw------- 1 root root 0 2007-05-29 21:46 tar: Pattern matching characters used in file names. Please,
Strange.
Show 7 quoted lines
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> 'tig.spec.in' is based on 'git.spec.in' from git repository.
> 
> This is the initial, minimal version.  For example it does not add
> TIG-VERSION-GEN file and the rest of versioning infrastructure that is
> used in git Makefile.
I would prefer to do without. ;)
 
Show 10 quoted lines
> Commands used to get version string (in RPM_VERSION) suitable as a
> version field in the rpm can, most probably, be improved.  Perhaps
> (with the new git-describe output) we should put closest version tag
> as version of tig in rpm, and distance from the tag (perhaps plus 1)
> as release number (in the rpm sense).
> 
> TODO: Change '--without docs' to '--with rebuild-docs' and use
> pre-generated docs when creating rpm, instead of generating them (and
> requiring asciidoc, xmlto and docbook2pdf to build rpm if we want tig
> documentation).

Yeah, once the "official" tarballs contains the version info, this sounds like a good idea.

> P.S. I have build tig-0.6.4.g9eded37-1.i386.rpm using "make rpm" from
> tig repository, and installed it without problems, but when trying to
> build it again _without network_ it failed on building
> manual.pdf. Error log attached.
Looks like some problems with the SGML catalogs info.
 
Show 13 quoted lines
>   asciidoc-7.1.2-2.fc3.rf
>   docbook-dtds-1.0-26
>   docbook-style-dsssl-1.79-1
>   docbook-style-xsl-1.68.1-1
>   docbook-utils-0.6.14-4
>   docbook-utils-pdf-0.6.14-4
>   jadetex-3.12-13
>   openjade-1.3.2-16
> 
> I think we can skip generation of manual.pdf, and generate it only on
> request (e.g. "make doc-pdf"), or using doc-man and doc-html in place
> of doc in the spec file... but this is better left for the next
> commit.

Good idea, PDF is not essential and probably suboptimal to either of the HTML versions of the manual.

> By the way, why do you use xmlto and docbook2pdf, instead of a2x from
> asciidoc package?

It is a fairly recent addition to the asciidoc. Besides, I just tried it and it seems to be completely unusable on ubuntu because of the way it has been packaged; it cannot find required files.

Show 32 quoted lines
>  .gitignore  |    2 ++
>  Makefile    |   34 ++++++++++++++++++++++++++++++++--
>  tig.spec.in |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 90 insertions(+), 2 deletions(-)
>  create mode 100644 tig.spec.in
> 
> diff --git a/.gitignore b/.gitignore
> index 8f6aa93..f7ab840 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -2,3 +2,5 @@ manual.html-chunked
>  manual.pdf
>  manual.toc
>  tig
> +tig.spec
> +tig-*.tar.gz
> diff --git a/Makefile b/Makefile
> index 06a5d6a..45c833b 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -18,8 +18,16 @@ DOCS	= $(DOCS_MAN) $(DOCS_HTML) \
>  ifneq (,$(wildcard .git))
>  VERSION = $(shell git-describe)
>  WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
> -CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
> +else
> +GEN_VER="tig-0.6.TIG"
> +VERSION = $(shell test -f version && cat version || echo "$(GEN_VER)")
>  endif
> +CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
> +RPM_VERSION  = $(subst tig-,,$(VERSION))
> +RPM_VERSION := $(subst -,.,$(RPM_VERSION))
I will probably try to simplify and clean this up a bit. 
Show 45 quoted lines
> +
> +TARNAME=tig-$(RPM_VERSION)
> +
>  
>  all: $(PROGS)
>  all-debug: $(PROGS)
> @@ -57,6 +65,9 @@ install-doc: install-doc-man install-doc-html
>  clean:
>  	rm -rf manual.html-chunked
>  	rm -f $(PROGS) $(DOCS) core *.xml
> +	rm -f *.spec
> +	rm -rf $(TARNAME)
> +	rm -f $(TARNAME).tar.gz
>  
>  spell-check:
>  	aspell --lang=en --check tig.1.txt tigrc.5.txt manual.txt
> @@ -64,7 +75,7 @@ spell-check:
>  strip: all
>  	strip $(PROGS)
>  
> -.PHONY: all all-debug doc doc-man doc-html install install-doc install-doc-man install-doc-html clean spell-check
> +.PHONY: all all-debug doc doc-man doc-html install install-doc install-doc-man install-doc-html clean spell-check dist rpm
>  
>  manual.html: manual.toc
>  manual.toc: manual.txt
> @@ -119,3 +130,22 @@ sync-docs:
>  	make doc
>  	cg commit -m "Sync docs"
>  	cg switch master
> +
> +tig.spec: tig.spec.in
> +	sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' < $< > $@+
> +	mv $@+ $@
> +
> +dist: tig.spec
> +	git-archive --format=tar \
> +		--prefix=$(TARNAME)/ HEAD^{tree} > $(TARNAME).tar
> +	@mkdir -p $(TARNAME)
> +	@cp tig.spec $(TARNAME)
> +	@echo $(VERSION) > $(TARNAME)/version
> +	tar rf $(TARNAME).tar \
> +	       $(TARNAME)/tig.spec \
> +	       $(TARNAME)/version
> +	@rm -rf $(TARNAME)
> +	gzip -f -9 $(TARNAME).tar

Does the .spec file need to be in the tarball for rpm to work? I mean, if it can be generated from .spec.in, I would rather have the rpm target create it?

Show 21 quoted lines
> +rpm: dist
> +	rpmbuild -ta $(TARNAME).tar.gz
> diff --git a/tig.spec.in b/tig.spec.in
> new file mode 100644
> index 0000000..2ce6cdb
> --- /dev/null
> +++ b/tig.spec.in
> @@ -0,0 +1,56 @@
> +# -*- mode: rpm-spec-mode; encoding: utf-8; -*-
> +# Pass '--without docs' to rpmbuild if you don't want the documentation
> +
> +Summary: 	Tig: text-mode interface for git
> +Name: 		tig
> +Version: 	@@VERSION@@
> +Release: 	1%{?dist}
> +License: 	GPL
> +Group: 		Development/Tools
> +Vendor: 	Jonas Fonseca <fonseca@diku.dk>
> +URL: 		http://jonas.nitro.dk/tig/
> +Source: 	http://jonas.nitro.dk/tig/releases/%{name}-%{version}.tar.gz
> +BuildRequires: 	ncurses-devel%{!?_without_docs:, xmlto, asciidoc > 6.0.3, /usr/bin/docbook2pdf}
Is the last entry a shorthand for the doc dependencies you listed above?
Show 36 quoted lines
> +BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
> +Requires: 	git-core, ncurses
> +
> +%description
> +Tig is a git repository browser that additionally can act as a pager
> +for output from various git commands.
> +
> +When browsing repositories, it uses the underlying git commands to
> +present the user with various views, such as summarized revision log
> +and showing the commit with the log message, diffstat, and the diff.
> +
> +Using it as a pager, it will display input from stdin and colorize it.
> +
> +%prep
> +%setup -q
> +
> +%build
> +CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
> +%{__make} %{_smp_mflags} \
> +	prefix=%{_prefix} \
> +	all %{!?_without_docs: doc}
> +
> +%install
> +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
> +CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
> +%{__make} %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT \
> +	prefix=%{_prefix} bindir=%{_bindir} mandir=%{_mandir} \
> +	install %{!?_without_docs: install-doc-man}
> +
> +%clean
> +[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
> +
> +%files
> +%defattr(-,root,root)
> +%{_bindir}/*
> +%doc README COPYING INSTALL SITES BUGS TODO tigrc

I don't know if manual.txt should perhaps be included if HTML and PDF files will not be generated.

Show 7 quoted lines
> +%{!?_without_docs: %{_mandir}/man1/*.1*}
> +%{!?_without_docs: %{_mandir}/man5/*.5*}
> +%{!?_without_docs: %doc *.html *.pdf}
> +
> +%changelog
> +* Mon May 28 2007 Jakub Narebski <jnareb@gmail.com>
> +- Initial tig spec file
-- 
Jonas Fonseca
Jakub Narebski· May 29, 2007, 23:31 UTC · re: Jonas Fonseca · lore

Re: [PATCH (tig)] Infrastructure for tig rpm builds.

On Tue, 29 May 2007, Jonas Fonseca wrote:
> Jakub Narebski <jnareb@gmail.com> wrote Mon, May 28, 2007:
Show 16 quoted lines
>> Minimally tested (meaning "make rpm" from tig repository works).
> 
> Trying 'make rpm' on ubuntu 7.04 I get:
> 
>   $ rpmbuild -ta tig-0.6.g2463b4e.tar.gz
>   error: Name field must be present in package: (main package)
>   error: Version field must be present in package: (main package)
>   error: Release field must be present in package: (main package)
>   error: Summary field must be present in package: (main package)
>   error: Group field must be present in package: (main package)
>   error: License field must be present in package: (main package)
>   $ ls -l /usr/src/rpm/SPECS/
>   total 0
>   -rw------- 1 root root 0 2007-05-29 21:46 tar: Pattern matching characters used in file names. Please,
> 
> Strange.

Hmmm... WORKSFORME. Aurox 11.1 (Fedora Core 4 based distribution), with rpm 4.4.1. By the way, isn't Ubuntu based on Debian? Do you have rpmbuild installed?

BTW. perhaps you could provide spec equivalent for building tig*.deb?
  1000:[master!tig]$ make rpm
  sed -e 's/@@VERSION@@/0.6.5.g2bba6eb/g' < tig.spec.in > tig.spec+
  mv tig.spec+ tig.spec
  git-archive --format=tar \
  --prefix=tig-0.6.5.g2bba6eb/ HEAD^{tree} > tig-0.6.5.g2bba6eb.tar
  tar rf tig-0.6.5.g2bba6eb.tar \
         tig-0.6.5.g2bba6eb/tig.spec \
         tig-0.6.5.g2bba6eb/version
  gzip -f -9 tig-0.6.5.g2bba6eb.tar
  rpmbuild -ta tig-0.6.5.g2bba6eb.tar.gz
  Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.85822
  + umask 022
  + cd /home/local/builddir/BUILD
  + LANG=C
  + export LANG
  + unset DISPLAY
  + cd /home/local/builddir/BUILD
  + rm -rf tig-0.6.5.g2bba6eb
  + /usr/bin/gzip -dc /home/jnareb/tig/tig-0.6.5.g2bba6eb.tar.gz
  + tar -xf -
  + STATUS=0
 
Show 9 quoted lines
>> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
>> ---
>> 'tig.spec.in' is based on 'git.spec.in' from git repository.
>> 
>> This is the initial, minimal version.  For example it does not add
>> TIG-VERSION-GEN file and the rest of versioning infrastructure that is
>> used in git Makefile.
> 
> I would prefer to do without. ;)
I think we can do without it, but in current implementation there is
no guarantee that we would not get wrong version.
 
[...]
Show 6 quoted lines
>> P.S. I have build tig-0.6.4.g9eded37-1.i386.rpm using "make rpm" from
>> tig repository, and installed it without problems, but when trying to
>> build it again _without network_ it failed on building
>> manual.pdf. Error log attached.
> 
> Looks like some problems with the SGML catalogs info.
If I only knew how to debug that...
Show 7 quoted lines
>> I think we can skip generation of manual.pdf, and generate it only on
>> request (e.g. "make doc-pdf"), or using doc-man and doc-html in place
>> of doc in the spec file... but this is better left for the next
>> commit.
> 
> Good idea, PDF is not essential and probably suboptimal to either of the
> HTML versions of the manual.

And it is very easy to implement: just replace 'doc' in make invocation in tig.spec.in by the 'doc-man doc-html'.

Show 6 quoted lines
>> By the way, why do you use xmlto and docbook2pdf, instead of a2x from
>> asciidoc package?
> 
> It is a fairly recent addition to the asciidoc. Besides, I just tried it
> and it seems to be completely unusable on ubuntu because of the way it
> has been packaged; it cannot find required files.
Fair enough.
 
[...]
Show 18 quoted lines
>> diff --git a/Makefile b/Makefile
>> index 06a5d6a..45c833b 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -18,8 +18,16 @@ DOCS	= $(DOCS_MAN) $(DOCS_HTML) \
>>  ifneq (,$(wildcard .git))
>>  VERSION = $(shell git-describe)
>>  WTDIRTY = $(shell git-diff-index --name-only HEAD 2>/dev/null)
>> -CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
>> +else
>> +GEN_VER="tig-0.6.TIG"
>> +VERSION = $(shell test -f version && cat version || echo "$(GEN_VER)")
>>  endif
>> +CFLAGS += '-DVERSION="$(VERSION)$(if $(WTDIRTY),-dirty)"'
>> +RPM_VERSION  = $(subst tig-,,$(VERSION))
>> +RPM_VERSION := $(subst -,.,$(RPM_VERSION))
> 
> I will probably try to simplify and clean this up a bit. 
That would be nice.
[...]
Show 15 quoted lines
>> +dist: tig.spec
>> +	git-archive --format=tar \
>> +		--prefix=$(TARNAME)/ HEAD^{tree}> $(TARNAME).tar
>> +	@mkdir -p $(TARNAME)
>> +	@cp tig.spec $(TARNAME)
>> +	@echo $(VERSION)> $(TARNAME)/version
>> +	tar rf $(TARNAME).tar \
>> +	       $(TARNAME)/tig.spec \
>> +	       $(TARNAME)/version
>> +	@rm -rf $(TARNAME)
>> +	gzip -f -9 $(TARNAME).tar
> 
> Does the .spec file need to be in the tarball for rpm to work? I mean,
> if it can be generated from .spec.in, I would rather have the rpm target
> create it?

Having .spec file in the tarbal allows to download tarball and use 'rpmbuild -ta tig-*.tar.gz' to build rpms; no need to unpack then do 'make rpm'.

Besides rpm target makes use of this, although there is alternate solution.

>> +rpm: dist
>> +	rpmbuild -ta $(TARNAME).tar.gz
[...]
>> +BuildRequires: 	ncurses-devel%{!?_without_docs:, xmlto, asciidoc> 6.0.3, /usr/bin/docbook2pdf}
> 
> Is the last entry a shorthand for the doc dependencies you listed above?

Nope, the list of packages was because the error with creating manual.pdf might depend on versions of packages I have installed.

The last entry written using name of binary (needed to generate manual.pdf) because I think where this tool can be found, i.e. in which package, might depend on distribution you use. For example in FC4 it is in docbook-utils-pdf package.

[...]
>> +%files
>> +%defattr(-,root,root)
>> +%{_bindir}/*
>> +%doc README COPYING INSTALL SITES BUGS TODO tigrc

By the way, should we put tigrc in examples/tigrc, or perhaps in some skeleton file?

Show 6 quoted lines
> I don't know if manual.txt should perhaps be included if
> HTML and PDF files will not be generated.
> 
>> +%{!?_without_docs: %{_mandir}/man1/*.1*}
>> +%{!?_without_docs: %{_mandir}/man5/*.5*}
>> +%{!?_without_docs: %doc *.html *.pdf}
O.K. It would be as easy as %{?_without_docs: %doc *.txt}
-- 
Jakub Narebski
Poland
Jonas Fonseca· May 31, 2007, 13:16 UTC · re: Jakub Narebski · lore

Re: [PATCH (tig)] Infrastructure for tig rpm builds.

Jakub Narebski <jnareb@gmail.com> wrote Wed, May 30, 2007:
Show 5 quoted lines
> On Tue, 29 May 2007, Jonas Fonseca wrote:
> > Jakub Narebski <jnareb@gmail.com> wrote Mon, May 28, 2007:
> [...]
> By the way, isn't Ubuntu based on Debian? Do you
> have rpmbuild installed?

Yes it is Debian-based and yes I do, but I don't know if I need to do something explicitly to get it working. Mostly, prefixing things with 'sudo' works magic on Ubuntu but not in this case. ;)

> BTW. perhaps you could provide spec equivalent for building tig*.deb?
Well, there already exists a Debian package for tig so it would be easy
to lift the files required and if the Debian maintainer wanted it, sure.
However, not as simple as a .spec file so it is more work to maintain.
 
>   1000:[master!tig]$ make rpm
Maybe you can test the newly released tig 0.7 tarball?
Your patch was added as commit 8cdf56913e7e486bb3f527c24ee4a4d19f2a4f61,
with a few minor adjustments.
 
Show 8 quoted lines
> [...]
> >> +%files
> >> +%defattr(-,root,root)
> >> +%{_bindir}/*
> >> +%doc README COPYING INSTALL SITES BUGS TODO tigrc
> 
> By the way, should we put tigrc in examples/tigrc, or perhaps in some
> skeleton file?

It is mostly the default (builtin) options, so I don't see the point. Maybe it is time tig got a contrib area though, since I've been wanting to make a bash completion file. The tigrc file could go there as tigrc.sample or something. Could make it more obvious the intension of the file?

Show 8 quoted lines
> > I don't know if manual.txt should perhaps be included if
> > HTML and PDF files will not be generated.
> > 
> >> +%{!?_without_docs: %{_mandir}/man1/*.1*}
> >> +%{!?_without_docs: %{_mandir}/man5/*.5*}
> >> +%{!?_without_docs: %doc *.html *.pdf}
> 
> O.K. It would be as easy as %{?_without_docs: %doc *.txt}
I will try to correct this together with the no-PDF doc-building.
-- 
Jonas Fonseca
Jakub Narebski· Jun 1, 2007, 16:24 UTC · re: Jonas Fonseca · lore

[PATCH 1/3] Remove PDF version of manual from being build and installed

Because PDF version of "The tig Manual" doesn't offer anything new that is not present in HTML version, and building PDF requires additional tools (docbook2pdf) and their dependencies present, remove it from tig rpm.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Jakub Narebski <jnareb@gmail.com> wrote Wed, May 30, 2007:
Show 13 quoted lines
> On Tue, 29 May 2007, Jonas Fonseca wrote:
>> Jakub Narebski <jnareb@gmail.com> wrote Mon, May 28, 2007:
>>
>>> I think we can skip generation of manual.pdf, and generate it only on
>>> request (e.g. "make doc-pdf"), or using doc-man and doc-html in place
>>> of doc in the spec file... but this is better left for the next
>>> commit.
>> 
>> Good idea, PDF is not essential and probably suboptimal to either of the
>> HTML versions of the manual.
>
> And it is very easy to implement: just replace 'doc' in make invocation
> in tig.spec.in by the 'doc-man doc-html'.
This patch (commit) does just that.
On Thu, 31 May 2007, Jonas Fonseca wrote:
> I will try to correct this together with the no-PDF doc-building.
I hope we didn't end up duplicating our efforts.
 tig.spec.in |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
Show changes to tig.spec.in +6 −3
diff --git a/tig.spec.in b/tig.spec.in
index 2ce6cdb..b7753fd 100644
--- a/tig.spec.in
+++ b/tig.spec.in
@@ -10,7 +10,7 @@ Group: 		Development/Tools
 Vendor: 	Jonas Fonseca <fonseca@diku.dk>
 URL: 		http://jonas.nitro.dk/tig/
 Source: 	http://jonas.nitro.dk/tig/releases/%{name}-%{version}.tar.gz
-BuildRequires: 	ncurses-devel%{!?_without_docs:, xmlto, asciidoc > 6.0.3, /usr/bin/docbook2pdf}
+BuildRequires: 	ncurses-devel%{!?_without_docs:, xmlto, asciidoc > 6.0.3}
 BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Requires: 	git-core, ncurses
 
@@ -31,7 +31,7 @@ Using it as a pager, it will display input from stdin and colorize it.
 CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
 %{__make} %{_smp_mflags} \
 	prefix=%{_prefix} \
-	all %{!?_without_docs: doc}
+	all %{!?_without_docs: doc-man doc-html}
 
 %install
 [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@@ -49,8 +49,11 @@ CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
 %doc README COPYING INSTALL SITES BUGS TODO tigrc
 %{!?_without_docs: %{_mandir}/man1/*.1*}
 %{!?_without_docs: %{_mandir}/man5/*.5*}
-%{!?_without_docs: %doc *.html *.pdf}
+%{!?_without_docs: %doc *.html}
 
 %changelog
+* Fri Jun  1 2007 Jakub Narebski <jnareb@gmail.com>
+- Remove PDF version of manual from being build and installed
+
 * Mon May 28 2007 Jakub Narebski <jnareb@gmail.com>
 - Initial tig spec file
-- 
1.5.2
Jonas Fonseca· Jun 2, 2007, 16:08 UTC · re: Jakub Narebski · lore

Re: [PATCH 1/3] Remove PDF version of manual from being build and installed

Jakub Narebski <jnareb@gmail.com> wrote Fri, Jun 01, 2007:
Show 5 quoted lines
> [...] 
> On Thu, 31 May 2007, Jonas Fonseca wrote:
> > I will try to correct this together with the no-PDF doc-building.
> 
> I hope we didn't end up duplicating our efforts.
Nope, it didn't. Again, thanks for doing this!
-- 
Jonas Fonseca
Jakub Narebski· Jun 1, 2007, 16:27 UTC · re: Jonas Fonseca · lore

[PATCH 2/3] Include documentation sources for rpmbuild with '--without docs'

This includes _all_ documentation sources (and not only manual.txt) in the rpm file build with '--without docs' option.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Jakub Narebski <jnareb@gmail.com> wrote Wed, May 30, 2007:
> On Tue, 29 May 2007, Jonas Fonseca wrote:
>> Jakub Narebski <jnareb@gmail.com> wrote Mon, May 28, 2007:
Show 8 quoted lines
>> I don't know if manual.txt should perhaps be included if
>> HTML and PDF files will not be generated.
>> 
>>> +%{!?_without_docs: %{_mandir}/man1/*.1*}
>>> +%{!?_without_docs: %{_mandir}/man5/*.5*}
>>> +%{!?_without_docs: %doc *.html *.pdf}
> 
> O.K. It would be as easy as %{?_without_docs: %doc *.txt}

Actually it does add more than manual.txt, it adds sources for all tig documentation (including manpages).

This patch textually depends on earlier patch, but in fact thic change is independent on previous one.

 tig.spec.in |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Show changes to tig.spec.in +3 −1
diff --git a/tig.spec.in b/tig.spec.in
index b7753fd..2385fb8 100644
--- a/tig.spec.in
+++ b/tig.spec.in
@@ -1,5 +1,5 @@
 # -*- mode: rpm-spec-mode; encoding: utf-8; -*-
-# Pass '--without docs' to rpmbuild if you don't want the documentation
+# Pass '--without docs' to rpmbuild if you don't want the documentation to be build
 
 Summary: 	Tig: text-mode interface for git
 Name: 		tig
@@ -50,9 +50,11 @@ CFLAGS="$RPM_OPT_FLAGS -DVERSION=tig-%{version}-%{release}"
 %{!?_without_docs: %{_mandir}/man1/*.1*}
 %{!?_without_docs: %{_mandir}/man5/*.5*}
 %{!?_without_docs: %doc *.html}
+%{?_without_docs:  %doc *.txt}
 
 %changelog
 * Fri Jun  1 2007 Jakub Narebski <jnareb@gmail.com>
+- Include documentation sources for --without docs
 - Remove PDF version of manual from being build and installed
 
 * Mon May 28 2007 Jakub Narebski <jnareb@gmail.com>
-- 
1.5.2
Jakub Narebski· Jun 1, 2007, 16:34 UTC · re: Jonas Fonseca · lore

[PATCH 3/3] Refresh VERSION file when building distribution tarball in "make dist"

Overwrite contents of VERSION file from the HEAD revision with the current version (at the time of building), so VERSION file in the tarball generated by "make dist" (and which follows also rpm package generated by "make rpm") is up to date.

Otherwise for example when building rpm it will be compiled with wrong version string.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On Thu, 31 May 2007, Jonas Fonseca wrote:
> Maybe you can test the newly released tig 0.7 tarball?
> 
> Your patch was added as commit 8cdf56913e7e486bb3f527c24ee4a4d19f2a4f61,
> with a few minor adjustments.

One of those changes was using HEAD version of VERSION file in "make dist", instead of regenerating it and replacing it with the one containing _current_ version in the tar file.

$ make rpm sed -e 's/@@VERSION@@/0.7.4.g1995120/g' < tig.spec.in > tig.spec git-archive --format=tar --prefix=tig-0.7.4.g1995120/ HEAD > tig-0.7.4.g1995120.tar tar rf tig-0.7.4.g1995120.tar tig-0.7.4.g1995120/tig.spec gzip -f -9 tig-0.7.4.g1995120.tar rpmbuild -ta tig-0.7.4.g1995120.tar.gz Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.72336 Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.72336 make[1]: Entering directory `/home/local/builddir/BUILD/tig-0.7.4.g1995120' cc -Wall -O2 '-DVERSION="0.7.git"' tig.c -lcurses -o tig asciidoc -b docbook -d manpage -aversion=0.7.git tig.1.txt xmlto -m manpage.xsl man tig.1.xml [...]

Note the mismatch in the versions: 0.7.4.g1995120 vs 0.7.git (by the way, shouldn't it be 0.7.tig?), even when building from live repo, and not from tarball.

This is 3rd patch in the series, but it is actually independent on the rest, and can be applied in any order.

 Makefile |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
Show changes to Makefile +4 −1
diff --git a/Makefile b/Makefile
index 0e42de6..bc8086f 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,10 @@ dist: tig.spec
 	git-archive --format=tar --prefix=$(TARNAME)/ HEAD > $(TARNAME).tar
 	@mkdir -p $(TARNAME)
 	@cp tig.spec $(TARNAME)
-	tar rf $(TARNAME).tar $(TARNAME)/tig.spec
+	echo $(VERSION) > $(TARNAME)/VERSION
+	tar rf $(TARNAME).tar \
+	       $(TARNAME)/tig.spec \
+	       $(TARNAME)/VERSION
 	@rm -rf $(TARNAME)
 	gzip -f -9 $(TARNAME).tar
 
-- 
1.5.2
Jonas Fonseca· Jun 2, 2007, 16:12 UTC · re: Jakub Narebski · lore

Re: [PATCH 3/3] Refresh VERSION file when building distribution tarball in "make dist"

Jakub Narebski <jnareb@gmail.com> wrote Fri, Jun 01, 2007:
Show 28 quoted lines
> On Thu, 31 May 2007, Jonas Fonseca wrote:
> 
> > Maybe you can test the newly released tig 0.7 tarball?
> > 
> > Your patch was added as commit 8cdf56913e7e486bb3f527c24ee4a4d19f2a4f61,
> > with a few minor adjustments.
> 
> One of those changes was using HEAD version of VERSION file in
> "make dist", instead of regenerating it and replacing it with the one
> containing _current_ version in the tar file.
> 
> $ make rpm
> sed -e 's/@@VERSION@@/0.7.4.g1995120/g' < tig.spec.in > tig.spec
> git-archive --format=tar --prefix=tig-0.7.4.g1995120/ HEAD > tig-0.7.4.g1995120.tar
> tar rf tig-0.7.4.g1995120.tar tig-0.7.4.g1995120/tig.spec
> gzip -f -9 tig-0.7.4.g1995120.tar
> rpmbuild -ta tig-0.7.4.g1995120.tar.gz
> Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.72336
> Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.72336
> make[1]: Entering directory `/home/local/builddir/BUILD/tig-0.7.4.g1995120'
> cc -Wall -O2 '-DVERSION="0.7.git"'    tig.c  -lcurses -o tig
> asciidoc -b docbook -d manpage -aversion=0.7.git tig.1.txt
> xmlto -m manpage.xsl man tig.1.xml
> [...]
> 
> Note the mismatch in the versions: 0.7.4.g1995120 vs 0.7.git
> (by the way, shouldn't it be 0.7.tig?), even when building from live
> repo, and not from tarball.

Gah, somehow I didn't realize the problems of not updating the VERSION file. Beautiful, so now it should actually work even for non-RPM builds using the 'make dist' result. :)

-- 
Jonas Fonseca
Jakub Narebski· Jun 2, 2007, 17:52 UTC · re: Jonas Fonseca · lore

[RFC/PATCH 4/3] Simplify naming (versioning) of non-release tig tarball and rpm file

Use the tag part of git-describe output, with `tig-' prefix stripped off, as version number. Use number of commits since given tag as release number, using 0 if we are at tagged version, and adding '.dirty' suffix if working directory is dirty. Do not use 'g<sha 1>' part of git-describe output.

For example, when git-describe output was tig-0.7-8-g26d0386, before this commit tarball was named tig-0.7.8.g26d0386.tar.gz and rpm was named tig-0.7.8.g26d0386-1.src.rpm (for dirty tree tarball was tig-0.7.8.g26d0386.dirty.tar.gz), now tarball is named tig-0.7-8.tar.gz and rpm is named tig-0.7-8.src.rpm (for dirty tree tarball is tig-0.7-8.dirty.tar.gz).

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is proposal to simplify naming of non-release tarballs and rpm file,
both for tig and also for git itself. Instead of using whole git-describe
output as version number in tarball/rpm name (BTW. it would be nice to
have command line switch to git-describe which would return old output,
without number of commits since given tag) use tag part as version number,
and number of commits since (plus optional marking dirty) as release
number.
What do you think about this?
 Makefile    |   13 ++++++++++---
 tig.spec.in |    2 +-
 2 files changed, 11 insertions(+), 4 deletions(-)
Show changes to 2 files +11 −4

Makefile, tig.spec.in

diff --git a/Makefile b/Makefile
index b49d7f8..1e67586 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,13 @@ ifdef DIST_VERSION
 VERSION	= $(DIST_VERSION)
 endif
 
-RPM_VERSION = $(subst -,.,$(VERSION))
+# $(GITDESC) looks like either x.y, or like x.y-z-g<sha1>
+SPLIT_VERSION := $(shell echo $(GITDESC) | \
+                   sed -e 's/^\(.*\)-\([0-9]\+\)-\(g[0-9a-f]\+\)$$/\1 \2 \3/g')
+RPM_VERSION = $(subst -,.,$(word 1,$(SPLIT_VERSION)))
+RPM_RELEASE = $(strip \
+              $(subst -,.,$(if $(word 2,$(SPLIT_VERSION)),\
+                               $(word 2,$(SPLIT_VERSION)),0)$(WTDIRTY)))
 
 LDLIBS	= -lcurses
 CFLAGS	= -Wall -O2 '-DVERSION="$(VERSION)"'
@@ -26,7 +32,7 @@ PROGS	= tig
 MANDOC	= tig.1 tigrc.5
 HTMLDOC	= tig.1.html tigrc.5.html manual.html README.html
 ALLDOC	= $(MANDOC) $(HTMLDOC) manual.html-chunked manual.pdf
-TARNAME	= tig-$(RPM_VERSION)
+TARNAME	= tig-$(RPM_VERSION)-$(RPM_RELEASE)
 
 all: $(PROGS)
 all-debug: $(PROGS)
@@ -104,7 +110,8 @@ release-dist: release-doc
 	install-doc-man install-doc-html clean spell-check dist rpm
 
 tig.spec: tig.spec.in
-	sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' < $< > $@
+	sed -e 's/@@VERSION@@/$(RPM_VERSION)/g' \
+	    -e 's/@@RELEASE@@/$(RPM_RELEASE)/g' < $< > $@
 
 tig: tig.c
 
diff --git a/tig.spec.in b/tig.spec.in
index 2385fb8..8606b23 100644
--- a/tig.spec.in
+++ b/tig.spec.in
@@ -4,7 +4,7 @@
 Summary: 	Tig: text-mode interface for git
 Name: 		tig
 Version: 	@@VERSION@@
-Release: 	1%{?dist}
+Release: 	@@RELEASE@@%{?dist}
 License: 	GPL
 Group: 		Development/Tools
 Vendor: 	Jonas Fonseca <fonseca@diku.dk>
-- 
1.5.2
Jonas Fonseca· Jun 3, 2007, 09:11 UTC · re: Jakub Narebski · lore

Re: [RFC/PATCH 4/3] Simplify naming (versioning) of non-release tig tarball and rpm file

Jakub Narebski <jnareb@gmail.com> wrote Sat, Jun 02, 2007:
Show 9 quoted lines
> This is proposal to simplify naming of non-release tarballs and rpm file,
> both for tig and also for git itself. Instead of using whole git-describe
> output as version number in tarball/rpm name (BTW. it would be nice to
> have command line switch to git-describe which would return old output,
> without number of commits since given tag) use tag part as version number,
> and number of commits since (plus optional marking dirty) as release
> number.
> 
> What do you think about this?

I like the simpler and less confusing names. How about the simpler version below?

BTW, I also added `make dist DIST_VERSION=X.Y` to make it easy to force a version. I used it when building the documentation in the release branch.

Show 19 quoted lines
> diff --git a/Makefile b/Makefile
> index b49d7f8..1e67586 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -17,7 +17,13 @@ ifdef DIST_VERSION
>  VERSION	= $(DIST_VERSION)
>  endif
>  
> -RPM_VERSION = $(subst -,.,$(VERSION))
> +# $(GITDESC) looks like either x.y, or like x.y-z-g<sha1>
> +SPLIT_VERSION := $(shell echo $(GITDESC) | \
> +                   sed -e 's/^\(.*\)-\([0-9]\+\)-\(g[0-9a-f]\+\)$$/\1 \2 \3/g')
> +RPM_VERSION = $(subst -,.,$(word 1,$(SPLIT_VERSION)))
> +RPM_RELEASE = $(strip \
> +              $(subst -,.,$(if $(word 2,$(SPLIT_VERSION)),\
> +                               $(word 2,$(SPLIT_VERSION)),0)$(WTDIRTY)))
>  
>  LDLIBS	= -lcurses
>  CFLAGS	= -Wall -O2 '-DVERSION="$(VERSION)"'
Show changes to Makefile +5 −1
diff --git a/Makefile b/Makefile
index 91cb097..622a916 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,11 @@ ifdef DIST_VERSION
 VERSION = $(DIST_VERSION)
 endif
 
-RPM_VERSION = $(subst -,.,$(VERSION))
+# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
+# and append 0 as a fallback offset for "exact" tagged versions.
+RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
+RPM_VERSION = $(word 1,$(RPM_VERLIST))
+RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
 
 LDLIBS	= -lcurses
 CFLAGS	= -Wall -O2
-- 
Jonas Fonseca
Jakub Narebski· Jun 3, 2007, 21:12 UTC · re: Jonas Fonseca · lore

Re: [RFC/PATCH 4/3] Simplify naming (versioning) of non-release tig tarball and rpm file

On Sun, 3 Jun 2007, Jonas Fonseca wrote:
> Jakub Narebski <jnareb@gmail.com> wrote Sat, Jun 02, 2007:
Show 12 quoted lines
>> This is proposal to simplify naming of non-release tarballs and rpm file,
>> both for tig and also for git itself. Instead of using whole git-describe
>> output as version number in tarball/rpm name (BTW. it would be nice to
>> have command line switch to git-describe which would return old output,
>> without number of commits since given tag) use tag part as version number,
>> and number of commits since (plus optional marking dirty) as release
>> number.
>> 
>> What do you think about this?
> 
> I like the simpler and less confusing names. How about the simpler
> version below?

This version would work for tig now, but is not very generic. See also comments below.

> BTW, I also added `make dist DIST_VERSION=X.Y` to make it easy to force
> a version. I used it when building the documentation in the release
> branch.
Nice idea.
 
Show 37 quoted lines
>> diff --git a/Makefile b/Makefile
>> index b49d7f8..1e67586 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -17,7 +17,13 @@ ifdef DIST_VERSION
>>  VERSION	= $(DIST_VERSION)
>>  endif
>>  
>> -RPM_VERSION = $(subst -,.,$(VERSION))
>> +# $(GITDESC) looks like either x.y, or like x.y-z-g<sha1>
>> +SPLIT_VERSION := $(shell echo $(GITDESC) | \
>> +                   sed -e 's/^\(.*\)-\([0-9]\+\)-\(g[0-9a-f]\+\)$$/\1 \2 \3/g')
>> +RPM_VERSION = $(subst -,.,$(word 1,$(SPLIT_VERSION)))
>> +RPM_RELEASE = $(strip \
>> +              $(subst -,.,$(if $(word 2,$(SPLIT_VERSION)),\
>> +                               $(word 2,$(SPLIT_VERSION)),0)$(WTDIRTY)))
>>  
>>  LDLIBS	= -lcurses
>>  CFLAGS	= -Wall -O2 '-DVERSION="$(VERSION)"'
> 
> diff --git a/Makefile b/Makefile
> index 91cb097..622a916 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -17,7 +17,11 @@ ifdef DIST_VERSION
>  VERSION = $(DIST_VERSION)
>  endif
>  
> -RPM_VERSION = $(subst -,.,$(VERSION))
> +# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
> +# and append 0 as a fallback offset for "exact" tagged versions.
> +RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
> +RPM_VERSION = $(word 1,$(RPM_VERLIST))
> +RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
>  
>  LDLIBS	= -lcurses
>  CFLAGS	= -Wall -O2

I'd like to note that I wanted to make _generic_ version of generating RPM_VERSION and RPM_RELEASE from the output of git-describe (also with marking that working directory was in dirty state). Your simpler version works for tags used in tig repository, but for example not necessarily so for git repository.

I assume that "version tags" are of the form
  [<prefix>]<version>

where optional <prefix> is "v" for git and linux repositories, "tig-" for tig repository, "gitgui-" for git-gui repository. <version> starts with a number, and usually consists of numbers separated by dots, but it can contain also alphanumeric suffix, for example "-rc1", "-pre7", "b" (c.f. v0.99.9b tag in git repository), etc. I assume that <version> is the part that starts with the number.

This means that git-describe output is either of the form
  [<prefix>]<version>
(if there is exact match), or of the form
  [<prefix>]<version>-<number of additional commits>-g<abbreviated sha-1>
For exact match (release tarball) I'd like to have
  RPM_VERSION = $(subst -,.,<version>)
  RPM_RELEASE = 0
and for non-exact match to have
  RPM_VERSION = $(subst -,.,<version>)
  RPM_RELEASE = <number of additional commits>.g<abbreviated sha-1>

The "g<abbreviated sha-1>", which was missing from my (and yours) proposal is needed because we can have multiple branches, and the part before "-g<abbreviated sha-1>" could be the same for different commits (on different branches, e.g. 'master' and 'next').

For "make dist" run from a dirty tree we want to have ".dirty" suffix added to RPM_RELEASE.

Example: if git-describe returns v1.4.3-rc2-21-g0a7a9a1 in a dirty tree
(with uncommitted changes) I'd like to have 1.4.3.rc2 as version number
and 21.g0a7a9a1.dirty as release number, so tarball would be named
git-1.4.3.rc2-21.g0a7a9a1.dirty.tar.gz

Now to the implementation. I wanted to do the above using only Makefile functions, if not for two complications. First I didn't know how to get second-to-last word, or how to remove last word from variable; trick with filter-out could work there. Second in generic version is quite hard to distinguish using only make functions between exact and non-exact match for arbitrary versioning (tagging versions) scheme.

P.S. Perhaps instead of RPM_VERSION we should (re)use DIST_VERSION, and instead of RPM_RELEASE use DIST_RELEASE?

-- 
Jakub Narebski
Poland

← back to recent threads