summaryrefslogtreecommitdiff
blob: 98b6b3f094191e4804ed7be69bb415c7addba48b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
--- genlop-0.30.8/genlop	2007-10-04 10:15:07.000000000 +0200
+++ plop-0.2.3/plop	2008-07-15 20:57:14.000000000 +0200
@@ -17,16 +17,17 @@
 #    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #
 
-use strict;
-use warnings;
+#use strict;
+#use warnings;
+#use diagnostics;
 use POSIX;
 use Term::ANSIColor;
 use Date::Manip;
 use LWP::Simple;
 use File::Basename;
 
-my $version  = "0.30.7";
-my @logfiles = ("/var/log/emerge.log");
+my $version  = "0.2.3";
+my @logfiles = ("/var/log/paludis.log");
 my %COLORS   = (
     'blue'  => 'bold blue',
     'green' => 'bold green',
@@ -109,9 +110,9 @@
 sub open_file
 {
     my ($file, $fh) = @_;
-    if ($file eq "/var/log/emerge.log" && !-r $file)
+    if ($file eq "/var/log/paludis.log" && !-r $file)
     {
-        print "$progname: cannot open " . $file . " for reading\n" . "maybe you are not a member of the portage group ?\n" . "try genlop -h for help\n";
+        print "$progname: cannot open " . $file . " for reading\n" . "maybe you are not a member of the portage group ?\n" . "try plop -h for help\n";
         exit 1;
     }
     if (-T $file)
@@ -334,24 +335,24 @@
 # provides help information
 sub help ()
 {
-    print "Usage: ", colored("genlop ", $COLORS{'blue'}), "[", colored("options", $COLORS{'green'}), "] [", colored("-f ", $COLORS{'green'}), "logfile] [",
+    print "Usage: ", colored(basename($0)." ", $COLORS{'blue'}), "[", colored("options", $COLORS{'green'}), "] [", colored("-f ", $COLORS{'green'}), "logfile] [",
       colored("category/package", $COLORS{'green'}), "]\n\n", colored("Options:\n", $COLORS{'green'}), colored("  -c   ", $COLORS{'green'}),
       "display the currently compiling packages (if any)\n", colored("  -e   ", $COLORS{'green'}) . "display package history; default if any option is used.\n",
-      colored("  -f   ", $COLORS{'green'}), "read emerge log information from \"logfile\" instead of ", $logfiles[0], "\n",
+      colored("  -f   ", $COLORS{'green'}), "read paludis log information from \"logfile\" instead of ", $logfiles[0], "\n",
       colored("  -h   ", $COLORS{'green'}), "print this help\n", colored("  -i   ", $COLORS{'green'}),
       "extra infos for the selected package (build specific USE ", "and CFLAGS\n       variables, average build time, etc)\n",
       colored("  -g   ", $COLORS{'green'}), "display GMT/UTC, not localized time.\n", colored("  -l   ", $COLORS{'green'}), "show full merge history.\n",
       colored("  -n   ", $COLORS{'green'}), "no color in output\n", colored("  -p   ", $COLORS{'green'}),
-      "estimate build time from a piped \"emerge -p\" output\n",              colored("  -q   ", $COLORS{'green'}),
+      "estimate build time from a piped \"paludis -p\" output\n",              colored("  -q   ", $COLORS{'green'}),
       "query gentoo.linuxhowtos.org database if no local emerge was found\n", colored("  -r   ", $COLORS{'green'}),
       "search for portage tree sync/rsync history.\n",                        colored("  -s   ", $COLORS{'green'}),
       "use (case insensitive) regular expressions to match package names\n",  colored("  -S   ", $COLORS{'green'}),
       "use case sensitive regular expressions to match package names\n",      colored("  -t   ", $COLORS{'green'}),
       "calculate merge time for the specific package(s).\n",                  colored("  -u   ", $COLORS{'green'}), "show when packages have been unmerged.\n",
-      colored("  -v   ", $COLORS{'green'}), "display genlop version and exit.\n\n", colored("  --date datestring1", $COLORS{'green'}), " [",
+      colored("  -v   ", $COLORS{'green'}), "display plop version and exit.\n\n", colored("  --date datestring1", $COLORS{'green'}), " [",
       colored(" --date datestring2", $COLORS{'green'}), "]  only shows results between datestring1\n",
-      "       and datestring2. datestring2 dafaults to \"now\" if not", " explicitly set.\n", "       (e.g. genlop --list --date 3 days ago)\n",
-      "\nThis program is licensed under the GPL v2. See COPYING.\n", "For further info about genlop please read the man page.\n";
+      "       and datestring2. datestring2 dafaults to \"now\" if not", " explicitly set.\n", "       (e.g. plop --list --date 3 days ago)\n",
+      "\nThis program is licensed under the GPL v2. See COPYING.\n", "For further info about plop please read the man page.\n";
     exit 0;
 }
 
@@ -432,7 +433,7 @@
         }
         else
         {
-            $regexp = qr/(.*)(-[0-9]{1,7}.*?)/i;
+            $regexp = qr/(.*)(-(?:[0-9]{1,7}|scm).*?)/i;
         }
         return "$regexp";
     }
