From e7a4ec17d66617f43cc9a6f62af9c5999c6b5ad7 Mon Sep 17 00:00:00 2001 From: Lv Ying Date: Fri, 29 Mar 2024 10:36:39 -0400 Subject: [PATCH] [Backport]cloud-utils: Use LANG=C to parse sfdisk output Signed-off-by: Lv Ying --- ...t-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch | 28 +++++++++++++ ...rt-Use-LANG-C-to-parse-sfdisk-output.patch | 42 +++++++++++++++++++ cloud-utils.spec | 11 ++++- 3 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 backport-Fix-growpart-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch create mode 100644 backport-growpart-Use-LANG-C-to-parse-sfdisk-output.patch diff --git a/backport-Fix-growpart-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch b/backport-Fix-growpart-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch new file mode 100644 index 0000000..d0a2d60 --- /dev/null +++ b/backport-Fix-growpart-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch @@ -0,0 +1,28 @@ +From 03aa9974e7eb438b798fe95afc7cf4efe72ea73a Mon Sep 17 00:00:00 2001 +From: Amy Chen <66719270+xiachen-rh@users.noreply.github.com> +Date: Wed, 12 May 2021 13:03:17 +0800 +Subject: [PATCH] Fix issue LP: #1928167 growpart doesn't work when + LANG=cs_CZ.UTF-8 + +Reference:https://github.com/canonical/cloud-utils/commit/03aa9974e7eb438b798fe95afc7cf4efe72ea73a +Conflict:NA +--- + bin/growpart | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bin/growpart b/bin/growpart +index 283eaa0..541b4ab 100755 +--- a/bin/growpart ++++ b/bin/growpart +@@ -230,7 +230,7 @@ get_sfdisk_version() { + return 0 + } + # expected output: sfdisk from util-linux 2.25.2 +- out=$(sfdisk --version) || ++ out=$(LANG=C sfdisk --version) || + { error "failed to get sfdisk version"; return 1; } + set -- $out + ver=$4 +-- +2.33.0 + diff --git a/backport-growpart-Use-LANG-C-to-parse-sfdisk-output.patch b/backport-growpart-Use-LANG-C-to-parse-sfdisk-output.patch new file mode 100644 index 0000000..f9ed2d9 --- /dev/null +++ b/backport-growpart-Use-LANG-C-to-parse-sfdisk-output.patch @@ -0,0 +1,42 @@ +From 3cde8344f64118c723b40ecff7066c2ff8c51013 Mon Sep 17 00:00:00 2001 +From: Nicolas Chauvet +Date: Fri, 26 Feb 2021 17:15:44 +0100 +Subject: [PATCH] growpart: Use LANG=C to parse sfdisk output + +Reference:https://github.com/canonical/cloud-utils/commit/3cde8344f64118c723b40ecff7066c2ff8c51013 +Conflict:NA + +This will prevent failure to parse output of in non-C locales leading to +failure to resize partition. + +Alternative would be to use sfdisk --dump, but this misses some +importants informations such as the sectors size + +Reported in: +https://bugs.launchpad.net/cloud-utils/+bug/1860479 + +This was tested on centos7 with sfdisk 2.23.2 and +centos8 with sfdisk 2.32.1 + +Reported-by: https://launchpad.net/~pickadi +Signed-off-by: Nicolas Chauvet +--- + bin/growpart | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/bin/growpart b/bin/growpart +index 994b258..cbc3f18 100755 +--- a/bin/growpart ++++ b/bin/growpart +@@ -292,7 +292,7 @@ resize_sfdisk() { + local pt_start pt_size pt_end max_end new_size change_info dpart + local sector_num sector_size disk_size tot out + +- rqe sfd_list sfdisk --list --unit=S "$DISK" >"$tmp" || ++ LANG=C rqe sfd_list sfdisk --list --unit=S "$DISK" >"$tmp" || + fail "failed: sfdisk --list $DISK" + if [ "${SFDISK_VERSION}" -lt ${SFDISK_2_26} ]; then + # exected output contains: Units: sectors of 512 bytes, ... +-- +2.33.0 + diff --git a/cloud-utils.spec b/cloud-utils.spec index 9db9ee6..3a1b475 100644 --- a/cloud-utils.spec +++ b/cloud-utils.spec @@ -1,6 +1,6 @@ Name: cloud-utils Version: 0.32 -Release: 2 +Release: 3 Summary: Cloud image management utilities License: GPLv3 URL: https://launchpad.net/cloud-utils/ @@ -15,6 +15,9 @@ This package provides a useful set of utilities for managing cloud images. Summary: Script for growing a partition Requires: gawk util-linux +Patch6000: backport-Fix-growpart-doesn-t-work-when-LANG-cs_CZ.UTF-8.patch +Patch6001: backport-growpart-Use-LANG-C-to-parse-sfdisk-output.patch + %description growpart This package provides the growpart script for growing a partition. @@ -50,7 +53,11 @@ This package provides the growpart script for growing a partition. %{_mandir}/man1/* %changelog -* Tue Oct 25 2022 yanglongkang - 0.33-2 +* Fri Mar 29 2024 Lv Ying - 0.32-3 +- Fix growpart doesn't work when LANG=cs_CZ.UTF-8; + growpart: Use LANG=C to parse sfdisk output + +* Tue Oct 25 2022 yanglongkang - 0.32-2 - rebuild for next release * Tue Dec 14 2021 yangzhuangzhuang - 0.32-1 -- Gitee