Bug#632627: Re[2]: Bug#632627: Re[2]: Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-09-02 Thread Askar Safin
Hi, kix, Maximilian and Michael.
First of all: this bug affected kernel-based hibernation, too (details follow).

So, I performed something like git bisect to determine why the bug was 
magically fixed. I debootstrapped a lot of minimal sid Debian systems from 
snapshot.debian.org. I wrote scripts, which automatically bootstrap system, run 
it in Qemu and check whenever this system contains bug. Steps to reproduce I 
used, was the following:
1. Bootstrap system (with swap present in /etc/fstab)
2. Start it in Qemu, install uswsusp, run s2disk, this causes Qemu to close
3. Start the system in Qemu again. If it wakes up - there is no bug, the system 
is good. If starts from scratch - bad
Result is:
current (2014-09-01) - good
http://snapshot.debian.org/archive/debian/20130601T035649Z - bad
http://snapshot.debian.org/archive/debian/20140101T042327Z - good
http://snapshot.debian.org/archive/debian/20130901T040738Z - bad  
http://snapshot.debian.org/archive/debian/20131101T040405Z - good 
http://snapshot.debian.org/archive/debian/20131001T035353Z - good
http://snapshot.debian.org/archive/debian/20130915T035028Z - bad
http://snapshot.debian.org/archive/debian/20130924T035052Z - good
http://snapshot.debian.org/archive/debian/20130920T034833Z - bad
http://snapshot.debian.org/archive/debian/20130922T035833Z - bad
http://snapshot.debian.org/archive/debian/20130923T035105Z - good
http://snapshot.debian.org/archive/debian/20130922T154933Z - bad
http://snapshot.debian.org/archive/debian/20130922T220333Z - good
So, the bug was fixed in 20130922T154933Z .. 20130922T220333Z.
Only one package (in this minimal systems) was updates at this time: 
initramfs-tools: it was bumped from 0.113 to 0.114.
Looking at the git log for initramfs-tools it seems that the bug was fixed in 
this commit:

commit fef37d599aae9f2f3fc6808b46e901a7a4267c76
Author: maximilian attems m...@debian.org
Date:   Wed Sep 11 00:40:10 2013 +0200

hooks: Add resume hook instead of hardcoding RESUME once on preinst

This logic is better run every time on update-initramfs,
as swap partition of a system might change.
Also there are scenarios where the preinstall picks up
a wrong value that stays wrongly hardcoded.
This results in a 5s useless wait on boot.

The biggest swap partition is used as valid guess.
This was previously the logic and is the logic used by ubiquity
(Ubuntu live installer) too.

Closes: #565225, LP 50437.

Thanks-to: Dmitrijs Ledkovs launch...@surgut.co.uk
Reviewed-by: Martin Pitt martin.p...@ubuntu.com
Reviewed-by: Michael Prokop m...@debian.org
Signed-off-by: maximilian attems m...@debian.org

If you want, I can give you scripts I wrote, I can preform bisect again for 
some reason, I can help with testing/reproducing etc.

I want to point some notes: I'm not Debian developer nor Debian maintainer. I'm 
just a bug reporter. This bug currently doesn't affect me, because 1) it is 
fixed 2) i can write resume file myself. I don't know whenever the bug is 
really fixed now or this is just some trick. I don't know how to fix it the 
best way. I don't understand some of the letters in this bug report. But I want 
to help you with fixing this bug.

Michael Prokop:
 Are you willing to work on this? :)
I had worked just now. So, now please say me is this bug really fixed or not.

Also, the bug was reproducible for kernel-based hibernation on 20130922T154933Z 
and not reproducible on 20130922T220333Z (i. e. before and after the 
initramfs-tools 0.114 release). Steps:
1. Bootstrap 20130922T154933Z (without swap)
2. Install pm-utils
3. Add swap
4. Reboot
5. dpkg-reconfigure initramfs-tools
6. pm-hibernate (fails)
7. Upgrade to initramfs-tools 0.114 (this will cause reconfiguring)
8. pm-hibernate (works)

