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

From: Jakub Narebski <[email-masked]>
Date: Wed, 30 May 2007 01:31:16 +0200

On Tue, 29 May 2007, Jonas Fonseca wrote:
> Jakub Narebski <[email-masked]> wrote Mon, May 28, 2007:

>> 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
 
>> Signed-off-by: Jakub Narebski <[email-masked]>
>> ---
>> '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.
 
[...]
>> 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...

>> 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'.

>> 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.
 
[...]
>> 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.

[...]
>> +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?

> 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