SHA256
1
0
forked from pool/os-prober
Dominique Leuenberger 2019-03-14 13:54:04 +00:00 committed by Git OBS Bridge
commit e32d5ba54d
3 changed files with 152 additions and 4 deletions

View File

@ -0,0 +1,127 @@
From 2ed7c3ae98aa671d504eba254fdd89ea26fe15c8 Mon Sep 17 00:00:00 2001
From: Michael Chang <mchang@suse.com>
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

View File

@ -1,3 +1,18 @@
-------------------------------------------------------------------
Tue Mar 12 06:47:59 UTC 2019 - mchang <mchang@suse.com>
- Update URL to current development project in Debian Salsa server.
- Update the Source0 to use local compressed archive since the remote URL is
not reliable to access, causing trouble to the factory-auto checker reporting
error as not valid one.
* os-prober.spec
-------------------------------------------------------------------
Thu Mar 7 08:56:53 UTC 2019 - mchang <mchang@suse.com>
- 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

View File

@ -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/
#
@ -22,8 +22,8 @@ Release: 0
Summary: Probes disks on the system for installed operating systems
License: GPL-2.0-or-later
Group: System/Boot
Url: http://kitenet.net/~joey/code/os-prober/
Source0: http://ftp.de.debian.org/debian/pool/main/o/os-prober/%{name}_%{version}.tar.xz
Url: https://salsa.debian.org/installer-team/os-prober
Source0: %{name}_%{version}.tar.xz
Source1: COPYING-note.txt
# move newns binary outside of os-prober subdirectory, so that debuginfo
# can be automatically generated for it
@ -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}