Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 410529 - net-misc/wget: wget progress bar does not format correctly for terminal less than 80 columns
Summary: net-misc/wget: wget progress bar does not format correctly for terminal less ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Normal minor (vote)
Assignee: Gentoo's Team for Core System packages
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 377365
  Show dependency tree
 
Reported: 2012-04-02 10:26 UTC by Rafał Mużyło
Modified: 2016-03-02 05:34 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Upstream wget patch that fixes the issue (wget-1.16-progressbar.patch,1.20 KB, patch)
2014-11-22 15:01 UTC, Alexander E. Patrakov
Details | Diff
Updated patch (wget-1.16-progressbar.patch,1.00 KB, patch)
2014-11-22 15:30 UTC, Alexander E. Patrakov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rafał Mużyło 2012-04-02 10:26:34 UTC
In an vte-based terminal (likely only part that matters here is that it's not console), if a fetch happens during 'emerge -1', the output is along the lines of:
0% [                                       ] 0           --.-K/s
0% [                                       ] 30.116       106K/s              0%[                                       ] 66.316       117K/s              1%[                                       ] 118.444      139K/s              1%[                                       ] 170.572      150K/s              2%[                                       ] 225.596      159K/s              2%[>                                      ] 297.996      175K/s              3%[>                                      ] 386.324      194K/s              4%[>                                      ] 471.756      212K/s              5%[=>                                     ] 528.228      217K/s              6%[=>                                     ] 616.556      227K/s

a bit surprisingly, output of 'emerge -1f' is normal - only a single line for the fetch.

[ebuild   R    ] dev-lang/python-2.7.2-r3  USE="doc examples gdbm ipv6 ncurses readline sqlite ssl threads (wide-unicode) xml -berkdb -build -tk -wininst" 0 kB
[ebuild     U ~] dev-lang/python-3.2.2-r1 [3.2.2] USE="doc examples gdbm ipv6 ncurses readline sqlite ssl threads (wide-unicode) xml -build -tk -wininst" 0 kB
[ebuild   R   *] sys-apps/portage-2.2.0_alpha98  USE="doc (ipc) -build -epydoc (-pypy1_8) -python2 -python3 (-selinux) -xattr" LINGUAS="-pl" 0 kB
Comment 1 Zac Medico gentoo-dev 2012-04-02 16:30:02 UTC
The EbuildFetcher class is supposed to create a pty device, which makes wget show a 1-line progress bar, if stdout is a tty. You can use this shell code to check if stdout is a tty in your terminal:

   [ -t 1 ] && echo yes || echo no

You can adjust FETCHCOMMAND to use a progress bar even without a tty, by using the wget --progress=bar:force option.
Comment 2 Rafał Mużyło 2012-04-02 16:49:21 UTC
Well, that line answers with "yes", also there's the part, that it's inconsistent between "emerge -1" and "emerge -1f".
Comment 3 Zac Medico gentoo-dev 2012-04-02 16:55:36 UTC
(In reply to comment #2)
> it's inconsistent between "emerge -1" and "emerge -1f".

That's puzzling, since the EbuildFetcher class is used in both cases, so it should use the same logic for whether or not it chooses to create a pty device. The code is as follows:

def _pipe(self, fd_pipes):
	"""When appropriate, use a pty so that fetcher progress bars,
	like wget has, will work properly."""
	if self.background or not sys.stdout.isatty():
		# When the output only goes to a log file,
		# there's no point in creating a pty.
		return os.pipe()
	stdout_pipe = None
	if not self.background:
		stdout_pipe = fd_pipes.get(1)
	got_pty, master_fd, slave_fd = \
		_create_pty_or_pipe(copy_term_size=stdout_pipe)
	return (master_fd, slave_fd)
Comment 4 Rafał Mużyło 2012-04-02 17:47:33 UTC
Something is indeed odd.
While the problem is not that recent, I've gone as far back as alpha86 (going even further would make me a bit twitchy, as I seem to recall there was a significant bug back then) and still see the problem. I'm not quite sure when I've seen the problem for the first time, as I usually fetch first, then emerge already fetched, so I might just missed the moment.
Comment 5 Zac Medico gentoo-dev 2012-04-02 18:27:02 UTC
(In reply to comment #0)
> a bit surprisingly, output of 'emerge -1f' is normal - only a single line
> for the fetch.

I guess this explained by the special fetchonly code in the EbuildBuild class, which forces background=False. I don't understand why background == True for your other command though, because that's only supposed to happen for --quiet-build=y or --jobs  1, when output is automatically redirected to a log file.
Comment 6 Rafał Mużyło 2012-04-03 01:00:35 UTC
...
Actually, I've got 'EMERGE_DEFAULT_OPTS="--quiet-build=n"' in make.conf...
Comment 7 Zac Medico gentoo-dev 2012-04-03 01:10:40 UTC
Does it make any difference in the wget output if you remove --quiet-build=n from EMERGE_DEFAULT_OPTS?
Comment 8 Rafał Mużyło 2012-04-03 16:20:58 UTC
(In reply to comment #7)
> Does it make any difference in the wget output if you remove --quiet-build=n
> from EMERGE_DEFAULT_OPTS?

No, it does not.
Comment 9 Rafał Mużyło 2012-04-26 01:49:40 UTC
Well, it seems that the reason is quite a funny thing:
my terminal was less than 80 char wide.
It was enough to use the mouse, for the output to become the expected form.
Comment 10 Zac Medico gentoo-dev 2012-04-26 03:35:55 UTC
Now that you mention it, it seems obvious that the terminal is not wide enough for the output in comment #0. It's not the --progress=dot output that wget automatically produces when stdout is not a tty.

Maybe it's a bug in wget, or maybe if portage exports the COLUMNS variable then wget will work correctly. Portage already uses stty to set the number of rows and columns on the pty device.
Comment 11 SpanKY gentoo-dev 2013-12-23 03:29:49 UTC
is this still an issue ?  portage has been updated to export COLUMNS ...
Comment 12 Rafał Mużyło 2013-12-24 04:47:29 UTC
(In reply to SpanKY from comment #11)
> is this still an issue ?  portage has been updated to export COLUMNS ...

If the question is "does this still happen with portage 2.2.7 ?", the answer is "yes".
Otherwise, please be more specific.

(well, it might play a role here, that the terminal in question doesn't resize itself quite correctly...)
Comment 13 Alexander E. Patrakov 2014-11-21 11:03:10 UTC
The bug definitely happens outside portage, even on wide terminals.

My Konsole is 211x60, and attempting to wget http://distribution.bbb3d.renderfarming.net/audio/bbb3d_sunflower_soundtrack_surround.flac
 results in the same kind of corrupted progress-bar as in the original bug report.
Comment 14 Alexander E. Patrakov 2014-11-22 15:01:49 UTC
Created attachment 390054 [details, diff]
Upstream wget patch that fixes the issue
Comment 15 Alexander E. Patrakov 2014-11-22 15:13:51 UTC
It turns out that the assertion is wrong and can be triggered. See https://lists.gnu.org/archive/html/bug-wget/2014-11/msg00135.html
Comment 16 Alexander E. Patrakov 2014-11-22 15:30:46 UTC
Created attachment 390056 [details, diff]
Updated patch
Comment 17 SpanKY gentoo-dev 2016-03-02 05:25:25 UTC
i get a segfault with current 1.17.1.  whee!
Comment 18 SpanKY gentoo-dev 2016-03-02 05:34:30 UTC
added a fix from upstream for the segfault:
https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=885437bfa2b7d96e6aa6dc846f0123051496b5d3

so this should work fine w/1.17.1-r1+