I think bug still is not fixed. Because initramfs-tools just uses current swap 
and doesn't use /etc/uswsusp.conf. But probably the bug is fixed for 
kernel-based hibernation. What to do? I don't know. Maybe uswsusp should 
always use current swap or add initramfs-tools hook which reads 
/etc/uswsusp.conf and writes resume or pick any solution from this bug 
report or debian-devel discussion.

I reopened this bug to make sure you will answer my message, will not forget 
this bug and will really resolve it.

==
Askar Safin
http://vk.com/safinaskar
Moscow, Russia
Moscow State University, http://msu.ru , Faculty of Mechanics and Mathematics, 
Department of Mathematical Logic and Theory of Algorithms
-
-


Bug#632627: Re[2]: Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-31 Thread maximilian attems
On Sun, Aug 31, 2014 at 04:11:07AM +0400, Askar Safin wrote:
 Sun, 31 Aug 2014 02:04:41 +0200 от Michael Prokop m...@debian.org:
 Are you willing to work on this? :)
 No, I'm just bug reporter :)

uswsusp has been outdated 2y ago and hasn't improved yet.
The support was removed in dracut in 2010.

Please just close that, alternatively reassign to uswsusp,
if it would be maintained the maintainer can/should lift that.

thanks for your work!

-- 
maks


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#632627: Re[2]: Bug#632627: Re[2]: Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-31 Thread Askar Safin
Hmm, I cannot reproduce the bug on modern jessie (i. e. jessie debootstrapped 
today) o_O.
I performed the steps from 
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=632627#72 :
 1. Installed uswsusp. uswsusp said to me that I have no swap and I should add 
 it and run dpkg-reconfigure uswsusp.
 2. I added swap
 3. Rebooted
 4. I ran dpkg-reconfigure uswsusp. uswsusp found my swap and it was happy. 
 It asked me a lot of questions. Then uswsusp triggered initramfs rebuilding
 5. Rebooted
 6. I ran s2disk and I could not wake up. So, this is a bug.
And I was able to wake up on the step 6. But /etc/initramfs-tools/conf.d/resume 
for some reason still doesn't exist. resume device in /etc/uswsusp.conf 
points to my swap device (and I did not edit this file manually).
So, please, investigate, what happened, is bug really fixed or this is some 
trick.
==
Askar Safin
-
-


Bug#632627: Re[2]: Bug#632627: Re[2]: Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-31 Thread Askar Safin
Hi, kix.

Sun, 31 Aug 2014 20:43:33 + от Rodolfo García Peñas (kix) 
k...@debian.org:
About this bug, I worked on it one year ago. I sent some emails. As
you can see in the bug history, uswsusp cannot update the file,
because it belongs to initramfs-tools. I sent some patches,...
And then there was discussion on debian-devel, which was lost for some reason.
So, we should just continue discussion.
And also we should understand why the bug was magically fixed in modern 
jessie.

Also NOTE for all people writing to this bug report: be sure you are writing to 
632...@bugs.debian.org and not to 632627-d...@bugs.debian.org (closing this bug 
again and again).

==
Askar Safin
http://vk.com/safinaskar
Moscow, Russia
Moscow State University, http://msu.ru , Faculty of Mechanics and Mathematics, 
Department of Mathematical Logic and Theory of Algorithms
-
-


Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-30 Thread Michael Prokop
Hi,

while going through the initramfs-tools bugs I stumbled upon this
one too:

* Rodolfo Garc�a [Sat Aug 10, 2013 at 10:37:16PM +0200]:

 No. uswsusp doesn't need the kernel package (you can boot from a
 floppy).

 We need a (new?) package. uswsusp and initramfs-tools should
 depend on it. This package should include a script
 (/usr/bin/update-resume-file?) and the script should create/update
 a config file. The config file will be used by initramfs-tools and
 uswsusp (and cryptsetup and probably others). The file should
 include two lines, one for the resume device and other for the
 offset.

 Perhaps we should continue this thread on debian-devel, because
 more people could help. Feel free to forward this mail (my
 Internet connection here is crap).

