Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 45593 - laptop mode init script for Gentoo Linux
Summary: laptop mode init script for Gentoo Linux
Status: VERIFIED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: x86 Linux
: High enhancement
Assignee: Mobile Herd (OBSOLETE)
URL:
Whiteboard:
Keywords: InVCS
: 73308 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-03-24 05:15 UTC by Johannes Ballé
Modified: 2005-04-13 02:19 UTC (History)
21 users (show)

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


Attachments
The init script (laptop_mode.tar.gz,1.49 KB, application/octet-stream)
2004-03-24 05:16 UTC, Johannes Ballé
Details
The patch which I used (laptop-mode-for-2.6.3.patch,22.37 KB, patch)
2004-03-24 05:18 UTC, Johannes Ballé
Details | Diff
laptop-mode-20040403.ebuild (laptop-mode-20040403.ebuild,861 bytes, text/plain)
2004-05-26 08:40 UTC, Dennis Nienhüser (RETIRED)
Details
files/laptop-mode.conf (laptop-mode.conf,1.11 KB, text/plain)
2004-05-26 08:41 UTC, Dennis Nienhüser (RETIRED)
Details
files/laptop-mode.init (laptop-mode.init,8.11 KB, text/plain)
2004-05-26 08:45 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode.conf (laptop-mode.conf,1.38 KB, text/plain)
2004-07-02 05:54 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode.init (laptop-mode.init,9.00 KB, text/plain)
2004-07-02 05:55 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode.conf (laptop-mode.conf,2.53 KB, text/plain)
2004-09-06 02:56 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode.init (laptop-mode.init,11.25 KB, text/plain)
2004-09-06 02:59 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode-tools.package.tar.gz (laptop-mode-tools.package.tar.gz,1.55 KB, application/octet-stream)
2004-09-12 19:01 UTC, Adrian Almenar
Details
laptop-mode-tools-1.04.ebuild (laptop-mode-tools-1.04.ebuild,2.13 KB, text/plain)
2004-10-07 09:34 UTC, Dennis Nienhüser (RETIRED)
Details
files/laptop-mode.init (laptop-mode.init,692 bytes, text/plain)
2004-10-07 09:35 UTC, Dennis Nienhüser (RETIRED)
Details
laptop-mode-tools-1.04.ebuild (alternative version) (laptop-mode-tools-1.04.ebuild,1.44 KB, text/plain)
2005-01-18 18:08 UTC, TGL
Details
laptop-mode-tools-1.04.ebuild (merged) (laptop-mode-tools-1.04.ebuild,2.14 KB, text/plain)
2005-02-18 07:54 UTC, Christian Ludwig
Details
laptop-mode.init (laptop-mode.init,882 bytes, text/plain)
2005-02-18 07:55 UTC, Christian Ludwig
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Ballé 2004-03-24 05:15:16 UTC
Hello,

I put together this init script, which initializes the kernel laptop_mode. I used the init script which is provided with the laptop_mode patch for the linux kernel 2.6.3, and gentooized it.

The script needs hdparm installed, linux kernel 2.4 or 2.6 with the laptop_mode patch applied (I think for the later 2.4 kernels it is official), and the directory /var/lib/laptop_mode created.

For my notebook it works like a charm.

Maybe someone would like to make an ebuild for it.


Reproducible: Always
Steps to Reproduce:
1.
2.
3.



Expected Results:
Comment 1 Johannes Ballé 2004-03-24 05:16:25 UTC
Created attachment 27911 [details]
The init script
Comment 2 Johannes Ballé 2004-03-24 05:18:12 UTC
Created attachment 27912 [details, diff]
The patch which I used
Comment 3 SpanKY gentoo-dev 2004-03-28 00:12:18 UTC
this is more than just an init script, it's also a kernel patch
Comment 4 Johannes Ballé 2004-03-28 02:58:22 UTC
> this is more than just an init script, it's also a kernel patch

actually, since kernel 2.4.something, the patch became part of the official kernel. I forgot in which release it was included first. a kernel patch is therefore only required for the 2.6 series and for older 2.4 kernels. as far as i know, the patch is expected to be included in one of the coming 2.6 releases, too.

