Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Status lines, emerge and tmux
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
wpettersson
n00b
n00b


Joined: 04 Jun 2014
Posts: 16

PostPosted: Sun Mar 01, 2015 9:51 am    Post subject: Status lines, emerge and tmux Reply with quote

First disclaimer, I don't know the technical terms/reasons behind what I will call "soft" and "hard" status lines. I just use those terms as eix uses the term "soft status line".

I run tmux, and many things (including emerge) inside it. tmux has the ability to automatically rename windows. That is, the windows are renamed by tmux to be the name of the last command run, or the current working directory if at a shell prompt. I want to be clear, this is the "window_name" setting, also referred to as #W, and this is something handled by tmux and not by all these various programs setting the xterm title.

When I run eix --sync the portage tree is sync'ed. Once the sync'ing is finished, eix sets the "soft status line" to be "eix: Finished". By "soft status line", I mean eix printf's
Code:
\033k%s\033\\
where "%s" is replaced with "eix: Finished". I can't find any specifics on where this escape code is defined, it doesn't seem to be part of ANSI but I could be wrong. Also worth pointing out that it's not the same escape code that sets the xterm title, which is
Code:
\033]0;%s\007


The point is that the automatic window renaming in tmux spots this "soft status line" and updates the "window name" to contain this. I want to be able to track the progress of an emerge in this manner.

I'm sure some people are already thinking "Just use the xterm title that emerge sets after each package is compiled/installed/etc", which works (use the pane_title #T option in tmux as the window name). This works, in that emerge now does give me progress updates in my tmux status line. However, this also disables the automatic renaming that tmux does. I want to have the best of both worlds.

I think the best way to get what I want is to make emerge also output the "status" to the "soft status line". This involves changes to portage/pym/portage/output.py, in the xtermTitle function. I'd have to check for "soft status capability" by looking for terminals that begin with "screen", and then printing the appropriate escape codes if detected.

Does anyone have tmux+emerge working in the way I desire (with automatic window renaming _and_ emerge status shown)? Am I going about this completely the wrong way? Is there a smarter way? Is this something others are interested in? Should I post a bug (enhancement) report?
Back to top
View user's profile Send private message
wpettersson
n00b
n00b


Joined: 04 Jun 2014
Posts: 16

PostPosted: Mon Mar 02, 2015 6:24 am    Post subject: Reply with quote

Ok, I've partially got this running, with fewer hacks. I used /etc/portage/bashrc to call a modified genlop-status script to set the soft status line. And it magically works as expected, which does somewhat surprise me. I see "1|Merging media-libs/mesa-10.3.7-r1 (4/39)" as the emerge pane title. Code/diffs follow, first some rambling.

I'm now pondering in supporting more phases (configure, pre_inst etc.) but at the same time I don't know how effective that is. Given that I'm also using genlop, I'm tempted to replace the (3/39) part of the status with something like (15%, 3hr) where 3hr indicates how long remaining (estimated). Or maybe having both bits of information. And possibly stripping out version information. I don't care what version of mesa is being installed, I generally just want to know what package is being installed and/or how long until it's done.

/etc/portage/bashrc
Code:
#!/usr/bin/env bash

if [ "${EBUILD_PHASE}" == "compile" ] ; then
  /usr/local/bin/genlop-status -c
fi


genlop diff follows
Code:
--- /usr/bin/genlop   2015-03-01 21:04:29.000000000 +1000
+++ /usr/local/bin/genlop-status   2015-03-02 13:40:40.980384223 +1000
@@ -743,43 +743,7 @@
       }
       $e_end = CORE::time();
       &gtime($e_end - $e_start);