I'm unsure what to do about this one and we have several bugs open
related to it (#530618, #574653 + #632627). Not being a user of
neither uswsusp nor resume from disk it's hard for me to decide how
to proceed here, is anyone willing to work on this?

regards,
-mika-


signature.asc
Description: Digital signature


Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-30 Thread Askar Safin
Sat, 30 Aug 2014 22:37:50 +0200 от Michael Prokop m...@debian.org:
Hi,

while going through the initramfs-tools bugs I stumbled upon this
one too:

 Perhaps we should continue this thread on debian-devel, because
 more people could help. Feel free to forward this mail (my
 Internet connection here is crap).
Discussion was really continued on debian-devel ( 
https://lists.debian.org/debian-devel/2013/08/msg00331.html ), but then 
disappeared :(

I agree that this bug should be fixed :)

==
Askar Safin
http://vk.com/safinaskar
Moscow, Russia
Moscow State University, http://msu.ru , Faculty of Mechanics and Mathematics, 
Department of Mathematical Logic and Theory of Algorithms

Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-30 Thread Michael Prokop
* Askar Safin [Sun Aug 31, 2014 at 01:02:04AM +0400]:
 Sat, 30 Aug 2014 22:37:50 +0200 от Michael Prokop m...@debian.org:

 while going through the initramfs-tools bugs I stumbled upon this
 one too:

  Perhaps we should continue this thread on debian-devel, because
  more people could help. Feel free to forward this mail (my
  Internet connection here is crap).

 Discussion was really continued on debian-devel (
 https://lists.debian.org/debian-devel/2013/08/msg00331.html ), but
 then disappeared :(

Well, from my PoV Ben's suggestion looks good:
https://lists.debian.org/debian-devel/2013/08/msg00716.html

 I agree that this bug should be fixed :)

Are you willing to work on this? :)

regards,
-mika-


signature.asc
Description: Digital signature


Bug#632627: Re[2]: Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2014-08-30 Thread Askar Safin
Sun, 31 Aug 2014 02:04:41 +0200 от Michael Prokop m...@debian.org:
Are you willing to work on this? :)
No, I'm just bug reporter :)

==
Askar Safin
http://vk.com/safinaskar
Moscow, Russia
Moscow State University, http://msu.ru , Faculty of Mechanics and Mathematics, 
Department of Mathematical Logic and Theory of Algorithms

Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-10 Thread Rodolfo Garc�a
On Fri, 09 Aug 2013, Ben Hutchings escribi�:

 On Fri, 2013-08-09 at 13:41 +, Rodolfo García Peñas (kix) wrote:
  Ben Hutchings b...@decadent.org.uk escribió:
  
   On Fri, 2013-08-09 at 14:22 +0200, Ben Hutchings wrote:
   [...]
   Reconfiguring uswsusp should definitely not affect the behaviour of
   swsusp; that would be very surprising.  I think the configuration should
   be transferred the other way: uswsusp should copy the resume device and
   offset from initramfs-tools configuration (if initramfs-tools is
   installed).
  
   Note, I'm only suggesting that this should be done at installation time.
   I think it would be confusing to simply make either of the current
   configuration files override the other.
  
   I do think it would be preferable to switch to a single configuration
   file for resume device and offset (or none, if automatic selection can
   work) but we would need a transition plan that minimises confusion and
   breakage.
  
  Yes, the best option is have only one configuration file.
  The user must select the resume device (if there are more than one).
  What package should modify that file?
 
 Perhaps linux-base?

No. uswsusp doesn't need the kernel package (you can boot from a floppy).

We need a (new?) package. uswsusp and initramfs-tools should depend on it. This 
package should include a script (/usr/bin/update-resume-file?) and the script 
should create/update a config file. The config file will be used by 
initramfs-tools and uswsusp (and cryptsetup and probably others). The file 
should include two lines, one for the resume device and other for the offset.
 
Perhaps we should continue this thread on debian-devel, because more people 
could help. Feel free to forward this mail (my Internet connection here is 
crap).

kix.

 Ben.
 
 -- 
 Ben Hutchings
 I say we take off; nuke the site from orbit.  It's the only way to be sure.


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-09 Thread Ben Hutchings
I think it could be useful to copy the uswsusp configuration when
initramfs-tools is installed, except that initramfs-tools is almost
always installed first.

Reconfiguring uswsusp should definitely not affect the behaviour of
swsusp; that would be very surprising.  I think the configuration should
be transferred the other way: uswsusp should copy the resume device and
offset from initramfs-tools configuration (if initramfs-tools is
installed).

Ben.

-- 
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.


signature.asc
Description: This is a digitally signed message part


Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-09 Thread Ben Hutchings
On Fri, 2013-08-09 at 14:22 +0200, Ben Hutchings wrote:
[...]
 Reconfiguring uswsusp should definitely not affect the behaviour of
 swsusp; that would be very surprising.  I think the configuration should
 be transferred the other way: uswsusp should copy the resume device and
 offset from initramfs-tools configuration (if initramfs-tools is
 installed).

Note, I'm only suggesting that this should be done at installation time.
I think it would be confusing to simply make either of the current
configuration files override the other.

I do think it would be preferable to switch to a single configuration
file for resume device and offset (or none, if automatic selection can
work) but we would need a transition plan that minimises confusion and
breakage.

Ben.

-- 
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.


signature.asc
Description: This is a digitally signed message part


Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-09 Thread Rodolfo García Peñas (kix)


Ben Hutchings b...@decadent.org.uk escribió:

Hi Ben,


I think it could be useful to copy the uswsusp configuration when
initramfs-tools is installed, except that initramfs-tools is almost
always installed first.


Yes. For this reason I made the patch. This patch moves the process to
select the resume device from the package installation to the
update-initramfs script.


Reconfiguring uswsusp should definitely not affect the behaviour of
swsusp; that would be very surprising.  I think the configuration should
be transferred the other way: uswsusp should copy the resume device and
offset from initramfs-tools configuration (if initramfs-tools is
installed).


I am not sure about that, but in any case, we need that both packages
interact.

I don't like too much the idea of copy the uswsusp configuration
*only* in the initramfs-tools package installation, because  if the
user could have a wrong uswsusp configuration, so the configuration
will be wrong forever.

About your idea (copy the initramfs-tools configuration), I don't like
too much too :-). Currently, uswsusp can configure the resume device.
With your idea, uswsusp must not configure the resume device (if
initramfs-tools is installed), else the resume device in
initramfs-tools and uswsusp could be different and then we continue
with these bugs/issues. So, if the user wants to change the resume
device, must do it updating the initramfs-tools configuration.

