From 621a480772298c097e6479a6d247910f578c2beb385113f66c56b12d3dc1e6cb Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 11 Mar 2019 10:05:37 +0000 Subject: [PATCH] Accepting request 683730 from home:michael-chang:os-prober:bsc:1125729 - os-prober isn't compatible with transactional update (boo#1125729) * os-prober-use-tmp-over-var-lib-for-transient-files.patch OBS-URL: https://build.opensuse.org/request/show/683730 OBS-URL: https://build.opensuse.org/package/show/Base:System/os-prober?expand=0&rev=93 --- ...tmp-over-var-lib-for-transient-files.patch | 127 ++++++++++++++++++ os-prober.changes | 6 + os-prober.spec | 10 +- 3 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 os-prober-use-tmp-over-var-lib-for-transient-files.patch diff --git a/os-prober-use-tmp-over-var-lib-for-transient-files.patch b/os-prober-use-tmp-over-var-lib-for-transient-files.patch new file mode 100644 index 0000000..3375d00 --- /dev/null +++ b/os-prober-use-tmp-over-var-lib-for-transient-files.patch @@ -0,0 +1,127 @@ +From 2ed7c3ae98aa671d504eba254fdd89ea26fe15c8 Mon Sep 17 00:00:00 2001 +From: Michael Chang +Date: Thu, 7 Mar 2019 16:31:19 +0800 +Subject: [PATCH] Use /tmp over /var/lib for transient files + +Create transient mount point in directory /tmp rather than /var/lib +which is not available during transactional update. Also clean up the +count_last_label function for not relying on /var/lib/os-prober/labels +file for the caculation. + +https://en.opensuse.org/openSUSE:Packaging_for_transactional-updates +--- + common.sh | 37 ++++++++++++++------------------ + linux-boot-prober | 2 +- + linux-boot-probes/common/50mounted-tests | 2 +- + os-prober | 3 --- + os-probes/common/50mounted-tests | 2 +- + 5 files changed, 19 insertions(+), 27 deletions(-) + +diff --git a/common.sh b/common.sh +index 19d2668..d73718c 100644 +--- a/common.sh ++++ b/common.sh +@@ -21,31 +21,26 @@ require_tmpdir() { + fi + } + +-count_for() { +- _labelprefix="$1" +- _result=$(grep "^${_labelprefix} " /var/lib/os-prober/labels 2>/dev/null || true) +- +- if [ -z "$_result" ]; then +- return +- else +- echo "$_result" | cut -d' ' -f2 +- fi +-} +- ++OS_PROBER_LABELS="" + count_next_label() { +- require_tmpdir +- + _labelprefix="$1" +- _cfor="$(count_for "${_labelprefix}")" +- +- if [ -z "$_cfor" ]; then +- echo "${_labelprefix} 1" >> /var/lib/os-prober/labels ++ _count="" ++ _labels="" ++ for i in $OS_PROBER_LABELS; do ++ _label="`echo $i | cut -d: -f1`" ++ if [ x"$_labelprefix" = x"$_label" ]; then ++ _count=`echo $i | cut -d: -f2` ++ _labels="$_labels $_label:`expr $_count + 1`" ++ else ++ _labels="$_labels $i" ++ fi ++ done ++ if [ -z "$_count" ]; then ++ OS_PROBER_LABELS="$OS_PROBER_LABELS $_labelprefix:1" + else +- sed "s/^${_labelprefix} ${_cfor}/${_labelprefix} $(($_cfor + 1))/" /var/lib/os-prober/labels > "$OS_PROBER_TMP/os-prober.tmp" +- mv "$OS_PROBER_TMP/os-prober.tmp" /var/lib/os-prober/labels ++ OS_PROBER_LABELS="$_labels" + fi +- +- echo "${_labelprefix}${_cfor}" ++ echo "${_labelprefix}${_count}" + } + + progname= +diff --git a/linux-boot-prober b/linux-boot-prober +index 243fd6c..4d0f5e8 100755 +--- a/linux-boot-prober ++++ b/linux-boot-prober +@@ -7,7 +7,7 @@ newns "$@" + require_tmpdir + ERR="n" + +-tmpmnt=/var/lib/os-prober/mount ++tmpmnt="$OS_PROBER_TMP/mount" + if [ ! -d "$tmpmnt" ]; then + mkdir "$tmpmnt" + fi +diff --git a/linux-boot-probes/common/50mounted-tests b/linux-boot-probes/common/50mounted-tests +index 84c3ced..7c9c717 100755 +--- a/linux-boot-probes/common/50mounted-tests ++++ b/linux-boot-probes/common/50mounted-tests +@@ -42,7 +42,7 @@ elif [ -z "$types" ]; then + types="$(grep -v nodev /proc/filesystems)" + fi + +-tmpmnt=/var/lib/os-prober/mount ++tmpmnt="$OS_PROBER_TMP/mount" + if [ ! -d "$tmpmnt" ]; then + mkdir "$tmpmnt" + fi +diff --git a/os-prober b/os-prober +index fb0f93c..903eddb 100755 +--- a/os-prober ++++ b/os-prober +@@ -141,9 +141,6 @@ parse_proc_mdstat () { + done + } + +-# Needed for idempotency +-rm -f /var/lib/os-prober/labels +- + for prog in /usr/lib/os-probes/init/*; do + if [ -x "$prog" ] && [ -f "$prog" ]; then + "$prog" || true +diff --git a/os-probes/common/50mounted-tests b/os-probes/common/50mounted-tests +index a9c20ef..9555c39 100755 +--- a/os-probes/common/50mounted-tests ++++ b/os-probes/common/50mounted-tests +@@ -58,7 +58,7 @@ elif [ -z "$types" ]; then + exit 0 + fi + +-tmpmnt=/var/lib/os-prober/mount ++tmpmnt="$OS_PROBER_TMP/mount" + if [ ! -d "$tmpmnt" ]; then + mkdir "$tmpmnt" + fi +-- +2.16.4 + diff --git a/os-prober.changes b/os-prober.changes index db7abc8..4bd58a5 100644 --- a/os-prober.changes +++ b/os-prober.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Mar 7 08:56:53 UTC 2019 - mchang + +- os-prober isn't compatible with transactional update (boo#1125729) + * os-prober-use-tmp-over-var-lib-for-transient-files.patch + ------------------------------------------------------------------- Tue Dec 11 07:30:19 UTC 2018 - mchang@suse.com diff --git a/os-prober.spec b/os-prober.spec index 07e7099..717a4ff 100644 --- a/os-prober.spec +++ b/os-prober.spec @@ -1,7 +1,7 @@ # # spec file for package os-prober # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,7 +12,7 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # @@ -70,6 +70,8 @@ Patch25: os-prober-05efi-blkid.patch Patch26: os-prober-multiple-initrd.patch # PATCH-FIX-OPENSUSE: os-prober unconditionally pulls btrfsprogs (boo#1118279) Patch27: os-prober-make-btrfsprogs-optional.patch +# PATCH-FIX-OPENSUSE: os-prober isn't compatible with transactional update (boo#1125729) +Patch28: os-prober-use-tmp-over-var-lib-for-transient-files.patch Requires: /bin/grep Requires: /bin/sed Requires: /sbin/modprobe @@ -114,6 +116,7 @@ cp %{SOURCE1} . %patch25 -p1 %patch26 -p1 %patch27 -p1 +%patch28 -p1 find . -name \*.orig -delete %build @@ -121,6 +124,9 @@ make %{?_smp_mflags} CC="gcc" CFLAGS="%{optflags}" %install install -m 0755 -d %{buildroot}%{_bindir} +# See also boo#1125729, we no longer use /var/lib/os-prober for runtime +# temporary files, but to keep compatible with upstream runtime we still keep +# it in place. install -m 0755 -d %{buildroot}%{_localstatedir}/lib/%{name} install -m 0755 -p os-prober linux-boot-prober %{buildroot}%{_bindir}