@@ -452,8 +453,8 @@
         {
             $regexp =
               $ssearch_found
-              ? qr/(.*$arg.*?)(-[0-9]{1,7}.*?)/
-              : qr/(.*$arg.*?)(-[0-9]{1,7}.*?)/i;
+              ? qr/(.*$arg.*?)(-(?:[0-9]{1,7}|scm).*?)/
+              : qr/(.*$arg.*?)(-(?:[0-9]{1,7}|scm).*?)/i;
         }
         return "$regexp";
     }
@@ -464,8 +465,8 @@
         $category = $arg;
         $regexp =
           $ssearch_found
-          ? qr/($category.*?)(-[0-9]{1,7}.*?)/
-          : qr/($category.*?)(-[0-9]{1,7}.*?)/i;
+          ? qr/($category.*?)(-(?:[0-9]{1,7}|scm).*?)/
+          : qr/($category.*?)(-(?:[0-9]{1,7}|scm).*?)/i;
         return "$regexp";
     }
     @list = split(/\//, $arg);
@@ -475,7 +476,7 @@
         $category = $list[0];
         $ebuild   = $list[1];
         @list     = ();
-        @list     = split(/(-[0-9]{1,7})/, $ebuild);
+        @list     = split(/(-(?:[0-9]{1,7}|scm))/, $ebuild);
         if ($list[1])
         {
             $ebuild = $list[0];
@@ -489,14 +490,14 @@
         }
         $regexp =
           $ssearch_found
-          ? qr!($category\/$ebuild)(-[0-9]{1,7}.*?)!
-          : qr!($category\/$ebuild)(-[0-9]{1,7}.*?)!i;
+          ? qr!($category\/$ebuild)(-(?:[0-9]{1,7}|scm).*?)!
+          : qr!($category\/$ebuild)(-(?:[0-9]{1,7}|scm).*?)!i;
         return "$regexp";
     }
     $regexp =
       $ssearch_found
-      ? qr!(.*?/$ebuild)(-[0-9]{1,7}.*?)!
-      : qr!(.*?/$ebuild)(-[0-9]{1,7}.*?)!i;
+      ? qr!(.*?/$ebuild)(-(?:[0-9]{1,7}|scm).*?)!
+      : qr!(.*?/$ebuild)(-(?:[0-9]{1,7}|scm).*?)!i;
     return "$regexp";
 }
 
@@ -558,10 +559,10 @@
         print "These are the pretended packages:";
         print " (this may take a while; wait...)\n\n";
 
