Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 342049

Summary: app-laptop/laptop-mode-tools and /var/run on tmpfs issue
Product: Gentoo Linux Reporter: i.Dark_Templar <idarktemplar>
Component: Current packagesAssignee: Mobile Herd (OBSOLETE) <mobile+disabled>
Status: RESOLVED FIXED    
Severity: QA CC: eras, hwoarang
Priority: High Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 332633    
Attachments: Fixed init script (full version)
init script patch
check before dir creation - full script
laptop_mode init script patch which checks dir before creation
script which uses builtin "checkpath" function
script patch which uses builtin "checkpath" function
More readable version of previous patch, uses builtin "checkpath" function
laptop mode full init script
init script patch
modified laptop-mode-tools ebuild. Removed keepdir line

Description i.Dark_Templar 2010-10-21 17:58:36 UTC
I'm using tmpfs for /var/run and laptop-mode-tools at default runlevel. Each time i boot i get message:

laptop_mode     |touch: cannot touch «/var/run/laptop-mode-tools/enabled»: No such file or directory

Looks like it doesn't check if directory «/var/run/laptop-mode-tools» exists. Later, it gets created and just restarting this service makes it start without any warnings.

Reproducible: Always

Steps to Reproduce:
1. Install laptop-mode-tools and add it's service to any used at boot time runlevel (i.e. boot or default for example)
2. Make /var/run on tmpfs
3. Reboot

Actual Results:  
Getting warning from laptop_mode service, probably incorrect behavior

Expected Results:  
Warningless boot of laptop_mode service

To fix this bug laptop-mode-tools should check if directory «/var/run/laptop-mode-tools» exists at startup
Comment 1 i.Dark_Templar 2010-10-21 18:04:34 UTC
Created attachment 251469 [details]
Fixed init script (full version)
Comment 2 i.Dark_Templar 2010-10-21 18:05:23 UTC
Created attachment 251471 [details, diff]
init script patch
Comment 3 Eray Aslan gentoo-dev 2010-10-22 06:12:42 UTC
@i.Dark_Templar:

Using checkpath in the init script is the preferred solution instead of calling mkdir.  You might also want to check the init scripts in bug #332633 for examples.
Comment 4 i.Dark_Templar 2010-10-22 13:35:45 UTC
I've used "mkdir -p" because it does nothing if dir already exists and creates dir if it not exists. But in case maintainers prefer check before creation, i'll now attach this version too. I've used dbus init script as example.
Comment 5 i.Dark_Templar 2010-10-22 13:36:50 UTC
Created attachment 251569 [details]
check before dir creation - full script
Comment 6 i.Dark_Templar 2010-10-22 13:37:40 UTC
Created attachment 251571 [details, diff]
laptop_mode init script patch which checks dir before creation
Comment 7 i.Dark_Templar 2010-10-22 14:14:32 UTC
Created attachment 251585 [details]
script which uses builtin "checkpath" function

I've made script that uses builtin "checkpath" function. But this fuction is unpreferrable for me - it gives extra warnings each time it starts at boot. Previous scripts fix problem silently.
Comment 8 i.Dark_Templar 2010-10-22 14:15:15 UTC
Created attachment 251587 [details, diff]
script patch which uses builtin "checkpath" function
Comment 9 i.Dark_Templar 2010-10-22 14:18:28 UTC
Created attachment 251589 [details, diff]
More readable version of previous patch, uses builtin "checkpath" function
Comment 10 Eray Aslan gentoo-dev 2010-10-22 14:44:25 UTC
(In reply to comment #7)
> it gives extra warnings each time it starts at boot.

Use the --quiet option

Also make sure you check the exit codes of the commands you run.  Something similar to the following perhaps?

if [ ! -d  "${PIDDIR}" ] ; then
    checkpath -q -d -o someuser:somegroup -m 0755 "${PIDDIR}" || return 1
fi
Comment 11 i.Dark_Templar 2010-10-22 15:48:47 UTC
Created attachment 251601 [details]
laptop mode full init script

There is no need to additionally check dir before running checkpath, because checkpass both checks and creates or modifies directory (or file, directory in this case) if necessary
Comment 12 i.Dark_Templar 2010-10-22 15:53:31 UTC
Created attachment 251603 [details, diff]
init script patch

There is no word about exit codes of "checkpath" in manual. So, i suppose it always works fine with correct arguments.
Comment 13 i.Dark_Templar 2011-03-26 17:21:59 UTC
Bug is still there and fix is in attachment. Maybe someone merge it into portage tree?
Comment 14 i.Dark_Templar 2011-03-26 18:00:56 UTC
Created attachment 267307 [details]
modified laptop-mode-tools ebuild. Removed keepdir line

diff with current ebuild:

--- /usr/portage/app-laptop/laptop-mode-tools/laptop-mode-tools-1.55-r1.ebuild	2010-09-28 09:23:31.000000000 +0400
+++ ./laptop-mode-tools-1.55-r1.ebuild	2011-03-26 20:57:22.000000000 +0300
@@ -48,8 +48,6 @@
 	# Commented out to avoid !sys-power/pm-utils depend wrt #327443
 	# exeinto /etc/pm/power.d
 	# newexe "${FILESDIR}"/laptop_mode_tools.pmutils laptop_mode_tools
-
-	keepdir /var/run/laptop-mode-tools
 }
 
 pkg_postinst() {
Comment 15 i.Dark_Templar 2011-10-20 14:25:21 UTC
This bug is long time ago marked as "in progress", but I didn't notice any progress...
Comment 16 Markos Chandras (RETIRED) gentoo-dev 2011-10-20 18:30:57 UTC
The mobile herd is pretty much dead. If you want to become maintainer for this package please contact us at proxy-maint@gentoo.org[1]

[1]: http://www.gentoo.org/proj/en/qa/proxy-maintainers/index.xml
Comment 17 i.Dark_Templar 2012-01-01 14:33:26 UTC
Bug is still there, at laptop-mode-tools-1.55-r3 and r4. While other laptop-mode-tools bugs get fixed, I guess there are people to look at this bug.
Comment 18 Markos Chandras (RETIRED) gentoo-dev 2012-01-01 14:45:25 UTC
I fixed it. Thanks for reporting.

+*laptop-mode-tools-1.55-r5 (01 Jan 2012)
+
+  01 Jan 2012; Markos Chandras <hwoarang@gentoo.org>
+  +laptop-mode-tools-1.55-r5.ebuild, files/laptop_mode.init-1.4:
+  Check if directory exists in /var/run. Non maintainer commit. Bug #342049.
+  Thanks to i.Dark_Templar <dark_templar@hotbox.ru>
+