Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 932098 - sys-boot/os-prober-1.81-r2: Fails to detect Windows if run with dash
Summary: sys-boot/os-prober-1.81-r2: Fails to detect Windows if run with dash
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Peter Levine
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks: nonbash
  Show dependency tree
 
Reported: 2024-05-17 14:54 UTC by Enno Tensing
Modified: 2024-05-21 15:50 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Enno Tensing 2024-05-17 14:54:17 UTC
If /bin/sh is dash, os-prober does not detect Windows, instead reporting the following error:

# os-prober
/usr/bin/os-prober: 335: [: 10: unexpected operator



It correctly detects Windows if modfied to run with bash:

# sed -e 's|/bin/sh|/bin/bash|1' -i /usr/bin/os-prober
# os-prober
/dev/sda1@/EFI/Microsoft/Boot/bootmgfw.efi:Windows Boot Manager:Windows:efi



# emerge --info
Portage 3.0.63 (python 3.11.9-final-0, default/linux/amd64/23.0/split-usr/desktop, gcc-13, glibc-2.38-r13, 6.9.1 x86_64)
=================================================================
System uname: Linux-6.9.1-x86_64-AMD_Ryzen_9_5900X_12-Core_Processor-with-glibc2.38
KiB Mem:    65751432 total,  61963968 free
KiB Swap:   33554428 total,  33554428 free
Timestamp of repository gentoo: Fri, 17 May 2024 13:30:00 +0000
Head commit of repository gentoo: b9046ead7a0a35ccba006e038ddd3b8100ca26b1
Timestamp of repository guru: Fri, 17 May 2024 12:20:59 +0000
Head commit of repository guru: 5bbca10c9fbe4f0c93b868e5436c2afe8c7a14cf

Timestamp of repository steam-overlay: Fri, 17 May 2024 12:20:53 +0000
Head commit of repository steam-overlay: 50cd00c3db1b246b78295a54101cc1b0ba385c64

sh dash 0.5.12
ld GNU ld (Gentoo 2.42 p3) 2.42.0
ccache version 4.9.1 [disabled]
app-misc/pax-utils:        1.3.7::gentoo
app-shells/bash:           5.1_p16-r6::gentoo
dev-build/autoconf:        2.71-r7::gentoo
dev-build/automake:        1.16.5-r2::gentoo
dev-build/cmake:           3.28.5::gentoo
dev-build/libtool:         2.4.7-r4::gentoo
dev-build/make:            4.4.1-r1::gentoo
dev-build/meson:           1.4.0-r1::gentoo
dev-java/java-config:      2.3.3-r1::gentoo
dev-lang/perl:             5.38.2-r3::gentoo
dev-lang/python:           3.11.9::gentoo, 3.12.3::gentoo
dev-lang/rust-bin:         1.77.1::gentoo
dev-util/ccache:           4.9.1-r1::gentoo
sys-apps/baselayout:       2.15::gentoo
sys-apps/openrc:           0.54::gentoo
sys-apps/sandbox:          2.38::gentoo
sys-devel/binutils:        2.42-r1::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           17.0.6::gentoo
sys-devel/gcc:             13.2.1_p20240210::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/llvm:            17.0.6::gentoo
sys-kernel/linux-headers:  6.6-r1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.38-r13::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: False
    sync-rsync-verify-metamanifest: yes
    sync-rsync-extra-opts: 
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo
    volatile: False

steam-overlay
    location: /var/db/repos/steam-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/steam-overlay.git
    masters: gentoo
    volatile: False

Binary Repositories:

binhost
    priority: 9999
    sync-uri: https://ftp.halifax.rwth-aachen.de/gentoo/releases/amd64/binpackages/23.0/x86-64

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@BINARY-REDISTRIBUTABLE OGL-1.0a"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-pipe -march=native -O2 -fstack-protector-strong -fcf-protection -fpie -fPIC -std=c99 -D_DEFAULT_SOURCE -fno-delete-null-pointer-checks -fno-strict-overflow -fno-strict-aliasing -ftrivial-auto-var-init=zero -fstrict-flex-arrays=3 -fstack-clash-protection -Wformat=2 -Wtrampolines -Wimplicit-fallthrough"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/tomoyo/conf /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CPPFLAGS="-pipe -march=native -O2 -fstack-protector-strong -fcf-protection -fpie -fPIC"
CXXFLAGS="-pipe -march=native -O2 -fstack-protector-strong -fcf-protection -fpie -fPIC"
DISTDIR="/var/cache/distfiles"
EMERGE_DEFAULT_OPTS="--ask-enter-invalid"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe -march=native"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance binpkg-request-signature buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict strict-keepdir unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync warn-on-large-env xattr"
FFLAGS="-O2 -pipe -march=native"
GENTOO_MIRRORS="rsync://ftp.wh2.tu-dresden.de/gentoo https://ftp.gwdg.de/pub/linux/gentoo/ rsync://ftp.gwdg.de/gentoo/ https://ftp.uni-hannover.de/gentoo/ https://mirror.netcologne.de/gentoo/ rsync://mirror.netcologne.de/gentoo/ https://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ rsync://linux.rz.ruhr-uni-bochum.de/gentoo https://ftp.halifax.rwth-aachen.de/gentoo/ rsync://ftp.halifax.rwth-aachen.de/gentoo/ rsync://ftp.tu-ilmenau.de/gentoo/ https://ftp.fau.de/gentoo rsync://ftp.fau.de/gentoo https://ftp-stud.hs-esslingen.de/pub/Mirrors/gentoo/ rsync://ftp-stud.hs-esslingen.de/gentoo/"
LANG="en_US.utf8"
LDFLAGS="-Wl,-z,defs -Wl,-z,now -Wl,-z,relro -Wl,-z,nodlopen -Wl,-z,noexecstack"
LEX="flex"
MAKEOPTS="-j24"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/zsh"
USE="X a52 aac acl acpi alsa amd64 aom appindicator avif bluetooth bluray branding bzip2 cairo cdda cdr cet cjk crypt cups dav1d dbus dri dts dvd dvdr elogind encode exif flac gdbm gif gpm gtk gui iconv icu io-uring ipv6 jpeg jpegxl latex lcms libnotify libtirpc mad man mng mp3 mp4 mpeg multilib ncurses nls numpy ogg openal opencl opengl openmp opus pam pango pcre pdf pipewire png policykit ppds qt5 readline screencast sdl seccomp sound spell split-usr ssl startup-notification svg test-rust tiff truetype udev udisks unicode upower usb vaapi vorbis vulkan wayland webp wxwidgets x264 xattr xcb xft xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2 aes avx avx2 f16c fma3 pclmul popcnt rdrand sha sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="wacom joystick libinput" KERNEL="linux" L10N="en en-UK en-US de de-DE ja" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PERL_FEATURES="quadmath" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby31" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS
Comment 1 Enno Tensing 2024-05-17 15:18:26 UTC
I tested it with 1.80, 1.81 and 1.81 with 1.81-boot-detected-twice.patch applied manually; With these versions Windows is detected.

So the problem probably is in list_mounts() of 1.81-boot-detected-twice-v2.patch?
Comment 2 Enno Tensing 2024-05-17 15:28:06 UTC
In line 15 of the patch (which is line 335 of /usr/share/os-prober/common.sh) the script checks if the first line of /proc/self/mountinfo is 10 or 11 words. It does that with '==', but it should be '-eq' or '=' for POSIX-sh support


[0] https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-boot/os-prober/files/os-prober-1.81-boot-detected-twice-v2.patch#n15
Comment 3 Larry the Git Cow gentoo-dev 2024-05-21 15:50:23 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=80f9bed892f17cb69eaab7ac9a1fa547384c4927

commit 80f9bed892f17cb69eaab7ac9a1fa547384c4927
Author:     Enno Tensing <tenno@suij.in>
AuthorDate: 2024-05-17 18:08:41 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2024-05-21 15:50:15 +0000

    sys-boot/os-prober: Make boot-detected-twice patch POSIX sh compliant
    
    This versions modfies the patch added by -r2 to be POSIX sh compliant.
    For this we just replace the '==' in line 15 with '-eq'.
    
    Closes: https://bugs.gentoo.org/932098
    Signed-off-by: Enno Tensing <tenno@suij.in>
    Closes: https://github.com/gentoo/gentoo/pull/36725
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 .../os-prober-1.81-boot-detected-twice-v3.patch    |  57 ++++++++++++
 sys-boot/os-prober/os-prober-1.81-r3.ebuild        | 103 +++++++++++++++++++++
 2 files changed, 160 insertions(+)