We could do these things (to support your idea):

1. initramfs-tools must provide a method to select the resume device
and the offset. The resume device won't be read from the
/etc/uswsusp.conf file when the package is installed. The user will
select the resume device and offset with initramfs-tools, because
currently the user can select it now with uswsusp (current behavior).
The user will select the resume device when initramfs-tools package is
installed (not read the /etc/uswsusp.conf file).

2. The debconf scripts will include the device and offset selection but:
2a. The user will continue using this behavior if initramfs-tools is
not installed.
2b. If initramfs-tools package is installed, the debconf scripts won't
show the selecion for the device and the offset. They will show a
message about the new process (run the initramfs-tools script to
select the device) to select the offset and resume device. The user
needs run the initramfs-tools script to select the new resume device
AND then reconfigure uswsusp again, because the /etc/uswsusp.conf
package won't be udpated.

I don't like this behaviour, because the user will:

1. Run dpkg-reconfigure uswsusp
2. See the message about select device with the initramfs-tools tool
3. Run the tool to select the new device
4. Run dpkg-reconfigure uswsup to update the config file.

The idea about initramfs-tools reads the uswsusp configuration don't
have these behavior. If the resume device changes, initramfs-tools
script could show a message to the user about that. The user will
understand that the resume problems will be related to uswsusp.conf
configuration. Because when the uswsusp package reconfiguration calls
update-initramfs tools, the user will exec only one command
dpkg-reconfigure uswsusp. IMO, this method is better.

More comments are very welcome.

Thanks a lot for your reply Ben.
kix


Ben.

--
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.



