Bug 60352

Summary: [patch] buildworld fails in sysinstall if terminfo database in /usr/share/misc/terminfo
Product: Base System Reporter: Daniel Hulme <d>
Component: miscAssignee: Antoine Brodin <antoine>
Status: Closed FIXED    
Severity: Affects Only Me CC: d
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch-rtermcap.c none

Description Daniel Hulme 2003-12-18 03:00:34 UTC
The compilation of [/usr/src/usr.sbin/sysinstall] depends on a small
program called "rtermcap".  The program is used to generate a file
called "makedevs.c" from several termcap entries (ansi, xterm, cons25,
etc.).

rtermcap, in turn, relies on a c call (ncurses) to "tgetent," which
checks for a termcap entry, and fills a buffer with the terminal
information.  On closer inspection, however, "tgetent" is also capable
of using terminfo, and in fact prefers terminfo over termcap (if the
terminal exists in terminfo, it will never check termcap--perhaps this
behavior can be changed in ncurses, but I'm not sure it should be).
Unfortunately, it acts a little differently when using terminfo:

[man curs_termcap]
The tgetent routine loads the entry for name.  It returns 1 on success,
0 if there is no such entry, and -1 if the terminfo database could  not
be found.  The emulation ignores the buffer pointer bp.

So, in the event that a terminfo database is present, tgetent will use
it, and will not fill the buffer.  However, the Makefile in
[/usr/src/usr.sbin/sysinstall] relies on the buffer being filled, so it
can use this data to create the arrays in makedevs.c.  There is no
detection of this issue currently, and the compilation of sysinstall
fails with the following message(s), due to the arrays being empty:

	makedevs.c:4: error: syntax error before ',' token
	makedevs.c:7: error: syntax error before ',' token
	makedevs.c:10: error: syntax error before ',' token
	makedevs.c:13: error: syntax error before ',' token
	makedevs.c:16: error: syntax error before ',' token
	makedevs.c:19: error: syntax error before ',' token
	makedevs.c:22: error: syntax error before ',' token
	makedevs.c:25: error: syntax error before ',' token
	makedevs.c:28: error: syntax error before ',' token
	makedevs.c:31: error: syntax error before ',' token

How-To-Repeat: [Install linux compat]

[Link linux terminfo database to /usr/share/misc]
ln -s /usr/compat/linux/usr/share/terminfo /usr/share/misc/

[note that any method of installing a valid terminfo where ncurses will find it should be sufficient]

[Compile sysinstall]
cd /usr/src/usr.sbin/sysinstall/
make clean
make

[Watch the errors]
Comment 1 Daniel Hulme 2003-12-18 19:27:06 UTC
By way of explanation, this code returns identical output as the 
original rtermcap.c, except in the case of an existing terminfo.  In 
that case, this code returns to correct output (i.e., the same as if 
there were no terminfo db), whereas the old code failed silently 
(printing nothing).

The choice to strip double colons and tabs was made not by necessity (I 
am not certain whether it is important or not, but I imagine the target 
program would ignore them), but rather to produce identical output.  
This way, there can be no doubt that this code should function as a 
drop-in replacement for the old code.

I tested this code and the resulting makedevs.c was identical in size 
and content to that created with the original code.  Again, the only 
difference is when a terminfo db exists, in which case *only* this code 
works.

-Dan
Comment 2 Antoine Brodin freebsd_committer freebsd_triage 2008-05-06 12:48:50 UTC
State Changed
From-To: open->closed

Close: this problem has been solved in revision 1.133 of 
src/usr.sbin/sysinstall/Makefile (december 2004) 
by using the TERMCAP environment variable. 


Comment 3 Antoine Brodin freebsd_committer freebsd_triage 2008-05-06 12:48:50 UTC
Responsible Changed
From-To: freebsd-bugs->antoine

Track.