so the development of this script may be a little ahead of time, but the functionality it provides is definitely worth it (at least for mobile users)
Comment 5 Dennis Nienhüser (RETIRED) gentoo-dev 2004-05-17 15:11:24 UTC
FYI: laptop mode got integrated into 2.6.6
http://kerneltrap.org/node/view/3070?PHPSESSID=f3d088276600ec6e5949261fd5f680be
Comment 6 Dennis Nienhüser (RETIRED) gentoo-dev 2004-05-26 08:40:06 UTC
Created attachment 32076 [details]
laptop-mode-20040403.ebuild

Ebuild to install the init script
Comment 7 Dennis Nienhüser (RETIRED) gentoo-dev 2004-05-26 08:41:09 UTC
Created attachment 32077 [details]
files/laptop-mode.conf

/etc/conf.d/laptop-mode
Comment 8 Dennis Nienhüser (RETIRED) gentoo-dev 2004-05-26 08:45:53 UTC
Created attachment 32078 [details]
files/laptop-mode.init

/etc/init.d/laptop-mode

I updated Johannes work on the init script 
(integrated the changes that come with kernel-2.6.6_rc1).

It would be nice to have this in the Portage tree. Quite a few kernel sources
include the laptop_mode patch today, and gentoo-dev-sources will do it with the
2.6.6. release, too.
Comment 9 Dennis Nienhüser (RETIRED) gentoo-dev 2004-06-30 00:33:50 UTC
gentoo-dev-sources-2.6.7 is out for some time now. Does anyone care to integrate laptop-mode into portage? I want to finish bug #52109 now, so if there'll be no progress on this I'll have to find another way.
Comment 10 Dennis Nienhüser (RETIRED) gentoo-dev 2004-07-02 05:54:13 UTC
Created attachment 34630 [details]
laptop-mode.conf

The init script that ships with 2.6.7 contains some minor changes (although the
last changed date was not updated).
Comment 11 Dennis Nienhüser (RETIRED) gentoo-dev 2004-07-02 05:55:04 UTC
Created attachment 34631 [details]
laptop-mode.init

as above
Comment 12 Alan Schmitt 2004-07-02 06:10:01 UTC
I would like to try the ebuild by putting it in my overlay dir, but I don't know where it should go. Is sys-apps/ the correct place? And does it matter?
Comment 13 johnny 2004-07-06 23:54:57 UTC
i personally put it in app-laptop
Comment 14 Peter Johanson (RETIRED) gentoo-dev 2004-07-20 16:00:18 UTC
Okay, CCing the base-system guys. This script itself is relatively ugly, and has a few pretty nasty hacks. What's your take on this? I'm wary of having an ebuild just for one script like this. Can we integrate either this or something like this into base-layout maybe? Please either comment here, or catch me on IRC.
Comment 15 Dennis Nienhüser (RETIRED) gentoo-dev 2004-07-27 17:14:55 UTC
*bump* I'm still trying to reach "FIXED" or "WONTFIX" :)
Does the init script need to be rewritten, or do parts of it have to be changed (like remounting /)?
Comment 16 Aron Griffis (RETIRED) gentoo-dev 2004-07-27 19:51:11 UTC
I don't see baselayout as being an appropriate target for this.  Single-script ebuilds are just fine, though it would be better if it could be grouped with some other laptop stuff.  sys-apps/acpi comes to mind since it makes more sense to have this script triggered by AC power events than an init script.

I looked through the script.  I agree that it looks pretty shaky, though I don't know that there's actually anything *wrong* with it.  A bunch of the sed stuff is overdone and could be accomplished with a few bash expressions (or at least a single invocation of sed!)
Comment 17 Dennis Nienhüser (RETIRED) gentoo-dev 2004-07-29 13:39:33 UTC
Thanks for looking through it. sys-apps/acpi is a good candidate for a
dependency (as it makes little sense without it). IMHO the init-script 
style is fine. It can easily be placed in a battery runlevel this way 
(and let acpi events switch runlevels).
Comment 18 Dennis Nienhüser (RETIRED) gentoo-dev 2004-08-02 14:44:31 UTC
> I don't see baselayout as being an appropriate target for this.
Who is an appropriate target then? (aka bump ;-)
Comment 19 Priit Laes (IRC: plaes) 2004-08-03 02:39:28 UTC
What about this? 