-      print "\n Currently merging $e_curmerge out of $e_lastmerge\n";
-      print colored("\n \*$e_current\n\n", $COLORS{'blue'});
-      print "       current merge time: ";
-      $current_found = undef;
-      &print_gtime();
-      $current_found = 1;
-      print "\n";
-      print "       ETA: ";
-
-      if (!$e_count && $online_query)
-      {
-
-         #query gentoo.linuxhowtos.org
-         $tm_secondi = lhtoquery($ebuild_arg, \$e_count);
-         $e_count = 1;
-      }
-
-      if ($e_count && $e_start)
-      {
-         &gtime(($tm_secondi / $e_count) - ($e_end - $e_start));
-         if (($e_end - $e_start) >= ($tm_secondi / $e_count))
-         {
-            print colored("any time now.\n", $COLORS{'green'});
-         }
-         else
-         {
-            &print_gtime();
-            print "\n";
-         }
-      }
-      else
-      {
-         print color 'bold red';
-         print "unknown.";
-         print color 'reset';
-         print "\n";
-      }
+      print "\033kMerging$e_current($e_curmerge/$e_lastmerge)\033\\";
    }
    exit;
 }
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Mon Mar 02, 2015 6:31 am    Post subject: Re: Status lines, emerge and tmux Reply with quote

wpettersson wrote:
First disclaimer, I don't know the technical terms/reasons behind what I will call "soft" and "hard" status lines. I just use those terms as eix uses the term "soft status line".

These names are a misnomer: Hardstatus line is ok (it refers to the ability to display an information line on some terminals), but softstatus line should more correctly be "windows title". However, for compatbility reasons, this will not change anymore in eix. Note that in screen (in contrast to tmux) the "opposite" information is used when you configure a hard status line.

Concerning genlop: genlop is a nice tool, but rather slow compared to qlop. Since in the portage-bashrc you know the package name, you actually do not need "-c".
Perhaps a corresponding possibility to print this data in the beginning will be added to portage-bashrc-mv from the mv ovleray in some days/weeks.

Unfortunately, I know neither a way to override portage's changing of the status line (or was it windows title?), nor to get the list of remaining packages in portage-bashrc: I suppose to get a "total" progress you have to patch portage itself.
Back to top
View user's profile Send private message
wpettersson
n00b
n00b


Joined: 04 Jun 2014
Posts: 16

PostPosted: Mon Mar 02, 2015 6:52 am    Post subject: Re: Status lines, emerge and tmux Reply with quote

mv wrote:
wpettersson wrote:
First disclaimer, I don't know the technical terms/reasons behind what I will call "soft" and "hard" status lines. I just use those terms as eix uses the term "soft status line".

These names are a misnomer: Hardstatus line is ok (it refers to the ability to display an information line on some terminals), but softstatus line should more correctly be "windows title". However, for compatbility reasons, this will not change anymore in eix. Note that in screen (in contrast to tmux) the "opposite" information is used when you configure a hard status line.

Yeah even those names I had trouble working out.

mv wrote:
Concerning genlop: genlop is a nice tool, but rather slow compared to qlop. Since in the portage-bashrc you know the package name, you actually do not need "-c".
Perhaps a corresponding possibility to print this data in the beginning will be added to portage-bashrc-mv from the mv ovleray in some days/weeks.

I went with genlop because it was written in perl (easy to modify) and prints the package counts by default (i.e. 13/39) for big emerges. I've had a look at qlop, and it does the timing thing fine, but I can't seem to spot if it tracks how many packages are in the current "emerge" and how many of those are completed. I realise genlop is slow, but since it's called one time per package emerged and (on my system at least) runs in under a second performance wasn't a big issue. I'd definitely like to see something better.

mv wrote:
Unfortunately, I know neither a way to override portage's changing of the status line (or was it windows title?), nor to get the list of remaining packages in portage-bashrc: I suppose to get a "total" progress you have to patch portage itself.


I think the "best" bet is to create an extra hook-phase accessible via portage-bashrc, which would also pass on all relevant details (number of packages merged/remaining/total, current package name). Then the user could set up whatever command they want, be it a tmux status line thing for me, or maybe libnotify based for desktop users. However, this will all depend on patching portage and that's a fairly big step compared to my few lines of edits here.
Back to top
View user's profile Send private message
mv
Watchman
Watchman


Joined: 20 Apr 2005
Posts: 6747

PostPosted: Mon Mar 02, 2015 9:45 pm    Post subject: Reply with quote

app-portage/portage-bashrc-mv from the mv overlay contains now a module which displays the average time and(!) the package count, using "qlop", "title" (from app-shells/runtitle, also available on the mv overaly), and "manual" parsing of emerge.log.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum