- New version
This commit is contained in:
parent
a4a8f7d12f
commit
e575b06cb0
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
powertop-1.11.tar.gz
|
||||
/powertop-1.13.tar.gz
|
||||
/powertop-1.97.tar.bz2
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
--- powertop-1.13/powertop.c.old 2010-12-06 11:32:53.879419977 +0100
|
||||
+++ powertop-1.13/powertop.c 2010-12-06 11:32:55.919868911 +0100
|
||||
@@ -23,6 +23,7 @@
|
||||
*/
|
||||
|
||||
#include <getopt.h>
|
||||
+#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -898,6 +899,7 @@
|
||||
FILE *file = NULL;
|
||||
uint64_t cur_usage[8], cur_duration[8];
|
||||
double wakeups_per_second = 0;
|
||||
+ struct termios tmp_tty;
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain ("powertop", "/usr/share/locale");
|
||||
@@ -968,6 +970,12 @@
|
||||
printf("PowerTOP " VERSION " (C) 2007 - 2010 Intel Corporation \n\n");
|
||||
if (geteuid() != 0)
|
||||
printf(_("PowerTOP needs to be run as root to collect enough information\n"));
|
||||
+
|
||||
+ if (!dump && tcgetattr(STDIN_FILENO, &tmp_tty) == -1) {
|
||||
+ printf(_("No valid input tty for interactive mode, aborting.\n"));
|
||||
+ exit(1);
|
||||
+ }
|
||||
+
|
||||
printf(_("Collecting data for %i seconds \n"), (int)ticktime);
|
||||
printf("\n\n");
|
||||
print_intel_cstates();
|
||||
@ -1,69 +0,0 @@
|
||||
diff -up powertop-1.13/cpufreqstats.c.old powertop-1.13/cpufreqstats.c
|
||||
--- powertop-1.13/cpufreqstats.c.old 2010-11-30 10:46:01.000000000 +0100
|
||||
+++ powertop-1.13/cpufreqstats.c 2010-11-30 10:29:16.944794124 +0100
|
||||
@@ -42,8 +42,9 @@ struct cpufreqdata oldfreqs[16];
|
||||
|
||||
struct cpufreqdata delta[16];
|
||||
|
||||
-char cpufreqstrings[6][80];
|
||||
+char cpufreqstrings[17][80];
|
||||
int topfreq = -1;
|
||||
+int maxfreq = 0;
|
||||
|
||||
static void zap(void)
|
||||
{
|
||||
@@ -107,9 +108,9 @@ void do_cpufreq_stats(void)
|
||||
char line[1024];
|
||||
|
||||
int ret = 0;
|
||||
- int maxfreq = 0;
|
||||
uint64_t total_time = 0;
|
||||
|
||||
+ maxfreq = 0;
|
||||
memcpy(&oldfreqs, &freqs, sizeof(freqs));
|
||||
memset(&cpufreqstrings, 0, sizeof(cpufreqstrings));
|
||||
sprintf(cpufreqstrings[0], _("P-states (frequencies)\n"));
|
||||
@@ -173,9 +174,11 @@ void do_cpufreq_stats(void)
|
||||
if (!total_time)
|
||||
return;
|
||||
|
||||
- qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_count);
|
||||
- if (maxfreq>4)
|
||||
- maxfreq=4;
|
||||
+ if (!dump) {
|
||||
+ qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_count);
|
||||
+ if (maxfreq>4)
|
||||
+ maxfreq=4;
|
||||
+ }
|
||||
qsort(&delta, maxfreq+1, sizeof(struct cpufreqdata), sort_by_freq);
|
||||
|
||||
if (delta[0].frequency == delta[1].frequency + 1000)
|
||||
diff -up powertop-1.13/display.c.old powertop-1.13/display.c
|
||||
--- powertop-1.13/display.c.old 2010-11-30 10:45:56.000000000 +0100
|
||||
+++ powertop-1.13/display.c 2010-11-30 10:51:55.435793964 +0100
|
||||
@@ -177,7 +177,7 @@ void show_cstates(void)
|
||||
}
|
||||
}
|
||||
|
||||
- for (i=0; i<6; i++) {
|
||||
+ for (i=0; i<(dump?maxfreq+2:6); i++) {
|
||||
if (i == topfreq+1)
|
||||
wattron(cstate_window, A_BOLD);
|
||||
else
|
||||
diff -up powertop-1.13/powertop.h.old powertop-1.13/powertop.h
|
||||
--- powertop-1.13/powertop.h.old 2010-11-30 10:45:56.000000000 +0100
|
||||
+++ powertop-1.13/powertop.h 2010-11-30 10:27:58.701793997 +0100
|
||||
@@ -65,11 +65,12 @@ void usb_activity_hint(void);
|
||||
|
||||
|
||||
extern char cstate_lines[12][200];
|
||||
-extern char cpufreqstrings[6][80];
|
||||
+extern char cpufreqstrings[17][80];
|
||||
|
||||
extern int topcstate;
|
||||
extern int topfreq;
|
||||
extern int dump;
|
||||
+extern int maxfreq;
|
||||
|
||||
extern int showpids;
|
||||
|
||||
@ -1,26 +0,0 @@
|
||||
--- powertop-1.13/cpufreq.c.old 2010-12-13 11:01:38.000000000 +0100
|
||||
+++ powertop-1.13/cpufreq.c 2010-12-13 14:36:18.766847905 +0100
|
||||
@@ -98,6 +98,23 @@
|
||||
if (strcmp(gov, line))
|
||||
ret = 1;
|
||||
fclose(file);
|
||||
+
|
||||
+ /* check the scaling driver */
|
||||
+ sprintf(filename, "/sys/devices/system/cpu/%s/cpufreq/scaling_driver", dirent->d_name);
|
||||
+ file = fopen(filename, "r");
|
||||
+ if (!file)
|
||||
+ continue;
|
||||
+ memset(line, 0, 1024);
|
||||
+ if (fgets(line, 1023, file)==NULL) {
|
||||
+ fclose(file);
|
||||
+ continue;
|
||||
+ }
|
||||
+ fclose(file);
|
||||
+ /* if the scaling driver is set to p4-clockmod, do not suggest ondemand and return */
|
||||
+ if (strstr(line, "p4-clockmod")) {
|
||||
+ closedir(dir);
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
@ -1,34 +0,0 @@
|
||||
--- powertop-1.13/powertop.c.orig 2009-12-18 14:28:04.000000000 +0100
|
||||
+++ powertop-1.13/powertop.c 2009-12-18 14:23:38.000000000 +0100
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <time.h>
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
+#include <errno.h>
|
||||
|
||||
#include "powertop.h"
|
||||
|
||||
@@ -867,8 +868,12 @@
|
||||
|
||||
key = select(1, &rfds, NULL, NULL, &tv);
|
||||
|
||||
- if (key && tv.tv_sec) ticktime = ticktime - tv.tv_sec - tv.tv_usec/1000000.0;
|
||||
+ if (key > 0 && tv.tv_sec) ticktime = ticktime - tv.tv_sec - tv.tv_usec/1000000.0;
|
||||
|
||||
+ if (key == -1 && errno != EINTR) {
|
||||
+ perror("select");
|
||||
+ exit(EXIT_FAILURE);
|
||||
+ }
|
||||
|
||||
stop_timerstats();
|
||||
clear_lines();
|
||||
@@ -1035,7 +1040,7 @@
|
||||
else
|
||||
ticktime = 45;
|
||||
|
||||
- if (key) {
|
||||
+ if (key > 0) {
|
||||
char keychar;
|
||||
int keystroke = fgetc(stdin);
|
||||
if (keystroke == EOF)
|
||||
|
||||
@ -1,71 +0,0 @@
|
||||
---
|
||||
display.c | 8 ++++----
|
||||
powertop.h | 5 ++++-
|
||||
suggestions.c | 4 ++--
|
||||
3 files changed, 10 insertions(+), 7 deletions(-)
|
||||
|
||||
--- powertop-1.13.orig/display.c
|
||||
+++ powertop-1.13/display.c
|
||||
@@ -45,7 +45,7 @@ static WINDOW *status_bar_window;
|
||||
|
||||
#define print(win, y, x, fmt, args...) do { if (dump) printf(fmt, ## args); else mvwprintw(win, y, x, fmt, ## args); } while (0)
|
||||
|
||||
-char status_bar_slots[10][40];
|
||||
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
|
||||
|
||||
static void cleanup_curses(void) {
|
||||
endwin();
|
||||
@@ -105,8 +105,8 @@ void setup_windows(void)
|
||||
suggestion_window = subwin(stdscr, 3, maxx, maxy-4, 0);
|
||||
status_bar_window = subwin(stdscr, 1, maxx, maxy-1, 0);
|
||||
|
||||
- strcpy(status_bar_slots[0], _(" Q - Quit "));
|
||||
- strcpy(status_bar_slots[1], _(" R - Refresh "));
|
||||
+ strncpy(status_bar_slots[0], _(" Q - Quit "), STATUS_BAR_SLOTSIZE);
|
||||
+ strncpy(status_bar_slots[1], _(" R - Refresh "), STATUS_BAR_SLOTSIZE);
|
||||
|
||||
werase(stdscr);
|
||||
refresh();
|
||||
@@ -150,7 +150,7 @@ void show_title_bar(void)
|
||||
werase(status_bar_window);
|
||||
|
||||
x = 0;
|
||||
- for (i=0; i<10; i++) {
|
||||
+ for (i=0; i < STATUS_BAR_NR_SLOTS; i++) {
|
||||
if (strlen(status_bar_slots[i])==0)
|
||||
continue;
|
||||
wattron(status_bar_window, A_REVERSE);
|
||||
--- powertop-1.13.orig/powertop.h
|
||||
+++ powertop-1.13/powertop.h
|
||||
@@ -73,7 +73,10 @@ extern int dump;
|
||||
|
||||
extern int showpids;
|
||||
|
||||
-extern char status_bar_slots[10][40];
|
||||
+#define STATUS_BAR_NR_SLOTS 10
|
||||
+#define STATUS_BAR_SLOTSIZE 40
|
||||
+char status_bar_slots[STATUS_BAR_NR_SLOTS][STATUS_BAR_SLOTSIZE + 1];
|
||||
+
|
||||
extern char suggestion_key;
|
||||
extern suggestion_func *suggestion_activate;
|
||||
|
||||
--- powertop-1.13.orig/suggestions.c
|
||||
+++ powertop-1.13/suggestions.c
|
||||
@@ -71,7 +71,7 @@ void reset_suggestions(void)
|
||||
ptr = next;
|
||||
}
|
||||
suggestions = NULL;
|
||||
- strcpy(status_bar_slots[8],"");
|
||||
+ strncpy(status_bar_slots[8],"", STATUS_BAR_SLOTSIZE);
|
||||
total_weight = 0;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void pick_suggestion(void)
|
||||
struct suggestion *ptr;
|
||||
int weight;
|
||||
|
||||
- strcpy(status_bar_slots[8],"");
|
||||
+ strncpy(status_bar_slots[8],"", STATUS_BAR_SLOTSIZE);
|
||||
suggestion_key = 255;
|
||||
suggestion_activate = NULL;
|
||||
|
||||
@ -1,28 +1,15 @@
|
||||
Name: powertop
|
||||
Version: 1.13
|
||||
Release: 3%{?dist}
|
||||
Version: 1.97
|
||||
Release: 1%{?dist}
|
||||
Summary: Power consumption monitor
|
||||
|
||||
Group: Applications/System
|
||||
License: GPLv2
|
||||
URL: http://www.lesswatts.org/
|
||||
Source0: http://www.lesswatts.org/projects/%{name}/download/%{name}-%{version}.tar.gz
|
||||
#Source0: http://www.lesswatts.org/projects/%{name}/download/%{name}-%{version}.tar.gz
|
||||
Source0: http://www.kernel.org/pub/linux/status/powertop/%{name}-%{version}.tar.bz2
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||
# Explicit requires for lspci (#653560)
|
||||
Requires: pciutils
|
||||
BuildRequires: gettext
|
||||
BuildRequires: ncurses-devel
|
||||
|
||||
# Fix for sigwinch handling (#644800)
|
||||
Patch0: powertop-1.13-sigwinch.patch
|
||||
# strncpy is safer than strcpy (#246796)
|
||||
Patch1: powertop-1.13-strncpy.patch
|
||||
# Print all P-states in dump mode (accepted by upstream)
|
||||
Patch2: powertop-1.13-dump-all-pstates.patch
|
||||
# Output error in interactive mode if there is no tty (#657212)
|
||||
Patch3: powertop-1.13-checktty.patch
|
||||
# Do not suggest ondemand when p4-clockmod scaling driver is used (#497167)
|
||||
Patch4: powertop-1.13-p4-clockmod-no-ondemand.patch
|
||||
BuildRequires: gettext, ncurses-devel, pciutils-devel, zlib-devel, libnl-devel
|
||||
|
||||
%description
|
||||
PowerTOP is a tool that finds the software component(s) that make your
|
||||
@ -30,31 +17,34 @@ computer use more power than necessary while it is idle.
|
||||
|
||||
%prep
|
||||
%setup -q
|
||||
%patch0 -p1 -b .sigwinch
|
||||
%patch1 -p1 -b .strncpy
|
||||
%patch2 -p1 -b .dump-all-pstates
|
||||
%patch3 -p1 -b .checktty
|
||||
%patch4 -p1 -b .p4-clockmod-no-ondemand
|
||||
# nl.po is not yet ready and blocks the build process, so remove it.
|
||||
rm -f po/nl.po
|
||||
|
||||
%build
|
||||
export CFLAGS="$RPM_OPT_FLAGS"
|
||||
make %{?_smp_mflags}
|
||||
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS"
|
||||
|
||||
%install
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
make install DESTDIR=$RPM_BUILD_ROOT
|
||||
%find_lang %{name}
|
||||
# No translation yet.
|
||||
#%find_lang %{name}
|
||||
|
||||
%clean
|
||||
rm -rf $RPM_BUILD_ROOT
|
||||
|
||||
%files -f %{name}.lang
|
||||
# No translation yet.
|
||||
#%files -f %{name}.lang
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc COPYING README
|
||||
%{_bindir}/powertop
|
||||
%{_mandir}/man8/powertop.8*
|
||||
# No man page yet.
|
||||
#%{_mandir}/man8/powertop.8*
|
||||
|
||||
%changelog
|
||||
* Tue Feb 15 2011 Jaroslav Škarvada <jskarvad@redhat.com> - 1.97-1
|
||||
- New version
|
||||
|
||||
* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.13-3
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user