http://www.xs4all.nl/~bsamwel/laptop_mode/tools/index.html
Comment 20 Dennis Nienhüser (RETIRED) gentoo-dev 2004-08-03 09:34:40 UTC
The /usr/sbin/laptop-mode script (actually a modified version of the init script) could be extracted from this.
Comment 21 Eli Ben-Shoshan 2004-08-09 18:14:27 UTC
Just tried it on my Dell D600. Haven't done any battery testing but I have confirmed that it does at least return the values in /proc back to the kernel defaults. This could be very useful in the mainline tree. Is there really any reason why it is not in there anymore?
Comment 22 Bret Towe 2004-08-14 16:47:30 UTC
i recently took the latest laptop mode init script from linux kernel and 
make a crappy init script out of it and made it so it loads right after localmount
now i dont think my ver is any better than whats here but i would like to see
the script included in baselayout  the script is good for desktop computers
also on desktop just dont enable the hdparm sleeping and it helps your compiles
as it prevents a bunch of small writes all the time this of course would help
on slower IO systems even more i dont have numbers for you but 
genlop -t somepackage and laptop mode being enabled and disabled can show you

Comment 23 Dennis Nienhüser (RETIRED) gentoo-dev 2004-09-06 02:56:00 UTC
Created attachment 39036 [details]
laptop-mode.conf
Comment 24 Dennis Nienhüser (RETIRED) gentoo-dev 2004-09-06 02:59:12 UTC
Created attachment 39037 [details]
laptop-mode.init

Here is the one from kernel 2.6.8.1, dated 2004-06-10
There are some code improvements and new features added. 
Please test and post if it works.
Comment 25 Adrian Almenar 2004-09-12 19:01:23 UTC
Created attachment 39477 [details]
laptop-mode-tools.package.tar.gz

This is a new full ebuild for laptop-mode-tools. It can go inside app-laptop.

Latexer, Here is what we talked about.
Comment 26 Dennis Nienhüser (RETIRED) gentoo-dev 2004-09-13 02:45:40 UTC
Thanks Adrian for attaching this.
I played around with it the last hour, but there are some questionable things left.
First, the ebuild has some problems (unpack is never called, chmod too early, init file needs some clean-up as well) but that can be fixed easily.
What I really don't like is all that file creation in /etc/acpi (or /etc/apm). While CONFIG_PROTECT will prevent damage, it will still be messy if someone wants to merge the files.
Comment 27 Adrian Almenar 2004-09-13 11:49:58 UTC
Yeah i know the ebuild can be improved a lot, but its 1000 times easier to maintain if the original package have big changes or anything than writing everytime a new init script.

The file creation in /etc/apm and /etc/acpi only gets done if the user has in USE apm and/or acpi. Its included in the original package. Also, in the install.sh in the original package, there is a part that talk about installing on Gentoo and it recommends or better it deletes all in /etc/acpi and /etc/apm.

Sorry but packages should be installed the standard way, just adjusting to only the strictly necessary.
Comment 28 Dennis Nienhüser (RETIRED) gentoo-dev 2004-09-13 12:13:03 UTC
> Yeah i know the ebuild can be improved a lot, but its 1000 times easier to
> maintain if the original package have big changes or anything than writing
> everytime a new init script.
Agreed. 

> Sorry but packages should be installed the standard way, just adjusting to
> only the strictly necessary.
That's a weak argument, if any. By not using the install.sh script, you are
violating "the standard way" yourself - which is IMHO really fine as it's a
rather ugly install script.
Maybe we can agree on putting the files somewhere in /usr/share/doc and ask the
user to run ebuild ... config in case he wants /etc/a* to be screwed up, eh
configured. pkg_config() has to be created, of course.
Comment 29 Edwin Shin 2004-10-06 20:04:41 UTC
>> Sorry but packages should be installed the standard way, just adjusting to
>> only the strictly necessary.
> That's a weak argument, if any. 

It's a perfectly reasonable stance to take: stick closely to the standard installer's behavior unless there's good reason to do otherwise.

Changing install locations and behavior can make support a pain. As the author of Product X, if an end-user reports a bug, configuration issue, etc., it potentially makes support that much more onerous if installation and configuration differ from the standard source or binary package I distribute.

This isn't to argue against customized packaging for Gentoo. Hardly. But in this case, I think Adrian is starting from the correct base assumption: stick closely to the default, by default. Then, adapt the ebuild to fit Gentoo requirements and customs.