-        # open STDIN; that's why emerge -p foo is piped to a genlop -p
+        # open STDIN; that's why emerge -p foo is piped to a plop -p
         while (<STDIN>)
         {
-            if ($_ =~ m/^\[e.*\] (.*?)\/(.*?)(\-[0-9])/)
+            if ($_ =~ m/^\* (.*?)\/(.*?)(\-(?:[0-9]|scm))/)
             {
                 push @targets, $2;
                 print;
@@ -580,11 +581,11 @@
                 open_file($logfile, \$handle);
                 foreach (<$handle>)
                 {
-                    if (m/^(.*?)\:  \>\>\> emerge.*?\/$ebuild_arg-[0-9].*/)
+                    if (m/^(.*?)\: starting install of package .*?\/$ebuild_arg-(?:[0-9]|scm).*?::/)
                     {
                         $e_start = $1;
                     }
-                    if (m/^(.*?)\:  ::: completed .*?\) .*\/$ebuild_arg-[0-9].* to \//)
+                    if (m/^(.*?)\: finished install of package .*?\/$ebuild_arg-(?:[0-9]|scm).*?::/)
                     {
                         $e_end = $1;
                         $tm_secondi += ($e_end - $e_start);
@@ -666,11 +667,12 @@
     # not check for sanity and have users check their FEATURES instead.
     my @targets      = ();
     my @sandbox_pids = ();
-    my @sandbox_procs = qx{ps ax -o pid,args | tail -n +2 | sed -e's/^ *//' | grep ' sandbox ' | grep -v ' grep '};
-    my ($e_curmerge, $e_lastmerge);
+    my @sandbox_procs = qx{ps ax -w -o pid,args|grep '[s]andbox'}; # [s] so you don't need this ugly grep -v grep, also the use of tail and such are foobar
+    my $r_start = 0;
+    my ($r_curmerge, $r_lastmerge, $r_current);
     foreach (@sandbox_procs)
     {
-        if (m/^(.*?) \[(.*?)\-[0-9].*?\]/)
+        if (m/^(.*?) sandbox .*? .*\/(.*?)\-(?:[0-9]|scm).*?\.(ebuild|kdebuild-1) .*/)
         {
             push @sandbox_pids, $1;
             push @targets, $2;
@@ -692,7 +694,6 @@
     }
     foreach my $ebuild_arg (@targets)
     {
-		my $e_current;
         $ebuild_arg =~ s/(\+)/\\$1/g;
         foreach my $logfile (@logfiles)
         {
@@ -700,14 +701,17 @@
             open_file($logfile, \$handle);
             foreach (<$handle>)
             {
-                if (m/^(.*?)\:  \>\>\> emerge \((.*?) of (.*?)\)(.*?\/$ebuild_arg-[0-9].*?)to \//)
+                if (m/^(.*?)\: starting install of package (.*?\/$ebuild_arg-(?:[0-9]|scm).*?::.*?) \((.*?) of (.*?)\)/)
                 {
+                  if ($1 > $r_start) {
+                    $r_start = $1;
+                    $r_curmerge  = $3;
+                    $r_lastmerge = $4;
+                    $r_current   = $2;
+                  }
                     $e_start     = $1;
-                    $e_curmerge  = $2;
-                    $e_lastmerge = $3;
-                    $e_current   = $4;
                 }
-                if (m/^(.*?)\:  ::: completed .*?\) .*\/$ebuild_arg-[0-9].* to \//)
+                if (m/^(.*?)\: finished install of package .*\/$ebuild_arg-(?:[0-9]|scm).*::.* \(.*\)/)
                 {
                     $e_end = $1;
                     $e_count++;
@@ -717,9 +721,9 @@
             }
         }
         $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'});
+        &gtime($e_end - $r_start);
+        print "\n Currently merging $r_curmerge out of $r_lastmerge\n";
+        print colored("\n \*$r_current\n\n", $COLORS{'blue'});
         print "       current merge time: ";
         $current_found = undef;
         &print_gtime();
@@ -735,10 +739,10 @@
             $e_count = 1;
         }
 
-        if ($e_count && $e_start)
+        if ($e_count && $r_start)
         {
-            &gtime(($tm_secondi / $e_count) - ($e_end - $e_start));
-            if (($e_end - $e_start) >= ($tm_secondi / $e_count))
+            &gtime(($tm_secondi / $e_count) - ($e_end - $r_start));
+            if (($e_end - $r_start) >= ($tm_secondi / $e_count))
             {
                 print colored("any time now.\n", $COLORS{'green'});
             }
@@ -808,7 +812,7 @@
                 #$package =~ s/(\+)/\\$1/g;
                 my $tmp_package = $package;
                 $tmp_package =~ s/\+/\\+/g;
-                if ("$categoria/$package_dir" =~ m/$tmp_package\-[0-9].*/)
+                if ("$categoria/$package_dir" =~ m/$tmp_package\-(?:[0-9]|scm).*/)
                 {
                     $info_ok = 1;
                     print colored("\n   * $categoria/$package_dir\n", $COLORS{'blue'});
@@ -821,8 +825,8 @@
                         open_file($logfile, \$handle);
                         foreach (<$handle>)
                         {
-                            my $pattern = gen_regexp("$categoria/$package_dir");
-                            if (m/^([0-9]{10})\:  ::: completed .*?\) $pattern to \//)
+													my $pattern = gen_regexp("$categoria/$package_dir");
+                            if (m/^([0-9]{10})\: finished install of package ${pattern}:.*::/)
                             {
                                 if ($gmt_found)
                                 {
@@ -851,13 +855,10 @@
 
                         # we search into the installed ebuild for USE flags available
                         # and store them in @potential_use.
-                        open(pkg_ebuild, "$db_pkg_dir/$1.ebuild") || return;
+                        open(pkg_ebuild, "$db_pkg_dir/IUSE") || return;
                         while (<pkg_ebuild>)
                         {
-                            if ($_ =~ m/^IUSE=\"(\$\{IUSE\} )?(.*)"/g)
-                            {
-                                @potential_use = split(/\ /, $2);
-                            }
+                                @potential_use = split(/\ /, $_);
                         }
                     }
 
@@ -917,7 +918,7 @@
 		my $handle;
 		open_file($_, \$handle);
 		while(<$handle>) {
-			if ($_ =~ m/^(.*?)\: \=\=\= Sync completed with/) {
+			if ($_ =~ m/^(.*?)\: finished sync of repository gentoo/) {
 				if ($date_found) {
 					if (datecompare($1) <= 0) {
 						next;
@@ -952,7 +953,10 @@
 help() if ($help_found);
 if ($version_found)
 {
-    print "genlop $version, maintained by Michael Cummings <mcummings\@gentoo.org>\n"
+    print "plop $version, patched genlop 0.30.8 for use with paludis\n"
+		. "patched by Tobias Hommel <software\@genoetigt.de>\n"
+		. "original genlop info:\n"
+		. "genlop, maintained by Michael Cummings <mcummings\@gentoo.org>\n"
 	  . "original code by Giorgio Mandolfo and Antonio Dolcetta\n"
 	  . "Please file any bugs found online at:\n"
 	  . "https://bugs.gentoo.org\n"
@@ -1015,15 +1019,15 @@
             if ($current_found) { &current; }
             if ($time_found or $info_found)
             {
-                if ($_ =~ m/^([0-9]{10})\:  \>\>\> emerge .*?\) $pattern/)
+                if ($_ =~ m/^([0-9]{10})\: starting install of package ${pattern}::/)
                 {
                     $e_start     = $1;
                     $info_target = $2;
                 }
             }
-            if ($_ =~ m/^([0-9]{10})\:  ::: completed .*?\) $pattern to \//)
+            if ($_ =~ m/^([0-9]{10})\: finished install of package ${pattern}::/)
             {
-				my $e_date;
+                my $e_date;
                 if ($gmt_found)
                 {
                     $e_date = scalar gmtime "$1";
@@ -1093,7 +1097,7 @@
             if ($unmerge_found or $info_found)
             {
                 $pattern = gen_regexp($ebuild_arg);
-                if (m/^([0-9]{10})\:  \>\>\> unmerge success: ($pattern.*)/g)
+                if (m/^([0-9]{10})\: finished uninstall of package ($pattern)::/g)
                 {
                     my $u_date = scalar localtime "$1";
                     if ($unmerge_found)