--
 .''`.
: :'  : Rodolfo García Peñas (kix) k...@debian.org
`. `'`  Proud Debian Developer
 `-


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-09 Thread Rodolfo García Peñas (kix)


Ben Hutchings b...@decadent.org.uk escribió:


On Fri, 2013-08-09 at 14:22 +0200, Ben Hutchings wrote:
[...]

Reconfiguring uswsusp should definitely not affect the behaviour of
swsusp; that would be very surprising.  I think the configuration should
be transferred the other way: uswsusp should copy the resume device and
offset from initramfs-tools configuration (if initramfs-tools is
installed).


Note, I'm only suggesting that this should be done at installation time.
I think it would be confusing to simply make either of the current
configuration files override the other.

I do think it would be preferable to switch to a single configuration
file for resume device and offset (or none, if automatic selection can
work) but we would need a transition plan that minimises confusion and
breakage.


Yes, the best option is have only one configuration file.
The user must select the resume device (if there are more than one).
What package should modify that file?

kix


Ben.

--
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.



--
 .''`.
: :'  : Rodolfo García Peñas (kix) k...@debian.org
`. `'`  Proud Debian Developer
 `-


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-09 Thread Ben Hutchings
On Fri, 2013-08-09 at 13:41 +, Rodolfo García Peñas (kix) wrote:
 Ben Hutchings b...@decadent.org.uk escribió:
 
  On Fri, 2013-08-09 at 14:22 +0200, Ben Hutchings wrote:
  [...]
  Reconfiguring uswsusp should definitely not affect the behaviour of
  swsusp; that would be very surprising.  I think the configuration should
  be transferred the other way: uswsusp should copy the resume device and
  offset from initramfs-tools configuration (if initramfs-tools is
  installed).
 
  Note, I'm only suggesting that this should be done at installation time.
  I think it would be confusing to simply make either of the current
  configuration files override the other.
 
  I do think it would be preferable to switch to a single configuration
  file for resume device and offset (or none, if automatic selection can
  work) but we would need a transition plan that minimises confusion and
  breakage.
 
 Yes, the best option is have only one configuration file.
 The user must select the resume device (if there are more than one).
 What package should modify that file?

Perhaps linux-base?

Ben.

-- 
Ben Hutchings
I say we take off; nuke the site from orbit.  It's the only way to be sure.


signature.asc
Description: This is a digitally signed message part


Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-08-06 Thread Rodolfo García Peñas
On Tue, 30 Jul 2013, Rodolfo García Peñas escribió:

 On Tue, 30 Jul 2013, Rodolfo García Peñas escribió:
 
 [snip]
 
  Hi Askar,
  
  thanks a lot for your reply. Could this initramfs-tools patch solve the 
  problem?
  
  Some tips:
  
  1. The patch reads the /etc/uswsusp.conf, and check if the file exists. The 
  value is not changed to UUID.
  2. I check if uswsusp is installed if the s2disk binary exists. Checking 
  the config file only could be an error if the package was removed (not 
  purged).
  3. The resume device is created always, not only when initramfs-tools is 
  installed. Because the user can change the device.
  
  Comments are welcome.
  
  Cheers,
  kix
 
 Hi,
 
 I am attaching the git patches for the initramfs-tools git. Is only a 
 proposal. Ben, what do you think? Please, apply them only if you agree with 
 this behaviour (and code).
 
 If you agree, I will forward the bug report to initramfs-tools and I will tag 
 it with +patch. Then, uswsusp package doesn't need changes.
 
 Cheers,
 kix

 From c92b6c76542baf254afe875d7fbc608460a3178a Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)?= 
 k...@debian.org
 Date: Tue, 30 Jul 2013 19:49:29 +0200
 Subject: [PATCH 1/2] code style: Extra tab
 
 This patch only adds an extra tab.
 ---
  update-initramfs |2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/update-initramfs b/update-initramfs
 index 998eaf0..251fb6b 100755
 --- a/update-initramfs
 +++ b/update-initramfs
 @@ -68,7 +68,7 @@ chrooted()
   # return false.
   return 1
   fi
 -return 0
 + return 0
  }
  
  mild_panic()
 -- 
 1.7.10.4
 

 From 47c8558cf3ae7b0918c96ae983d9738acfef8159 Mon Sep 17 00:00:00 2001
 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)?= 
 k...@debian.org
 Date: Tue, 30 Jul 2013 19:54:43 +0200
 Subject: [PATCH 2/2] resume using uswsusp configuration
 
 This patch reads the uswsusp configuration file (/etc/uswsusp.conf)
 to get the resume device. If the file exists and uswsusp package is
 installed, it save the value in the /etc/initramfs-tools/conf.d/resume
 file. When the initrd image is created, this value is stored in the
 conf/conf.d/resume file.
 
 If the uswsusp package is not installed, if the configuration file
 doesn't exists, or the file included in the configuration file doesn't
 exist, the value is not used, and the previous scheme is used.
 
 The main difference between this patch and the previous behaviour is
 the resume file is now created when the user run update-initramfs not
 when the user install the initramfs-tools package. The reason is because
 the user run 'dpkg-reconfigure uswsusp' can change the swap device, so
 the swap included in the configuration file could be wrong. The code
 to update the configuration file is moved from debian/initramfs-tools.preinst
 file to update-initramfs file. The function chrooted() was previously
 included in the file update-initramfs.
 ---
  debian/initramfs-tools.preinst |   34 ---
  update-initramfs   |   43 
 
  2 files changed, 43 insertions(+), 34 deletions(-)
 
 diff --git a/debian/initramfs-tools.preinst b/debian/initramfs-tools.preinst
 index b0216a1..01ff9df 100644
 --- a/debian/initramfs-tools.preinst
 +++ b/debian/initramfs-tools.preinst
 @@ -2,43 +2,9 @@
  
  set -e
  
 -chrooted() {
 - # borrowed from udev's postinst
 - if [ $(stat -c %d/%i /) = $(stat -Lc %d/%i /proc/1/root 
 2/dev/null) ]; then
 - # the devicenumber/inode pair of / is the same as that of
 - # /sbin/init's root, so we're *not* in a chroot and hence
 - # return false.
 - return 1
 - fi
 - return 0
 -}
 -
  case $1 in
   install)
   mkdir -p /etc/initramfs-tools/conf.d
 -
 - # First time install.  Can we autodetect the RESUME partition?
 - if [ -r /proc/swaps ]; then
 - RESUME=$(grep ^/dev/ /proc/swaps | sort -rk3 \
 - | head -n 1 | cut -d   -f 1)
 - if command -v blkid /dev/null 21; then
 - UUID=$(blkid -s UUID -o value $RESUME || true)
 - # FIXME: post-Wheezy remove vol_id invocations
 - elif command -v vol_id /dev/null 21; then
 - UUID=$(vol_id -u $RESUME || true)
 - elif [ -x /lib/udev/vol_id ]; then
 - UUID=$(/lib/udev/vol_id -u $RESUME || true)
 - fi
 - if [ -n $UUID ]; then
 - RESUME=UUID=$UUID
 - fi
 - fi
 -
 - # write conf.d/resume if not in a chroot
 - if [ -n ${RESUME} ]  ! chrooted; then
 - echo RESUME=${RESUME}  
 /etc/initramfs-tools/conf.d/resume
 - fi
 -
   ;;
  

Bug#632627: uswsusp patches for initramfs-tools (was: Bug#632627: Re[2]: resume file)

2013-07-30 Thread Rodolfo García Peñas
On Tue, 30 Jul 2013, Rodolfo García Peñas escribió:

[snip]

 Hi Askar,
 
 thanks a lot for your reply. Could this initramfs-tools patch solve the 
 problem?
 
 Some tips:
 
 1. The patch reads the /etc/uswsusp.conf, and check if the file exists. The 
 value is not changed to UUID.
 2. I check if uswsusp is installed if the s2disk binary exists. Checking the 
 config file only could be an error if the package was removed (not purged).
 3. The resume device is created always, not only when initramfs-tools is 
 installed. Because the user can change the device.
 
 Comments are welcome.
 
 Cheers,
 kix

Hi,

I am attaching the git patches for the initramfs-tools git. Is only a proposal. 
Ben, what do you think? Please, apply them only if you agree with this 
behaviour (and code).

If you agree, I will forward the bug report to initramfs-tools and I will tag 
it with +patch. Then, uswsusp package doesn't need changes.

Cheers,
kix
From c92b6c76542baf254afe875d7fbc608460a3178a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)?= k...@debian.org
Date: Tue, 30 Jul 2013 19:49:29 +0200
Subject: [PATCH 1/2] code style: Extra tab

This patch only adds an extra tab.
---
 update-initramfs |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/update-initramfs b/update-initramfs
index 998eaf0..251fb6b 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -68,7 +68,7 @@ chrooted()
 		# return false.
 		return 1
 	fi
-return 0
+	return 0
 }
 
 mild_panic()
-- 
1.7.10.4

From 47c8558cf3ae7b0918c96ae983d9738acfef8159 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20(kix)?= k...@debian.org
Date: Tue, 30 Jul 2013 19:54:43 +0200
Subject: [PATCH 2/2] resume using uswsusp configuration

This patch reads the uswsusp configuration file (/etc/uswsusp.conf)
to get the resume device. If the file exists and uswsusp package is
installed, it save the value in the /etc/initramfs-tools/conf.d/resume
file. When the initrd image is created, this value is stored in the
conf/conf.d/resume file.

If the uswsusp package is not installed, if the configuration file
doesn't exists, or the file included in the configuration file doesn't
exist, the value is not used, and the previous scheme is used.

The main difference between this patch and the previous behaviour is
the resume file is now created when the user run update-initramfs not
when the user install the initramfs-tools package. The reason is because
the user run 'dpkg-reconfigure uswsusp' can change the swap device, so
the swap included in the configuration file could be wrong. The code
to update the configuration file is moved from debian/initramfs-tools.preinst
file to update-initramfs file. The function chrooted() was previously
included in the file update-initramfs.
---
 debian/initramfs-tools.preinst |   34 ---
 update-initramfs   |   43 
 2 files changed, 43 insertions(+), 34 deletions(-)

diff --git a/debian/initramfs-tools.preinst b/debian/initramfs-tools.preinst
index b0216a1..01ff9df 100644
--- a/debian/initramfs-tools.preinst
+++ b/debian/initramfs-tools.preinst
@@ -2,43 +2,9 @@
 
 set -e
 
-chrooted() {
-	# borrowed from udev's postinst
-	if [ $(stat -c %d/%i /) = $(stat -Lc %d/%i /proc/1/root 2/dev/null) ]; then
-		# the devicenumber/inode pair of / is the same as that of
-		# /sbin/init's root, so we're *not* in a chroot and hence
-		# return false.
-		return 1
-	fi
-	return 0
-}
-
 case $1 in
 	install)
 		mkdir -p /etc/initramfs-tools/conf.d
-
-		# First time install.  Can we autodetect the RESUME partition?
-		if [ -r /proc/swaps ]; then
-			RESUME=$(grep ^/dev/ /proc/swaps | sort -rk3 \
-| head -n 1 | cut -d   -f 1)
-			if command -v blkid /dev/null 21; then
-UUID=$(blkid -s UUID -o value $RESUME || true)
-			# FIXME: post-Wheezy remove vol_id invocations
-			elif command -v vol_id /dev/null 21; then
-UUID=$(vol_id -u $RESUME || true)
-			elif [ -x /lib/udev/vol_id ]; then
-UUID=$(/lib/udev/vol_id -u $RESUME || true)
-			fi
-			if [ -n $UUID ]; then
-RESUME=UUID=$UUID
-			fi
-		fi
-
-		# write conf.d/resume if not in a chroot
-		if [ -n ${RESUME} ]  ! chrooted; then
-			echo RESUME=${RESUME}  /etc/initramfs-tools/conf.d/resume
-		fi
-
 	;;
 esac
 
diff --git a/update-initramfs b/update-initramfs
index 251fb6b..285e5c1 100755
--- a/update-initramfs
+++ b/update-initramfs
@@ -161,6 +161,45 @@ remove_initramfs_bak()
 	verbose Removing ${initramfs_bak}
 }
 
+# Update the resume device
+update_resume_device()
+{
+	USWSUSPCFG=/etc/uswsusp.conf
+	S2DISK=/usr/sbin/s2disk
+
+	# If uswsusp installed, use that swap device
+	if [ -r ${USWSUSPCFG} ]  [ -x ${S2DISK} ]; then
+		RESUME=`sed -n 's/^[[:space:]]*'resume device'[[:space:]]*[=:][[:space:]]*\([^[:space:]]*\)/\1/ p' $USWSUSPCFG`
+
+		if [ ! -e ${RESUME} ]; then
+			RESUME=
+		fi
+	fi
+
+	# If not found in uswsusp config, get from running system
+	if [