Don't mean to rant; and certainly not against Dennis--I'm very appreciative of everyone who already worked on this. I was just about to make an ebuild for laptop-mode tools if I didn't find it here (precisely because I think in this case, install.sh is a bit messy).
Comment 30 Dennis Nienhüser (RETIRED) gentoo-dev 2004-10-07 02:39:05 UTC
>>> Sorry but packages should be installed the standard way, just adjusting to
>>> only the strictly necessary.
>> That's a weak argument, if any. 
>It's a perfectly reasonable stance to take: stick closely to the standard
> installer's behavior unless there's good reason to do otherwise.

I guess you got me wrong (looking at the point you chose to cut the quote). Nevertheless, I think we all agree on your point and don't need a general discussion here. If you're going to fix the ebuild that would be really awesome, if not I'm going to do it in the next days (yeah! finally I'll have more time soon)
Comment 31 Dennis Nienhüser (RETIRED) gentoo-dev 2004-10-07 09:34:08 UTC
Created attachment 41295 [details]
laptop-mode-tools-1.04.ebuild

Ebuild for the new version 1.02, even using install.sh to make maintaining it
as easy as possible (this screams for integration into portage, doesn't it? :)
)
Someone running apm (USE=apm) please confirm it works.
Comment 32 Dennis Nienhüser (RETIRED) gentoo-dev 2004-10-07 09:35:08 UTC
Created attachment 41296 [details]
files/laptop-mode.init

init script necessary for the ebuild. Put in files directory.
Comment 33 Dennis Nienhüser (RETIRED) gentoo-dev 2004-10-31 11:05:17 UTC
Rename the ebuild to laptop-mode-tools-1.03 to get the new version.
Comment 34 Raphael Slinckx 2004-11-01 07:25:55 UTC
I tested and it worked for me, installation is flawless (not tested apm, though)

This is somehting that realy should go in portage in app-laptop/laptop-mode-utils or somthing..
Comment 35 gad.kadosh 2004-11-01 12:53:23 UTC
working very well here. except that apparently my laptop does not send ac events, but when i change the related config in the configuration file it works perfectly. this should really be in portage... as well as the hibernate-script...
Comment 36 Ehud Shabtai 2004-11-02 08:07:25 UTC
Does laptop mode support reiser4 file system?
Comment 37 Remy Blank 2004-11-15 12:32:17 UTC
Works well for me on a Dell Inspiron 8600c with laptop-mode-tools 1.04 by renaming the ebuild.
Comment 38 Dennis Nienhüser (RETIRED) gentoo-dev 2004-11-24 14:35:06 UTC
Comment on attachment 41295 [details]
laptop-mode-tools-1.04.ebuild

bump
Comment 39 Sven Vermeulen (RETIRED) gentoo-dev 2004-11-28 06:56:51 UTC
Mobile herd, can you dedicate a few minutes of your time to verify this ebuild and the accompanying files?

It's blocking a documentation update that's getting more and more requested (regarding powermanagement guide).
Comment 40 Henrik Brix Andersen 2004-12-02 05:48:59 UTC
I'm currently working on improving the current laptop-mode-tools package - latexer and I have been discussing the state of laptop-mode-tools; we do not feel it is production ready yet.

I'll keep you posted.
Comment 41 Peter Johanson (RETIRED) gentoo-dev 2004-12-06 08:00:53 UTC
*** Bug 73308 has been marked as a duplicate of this bug. ***
Comment 42 Aman Gupta 2004-12-27 14:17:33 UTC
If its not production ready yet, can it be added to the portage tree with testing status, or is it still a step below testing?
Comment 43 Antti Mäkelä 2005-01-01 04:39:38 UTC
One thing that should be patched in the 1.04 version is the syslog support. The laptop mode script currently has a line that says 

"killall -HUP syslogd".

However, I think most gentoo users (at least if they go through installation guide) are using syslog-ng.

Also, I think there should be a notification that (maybe) the best way to split the syslogs is to use otherwise identical files, but add "sync(20);" to the options{}-section - that is, the log is written only now and then on batteries, not after every message. Another possibility might be and idea of additional filters, ie. remove all the non-essential messages, like this:

log { source(src); filter(f_important); destination(messages); };
log { source(src); destination(console_all); };
filter f_important { level(emerg,alert,crit,err,warn,notice); };

This does not save debug and info-level messages to /var/log (it still saves them to tty 12). 

