diff -Nru ec2-hibinit-agent-1.0.0/debian/changelog ec2-hibinit-agent-1.0.0/debian/changelog --- ec2-hibinit-agent-1.0.0/debian/changelog 2019-02-27 16:30:33.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/changelog 2019-03-01 22:16:18.000000000 +0000 @@ -1,15 +1,30 @@ -ec2-hibinit-agent (1.0.0-0ubuntu1~16.04.1) xenial; urgency=medium +ec2-hibinit-agent (1.0.0-0ubuntu4~16.04.0) xenial; urgency=medium - * Detect disabled hibernation with Python 3's urllib, too. (LP: #1817926) + * Backport to Xenial (LP: #1812166) - -- Balint Reczey Wed, 27 Feb 2019 17:30:33 +0100 + -- Balint Reczey Fri, 01 Mar 2019 23:16:18 +0100 -ec2-hibinit-agent (1.0.0-0ubuntu1~16.04.0) xenial; urgency=medium +ec2-hibinit-agent (1.0.0-0ubuntu4) disco; urgency=medium - * Backport to Xenial (LP: #1812166) - * Revert to build-depending on debhelper (>= 9) and dh-systemd + * Update grub configuration snippet even when it exists but has outdated + content + + -- Balint Reczey Fri, 01 Mar 2019 22:43:46 +0100 + +ec2-hibinit-agent (1.0.0-0ubuntu3) disco; urgency=medium + + * Refer to root partition in resume=... the same way as GRUB2 refers to it + (LP: #1818150) + + -- Balint Reczey Thu, 28 Feb 2019 23:25:57 +0100 + +ec2-hibinit-agent (1.0.0-0ubuntu2) disco; urgency=medium + + * debian/gbp.conf: Use ubuntu/ prefix for tags + * Silence swapoff when purging the package + * Detect disabled hibernation with Python 3's urllib, too. (LP: #1817926) - -- Balint Reczey Thu, 17 Jan 2019 14:38:23 +0700 + -- Balint Reczey Wed, 27 Feb 2019 17:03:37 +0100 ec2-hibinit-agent (1.0.0-0ubuntu1) disco; urgency=medium diff -Nru ec2-hibinit-agent-1.0.0/debian/gbp.conf ec2-hibinit-agent-1.0.0/debian/gbp.conf --- ec2-hibinit-agent-1.0.0/debian/gbp.conf 2019-02-27 16:30:33.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/gbp.conf 2019-03-01 22:16:18.000000000 +0000 @@ -3,3 +3,5 @@ upstream-branch=upstream # the default branch for the debian patch debian-branch=ubuntu/devel +debian-tag = ubuntu/%(version)s +sign-tags = True diff -Nru ec2-hibinit-agent-1.0.0/debian/patches/0009-Refer-to-root-partition-in-resume-.-the-same-way-as-.patch ec2-hibinit-agent-1.0.0/debian/patches/0009-Refer-to-root-partition-in-resume-.-the-same-way-as-.patch --- ec2-hibinit-agent-1.0.0/debian/patches/0009-Refer-to-root-partition-in-resume-.-the-same-way-as-.patch 1970-01-01 00:00:00.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/patches/0009-Refer-to-root-partition-in-resume-.-the-same-way-as-.patch 2019-03-01 22:16:18.000000000 +0000 @@ -0,0 +1,48 @@ +From: Balint Reczey +Date: Thu, 28 Feb 2019 22:54:27 +0100 +Subject: Refer to root partition in resume=... the same way as GRUB2 refers + to it + +LP: #1818150 +--- + agent/hibinit-agent | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/agent/hibinit-agent b/agent/hibinit-agent +index e2cbed1..e41e2af 100755 +--- a/agent/hibinit-agent ++++ b/agent/hibinit-agent +@@ -12,6 +12,7 @@ import array + import atexit + import ctypes as ctypes + import fcntl ++import re + import mmap + import os, signal + import struct +@@ -87,6 +88,15 @@ def get_rootfs_size(): + return math.ceil(float(stat.f_bsize * stat.f_blocks)/(1024*1024*1024)) + + ++def get_rootfs_grub_reference(): ++ """ Return rootfs' reference as GRUB passes it to the kernel""" ++ with open("/boot/grub/grub.cfg") as grub_cfg: ++ for line in grub_cfg: ++ match = re.search('(?<= root=)[^ ]*', line) ++ if match: ++ return match.group(0) ++ ++ + def patch_grub_config(swap_device, offset, grub2_dir): + log("Updating GRUB to use the device %s with offset %d for resume" % (swap_device, offset)) + lines = [] +@@ -95,6 +105,9 @@ def patch_grub_config(swap_device, offset, grub2_dir): + if grub2_dir and os.path.exists(grub2_dir): + offset_file = os.path.join(grub2_dir, '99-set-swap.cfg') + if not os.path.exists(offset_file): ++ if swap_device in ("/dev/root"): ++ swap_device = get_rootfs_grub_reference() ++ log("Updating GRUB referencing root device as %s" % (swap_device)) + with open(offset_file, 'w') as fl: + fl.write('GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT no_console_suspend=1 ' + 'resume_offset=%d resume=%s"\n' % (offset, swap_device)) diff -Nru ec2-hibinit-agent-1.0.0/debian/patches/0010-Update-grub-configuration-when-it-needs-an-update.patch ec2-hibinit-agent-1.0.0/debian/patches/0010-Update-grub-configuration-when-it-needs-an-update.patch --- ec2-hibinit-agent-1.0.0/debian/patches/0010-Update-grub-configuration-when-it-needs-an-update.patch 1970-01-01 00:00:00.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/patches/0010-Update-grub-configuration-when-it-needs-an-update.patch 2019-03-01 22:16:18.000000000 +0000 @@ -0,0 +1,48 @@ +From: Balint Reczey +Date: Fri, 1 Mar 2019 22:33:57 +0100 +Subject: Update grub configuration when it needs an update + +Also log update steps accurately +--- + agent/hibinit-agent | 24 +++++++++++++----------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/agent/hibinit-agent b/agent/hibinit-agent +index e41e2af..6d1580a 100755 +--- a/agent/hibinit-agent ++++ b/agent/hibinit-agent +@@ -98,21 +98,23 @@ def get_rootfs_grub_reference(): + + + def patch_grub_config(swap_device, offset, grub2_dir): +- log("Updating GRUB to use the device %s with offset %d for resume" % (swap_device, offset)) +- lines = [] +- +- # Do GRUB2 update as well ++ """Update GRUB2 config when needed""" + if grub2_dir and os.path.exists(grub2_dir): + offset_file = os.path.join(grub2_dir, '99-set-swap.cfg') +- if not os.path.exists(offset_file): +- if swap_device in ("/dev/root"): +- swap_device = get_rootfs_grub_reference() +- log("Updating GRUB referencing root device as %s" % (swap_device)) ++ if swap_device in ("/dev/root"): ++ swap_device = get_rootfs_grub_reference() ++ grub_snippet = ( ++ 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT' ++ ' no_console_suspend=1 resume_offset=%d resume=%s"\n' ++ % (offset, swap_device)) ++ if ((not os.path.exists(offset_file) ++ or open(offset_file).read() not in (grub_snippet))): ++ log("Updating GRUB to use the device %s with offset %d for resume" ++ % (swap_device, offset)) + with open(offset_file, 'w') as fl: +- fl.write('GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT no_console_suspend=1 ' +- 'resume_offset=%d resume=%s"\n' % (offset, swap_device)) ++ fl.write(grub_snippet) + check_call('/usr/sbin/update-grub2') +- log("GRUB configuration is updated") ++ log("GRUB configuration is updated") + + + def update_kernel_swap_offset(swapon, swapoff, filename, grub_update): diff -Nru ec2-hibinit-agent-1.0.0/debian/patches/series ec2-hibinit-agent-1.0.0/debian/patches/series --- ec2-hibinit-agent-1.0.0/debian/patches/series 2019-02-27 16:30:33.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/patches/series 2019-03-01 22:16:18.000000000 +0000 @@ -6,3 +6,5 @@ 0006-Use-swap-hibinit-instead-of-too-generic-swap.patch 0007-Match-ACPI-sleep-action-in-a-very-liberal-way.patch 0008-Detect-disabled-hibernation-with-Python-3-s-urllib-t.patch +0009-Refer-to-root-partition-in-resume-.-the-same-way-as-.patch +0010-Update-grub-configuration-when-it-needs-an-update.patch diff -Nru ec2-hibinit-agent-1.0.0/debian/postrm ec2-hibinit-agent-1.0.0/debian/postrm --- ec2-hibinit-agent-1.0.0/debian/postrm 2019-02-27 16:30:33.000000000 +0000 +++ ec2-hibinit-agent-1.0.0/debian/postrm 2019-03-01 22:16:18.000000000 +0000 @@ -14,7 +14,7 @@ # clean up dynamically added conffile if exists rm -f /etc/default/grub.d/99-set-swap.cfg update-grub2 || true - swapoff /swap-hibinit > /dev/null || true + swapoff /swap-hibinit > /dev/null 2>&1 || true rm -f /swap-hibinit ;; *)