From aea4f9e88e59ce3b965ae81f7037a9b01a271906 Mon Sep 17 00:00:00 2001 From: Hedayat Vatankhah Date: Wed, 24 Dec 2014 00:20:39 +0330 Subject: [PATCH] Fix using grep for searching binary files, fixes #1172405. Thanks Paul Eggert for initial patch fixing grep usage in 83haiku --- os-prober-grepfix.patch | 44 ++++++++++++++++++++++++++++ os-prober-no-dummy-mach-kernel.patch | 9 ++---- os-prober.spec | 8 ++++- 3 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 os-prober-grepfix.patch diff --git a/os-prober-grepfix.patch b/os-prober-grepfix.patch new file mode 100644 index 0000000..c687d08 --- /dev/null +++ b/os-prober-grepfix.patch @@ -0,0 +1,44 @@ +Index: b/os-probes/mounted/x86/20microsoft +=================================================================== +--- a/os-probes/mounted/x86/20microsoft ++++ b/os-probes/mounted/x86/20microsoft +@@ -31,19 +31,19 @@ if item_in_dir -q bootmgr "$2"; then + for boot in $(item_in_dir boot "$2"); do + bcd=$(item_in_dir bcd "$2/$boot") + if [ -n "$bcd" ]; then +- if grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then ++ if grep -aqs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then + long="Windows 8 (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then + long="Windows 7 (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then + long="Windows Vista (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8. .R.2." "$2/$boot/$bcd"; then + long="Windows Server 2008 R2 (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .S.e.r.v.e.r. .2.0.0.8." "$2/$boot/$bcd"; then + long="Windows Server 2008 (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .R.e.c.o.v.e.r.y. .E.n.v.i.r.o.n.m.e.n.t" "$2/$boot/$bcd"; then + long="Windows Recovery Environment (loader)" +- elif grep -qs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then ++ elif grep -aqs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then + long="Windows Recovery Environment (loader)" + else + long="Windows Vista (loader)" +Index: b/os-probes/mounted/x86/83haiku +=================================================================== +--- a/os-probes/mounted/x86/83haiku ++++ b/os-probes/mounted/x86/83haiku +@@ -13,7 +13,7 @@ case "$type" in + *) debug "$partition is not a BeFS partition: exiting"; exit 1 ;; + esac + +-if head -c 512 "$partition" | grep -qs "system.haiku_loader"; then ++if head -c 512 "$partition" | grep -aqs "system.haiku_loader"; then + debug "Stage 1 bootloader found" + else + debug "Stage 1 bootloader not found: exiting" diff --git a/os-prober-no-dummy-mach-kernel.patch b/os-prober-no-dummy-mach-kernel.patch index 7c16af9..b9e1254 100644 --- a/os-prober-no-dummy-mach-kernel.patch +++ b/os-prober-no-dummy-mach-kernel.patch @@ -7,8 +7,8 @@ Subject: [PATCH] Don't count our dummy mach_kernel as real MacOS X. os-probes/mounted/powerpc/20macosx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -diff --git a/os-probes/mounted/powerpc/20macosx b/os-probes/mounted/powerpc/20macosx -index dd4207f..d630fec 100755 +Index: b/os-probes/mounted/powerpc/20macosx +=================================================================== --- a/os-probes/mounted/powerpc/20macosx +++ b/os-probes/mounted/powerpc/20macosx @@ -21,7 +21,7 @@ esac @@ -16,10 +16,7 @@ index dd4207f..d630fec 100755 # shell will be nasty. -if [ -e "$2/mach_kernel" ]; then -+if [ -e "$2/mach_kernel" ] && ! dd if="$2/mach_kernel" count=1 bs=5 2>/dev/null | grep -q Dummy ; then ++if [ -e "$2/mach_kernel" ] && ! dd if="$2/mach_kernel" count=1 bs=5 2>/dev/null | grep -aq Dummy ; then label="$(count_next_label MacOSX)" result "$1:Mac OS X:$label:macosx" exit 0 --- -1.7.10.1 - diff --git a/os-prober.spec b/os-prober.spec index 4a601bc..4ade2df 100644 --- a/os-prober.spec +++ b/os-prober.spec @@ -1,6 +1,6 @@ Name: os-prober Version: 1.65 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Probes disks on the system for installed operating systems Group: System Environment/Base @@ -26,6 +26,7 @@ Patch10: os-prober-factor-out-logger.patch Patch11: os-prober-factored-logger-efi-fix.patch Patch12: os-prober-umount-fix.patch Patch13: os-prober-grub2-parsefix.patch +Patch14: os-prober-grepfix.patch Requires: udev coreutils util-linux Requires: grep /bin/sed /sbin/modprobe @@ -51,6 +52,7 @@ distributions can be added easily. %patch11 -p1 -b .factor-out-logger-efi-fix %patch12 -p1 -b .umount-fix %patch13 -p1 -b .grub2-parsefix +%patch14 -p1 -b .grepfix find -type f -exec sed -i -e 's|usr/lib|usr/libexec|g' {} \; sed -i -e 's|grub-probe|grub2-probe|g' os-probes/common/50mounted-tests \ @@ -101,6 +103,10 @@ fi %{_var}/lib/%{name} %changelog +* Tue Dec 23 2014 Hedayat Vatankhah - 1.65-2 +- Fix using grep for searching binary files, fixes #1172405. Thanks Paul Eggert + for initial patch fixing grep usage in 83haiku + * Sun Dec 07 2014 Hedayat Vatankhah - 1.65-1 - Using latest upstream version tarball to be consistent with upstream versioning