Take these into consideration when you prepare the "production-ready" laptop-mode..
Comment 44 TGL 2005-01-18 18:08:14 UTC
Created attachment 48913 [details]
laptop-mode-tools-1.04.ebuild  (alternative version)

Errr... i should have searched bugzilla before writing my own ebuild. Bah, i'll
attach it anyway, because there are a few differences: 

 - i've not installed acpi or apm events handlers, but instead put them in the
documentation, just as it is in the ibm-acpi package for instance. Really, i
don't like package which install events handlers: it can interfere badly with
user's configuration (it would with mine), and etc-update won't be of any help
to prevent that since they are new files. From the moment the package is
installed, there are things that will start getting executed without any
agreement from user's side.

 - i've not used the makefile (to sed changes to do, especially since i also
move scripts to documentation dir), but instead rewrote it in src_install. But
i don't have strong arguments on that point, i don't really care.

Apart from that, my init script was 100% similar to the one in this bug (also
adapted from the one in the source package), so i won't submit it.
Comment 45 TGL 2005-01-18 18:16:05 UTC
Oh, i forgot to comment about testing if kernel actually supports laptop mode.  I personally did not put a test in the ebuild. If the kernel does not support it, then the script will fail, but that won't hurt. 

The point is that testing the running kernel is not really relevant (what if i'm installing in a non-"/" $ROOT, etc.). If there must really be a test, it must be done on ${ROOT}/usr/src/linux sources. As it has been said, the kernel version is not really relevant, but a trick may be to test if a given file is there. Something like that:

pkg_setup() {
	if [ ! -f ${ROOT}usr/src/linux/Documentation/laptop-mode.txt ] ; then
		eerror "Your kernel does not support laptop mode."
		eerror "Try 2.4.23 and above or 2.6.6 and above."
		die "Kernel too old."
	fi
}

That said, that introduces a DEPEND on virtual/linux-sources for a very small benefit imho.
Comment 46 Christian Ludwig 2005-02-18 07:54:13 UTC
Created attachment 51525 [details]
laptop-mode-tools-1.04.ebuild (merged)

I have merged and cleaned up both ebuild version commited here earlier.

Changes to ebuild:
 - merge DEPEND and instalation of certain bits depending on use-flags
 - fixed typos
 - added pkg_setup() as suggested by TGL, but changed errors to warnings only

People could boot into a laptop_mode enabled kernel any time, so this should
not prevent the package from installing on non-laptop_mode kernels. That's why
I changed the init-script to check if it is available on the current running
kernel, when invoked.

Changes to init-script:
 - add checkconfig()
Comment 47 Christian Ludwig 2005-02-18 07:55:09 UTC
Created attachment 51527 [details]
laptop-mode.init
Comment 48 Petteri Räty (RETIRED) gentoo-dev 2005-03-22 08:00:54 UTC
The merged ebuild has a bug in DEPEND:
--- attachment.cgi?id=51525     2005-03-22 17:59:22.498246700 +0200
+++ laptop-mode-tools-1.04.ebuild       2005-03-22 17:59:58.156839244 +0200
@@ -10,9 +10,10 @@
 SLOT="0"
 KEYWORDS="~x86"
 IUSE="acpi apm doc"
-DEPEND=        "acpi?  ( sys-apps/acpid )
-        apm?   ( sys-apps/apmd )
-        virtual/linux-sources"
+
+DEPEND=" acpi?( sys-power/acpid )
+                apm? ( sys-apps/apmd )
+                virtual/linux-sources"

There should be no space after DEPEND and sys-apps/acpid is now sys-power/acpid
Comment 49 Petteri Räty (RETIRED) gentoo-dev 2005-03-22 08:01:51 UTC
Someone should mark the old attachments as obsolete. 
Comment 50 Henrik Brix Andersen 2005-03-22 10:53:59 UTC
I've added this to app-laptop/laptop-mode-tools. Thank you to all who commented on this bug report.
Comment 51 Antti Mäkelä 2005-04-13 01:59:03 UTC
Laptop-mode-tools 1.05 is out..
Comment 52 Henrik Brix Andersen 2005-04-13 02:19:33 UTC
... and it was added to portage two days ago:

*laptop-mode-tools-1.05 (11 Apr 2005)

  11 Apr 2005; <brix@gentoo.org> +files/laptop-mode-tools-1.05.init,
  +laptop-mode-tools-1.05.ebuild:
  Version bump.