From d86cd3583c321c7bc4d95a3b306c9f41d72917dc Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 16 2020 09:38:16 +0000 Subject: os-prober-1.74 base --- diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1175bba --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +CFLAGS := -Os -g -Wall + +all: newns + +newns: newns.c + $(CC) $(CFLAGS) $(LDFLAGS) $^ -o $@ + +clean: + rm -f newns diff --git a/README b/README new file mode 100644 index 0000000..e747a7f --- /dev/null +++ b/README @@ -0,0 +1,71 @@ +This is a small package that may be depended on by any bootloader +installer package to detect other filesystems with operating systems on +them, and work out how to boot other linux installs. + +os-prober +--------- + +All one has to do is Depend on os-prober, and then run the os-prober +command. This command takes no arguments: it will scan all disks available +on the system for other operating systems, and output a list of strings +such as: + + /dev/sda1:Windows NT/2000/XP:WinNT:chain + ^-------^ ^----------------^ ^---^ ^---^ + part. OS name for boot short May change: type of boot loader + loader's pretty name required. Usually there is only + output a 'linux' style bootloader or + a chain one for other partitions + with their own boot sectors. + +Tests are executable programs in the directory /usr/lib/os-probes/. Each +test is called once per partition, with the partition to check as its +parameter, and may output a string as described above, or nothing if it does +not recognise an OS on that partition. Tests return an exit code of 0 +if they successfully found an OS, and no further tests will be run on that +partition; or return an exit code of 1 to indicate that no OS was found, +and let the next test run. + +Tests that require the partition to be mounted can be placed in +/usr/lib/os-probes/mounted/. These tests are passed the following +parameters: partition, mount point, filesystem. + +Bootloader installer packages will then have to process this output (fairly +trivial) to create valid configuration entries for the bootloader. + +Note that os-prober can find other Linux installations, as well as other +operating systems. It does not try to work out all the information needed +to boot Linux (initrd, kernel params, etc). That task is left to +linux-boot-prober. + +linux-boot-prober +----------------- + +The linux-boot-prober command should be run with a single argument +consisting of a partition that is known to have a linux root filesystem on +it, as returned by the os-prober command. It will try to work out how to +boot that linux installation, and if it is successful, will output one or +more lines in the form: + + /dev/sda2:/dev/sda1:Linux:/vmlinuz:/initrd.gz:root=/dev/sda1 + ^-------^ ^-------^ ^---^ ^------^ ^--------^ ^------------^ + root boot label kernel initrd kernel params + part. part. + +The root partition and boot partition may of course be the same. No guarantee +is made that any partitions referred to in the kernel parameters will still be +in the same place after Debian is installed, or that the /etc/fstab of the +system will be right, or that the system will even boot. The initrd field may +be empty if there is no initrd. The label is whatever label was used in the +boot loader for this linux installation, and it may be quite long or very +short (or nonexistent), and may be inaccurate, confusing, or non-unique. See +TODO for other limitations. + +The tests used by linux-boot-prober are in the directory +/usr/lib/linux-boot-probes/ and also in /usr/lib/linux-boot-probes/mounted, +and they are called in a similar way as the os-probes described above. +The mounted probes are passed parameters for the root partition, the boot +partition, and the directory the filesystems are mounted in. + +linux-boot-prober skips over partitions that are currently mounted on /, +/target, or /target/boot. diff --git a/TODO b/TODO new file mode 100644 index 0000000..b08e72f --- /dev/null +++ b/TODO @@ -0,0 +1,24 @@ +This thing needs a regression test suite. + +The grub linux-boot-probe has these limitations: + + - Does not handle grub present menus. + - Does not support things like (hd0,1)/path/to/file + although in the case of the kernel it will strip + off the drive specification, and look for the file in the current + partition. + +The lilo linux-boot-probe has these limitations: + + - Doesn't map from devfs to normal if the lilo.conf uses devfs names + (valid?) + +linux-boot-prober: + +- Partition names in boot loader config may have changed during + the debian install, so cannot be trusted. Fix up root= lines, + etc. +- To get to boot/, may need to parse fstab. But this can fail because + as noted above, drive names may have changed! +- Maybe do some probing before partitioning and store info? + Or don't support adding partitions before existing /boot partitions. diff --git a/common.sh b/common.sh new file mode 100644 index 0000000..a57e2a4 --- /dev/null +++ b/common.sh @@ -0,0 +1,328 @@ +newns () { + [ "$OS_PROBER_NEWNS" ] || exec /usr/lib/os-prober/newns "$0" "$@" +} + +cleanup_tmpdir=false +cleanup () { + if $cleanup_tmpdir; then + rm -rf "$OS_PROBER_TMP" + fi +} + +require_tmpdir() { + if [ -z "$OS_PROBER_TMP" ]; then + if type mktemp >/dev/null 2>&1; then + export OS_PROBER_TMP="$(mktemp -d /tmp/os-prober.XXXXXX)" + cleanup_tmpdir=: + trap cleanup EXIT HUP INT QUIT TERM + else + export OS_PROBER_TMP=/tmp + fi + 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 +} + +count_next_label() { + require_tmpdir + + _labelprefix="$1" + _cfor="$(count_for "${_labelprefix}")" + + if [ -z "$_cfor" ]; then + echo "${_labelprefix} 1" >> /var/lib/os-prober/labels + 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 + fi + + echo "${_labelprefix}${_cfor}" +} + +progname= +cache_progname() { + case $progname in + '') + progname="${0##*/}" + ;; + esac +} + +log() { + cache_progname + logger -t "$progname" "$@" +} + +error() { + log "error: $@" +} + +warn() { + log "warning: $@" +} + +debug() { + if [ -z "$OS_PROBER_DISABLE_DEBUG" ]; then + log "debug: $@" + fi +} + +result () { + log "result:" "$@" + echo "$@" +} + +# shim to make it easier to use os-prober outside d-i +if ! type mapdevfs >/dev/null 2>&1; then + mapdevfs () { + readlink -f "$1" + } +fi + +item_in_dir () { + if [ "$1" = "-q" ]; then + q="-q" + shift 1 + else + q="" + fi + [ -d "$2" ] || return 1 + # find files with any case + ls -1 "$2" | grep $q -i "^$1$" +} + +# We can't always tell the filesystem type up front, but if we have the +# information then we should use it. Note that we can't use block-attr here +# as it's only available in udebs. +# If not detected after different attempts then "NOT-DETECTED" will be printed +# because function is not supposed to exit error codes. +fs_type () { + local fstype="" + if (export PATH="/lib/udev:$PATH"; type vol_id) >/dev/null 2>&1; then + PATH="/lib/udev:$PATH" \ + fstype=$(vol_id --type "$1" 2>/dev/null || true) + [ -z "$fstype" ] || { echo "$fstype"; return; } + fi + if type lsblk >/dev/null 2>&1 ; then + fstype=$(lsblk --nodeps --noheading --output FSTYPE -- "$1" || true) + [ -z "$fstype" ] || { echo "$fstype"; return; } + fi + if type blkid >/dev/null 2>&1; then + fstype=$(blkid -o value -s TYPE "$1" 2>/dev/null || true) + [ -z "$fstype" ] || { echo "$fstype"; return; } + fi + echo "NOT-DETECTED" +} + +is_dos_extended_partition() { + if type blkid >/dev/null 2>&1; then + local output + + output="$(blkid -o export $1)" + + # old blkid (util-linux << 2.24) errors out on extended p. + if [ "$?" = "2" ]; then + return 0 + fi + + # dos partition type and no filesystem type?... + if echo $output | grep -q ' PTTYPE=dos ' && + ! echo $output | grep -q ' TYPE='; then + return 0 + else + return 1 + fi + fi + + return 1 +} + +parse_proc_mounts () { + while read -r line; do + set -f + set -- $line + set +f + printf '%s %s %s\n' "$(mapdevfs "$1")" "$2" "$3" + done +} + +parsefstab () { + while read -r line; do + case "$line" in + "#"*) + : + ;; + *) + set -f + set -- $line + set +f + printf '%s %s %s\n' "$1" "$2" "$3" + ;; + esac + done +} + +unescape_mount () { + printf %s "$1" | \ + sed 's/\\011/ /g; s/\\012/\n/g; s/\\040/ /g; s/\\134/\\/g' +} + +find_label () { + local output + if type blkid >/dev/null 2>&1; then + # Hopefully everyone has blkid by now + output="$(blkid -o device -t LABEL="$1")" || return 1 + echo "$output" | head -n1 + elif [ -h "/dev/disk/by-label/$1" ]; then + # Last-ditch fallback + readlink -f "/dev/disk/by-label/$1" + else + return 1 + fi +} + +find_uuid () { + local output + if type blkid >/dev/null 2>&1; then + # Hopefully everyone has blkid by now + output="$(blkid -o device -t UUID="$1")" || return 1 + echo "$output" | head -n1 + elif [ -h "/dev/disk/by-uuid/$1" ]; then + # Last-ditch fallback + readlink -f "/dev/disk/by-uuid/$1" + else + return 1 + fi +} + +do_dmsetup () { + local prefix partition dm_device partition_name size_p + prefix="$1" + partition="$2" + dm_device= + + if type dmsetup >/dev/null 2>&1 && \ + type blockdev >/dev/null 2>&1; then + partition_name="osprober-linux-${partition##*/}" + dm_device="/dev/mapper/$partition_name" + size_p=$(blockdev --getsize $partition ) + if [ -e "$dm_device" ]; then + error "$dm_device already exists" + dm_device= + else + debug "creating device mapper device $dm_device" + echo "0 $size_p linear $partition 0" | dmsetup create -r $partition_name + fi + fi + echo "$dm_device" +} + +# Sets $mountboot and $dm_device as output variables. This is very messy, +# but POSIX shell isn't really up to the task of doing it more cleanly. +linux_mount_boot () { + partition="$1" + tmpmnt="$2" + + bootpart="" + mounted="" + dm_device="" + if [ -e "$tmpmnt/etc/fstab" ]; then + # Try to mount any /boot partition. + bootmnt=$(parsefstab < "$tmpmnt/etc/fstab" | grep " /boot ") || true + if [ -n "$bootmnt" ]; then + set -f + set -- $bootmnt + set +f + boottomnt="" + + # Try to map labels and UUIDs ourselves if possible, + # so that we can check whether they're already + # mounted somewhere else. + tmppart="$1" + if echo "$1" | grep -q "LABEL="; then + label="$(echo "$1" | cut -d = -f 2)" + if tmppart="$(find_label "$label")"; then + debug "mapped LABEL=$label to $tmppart" + else + debug "found boot partition LABEL=$label for Linux system on $partition, but cannot map to existing device" + mountboot="$partition 0" + return + fi + elif echo "$1" | grep -q "UUID="; then + uuid="$(echo "$1" | cut -d = -f 2)" + if tmppart="$(find_uuid "$uuid")"; then + debug "mapped UUID=$uuid to $tmppart" + else + debug "found boot partition UUID=$uuid for Linux system on $partition, but cannot map to existing device" + mountboot="$partition 0" + return + fi + fi + shift + set -- "$(mapdevfs "$tmppart")" "$@" + + if grep -q "^$1 " "$OS_PROBER_TMP/mounted-map"; then + bindfrom="$(grep "^$1 " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2)" + bindfrom="$(unescape_mount "$bindfrom")" + if [ "$bindfrom" != "$tmpmnt/boot" ]; then + if mount --bind "$bindfrom" "$tmpmnt/boot"; then + mounted=1 + bootpart="$1" + else + debug "failed to bind-mount $bindfrom onto $tmpmnt/boot" + fi + fi + fi + if [ "$mounted" ]; then + : + elif [ -e "$1" ]; then + bootpart="$1" + boottomnt="$1" + elif [ -e "$tmpmnt/$1" ]; then + bootpart="$1" + boottomnt="$tmpmnt/$1" + elif [ -e "/target/$1" ]; then + bootpart="$1" + boottomnt="/target/$1" + else + bootpart="" + fi + + if [ ! "$mounted" ]; then + if [ -z "$bootpart" ]; then + debug "found boot partition $1 for linux system on $partition, but cannot map to existing device" + else + debug "found boot partition $bootpart for linux system on $partition" + if type grub-mount >/dev/null 2>&1 && \ + grub-mount "$boottomnt" "$tmpmnt/boot" 2>/dev/null; then + mounted=1 + elif dm_device="$(do_dmsetup osprober-linux "$boottomnt")" && [ "$dm_device" ]; then + if mountinfo=`mount -o ro "$dm_device" "$tmpmnt/boot" -t "$3"`; then + debug "mounted as $3 filesystem" + mounted=1 + else + error "failed to mount $dm_device on $tmpmnt/boot: $mountinfo" + fi + fi + fi + fi + fi + fi + if [ -z "$bootpart" ]; then + bootpart="$partition" + fi + if [ -z "$mounted" ]; then + mounted=0 + fi + + mountboot="$bootpart $mounted" +} diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..d05f5eb --- /dev/null +++ b/debian/changelog @@ -0,0 +1,1033 @@ +os-prober (1.74) unstable; urgency=high + + [ Ivo De Decker ] + * os-probes/common/50mounted-tests: Skip partition when FS type is + LVM2_member, since one isn't supposed to touch physical volumes + directly. This avoids hanging during “dmcreate setup” with + unencrypted LVM setups (Closes: #853277). + + -- Cyril Brulebois Wed, 01 Feb 2017 00:01:17 +0100 + +os-prober (1.73) unstable; urgency=medium + + [ Cyril Brulebois ] + * Add support for Mageia, thanks to Neal Gompa (Closes: #851983). + + -- Christian Perrier Sat, 21 Jan 2017 08:44:01 +0100 + +os-prober (1.72) unstable; urgency=medium + + * Improve logging of mounting and setting partitions to ro/rw (thanks, Ivo + De Decker). + * Use a read-only device-mapper entry if possible rather than setting the + underlying device to read-only (thanks, Ivo De Decker; closes: #701814). + Note that this introduces a dependency on dmsetup on Linux + architectures. + * Remove the "blockdev --setro" code path entirely, since the read-only + device-mapper arrangement supersedes it and should be safer (closes: + #648208). + * Make os-prober-udeb depend on grub-mount-udeb on all Linux and kFreeBSD + architectures, now that it's available on them all (thanks, James + Cowgill; closes: #776275). + * Make os-prober depend on grub-common on Linux and kFreeBSD, in order + that grub-mount is consistently available. + * Fix detection of /usr/ partition as a GNU/Linux root partition when + /lib* directories are moved to /usr/ completely (thanks, Hedayat + Vatankhah; closes: #698733). + * Make the yaboot parser more tolerant about the syntax of "append" + options (thanks, Hedayat Vatankhah; closes: #674561). + * Disable debugging if OS_PROBER_DISABLE_DEBUG is set (thanks, Hedayat + Vatankhah; closes: #698598). + * Replace basename/dirname with shell string processing (thanks, Hedayat + Vatankhah; part of #694668). + * Call dmraid only once (thanks, Jeff Mahoney). + * Fix typos in README (thanks, Nyav; closes: #803155). + * Add os-release support (based loosely on a patch by Török Edwin; closes: + #794409). + * Add Devuan detection (thanks, David Hare; closes: #801631). + * Work harder to avoid trying to mount extended partitions (thanks, + Philippe Coval; closes: #784709). + * Drop " (loader)" suffixes on Microsoft operating systems (thanks, Chris + Lamb; closes: #787418). + + -- Colin Watson Fri, 20 Jan 2017 12:44:34 +0000 + +os-prober (1.71) unstable; urgency=medium + + [ Cyril Brulebois ] + * Add support for 4MLinux, thanks to Zbigniew Konojacki. + + [ Colin Watson ] + * Use HTTPS for Vcs-* URLs, and link to cgit rather than gitweb. + + -- Christian Perrier Sat, 30 Jan 2016 07:38:56 +0100 + +os-prober (1.70) unstable; urgency=medium + + [ Justus Winter ] + * Fix hurd-any support: Test for /servers instead of /servers/exec to avoid + starting an translator in the mounted system. Also, /hurd/init might be + phased out at some point (Closes: #802053). + + -- Christian Perrier Tue, 27 Oct 2015 06:45:58 +0100 + +os-prober (1.68) unstable; urgency=medium + + * Adjust extended dos partition support for blkid/util-linux 2.24+, + thanks to Andreas Henriksson (Closes: #735169). + * Add support for Windows 10 (otherwise reported as Windows Recovery + Environment). Thanks, Philipp Wolfer! (Closes: #801278). + + -- Cyril Brulebois Thu, 08 Oct 2015 14:26:16 +0200 + +os-prober (1.67) unstable; urgency=medium + + [ James Clarke ] + * rules: Use DEB_HOST_ARCH_CPU instead of DEB_HOST_ARCH, and thus treat + *-{i386,amd64} as x86 + * Support probing on hurd-any. Closes: #799883. + + -- Christian Perrier Wed, 30 Sep 2015 06:55:48 +0200 + +os-prober (1.66) unstable; urgency=medium + + * Add -a flag to grep -qs for Windows Vista detection. It appears the + file isn't always considered as a text file, so this should be more + robust. Thanks to Gianluigi Tiesi for the report and the suggestion + (Closes: #791383). + + -- Cyril Brulebois Fri, 10 Jul 2015 01:34:23 +0200 + +os-prober (1.65) unstable; urgency=medium + + [ Steve McIntyre ] + * Recognise the new ignore_uefi flag from partman-efi. + + -- Steve McIntyre <93sam@debian.org> Tue, 25 Nov 2014 17:41:06 +0000 + +os-prober (1.64) unstable; urgency=medium + + [ Frederic Bonnard ] + * Add ppc64el support. Closes: #752416. + + -- Aurelien Jarno Sun, 17 Aug 2014 23:36:52 +0200 + +os-prober (1.63) unstable; urgency=low + + [ Cyril Brulebois ] + * Drop reiserfs, it's no longer supported. + + -- Christian Perrier Tue, 23 Jul 2013 09:38:17 +0200 + +os-prober (1.62) unstable; urgency=low + + [ Dmitrijs Ledkovs ] + * Set debian source format to '3.0 (native)'. + * Bump debhelper compat level to 9. + * Set Vcs-* to canonical format. + + [ Christian Perrier ] + * Update Standards to 3.9.4 (checked) + + -- Christian Perrier Sun, 14 Jul 2013 12:43:27 +0200 + +os-prober (1.61) unstable; urgency=low + + * Add an extra backslash to the code in parse_proc_mdstat to remove [...], + so that it works properly in dash (thanks, John Ryan; LP: #905607). + + -- Colin Watson Tue, 21 May 2013 22:57:42 +0100 + +os-prober (1.60) unstable; urgency=low + + * os-probes/mounted/x86/05efi: Handle the case where we used grub-mount to + mount the EFI System Partition. + + -- Colin Watson Fri, 17 May 2013 13:02:41 +0100 + +os-prober (1.59) unstable; urgency=low + + [ Colin Watson ] + * Fix cross-building and use dpkg-buildflags. + + -- Christian Perrier Wed, 15 May 2013 17:36:49 +0200 + +os-prober (1.58) unstable; urgency=low + + [ Steve McIntyre ] + * add UEFI support, patch from Andrey Borzenkov: + + skip legacy MS loader detection on UEFI platform + + add framework for searching EFI System Partition + + add scripts that detect Microsoft bootloader and ELILO. + * Add myself to uploaders. + + -- Steve McIntyre <93sam@debian.org> Sun, 28 Apr 2013 16:01:50 +0100 + +os-prober (1.57) unstable; urgency=low + + [ Christian Perrier ] + * Deal with grub-probe exiting with non zero status on some + devices, which in turns can stuck update-grub + Closes: #680084 + + [ Joey Hess ] + * Fix detection of Fedora and other distros that moved /lib into /usr + and left behind a symlink. Grub's filesystem code does not support + symlinks. Closes: #685159 Thanks Andreas Bombe for the patch. + + -- Christian Perrier Sat, 22 Dec 2012 12:54:54 +0100 + +os-prober (1.56) unstable; urgency=low + + [ Hedayat Vatankhah ] + * Add support for probing Fedora's location for the GRUB 2 configuration + file (closes: #674560). + + [ Colin Watson ] + * Fix the parsing code in the grub2 handler so that it no longer gets + hopelessly confused by multiple single-quoted strings on the same line, + as produced by GRUB 2.00. + + -- Colin Watson Mon, 17 Sep 2012 19:02:29 +0100 + +os-prober (1.55) unstable; urgency=low + + * Improve detection of Haiku: detect the 64-bit version + Closes: #685228 + * Add myself to Uploaders + + -- Christian Perrier Sat, 25 Aug 2012 09:58:51 +0200 + +os-prober (1.54) unstable; urgency=low + + * Team upload + + [ Joey Hess ] + * Avoid noise when /proc/swaps does not exist. Closes: #673566 + + -- Christian Perrier Sat, 07 Jul 2012 20:42:47 +0200 + +os-prober (1.53) unstable; urgency=low + + * Team upload + * Use Package-Type instead of deprecated XC-Package-Type + for os-prober-udeb + * Add ${misc:Depends} to udeb dependencies + * Link to explicit GPL-2 document in debian/copyright + * sed off (hdn,n) from the front of an initrd path, + as seen in Mandriva/Mageia grub configs. + Thanks to François Jaouen and Barry Jackson for the patch + Closes: #566102 + + -- Christian Perrier Mon, 07 May 2012 22:37:20 +0200 + +os-prober (1.52) unstable; urgency=low + + [ Stéphane Graber ] + * Add support for Windows 8. + + [ Colin Watson ] + * Install README and TODO in the .deb. + + [ Joey Hess ] + * Revert broken patch adding support for BSD distributions. Closes: #668860 + + -- Joey Hess Fri, 20 Apr 2012 10:50:38 -0400 + +os-prober (1.51) unstable; urgency=low + + [ Joey Hess ] + * Relax the MS-DOS detection again now that it will not cause + false positives for non-FAT filesystems. + + [ Colin Watson ] + * Use 'type' rather than 'which' to test for grub-mount, as d-i doesn't + have 'which'. Also test for grub-probe before using it, as that isn't + currently in grub-mount-udeb and I'm going to need to add it + (LP: #963471). + + -- Colin Watson Tue, 27 Mar 2012 15:47:04 +0100 + +os-prober (1.50) unstable; urgency=low + + [ Joey Hess ] + * Clarify license version is GPL-2+, for all code written by Joey + Hess, Colin Watson, Christian Perrier, Otavio Salvador and + Joshua Kwan. The license had just been "GNU GPL"; other contributors + to os-prober are encouraged to clarify which GPL versions apply to + their code. + + [ Otavio Salvador ] + * Add support to detect BSD systems. Thanks to Gavrilin Andrey + for the patch (refs: #659208). + + [ Joey Hess ] + * Avoid false positives in MS-DOS detection by also looking for + autoexec.bat. Closes: #663540 + + [ Colin Watson ] + * When using grub-mount, pass the GRUB filesystem type to individual tests + rather than "fuseblk". Adjust a number of tests to handle GRUB + filesystem names as well as OS names (closes: #663540, #663600). + + -- Colin Watson Thu, 15 Mar 2012 13:52:30 +0000 + +os-prober (1.49) unstable; urgency=low + + [ Robert Millan ] + * Depend on grub-mount-udeb only on architectures with FUSE support. + + [ Colin Watson ] + * Restrict grub-mount-udeb dependency to architectures where + grub-mount-udeb exists (closes: #639599). + + -- Colin Watson Mon, 29 Aug 2011 12:34:21 +0100 + +os-prober (1.48) unstable; urgency=low + + [ Colin Watson ] + * Depend on grub-mount-udeb (see changelog for 1.45). + * item_in_dir: return 1 immediately if second argument is not a directory + (thanks, Daniel Richard G.; LP: #798447). + + [ Otavio Salvador ] + * add MeeGo detection support; thanks to Chengwei Yang + for the patch. + * Fix Windows detection when there are more then one boot directories + (e.g boot and Boot). Closes: #634649. + + -- Otavio Salvador Sat, 23 Jul 2011 17:46:13 +0200 + +os-prober (1.47) unstable; urgency=low + + [ Joey Hess ] + * Fix unwanted wildcard expansions. Closes: #624815 + + -- Otavio Salvador Sun, 15 May 2011 17:49:10 -0300 + +os-prober (1.46) unstable; urgency=low + + * Correct syntax error in LFS detection. Closes: #623981 + + -- Christian Perrier Mon, 25 Apr 2011 07:09:02 +0200 + +os-prober (1.45) unstable; urgency=low + + [ Matti Kurkela ] + * Improve MS-DOS detection by using an absolute path when verifying + that "dos" is a directory. + + [ Colin Watson ] + * Fix fatal typo in QNX prober. + * Use grub-mount if it exists. This lets us do true read-only mounts, and + works better on journalling filesystems that were mounted uncleanly + (LP: #683355). + * Attempt to load the fuse module, to improve the chances of grub-mount + working. + + [ Armin Krejzi ] + * Add detection of Linux From Scratch distribution. Closes: #623939 + + -- Christian Perrier Sun, 24 Apr 2011 20:02:10 +0200 + +os-prober (1.44) unstable; urgency=low + + * Team upload + * Fix syntax errors in 83haiku and make it executable + + -- Christian Perrier Fri, 18 Feb 2011 20:17:55 +0100 + +os-prober (1.43) unstable; urgency=low + + * Team upload + + [ Christian Perrier ] + * Fix Gentoo detection (different name for kernel and initrd + files). Thanks to caillean for the patch + Closes: #611670 + * Detect Haiku on BeFS partitions. + Thanks to Jeroen Oortwijn for the proposed patch + Closes: #590897 + + [ Joey Hess ] + * 90fallback: Avoid ever accidentially identifying the same file + as initrd and kernel. Closes: #612303 + + -- Christian Perrier Fri, 18 Feb 2011 06:02:22 +0100 + +os-prober (1.42) unstable; urgency=low + + [ Milan Kupcevic ] + * Let yaboot linux-boot-prober work on all chrp machines. + * Handle YDL initrd image in linux-boot-prober fallback test. + + -- Otavio Salvador Fri, 24 Dec 2010 19:13:19 -0200 + +os-prober (1.41) unstable; urgency=low + + [ Joey Hess ] + * Fix probes for MacOS 9 on m68k and powerpc. Closes: #604192 + (Thanks, Milan Kupcevic) + + -- Otavio Salvador Wed, 24 Nov 2010 09:58:18 -0200 + +os-prober (1.40) unstable; urgency=low + + [ Christian Perrier ] + * Fix Windows Vista and Windows Recovery Environment partitions + recognition. (Thanks, Bouke Bunnik) + Closes: #589676, LP: #476625 + * Allow recognition of recent MINIX installations. + Thanks to Feiran Zheng + Closes: #592924 + + [ Colin Watson ] + * Improve error message when /sys/block is missing. + * os-prober doesn't know how to probe other OSes on non-Linux kernels. + For now, just exit quietly rather than confusing people (closes: + #567953). + * Ignore active swap partitions (thanks, Alex Owen; see #417407). + * Refactor linux_mount_boot to look up labels and UUIDs using blkid or + /dev/disk/by-*/ rather than relying on mount being smart enough. This + removes some horrible code that executes mount from /target. + * Set partitions read-only before mounting them (based on a patch by Alex + Owen; closes: #417407, #556739, #599203). + + -- Colin Watson Wed, 10 Nov 2010 11:51:19 +0000 + +os-prober (1.39) unstable; urgency=low + + [ Joey Hess ] + * Fix FreeDOS test to use case-insensative filename lookup + as was already done for all other DOS/Windows tests. Closes: #582257 + (Thanks, Harald Dunkel) + + [ Colin Watson ] + * Handle Dracut-generated initramfs names in linux-boot-prober fallback + test (thanks, Piscium; LP: #420900). + + -- Colin Watson Mon, 28 Jun 2010 18:01:00 +0100 + +os-prober (1.38) unstable; urgency=low + + * Handle single-quoted items in grub.cfg; this has been part of the syntax + for a while, but recently started being used upstream to avoid another + bug. + + -- Colin Watson Fri, 16 Apr 2010 12:17:28 +0100 + +os-prober (1.37) unstable; urgency=low + + [ Frans Pop ] + * 90linux-distro: also allow for lib32 and lib64 directories when looking + for ld*.so*. With thanks to Maximilian Gerhard. Closes: #574407. + + [ Colin Watson ] + * Detect Windows Server 2008 and Windows Server 2008 R2, thanks to + Thorsten. LP: #544117 + * Detect Arch Linux initrds: http://wiki.archlinux.org/index.php/GRUB2 and + http://repos.archlinux.org/wsvn/packages/grub2/trunk/grubconfig.archlinux.patch + indicate that /boot/vmlinuz26 is associated with /boot/kernel26.img. + LP: #518826 + + -- Colin Watson Tue, 13 Apr 2010 14:15:35 +0100 + +os-prober (1.36) unstable; urgency=low + + [ Colin Watson ] + * Suppress tedious fd leak warnings from LVM tools. + + [ Frans Pop ] + * Drop support for the discontinued lpia architecture. + + [ Christian Perrier ] + * Properly quote variable in os-probes/mounted/x86. Thanks + to Fabian Greffrath for the patch. Closes: #563825 + + [ Otavio Salvador ] + * Applied patch from Brad Jorsch to + properly detect Windows' recovery partitions. Closes: #547382 + + [ Joey Hess ] + * Load btrfs module if available. + * Fix arbitrary code execution via eval. Closes: #569229 + * Tighten up quoting of shell variables overall. + * Avoid ever running mount command from filesystems being probed. + Closes: #569222 + * Avoid leaving a temporary mountpoint behind when exiting + in some exceptional conditions. Closes: #569235 + + -- Otavio Salvador Tue, 23 Feb 2010 15:50:17 -0300 + +os-prober (1.35) unstable; urgency=medium + + * Set LC_ALL=C when grepping out accented characters from Windows + descriptions (LP: #438095). + + -- Colin Watson Mon, 05 Oct 2009 23:12:11 +0100 + +os-prober (1.34) unstable; urgency=low + + * Only look for a smart version of mount if we're using busybox mount. In + a normal system, mount probably already handles labels and UUIDs, and + using mount from another filesystem is risky enough that it's worth + avoiding if possible. + * Memoise calls to 'basename $0' in log function. + * Handle escaped special characters in /etc/fstab and /proc/mounts + (LP: #433910). + * dash defines test's -nt operator differently from bash, as it's entitled + to do since this is an extension not defined in POSIX. If file1 exists + and file2 does not, bash returns true but dash returns false. Don't rely + on bash's behaviour when checking whether to use GRUB Legacy or GRUB 2 + configuration files, otherwise we end up using neither when only one set + of configuration exists and /bin/sh is dash. + * Try to map LABEL= and UUID= ourselves in linux_mount_boot rather than + relying on mount to do it, to further reduce the chance that we need to + use mount from another filesystem. + * If the filesystem identified by linux-boot-prober as /boot is already + mounted somewhere else, then bind-mount it rather than trying to mount + it again. + + -- Colin Watson Mon, 21 Sep 2009 14:55:23 +0100 + +os-prober (1.33) unstable; urgency=low + + * Distinguish Windows 7, based on a patch from "mattduckman" + (LP: #393565). + * Don't try to mount LUKS partitions (thanks, Chow Loong Jin and Soren + Hansen; closes: #546546, LP: #428785). + + -- Colin Watson Tue, 15 Sep 2009 14:02:45 +0100 + +os-prober (1.32) unstable; urgency=low + + * Pass arguments properly to newns (thanks, Roger E Critchlow Jr; LP: + #426061). + + -- Colin Watson Tue, 08 Sep 2009 12:29:05 +0100 + +os-prober (1.31) unstable; urgency=low + + * Upgrade to debhelper v7. + * Detect Acronis Secure Zone (thanks, Alexey Fisher; LP: #354334). + * Run os-prober and linux-boot-prober in a private mount namespace if + possible, to avoid desktop environments picking up the mounts. Thanks to + Gabor Gombas for the suggestion. (Closes: #476184) + * Use vol_id/blkid output if possible to avoid having to try every + possible filesystem for every partition. This isn't actually very much + faster for me, but it certainly cuts down on syslog noise. + * Skip extended and swap partitions (closes: #511518). + * Install Mac OS X probe on i386/amd64 too (LP: #353639). + + -- Colin Watson Mon, 07 Sep 2009 11:06:55 +0100 + +os-prober (1.30) unstable; urgency=low + + [ Colin Watson ] + * Use result function in macosx prober, so that its output appears in + syslog. + * Quote arguments to tests, and in general quote mountpoints that were + fetched from mounted-maps. I've seen the odd log with errors due to + funny characters in mount points. + + [ Otavio Salvador ] + * When there're both grub-legacy and grub2 configuration files available + we ought to use the most recently changed. Closes: 534478 + + -- Otavio Salvador Tue, 21 Jul 2009 12:22:09 -0300 + +os-prober (1.29) unstable; urgency=low + + [ Colin Watson ] + * Merge from Ubuntu: + - Load ext4 module if available. + - Check dmraid's exit code rather than parsing its output. + * Windows Vista has been released for some time now, so just call it that + rather than "Vista/Longhorn". + + [ Frans Pop ] + * Remove myself as uploader. + + -- Colin Watson Wed, 11 Mar 2009 16:45:32 +0000 + +os-prober (1.28) unstable; urgency=low + + [ Giuseppe Iuculano ] + * Probe all partitions that are a part of active dmraid arrays. + Patch based on work done by Luke Yelavich in Ubuntu. + + -- Otavio Salvador Sun, 21 Sep 2008 22:02:30 -0300 + +os-prober (1.27) unstable; urgency=low + + [ Joey Hess ] + * Add support for detecting K-DEMar based on an example from Adonay Sanz. + Closes: #485617 + + -- Otavio Salvador Tue, 29 Jul 2008 12:33:43 -0300 + +os-prober (1.26) unstable; urgency=HIGH + + * Remove hardcoded line in grub2 that must have slipped in during testing. + Closes: #476389 + + -- Joey Hess Tue, 03 Jun 2008 13:35:39 -0400 + +os-prober (1.25) unstable; urgency=low + + [ Frans Pop ] + * Disable excessive debug messages when parsing grub configs (see #471501). + + [ Joey Hess ] + * Warn if umount fails for some reason (such as a desktop environment + keeping the mount point busy). + * Avoid exiting test scripts when a umount fails, as that can result in + incomplete OS detection, and does not result in os-prober as a whole + failing. + + -- Otavio Salvador Thu, 08 May 2008 13:31:46 -0300 + +os-prober (1.24) unstable; urgency=low + + [ Colin Watson ] + * udev 117 merged all udev tools into a single binary called udevadm. + Check for this and use it instead of udevinfo if available. + + [ Joey Hess ] + * Avoid using log-output when run outside of d-i. + * Add preliminary support for grub2's grub.cfg file. Closes: #464928 + + -- Otavio Salvador Fri, 15 Feb 2008 15:23:52 -0200 + +os-prober (1.23) unstable; urgency=low + + * If fuseblk is in /proc/filesystems and ntfs-3g is present, try mounting + filesystems as ntfs-3g. + * Try finding a LABEL/UUID-capable /bin/mount in $tmpmnt as well as in + /target. + * Set LD_LIBRARY_PATH appropriately in the event that we have to use a + foreign mount binary (LP: #145424). + * Adjust Microsoft probe to cope with NTFS partitions appearing with type + ntfs-3g. + + -- Colin Watson Mon, 26 Nov 2007 15:20:17 +0000 + +os-prober (1.22) unstable; urgency=low + + [ Joey Hess ] + * Call dh_md5sums. + + [ Jérémy Bobbio ] + * Remove references to devfs-style device names in documentation and + comments. + + [ Colin Watson ] + * Accept fuseblk as well as fuse in the Microsoft probe. + * Make sure to select only the first mountpoint for a given device (in + case of bind mounts). + * Treat the lpia architecture (used in the Ubuntu mobile project) as x86, + since it is. + + -- Jérémy Bobbio Thu, 27 Sep 2007 18:43:50 +0200 + +os-prober (1.21) unstable; urgency=low + + [ Joey Hess ] + * Remove the largely obsolete --mounted option. + + [ Colin Watson ] + * Recognise filesystems of type 'fuse' as applicable to the Microsoft + probe (thanks, Agostino Russo). + * Handle vga= options in lilo.conf (LP: #59525). + + -- Colin Watson Tue, 31 Jul 2007 17:03:10 +0100 + +os-prober (1.20) unstable; urgency=low + + * Skip grub-installer's "(on /dev/blah)" entries detected in GRUB + configuration files, as if they're useful they will probably be found by + another probe, and detecting them can result in exponential growth of + menu.lst files if you do repeated test installs on multiple partitions. + * Use readlink -f in mapdevfs shim so that os-prober runs outside d-i + handle mount-by-UUID correctly. + * Use mktemp -d rather than /tmp, to make use outside d-i safer. + * Merge from Ubuntu: + - Try to install fs-core-modules and fs-secondary-modules udebs. These + are specific to the Ubuntu kernel udeb layout, but it's fairly cheap + to check for them as well and saves on divergence here. + - Add os-probes/mounted/sparc/80solaris to recognize Solaris/SPARC + (Fabio M. Di Nitto). + - Add linux-boot-probes/mounted/sparc/50silo support (Fabio M. Di + Nitto). + - Try to load ufs module, for Solaris support (Fabio M. Di Nitto). + - Tighten check for whether we're running in d-i; anna-install isn't + quite enough because if you're running d-i code outside d-i it's + sometimes reasonable to install a shim for anna-install. + * Don't probe partitions mounted on /target/boot. + * Teach linux-boot-prober to deal with mounted partitions correctly, + unless they're mounted on /, /target, or /target/boot (LP: #14780). This + should largely obsolete the --mounted option. + * Only use /target/bin/mount if it exists, in order to work better outside + d-i. + + -- Colin Watson Thu, 26 Jul 2007 12:33:31 +0100 + +os-prober (1.19) unstable; urgency=low + + [ Joey Hess ] + * Make the microsoft OS test completely case-insensative in the file and + directory named it looks for. This is reportedly needed at least for + Vista (Boot/BCD vs boot/bcd), and was already done on an ad-hoc basis + for 2000/XP/NT4.0. + * Patch from VMiklos to add support for recognising Frugalware. + + [ Frans Pop ] + * Skip partitions on a physical disk that is part of a Serial ATA RAID disk. + * Use log-output when checking for volume groups. + * Also use the case insensitive test for Dell Utility partition detection. + + [ Fabio M. Di Nitto ] + * Skip partitions that have the "whole_disk" sysfs attribute set. + The kernel set the attribute for partitions like SUN Whole Disk. + These partitions that encompass the whole disk can be mounted + and often confused for the first partition on the disk. + In situations where the OS is on the first partition, it would be + detected twice in the first and the whole disk partition. + + -- Frans Pop Sat, 07 Jul 2007 20:11:49 +0200 + +os-prober (1.18) unstable; urgency=low + + * Add detection for Dell Utility partition (can be chainloaded). + Closes: #417279. + * Remove support for devfs style paths. + + -- Frans Pop Sat, 21 Apr 2007 01:11:08 +0200 + +os-prober (1.17) unstable; urgency=low + + * Check for both upper and lowercase filenames when detecting Windows + NT/XP/2000. Thanks to Thanatermesis. + + -- Frans Pop Tue, 27 Feb 2007 20:16:49 +0100 + +os-prober (1.16) unstable; urgency=low + + [ Joey Hess ] + * Support for recognising Pardus linux. + + [ Frans Pop ] + * Skip grub entries that have "module" lines as we currently don't support + those. Based on #399882 where they were used for entries related to Xen. + * Support for recognizing Kanotix linux. + * Add support for probing other operating systems on LVM partitions. This + will only work if LVM support has already been loaded. Closes: #277901. + + -- Frans Pop Tue, 20 Feb 2007 12:57:42 +0100 + +os-prober (1.15) unstable; urgency=low + + [ Colin Watson ] + * Discard stderr from udevinfo call in parse_proc_mdstat. + + [ Fabio M. Di Nitto ] + * Nuke os-probes/x86. Empty useless dir. + * Use -qs to grep and avoid an annoying warning when running os-probes. + + -- Frans Pop Thu, 21 Dec 2006 16:29:06 +0100 + +os-prober (1.14) unstable; urgency=low + + * Use udevinfo if available in parse_proc_mdstat to figure out whether a + device is a partition. + + -- Colin Watson Tue, 29 Aug 2006 11:27:47 +0100 + +os-prober (1.13) unstable; urgency=low + + * Add support for detecting Windows Vista/Longhorn. + + -- Frans Pop Tue, 25 Jul 2006 13:06:13 +0200 + +os-prober (1.12) unstable; urgency=low + + [ Joey Hess ] + * Patch from VMiklos to sed off (hdn,n) from the front of a kernel path, + as seen in SuSE grub configs. Closes: #258623 although this is fixed + imprefectly since it assumes stripping the string is enough. + * Patch from VMiklos to not require an initrd be specified in the grub + probe. + * Patch from VMiklos to add --mounted option to linux-boot-prober. + May not be useful for d-i but in other situations including for the + Frugalware installer. + + [ Frans Pop ] + * When parsing a lilo configuration, dereference symbolic links. Not doing + this will break booting the old OS if the link was in / and there was a + separate /boot partition. And grub in general prefers full paths. + Closes: #259825. + * Use environment variable to pass --mounted option to lower level scripts + instead of perpetuating the parameter. + * Add myself to uploaders. + + -- Frans Pop Fri, 23 Jun 2006 21:46:41 +0200 + +os-prober (1.11) unstable; urgency=low + + * Remove a useless debug message. + + -- Joey Hess Wed, 7 Jun 2006 22:10:10 -0400 + +os-prober (1.10) unstable; urgency=low + + [ Colin Watson ] + * Drop os-prober's priority to extra to match overrides. + + [ Frans Pop ] + * Old-style options for head/tail are no longer supported by new busybox. + + -- Frans Pop Fri, 12 May 2006 15:26:30 +0200 + +os-prober (1.09) unstable; urgency=low + + * To make it easier to use os-prober outside d-i, add a mapdevfs shim and + avoid using anna-install if it isn't present. + * Fix count_for to avoid failing outside d-i if /var/lib/os-prober/labels + is missing. + * Look for partitions in /sys/block if /dev/discs isn't present. + * Add /usr/share/common-licenses/GPL reference to debian/copyright. + * Rename os-prober to os-prober-udeb (leaving a Provides: behind) and + create an os-prober deb. + * Avoid yaboot probe failing outside d-i due to archdetect being missing. + * Don't install /var/lib/os-prober/mount in either binary package, just + /var/lib/os-prober; the former will be created/removed on the fly + anyway. + + -- Colin Watson Thu, 8 Dec 2005 02:58:36 +0000 + +os-prober (1.08) unstable; urgency=low + + [ Colin Watson ] + * Install necessary kernel modules on the fly using anna-install, rather + than depending on them. Requires anna >= 1.16. + + -- Frans Pop Tue, 15 Nov 2005 20:37:52 +0100 + +os-prober (1.07) unstable; urgency=low + + [ Matt Kraai ] + * Add support for QNX. + + -- Joey Hess Mon, 26 Sep 2005 17:18:18 +0200 + +os-prober (1.06) unstable; urgency=low + + * Frans Pop + - Make idempotent by deleting files in /var/lib/os-prober/ on start + (resets count_next_label). + - Properly determine whether partitions are mounted or not by using + mapdevfs to match device names. Closes: #251794, #251662. + - Add dependency on di-utils-mapdevfs. + + -- Joey Hess Sun, 1 May 2005 16:52:18 -0400 + +os-prober (1.05) unstable; urgency=low + + * Colin Watson + - 'boot' is implicit at the end of a grub menu entry. Cope with it being + missing (part of #258623). + + -- Colin Watson Sat, 26 Mar 2005 16:55:23 +0000 + +os-prober (1.04) unstable; urgency=low + + * Joey Hess + - Fix micosoft and lsb tests to use count_next_label to get unique + short labels. Closes: #299001 + + -- Joey Hess Fri, 11 Mar 2005 14:06:00 -0500 + +os-prober (1.03) unstable; urgency=low + + * Joey Hess + - Applied patch from Guillem Jover to detect many redhat derived + distributions. + * Frans Pop + - Exclude partitions that are part of a software raid array. + Closes: #273960. + - Don't use the description from Windows' boot.ini if it contains + non-ascii (or other unusual) characters. Closes: #293859. + * Colin Watson + - Probe ext3, xfs, and jfs modules too. + + -- Joey Hess Fri, 11 Feb 2005 20:30:56 -0500 + +os-prober (1.02) unstable; urgency=low + + * Joshua Kwan + - I don't have time to test/improve os-prober these days, so removing + myself from Uploaders. + * Colin Watson + - Install i386 tests on amd64 too (closes: #261378). + + -- Colin Watson Thu, 21 Oct 2004 14:02:05 +0100 + +os-prober (1.01) unstable; urgency=low + + * Joey Hess + - Applied patch from eddyp to parse boot.ini to determine correct names + of modern versions of Windows. Closes: #275882 + + -- Joey Hess Wed, 20 Oct 2004 15:20:12 -0400 + +os-prober (1.00) unstable; urgency=low + + * Joey Hess + - Fedora uses a grub.conf. This may or may not be linked to menu.lst + (unknown). Look for it if menu.lst is not found. + - Gratuitous version number bump. + + -- Joey Hess Sun, 3 Oct 2004 18:27:10 -0400 + +os-prober (0.14) unstable; urgency=low + + * Joey Hess + - It's actually allowed and common for /etc/lsb-release to not include a + DISTRIB_DESCRIPTION or DISTRIB_CODENAME, so don't call such distros + "Unknown semi-LSB-compliant Linux distribution", just skip to the next + test. This affected FC2. + + -- Joey Hess Fri, 27 Aug 2004 12:57:06 -0400 + +os-prober (0.13) unstable; urgency=low + + * Giuseppe Sacco + - Added preliminary test for Solaris/IA32. Closes: #255206 + * Joey Hess + - Add support for fstabs with UUIDs or disk labels. Closes:#257794 + - In fallback os-prober test, skip over symlinks, since they could point + from root into /boot or result in confusing duplicate entries. + Closes: #258624 + - Make the fallback os-prober really find kernels matched by globs. + + -- Joey Hess Sat, 10 Jul 2004 14:32:17 -0400 + +os-prober (0.12) unstable; urgency=low + + * Colin Watson + - Fix syntax error in already-mounted case. + - Cope with empty initrd parameter in yaboot.conf parser. + + -- Colin Watson Wed, 12 May 2004 01:16:05 +0100 + +os-prober (0.11) unstable; urgency=low + + * Colin Watson + - Make linux-distro test work on architectures that don't have + /lib/ld-linux.so* (closes: #244076). + - Fix a typo in the yaboot parser. + + -- Colin Watson Sun, 9 May 2004 16:35:43 +0100 + +os-prober (0.10) unstable; urgency=low + + * Colin Watson + - Restore module dependencies, using debian/module-depends.$(ARCH). + Closes: #246700 + * Joey Hess + - Have os-prober run mounted tests on partitions that are already + mounted (skipping / and /target). Closes: #247080 + + -- Joey Hess Tue, 4 May 2004 20:52:29 -0400 + +os-prober (0.09) unstable; urgency=low + + * Guillem Jover + - Added more distros support. + * Joey Hess + - Use just "Windows" as the shortname for Windows 2k/NT/XP. + + -- Joey Hess Thu, 22 Apr 2004 12:07:11 -0400 + +os-prober (0.08) unstable; urgency=low + + * Joey Hess + - Initialise variables in lilo and grub probes, to avoid inheriting + settings for things like $initrd from the kernel command line. + This fixes processing of things like lilo.conf stanzas that do not set + an initrd. Thanks to Frans Pop. + - Add some extra debug logging. + + -- Joey Hess Tue, 20 Apr 2004 16:40:16 -0400 + +os-prober (0.07) unstable; urgency=low + + * Colin Watson + - Add a Mac OS 6-9 check for powerpc. This is currently a copy of the + m68k version with a different loader name for yaboot's benefit, which + may not be ideal ... + - Send modprobe's standard output to syslog so that it doesn't confuse + programs parsing os-prober's output. + + -- Colin Watson Sun, 18 Apr 2004 11:23:51 +0100 + +os-prober (0.06) unstable; urgency=low + + * Colin Watson + - Add a Linux boot probe for /etc/yaboot.conf. + - Make sure hfs is available for the Mac OS 9 check. + - Delay hfs until last in mounted checks so that we can tell the + difference between that and hfsplus. + - Add count to Mac OS X labels; change loader type to macosx. + - Add myself to Uploaders. + + -- Colin Watson Wed, 14 Apr 2004 01:15:53 +0100 + +os-prober (0.05) unstable; urgency=low + + * Joey Hess + - Fix broken mounting of /boot partitions. + - Fix grub probe to support systems that have /boot on a separate + partition, by looking for kernels in /boot as well. + - Same for initrds. + + -- Joey Hess Sat, 10 Apr 2004 16:06:49 -0400 + +os-prober (0.04) unstable; urgency=low + + * Joey Hess + - Return "hurd" as the OS type for hurd, rather than "multiboot". + The latter is not enough info to boot the hurd. + - Fix broken hurd detection. + + -- Joey Hess Fri, 9 Apr 2004 22:18:54 -0400 + +os-prober (0.03) unstable; urgency=low + + * Joshua Kwan + - Allow for unique short names via functions in new common.sh library. + - Revamp all the dh_install stuff. + - Use /var/lib/os-prober as our sandbox. + * Colin Watson + - Add Mac OS X probing support. + * Joey Hess + - Added linux-boot-prober, with sorta working support for grub. + - Reorg the probes, and move to /usr/lib. + - Remove broken depends line. + - Add a linux boot probe that searches for kernels and initrds with no + bootloader config file, as a fallback. + - Add a linux boot probe that parses /etc/lilo.conf. + + -- Joey Hess Wed, 7 Apr 2004 21:40:39 -0400 + +os-prober (0.02) unstable; urgency=low + + * Include init dir in the udeb. + + -- Joey Hess Sun, 4 Apr 2004 00:43:12 -0500 + +os-prober (0.01) unstable; urgency=low + + * Initial Release. + + -- Joey Hess Sat, 3 Apr 2004 23:45:29 -0500 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..264c6ca --- /dev/null +++ b/debian/control @@ -0,0 +1,28 @@ +Source: os-prober +Section: debian-installer +Priority: optional +Maintainer: Debian Install System Team +Uploaders: Colin Watson , Christian Perrier , Steve McIntyre <93sam@debian.org> +Build-Depends: debhelper (>= 9), dpkg-dev (>= 1.15.7) +Standards-Version: 3.9.4 +Vcs-Browser: https://anonscm.debian.org/cgit/d-i/os-prober.git +Vcs-Git: https://anonscm.debian.org/git/d-i/os-prober.git + +Package: os-prober-udeb +Package-Type: udeb +Architecture: any +Depends: ${misc:Depends}, ${shlibs:Depends}, di-utils-mapdevfs, anna (>= 1.16), grub-mount-udeb [linux-any kfreebsd-any], dmsetup-udeb [linux-any] +Provides: os-prober +Description: utility to detect other OSes on a set of drives + This package is to be used by boot loader installers to detect other OSes + available on a system, in a generic format, which it can then adapt to its + own configuration format. + +Package: os-prober +Architecture: any +Section: utils +Priority: extra +Depends: ${shlibs:Depends}, ${misc:Depends}, grub-common [linux-any kfreebsd-any], dmsetup [linux-any] +Description: utility to detect other OSes on a set of drives + This package detects other OSes available on a system and outputs the + results in a generic machine-readable format. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..08a46e1 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,11 @@ +The majority of code in os-prober is Copyright 2004-2011 by Joshua +Kwan, Joey Hess, Christian Perrier, Colin Watson and Otavio Salvador. +This is licensed $under the terms of the GNU GPL, either version 2 or, +at your option, any later version. + + +Some portions of os-prober by other contributors has an unclear license +of "GNU GPL", with the version not specified. + +On Debian systems, a copy of the GNU General Public License is available in +/usr/share/common-licenses/GPL-2. diff --git a/debian/os-prober-udeb.dirs b/debian/os-prober-udeb.dirs new file mode 100644 index 0000000..a4b48fe --- /dev/null +++ b/debian/os-prober-udeb.dirs @@ -0,0 +1 @@ +var/lib/os-prober diff --git a/debian/os-prober-udeb.install b/debian/os-prober-udeb.install new file mode 100644 index 0000000..956a68a --- /dev/null +++ b/debian/os-prober-udeb.install @@ -0,0 +1,3 @@ +os-prober linux-boot-prober bin +newns usr/lib/os-prober +common.sh usr/share/os-prober diff --git a/debian/os-prober.dirs b/debian/os-prober.dirs new file mode 120000 index 0000000..5a40f4a --- /dev/null +++ b/debian/os-prober.dirs @@ -0,0 +1 @@ +os-prober-udeb.dirs \ No newline at end of file diff --git a/debian/os-prober.docs b/debian/os-prober.docs new file mode 100644 index 0000000..724e084 --- /dev/null +++ b/debian/os-prober.docs @@ -0,0 +1,2 @@ +README +TODO diff --git a/debian/os-prober.install b/debian/os-prober.install new file mode 100644 index 0000000..b39e60c --- /dev/null +++ b/debian/os-prober.install @@ -0,0 +1,3 @@ +os-prober linux-boot-prober usr/bin +newns usr/lib/os-prober +common.sh usr/share/os-prober diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..81e9ad9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,42 @@ +#! /usr/bin/make -f +# debhelper rules for os-prober +# (C) 2004 Joshua Kwan + +%: + dh $@ + +ARCH=$(shell dpkg-architecture -qDEB_HOST_ARCH_CPU) +ifneq (,$(filter i386 amd64,$(ARCH))) +ARCH=x86 +endif + +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + +ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE)) +CC := gcc +else +CC := $(DEB_HOST_GNU_TYPE)-gcc +endif + +export DEB_CFLAGS_MAINT_APPEND := -Os -Wall + +CFLAGS := $(shell dpkg-buildflags --get CPPFLAGS; dpkg-buildflags --get CFLAGS) +LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS) + +override_dh_auto_build: + $(MAKE) CC=$(CC) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" + +override_dh_install: + dh_install + for probes in os-probes os-probes/mounted os-probes/init \ + linux-boot-probes linux-boot-probes/mounted; do \ + dh_install $$probes/common/* usr/lib/$$probes; \ + if [ -e "$$probes/$(ARCH)" ]; then \ + dh_install $$probes/$(ARCH)/* usr/lib/$$probes; \ + fi; \ + done +ifeq ($(ARCH),x86) + dh_install os-probes/mounted/powerpc/20macosx usr/lib/os-probes/mounted +endif + cp -a debian/os-prober-udeb/usr/lib debian/os-prober/usr/ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/linux-boot-prober b/linux-boot-prober new file mode 100755 index 0000000..e32dc84 --- /dev/null +++ b/linux-boot-prober @@ -0,0 +1,61 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh + +set -e + +newns "$@" +require_tmpdir + +grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true + +partition="$1" + +if [ -z "$partition" ]; then + echo "usage: linux-boot-prober partition" >&2 + exit 1 +fi + +if ! mapped="$(mapdevfs "$partition")"; then + log "Device '$partition' does not exist; skipping" + continue +fi + +if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map"; then + for test in /usr/lib/linux-boot-probes/*; do + debug "running $test" + if [ -x $test ] && [ -f $test ]; then + if $test "$partition"; then + debug "linux detected by $test" + break + fi + fi + done +else + mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2) + mpoint="$(unescape_mount "$mpoint")" + if [ "$mpoint" != "/target/boot" ] && [ "$mpoint" != "/target" ] && [ "$mpoint" != "/" ]; then + type=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 3) + if ! grep -q " $mpoint/boot " "$OS_PROBER_TMP/mounted-map"; then + linux_mount_boot "$partition" "$mpoint" + bootpart="${mountboot%% *}" + bootmounted="${mountboot#* }" + else + bootpart="$partition" + bootmounted=0 + fi + for test in /usr/lib/linux-boot-probes/mounted/*; do + if [ -f $test ] && [ -x $test ]; then + debug "running $test on mounted $partition" + if $test "$partition" "$bootpart" "$mpoint" "$type"; then + debug "$test succeeded" + break + fi + fi + done + if [ "$bootmounted" = 1 ]; then + if ! umount "$mpoint/boot"; then + warn "failed to umount $mpoint/boot" + fi + fi + fi +fi diff --git a/linux-boot-probes/common/50mounted-tests b/linux-boot-probes/common/50mounted-tests new file mode 100755 index 0000000..01bca81 --- /dev/null +++ b/linux-boot-probes/common/50mounted-tests @@ -0,0 +1,100 @@ +#!/bin/sh +# Sub-tests that require a mounted partition. +. /usr/share/os-prober/common.sh +set -e + +do_unmount() { + if [ "$mounted" ]; then + umount "$tmpmnt/boot" 2>/dev/null || true + if ! umount "$tmpmnt"; then + warn "failed to umount $tmpmnt" + fi + fi + for dm_device in $dm_devices; do + if [ -e "$dm_device" ]; then + debug "remove device mapper device $dm_device" + dmsetup remove $dm_device + fi + done + rmdir "$tmpmnt" || true +} + +partition="$1" + +types="$(fs_type "$partition")" +if [ "$types" = NOT-DETECTED ]; then + debug "$1 type not recognised; skipping" + exit 0 +elif [ "$types" = swap ]; then + debug "$1 is a swap partition; skipping" + exit 0 +elif [ "$types" = crypto_LUKS ]; then + debug "$1 is a LUKS partition; skipping" + exit 0 +elif [ "$types" = ntfs ]; then + if type ntfs-3g >/dev/null 2>&1; then + types='ntfs-3g ntfs' + fi +elif [ -z "$types" ]; then + if is_dos_extended_partition "$partition"; then + debug "$1 looks like an extended dos partition; skipping" + exit 0 + fi + if type cryptsetup >/dev/null 2>&1 && \ + cryptsetup luksDump "$partition" >/dev/null 2>&1; then + debug "$1 is a LUKS partition; skipping" + exit 0 + fi + types="$(grep -v nodev /proc/filesystems)" +fi + +tmpmnt=/var/lib/os-prober/mount +if [ ! -d "$tmpmnt" ]; then + mkdir "$tmpmnt" +fi + +mounted= +dm_devices= +if type grub-mount >/dev/null 2>&1 && \ + type grub-probe >/dev/null 2>&1 && \ + grub-mount "$partition" "$tmpmnt" 2>/dev/null; then + mounted=1 + type="$(grub-probe -d "$partition" -t fs)" + [ "$type" ] || type=fuseblk +elif dm_device="$(do_dmsetup osprober-linux "$partition")" && \ + [ "$dm_device" ]; then + dm_devices="$dm_device" + for type in $types; do + if mountinfo=`mount -o ro -t "$type" "$dm_device" "$tmpmnt" 2>&1`; then + debug "mounted as $type filesystem" + mounted=1 + break + else + debug "mounting $dm_device ($partition) as $type failed: $mountinfo" + fi + done +fi + +if [ "$mounted" ]; then + linux_mount_boot "$partition" "$tmpmnt" + bootpart="${mountboot%% *}" + mounted="${mountboot#* }" + if [ "$dm_device" ]; then + dm_devices="$dm_device $dm_devices" + fi + + for test in /usr/lib/linux-boot-probes/mounted/*; do + if [ -f "$test" ] && [ -x "$test" ]; then + debug "running $test $partition $bootpart $tmpmnt $type" + if $test "$partition" "$bootpart" "$tmpmnt" "$type"; then + debug "$test succeeded" + do_unmount + exit 0 + fi + fi + done +fi +do_unmount + +# No tests found anything. +exit 1 diff --git a/linux-boot-probes/mounted/common/40grub2 b/linux-boot-probes/mounted/common/40grub2 new file mode 100755 index 0000000..885614e --- /dev/null +++ b/linux-boot-probes/mounted/common/40grub2 @@ -0,0 +1,110 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +found_item=0 + +entry_result () { + if [ "$ignore_item" = 0 ] && \ + [ -n "$kernel" ] && \ + [ -e "$mpoint/$kernel" ]; then + result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" + found_item=1 + fi + kernel="" + parameters="" + initrd="" + title="" + ignore_item=0 +} + +parse_grub_menu () { + mpoint="$1" + rootpart="$2" + bootpart="$3" + + kernel="" + parameters="" + initrd="" + title="" + ignore_item=0 + + while read line; do + debug "parsing: $line" + set -f + set -- $line + set +f + case "$1" in + menuentry) + entry_result + shift 1 + # The double-quoted string is the title. + # Make sure to look at the text of the line + # before 'set' mangled it. + title="$(echo "$line" | sed -n 's/[^"]*"\(.*\)".*/\1/p' | sed 's/://g')" + if [ -z "$title" ]; then + # ... or single-quoted? Be careful + # to handle constructions like + # 'foo'\''bar' (which expands to + # foo'bar, as in shell), and to + # handle multiple single-quoted + # strings on the same line. + title="$(echo "$line" | sed -n "s/[^']*'\(\([^']\|'\\\\''\)*\)'.*/\1/p" | sed "s/'\\\\''/'/; s/://g")" + fi + if [ -z "$title" ]; then + ignore_item=1 + elif echo "$title" | grep -q '(on /dev/[^)]*)$'; then + log "Skipping entry '$title':" + log "appears to be an automatic reference taken from another menu.lst" + ignore_item=1 + fi + ;; + linux) + # Hack alert: sed off any (hdn,n) but + # assume the kernel is on the same + # partition. + kernel="$(echo "$2" | sed 's/(.*)//')" + shift 2 + parameters="$@" + # Systems with a separate /boot will not have + # the path to the kernel in grub.cfg. + if [ "$partition" != "$bootpart" ]; then + kernel="/boot$kernel" + fi + ;; + initrd) + initrd="$(echo "$2" | sed 's/(.*)//')" + # Initrd same. + if [ "$partition" != "$bootpart" ]; then + initrd="/boot$initrd" + fi + ;; + "}") + entry_result + ;; + esac + done + + entry_result +} + +if [ -e "$mpoint/boot/grub/grub.cfg" ] && \ + ([ ! -e "$mpoint/boot/grub/menu.lst" ] || \ + [ "$mpoint/boot/grub/grub.cfg" -nt "$mpoint/boot/grub/menu.lst" ]); then + debug "parsing grub.cfg" + parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/grub.cfg" +elif [ -e "$mpoint/boot/grub2/grub.cfg" ]; then + debug "parsing grub.cfg" + parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub2/grub.cfg" +fi + +if [ "$found_item" = 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/linux-boot-probes/mounted/common/90fallback b/linux-boot-probes/mounted/common/90fallback new file mode 100755 index 0000000..9ff78e1 --- /dev/null +++ b/linux-boot-probes/mounted/common/90fallback @@ -0,0 +1,53 @@ +#!/bin/sh +# Fallback in case nothing else works. Look for vmlinu[xz] file in root and +# /boot, see if there is a matching initrd, and wing it. +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +mappedpartition=$(mapdevfs "$partition" 2>/dev/null) || mappedpartition="$partition" + +exitcode=1 +for kernpat in /vmlinuz /vmlinux /boot/vmlinuz /boot/vmlinux "/boot/vmlinuz*" \ + "/boot/vmlinux*" "/vmlinuz*" "/vmlinux*" "/kernel-*" "/boot/kernel-*"; do + if echo "$kernpat" | grep -q boot/; then + kernbootpart="$bootpart" + else + kernbootpart="$partition" + fi + for kernfile in $(eval ls "$mpoint$kernpat" 2>/dev/null); do + kernbasefile=$(echo "$kernfile" | sed "s!^$mpoint!!") + if [ -f "$kernfile" ] && [ ! -L "$kernfile" ]; then + initrdname=$(echo "$kernfile" | sed "s/vmlinu[zx]/initrd\*/") + # Yellow Dog Linux appends .img to it. + initrdname1="${initrdname}.img" + # Arch Linux names its initrds weirdly. We take + # some care here to avoid false positives on other + # systems, since kernel.img could conceivably be a + # kernel itself. + initrdname2=$(echo "$kernfile" | sed -n 's/vmlinu[zx]\([0-9][0-9]*\)/kernel\1/p' | sed 's/$/.img/') + # Dracut initramfses are named differently again. + initrdname3=$(echo "$kernfile" | sed "s/vmlinu[zx]/initramfs\*/" | sed 's/$/.img/') + # And Gentoo's also + initrdname4=$(echo "$kernfile" | sed "s/kernel/initramfs\*/") + foundinitrd=0 + for initrd in $(eval ls "$initrdname" "$initrdname1" "$initrdname2" "$initrdname3" "$initrdname4" 2>/dev/null); do + if [ "$initrd" != "$kernfile" ] && [ -f "$initrd" ] && [ ! -L "$initrd" ]; then + initrd=$(echo "$initrd" | sed "s!^$mpoint!!") + result "$partition:$kernbootpart::$kernbasefile:$initrd:root=$mappedpartition" + exitcode=0 + foundinitrd=1 + fi + done + if [ "$foundinitrd" = 0 ]; then + result "$partition:$kernbootpart::$kernbasefile::root=$mappedpartition" + exitcode=0 + fi + fi + done +done +exit "$exitcode" diff --git a/linux-boot-probes/mounted/powerpc/40yaboot b/linux-boot-probes/mounted/powerpc/40yaboot new file mode 100755 index 0000000..764621c --- /dev/null +++ b/linux-boot-probes/mounted/powerpc/40yaboot @@ -0,0 +1,122 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +found_item=0 + +dequote () { + item="${1%\"}" + echo "${item#\"}" +} + +recordstanza () { + if [ -n "$kernel" ]; then + # TODO: handle device=/partition= to find images + if ! [ -e "$mpoint/$kernel" ]; then + debug "cannot find $kernel; not recording" + return + fi + if [ "$initrd" ] && ! [ -e "$mpoint/$initrd" ]; then + debug "cannot find $initrd: not recording" + return + fi + + if [ -z "$title" ]; then + title="${kernel##*/}" + fi + if [ "$read_only" ]; then + parameters="ro $parameters" + fi + if [ "$rootdev" ]; then + parameters="root=$rootdev $parameters" + fi + parameters="${parameters% }" + result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" + found_item=1 + + title= + rootdev="$default_rootdev" + kernel="$default_kernel" + parameters="$default_parameters" + initrd="$default_initrd" + read_only="$default_read_only" + else + # Everything in the global options section set default values. + default_rootdev="$rootdev" + default_kernel="$kernel" + default_parameters="$parameters" + default_initrd="$initrd" + default_read_only="$read_only" + fi +} + +parse_yaboot_conf () { + mpoint="$1" + rootpart="$2" + bootpart="$3" + IFS=" =" + while read line; do + debug "parsing: $line" + set -f + set -- $line + set +f + case "$1" in + root) + rootdev="$(dequote "$2")" + ;; + image) + recordstanza + kernel="$(dequote "$2")" + ;; + append) + cleanappend=`printf %s "$line" | sed 's/append\([[:space:]]\)*=\([[:space:]]\)*//'` + parameters="$(dequote "$cleanappend")" + ;; + initrd) + initrd="$(dequote "$2")" + ;; + label) + shift 1 + title="$(dequote "$*")" + ;; + alias) + shift 1 + titlealias="$(dequote "$*")" + ;; + read-only) + read_only=1 + ;; + esac + done + recordstanza +} + +# Avoid failing if archdetect is missing (running outside d-i). This is +# suboptimal but will do for now. +if type archdetect >/dev/null 2>&1; then + case "`archdetect`" in + powerpc/powermac_newworld) + ;; + powerpc/chrp*) + ;; + *) + exit 1 + ;; + esac +fi + +if [ -e "$mpoint/etc/yaboot.conf" ]; then + debug "parsing yaboot.conf" + parse_yaboot_conf "$mpoint" "$partition" "$bootpart" < "$mpoint/etc/yaboot.conf" +fi + +if [ "$found_item" = 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/linux-boot-probes/mounted/sparc/50silo b/linux-boot-probes/mounted/sparc/50silo new file mode 100755 index 0000000..bb5c41c --- /dev/null +++ b/linux-boot-probes/mounted/sparc/50silo @@ -0,0 +1,123 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +found_item=0 + +title="" +rootdev="" +kernel="" +parameters="" +initrd="" +read_only="" +default_rootdev="" +default_kernel="" +default_parameters="" +default_initrd="" +default_read_only="" + +dequote () { + item="${1%\"}" + echo "${item#\"}" +} + +recordstanza () { + if [ -n "$kernel" ] && [ -n "$title" ]; then + if [ -e "$mpoint/$kernel" ] || [ -e "$mpoint/boot$kernel" ]; then + if [ -e "$mpoint/boot$initrd" ] || [ -e "$mpoint/$initrd" ]; then + if [ "$read_only" ]; then + parameters="ro $parameters" + fi + if [ "$rootdev" ]; then + parameters="root=$rootdev $parameters" + fi + parameters="${parameters% }" + result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" + found_item=1 + else + debug "cannot find $initrd, not recording" + fi + else + debug "cannot find $kernel, not recording" + fi + title="" + rootdev="$default_rootdev" + kernel="$default_kernel" + parameters="$default_parameters" + initrd="$default_initrd" + read_only="$default_read_only" + else + # Everything before set default values. + default_rootdev="$rootdev" + default_kernel="$kernel" + default_parameters="$parameters" + default_initrd="$initrd" + default_read_only="$read_only" + fi +} + +parse_silo_conf () { + mpoint="$1" + rootpart="$2" + bootpart="$3" + IFS=" =" + while read line; do + debug "parsing: $line" + set -f + set -- $line + set +f + case "$1" in + root) + rootdev=$(dequote "$2") + ;; + image) + recordstanza + # Dereference if symbolic link + if echo "$2" | grep -qs "/boot/"; then + kernel="$(readlink -f "$(dequote "$mpoint$2")" | sed -e 's#'"$mpoint"'##g')" + else + kernel="$(readlink -f "$(dequote "$mpoint/boot$2")" | sed -e 's#'"$mpoint"'/boot##g')" + fi + ;; + append) + shift 1 + parameters=$(dequote "${line#append=}") + ;; + initrd) + # Dereference if symbolic link + if echo "$2" | grep -qs "/boot/"; then + initrd="$(readlink -f "$(dequote "$mpoint$2")" | sed -e 's#'"$mpoint"'##g')" + else + initrd="$(readlink -f "$(dequote "$mpoint/boot$2")" | sed -e 's#'"$mpoint"'/boot##g')" + fi + ;; + label) + shift 1 + title=$(dequote "$*" | sed -e 's/:/ /g') + ;; + other) + recordstanza + ;; + read-only) + read_only=1 + ;; + esac + done + recordstanza +} + +if [ -e "$mpoint/boot/silo.conf" ]; then + debug "parsing silo.conf" + parse_silo_conf "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/silo.conf" +fi + +if [ "$found_item" = 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/linux-boot-probes/mounted/x86/40grub b/linux-boot-probes/mounted/x86/40grub new file mode 100755 index 0000000..08f6605 --- /dev/null +++ b/linux-boot-probes/mounted/x86/40grub @@ -0,0 +1,107 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +found_item=0 + +entry_result () { + if [ "$ignore_item" = 0 ] && \ + [ -n "$kernel" ] && \ + [ -e "$mpoint/$kernel" ]; then + result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" + found_item=1 + fi + kernel="" + parameters="" + initrd="" + title="" + ignore_item=0 +} + +parse_grub_menu () { + mpoint="$1" + rootpart="$2" + bootpart="$3" + + kernel="" + parameters="" + initrd="" + title="" + ignore_item=0 + + while read line; do + #debug "parsing: $line" + set -f + set -- $line + set +f + case "$1" in + title) + entry_result + shift 1 + title="$(echo "$@" | sed 's/://g')" + if echo "$title" | grep -q '(on /dev/[^)]*)$'; then + log "Skipping entry '$title':" + log "appears to be an automatic reference taken from another menu.lst" + ignore_item=1 + fi + ;; + kernel) + # Hack alert: sed off any (hdn,n) but + # assume the kernel is on the same + # partition. + kernel="$(echo "$2" | sed 's/(.*)//')" + shift 2 + parameters="$@" + # Systems with a separate /boot will not have + # the path to the kernel in menu.lst. + if [ "$partition" != "$bootpart" ]; then + kernel="/boot$kernel" + fi + ;; + initrd) + # Hack alert take 2: sed off any (hdn,n) + # See #566102 + initrd="$(echo "$2" | sed 's/(.*)//')" + # Initrd same. + if [ "$partition" != "$bootpart" ]; then + initrd="/boot$initrd" + fi + ;; + boot) + entry_result + ;; + module) + log "Skipping entry '$title':" + log "parsing of entries containing 'module' lines is currently not supported" + ignore_item=1 + ;; + esac + done + + entry_result +} + +grubconf= +if [ -e "$mpoint/boot/grub/menu.lst" ]; then + grubconf="menu.lst" +elif [ -e "$mpoint/boot/grub/grub.conf" ]; then + grubconf="grub.conf" +fi + +if [ "$grubconf" ] && \ + ([ ! -e "$mpoint/boot/grub/grub.cfg" ] || \ + [ "$mpoint/boot/grub/$grubconf" -nt "$mpoint/boot/grub/grub.cfg" ]); then + debug "parsing $grubconf" + parse_grub_menu "$mpoint" "$partition" "$bootpart" < "$mpoint/boot/grub/$grubconf" +fi + +if [ "$found_item" = 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/linux-boot-probes/mounted/x86/50lilo b/linux-boot-probes/mounted/x86/50lilo new file mode 100755 index 0000000..a011b56 --- /dev/null +++ b/linux-boot-probes/mounted/x86/50lilo @@ -0,0 +1,126 @@ +#!/bin/sh +. /usr/share/os-prober/common.sh +set -e + +partition="$1" +bootpart="$2" +mpoint="$3" +type="$4" + +found_item=0 + +title="" +rootdev="" +kernel="" +parameters="" +initrd="" +read_only="" +added_parameters=0 +default_rootdev="" +default_kernel="" +default_parameters="" +default_initrd="" +default_read_only="" + +dequote () { + item="${1%\"}" + echo "${item#\"}" +} + +addparams () { + # Any parameters we find replace the default parameters, but + # otherwise append. + if [ "$added_parameters" = 0 ]; then + parameters="$1" + added_parameters=1 + else + parameters="${parameters:+$parameters }$1" + fi +} + +recordstanza () { + if [ -n "$kernel" ] && [ -n "$title" ]; then + if [ -e "$mpoint/$kernel" ] && [ -e "$mpoint/$initrd" ]; then + if [ "$read_only" ]; then + parameters="ro $parameters" + fi + if [ "$rootdev" ]; then + parameters="root=$rootdev $parameters" + fi + parameters="${parameters% }" + result "$rootpart:$bootpart:$title:$kernel:$initrd:$parameters" + found_item=1 + else + debug "cannot find $kernel or $initrd, not recording" + fi + title="" + rootdev="$default_rootdev" + kernel="$default_kernel" + parameters="$default_parameters" + initrd="$default_initrd" + read_only="$default_read_only" + added_parameters=0 + else + # Everything before set default values. + default_rootdev="$rootdev" + default_kernel="$kernel" + default_parameters="$parameters" + default_initrd="$initrd" + default_read_only="$read_only" + fi +} + +parse_lilo_conf () { + mpoint="$1" + rootpart="$2" + bootpart="$3" + IFS=" =" + while read line; do + debug "parsing: $line" + set -f + set -- $line + set +f + case "$1" in + root) + rootdev=$(dequote "$2") + ;; + image) + recordstanza + # Dereference if symbolic link + kernel="$(readlink -f "$(dequote "$2")")" + ;; + append) + addparams "$(dequote "${line#append=}")" + ;; + initrd) + # Dereference if symbolic link + initrd="$(readlink -f "$(dequote "$2")")" + ;; + label) + shift 1 + title="$(dequote "$*" | sed -e 's/:/ /g')" + ;; + other) + recordstanza + ;; + read-only) + read_only=1 + ;; + vga) + addparams "$line" + ;; + esac + done + recordstanza +} + +if [ -e "$mpoint/etc/lilo.conf" ]; then + debug "parsing lilo.conf" + parse_lilo_conf "$mpoint" "$partition" "$bootpart" < "$mpoint/etc/lilo.conf" +fi + +if [ "$found_item" = 0 ]; then + exit 1 +else + exit 0 +fi diff --git a/newns.c b/newns.c new file mode 100644 index 0000000..cee355f --- /dev/null +++ b/newns.c @@ -0,0 +1,29 @@ +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + if (argc < 2) { + fprintf(stderr, "Usage: newns PROGRAM [ARGUMENTS ...]\n"); + exit(1); + } + + /* This is best-effort; if the kernel is too old (Linux << 2.6.16), + * or indeed if the kernel isn't Linux so we don't have + * unshare(CLONE_NEWNS), don't worry about it. + */ +#ifdef __linux__ + if (unshare(CLONE_NEWNS) < 0 && errno != ENOSYS) + perror("unshare failed"); + /* ... but continue anyway */ +#endif /* __linux__ */ + setenv("OS_PROBER_NEWNS", "1", 1); + execvp(argv[1], argv + 1); + + perror("execvp failed"); + _exit(127); +} diff --git a/os-prober b/os-prober new file mode 100755 index 0000000..a48863e --- /dev/null +++ b/os-prober @@ -0,0 +1,178 @@ +#!/bin/sh +set -e + +. /usr/share/os-prober/common.sh + +newns "$@" +require_tmpdir + +log_output () { + if type log-output >/dev/null 2>&1; then + log-output -t os-prober --pass-stdout $@ + else + $@ + fi +} + +: >"$OS_PROBER_TMP/dmraid-map" +DMRAID=$(type dmraid >/dev/null 2>&1 || true) +if [ "$DMRAID" ]; then + dmraid -r -c >"$OS_PROBER_TMP/dmraid-map" +fi + +on_sataraid () { + local parent="${1%/*}" + local device="/dev/${parent##*/}" + if grep -q "$device" "$OS_PROBER_TMP/dmraid-map"; then + return 0 + fi + return 1 +} + +partitions () { + os_name="$(uname -s)" + # Exclude partitions that have whole_disk sysfs attribute set. + if [ -d /sys/block ]; then + # Exclude partitions on physical disks that are part of a + # Serial ATA RAID disk. + for part in /sys/block/*/*[0-9]; do + if [ -f "$part/start" ] && \ + [ ! -f "$part/whole_disk" ] && ! on_sataraid $part; then + name="$(echo "${part##*/}" | sed 's,[!.],/,g')" + if [ -e "/dev/$name" ]; then + echo "/dev/$name" + fi + fi + done + + # Add Serial ATA RAID devices + if type dmraid >/dev/null 2>&1 && \ + dmraid -s -c >/dev/null 2>&1; then + for raidset in $(dmraid -sa -c); do + for part in /dev/mapper/"$raidset"*[0-9]; do + echo "$part" + done + done + fi + elif [ "$os_name" = Linux ]; then + echo "Cannot find list of partitions! (Try mounting /sys.)" >&2 + exit 1 + elif [ "$os_name" = GNU ]; then + for part in /dev/hd*s*[0-9] /dev/sd*s*[0-9]; do + if [ -s "$part" ]; then + echo "$part" + fi + done + else + # We don't know how to probe OSes on non-Linux and non-GNU kernels. + # For now, just don't get in the way. + exit 0 + fi + + # Also detect OSes on LVM volumes (assumes LVM is active) + if type lvs >/dev/null 2>&1; then + echo "$(LVM_SUPPRESS_FD_WARNINGS=1 log_output lvs --noheadings --separator : -o vg_name,lv_name | + sed "s|-|--|g;s|^[[:space:]]*\(.*\):\(.*\)$|/dev/mapper/\1-\2|")" + fi +} + +parse_proc_swaps () { + while read line; do + set -f + set -- $line + set +f + echo "$(mapdevfs $1) swap" + done +} + +parse_proc_mdstat () { + if type udevadm >/dev/null 2>&1; then + udevinfo () { + udevadm info "$@" + } + fi + while read line; do + for word in $line; do + dev="${word%%\[*}" + # TODO: factor this out to something in di-utils if + # it's needed elsewhere + if [ -d /sys/block ] && type udevinfo >/dev/null 2>&1; then + if ! udevinfo -q path -n "/dev/$dev" 2>/dev/null | \ + grep -q '/.*/.*/'; then + continue + fi + elif ! echo "$dev" | grep -q "/part"; then + continue + fi + raidpart="/dev/$dev" + echo "$(mapdevfs "$raidpart")" + done + 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 + fi +done + +# We need to properly canonicalize partitions with mount points and partitions +# used in RAID +grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true +: >"$OS_PROBER_TMP/swaps-map" +if [ -f /proc/swaps ]; then + grep "^/dev/" /proc/swaps | parse_proc_swaps >"$OS_PROBER_TMP/swaps-map" || true +fi +: >"$OS_PROBER_TMP/raided-map" +if [ -f /proc/mdstat ] ; then + grep "^md" /proc/mdstat | parse_proc_mdstat >"$OS_PROBER_TMP/raided-map" || true +fi + +for partition in $(partitions); do + if ! mapped="$(mapdevfs "$partition")"; then + log "Device '$partition' does not exist; skipping" + continue + fi + + # Skip partitions used in software RAID arrays + if grep -q "^$mapped" "$OS_PROBER_TMP/raided-map" ; then + debug "$partition: part of software raid array" + continue + fi + + # Skip partitions used as active swap + if grep -q "^$mapped " "$OS_PROBER_TMP/swaps-map" ; then + debug "$partition: is active swap" + continue + fi + + if ! grep -q "^$mapped " "$OS_PROBER_TMP/mounted-map" ; then + for test in /usr/lib/os-probes/*; do + if [ -f "$test" ] && [ -x "$test" ]; then + debug "running $test on $partition" + if "$test" "$partition"; then + debug "os detected by $test" + break + fi + fi + done + else + mpoint=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 2) + mpoint="$(unescape_mount "$mpoint")" + if [ "$mpoint" != "/target/boot" ] && [ "$mpoint" != "/target" ] && [ "$mpoint" != "/" ]; then + type=$(grep "^$mapped " "$OS_PROBER_TMP/mounted-map" | head -n1 | cut -d " " -f 3) + for test in /usr/lib/os-probes/mounted/*; do + if [ -f "$test" ] && [ -x "$test" ]; then + debug "running $test on mounted $partition" + if "$test" "$partition" "$mpoint" "$type"; then + debug "os detected by $test" + break + fi + fi + done + fi + fi +done diff --git a/os-probes/common/50mounted-tests b/os-probes/common/50mounted-tests new file mode 100755 index 0000000..2951ef9 --- /dev/null +++ b/os-probes/common/50mounted-tests @@ -0,0 +1,105 @@ +#!/bin/sh +# Sub-tests that require a mounted partition. +set -e +partition="$1" + +. /usr/share/os-prober/common.sh + +do_unmount() { + if [ "$mounted" ]; then + if ! umount "$tmpmnt"; then + warn "failed to umount $tmpmnt" + fi + fi + if [ -e "$dm_device" ] + then + debug "remove device mapper device $dm_device" + dmsetup remove $dm_device + fi + rmdir "$tmpmnt" || true +} + +types="$(fs_type "$partition")" +if [ "$types" = NOT-DETECTED ]; then + debug "$1 type not recognised; skipping" + exit 0 +elif [ "$types" = swap ]; then + debug "$1 is a swap partition; skipping" + exit 0 +elif [ "$types" = crypto_LUKS ]; then + debug "$1 is a LUKS partition; skipping" + exit 0 +elif [ "$types" = LVM2_member ]; then + debug "$1 is an LVM member; skipping" + exit 0 +elif [ "$types" = ntfs ]; then + if type ntfs-3g >/dev/null 2>&1; then + types='ntfs-3g ntfs' + fi +elif [ -z "$types" ]; then + if type cryptsetup >/dev/null 2>&1 && \ + cryptsetup luksDump "$partition" >/dev/null 2>&1; then + debug "$1 is a LUKS partition; skipping" + exit 0 + fi + for type in $(grep -v nodev /proc/filesystems); do + # hfsplus filesystems are mountable as hfs. Try hfs last so + # that we can tell the difference. + if [ "$type" = hfs ]; then + delaytypes="${delaytypes:+$delaytypes }$type" + elif [ "$type" = fuseblk ]; then + if type ntfs-3g >/dev/null 2>&1; then + types="${types:+$types }ntfs-3g" + fi + else + types="${types:+$types }$type" + fi + done +fi + +tmpmnt=/var/lib/os-prober/mount +if [ ! -d "$tmpmnt" ]; then + mkdir "$tmpmnt" +fi + +mounted= +if type grub-mount >/dev/null 2>&1 && \ + type grub-probe >/dev/null 2>&1 && \ + grub-mount "$partition" "$tmpmnt" 2>/dev/null; then + mounted=1 + type="$(grub-probe -d "$partition" -t fs)" || true + if [ "$type" ]; then + debug "mounted using GRUB $type filesystem driver" + else + debug "mounted using GRUB, but unknown filesystem?" + type=fuseblk + fi +elif dm_device="$(do_dmsetup osprober "$partition")" && \ + [ "$dm_device" ]; then + for type in $types $delaytypes; do + if mountinfo=`mount -o ro -t "$type" "$dm_device" "$tmpmnt" 2>&1`; then + debug "mounted as $type filesystem" + mounted=1 + break + else + debug "mounting $dm_device ($partition) as $type failed: $mountinfo" + fi + done +fi + +if [ "$mounted" ]; then + for test in /usr/lib/os-probes/mounted/*; do + debug "running subtest $test" + if [ -f "$test" ] && [ -x "$test" ]; then + if "$test" "$partition" "$tmpmnt" "$type"; then + debug "os found by subtest $test" + do_unmount + exit 0 + fi + fi + done +fi +do_unmount + +# No tests found anything. +exit 1 diff --git a/os-probes/init/common/10filesystems b/os-probes/init/common/10filesystems new file mode 100755 index 0000000..f50e55e --- /dev/null +++ b/os-probes/init/common/10filesystems @@ -0,0 +1,39 @@ +#!/bin/sh +# Make sure filesystems are available. +set +e # ignore errors from modprobe + +FILESYSTEMS='ext2 ext3 ext4 xfs jfs msdos vfat ntfs minix hfs hfsplus qnx4 ufs btrfs' +# fuse is needed to make grub-mount work. +FILESYSTEMS="$FILESYSTEMS fuse" +# The Ubuntu kernel udebs put a number of filesystem modules in +# fs-{core,secondary}-modules. It's fairly cheap to check for these too. +FILESYSTEMS="$FILESYSTEMS fs-core fs-secondary" + +if [ ! -e /var/lib/os-prober/modules ]; then + # Check for anna-install to make it easier to use os-prober outside + # d-i. + if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then + for fs in $FILESYSTEMS; do + ANNA_QUIET=1 DEBIAN_FRONTEND=none \ + log-output -t os-prober \ + anna-install "$fs-modules" || true + done + depmod -a >/dev/null 2>&1 || true + fi + + for fs in $FILESYSTEMS; do + case "$fs" in + fs-*) + ;; + *) + modprobe "$fs" 2>/dev/null | logger -t os-prober + ;; + esac + done + + # We only want to keep this state inside d-i, so this is as good a + # check as any. + if type anna-install >/dev/null 2>&1 && [ -d /lib/debian-installer ]; then + touch /var/lib/os-prober/modules + fi +fi diff --git a/os-probes/mounted/common/40lsb b/os-probes/mounted/common/40lsb new file mode 100755 index 0000000..ce8d4e1 --- /dev/null +++ b/os-probes/mounted/common/40lsb @@ -0,0 +1,48 @@ +#!/bin/sh +# Test for LSB systems. +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +lsb_field () { + file="$1" + field="$2" + grep ^"$field" "$file" | cut -d = -f 2 | sed 's/^"//' | sed 's/"$//' | sed 's/:/ /g' +} + +file="$dir/etc/lsb-release" +if [ ! -e "$file" ]; then + exit 1 +fi + +release=$(lsb_field "$file" DISTRIB_RELEASE) +if [ -z "$release" ]; then + release=$(lsb_field "$file" DISTRIB_CODENAME) +fi +description=$(lsb_field "$file" DISTRIB_DESCRIPTION) +if [ -z "$description" ]; then + description=$(lsb_field "$file" DISTRIB_CODENAME) +fi + +if [ -n "$description" ]; then + if [ -n "$release" ]; then + long="$description ($release)" + else + long="$description" + fi +else + exit 1 +fi + +short=$(lsb_field "$file" DISTRIB_ID | sed 's/ //g') +if [ -z "$short" ]; then + short="UnknownLSB" +fi + +label="$(count_next_label "$short")" +result "$partition:$long:$label:linux" +exit 0 diff --git a/os-probes/mounted/common/90linux-distro b/os-probes/mounted/common/90linux-distro new file mode 100755 index 0000000..badfbb1 --- /dev/null +++ b/os-probes/mounted/common/90linux-distro @@ -0,0 +1,150 @@ +#!/bin/sh +# Test for linux distributions. +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +# This test is inaccurate, but given separate / and /boot partitions and the +# fact that only some architectures have ld-linux.so, I can't see anything +# better. Make sure this test has a high number so that more accurate tests +# can come first. +# Unless volumes to checked are already mounted, they will be mounted using +# GRUB's own filesystems through FUSE. Since these ATM doesn't support +# symlinks we need to also check in $dir/usr/lib* for distributions that +# moved /lib* to /usr and only left symlinks behind. +# TODO: look for ld-linux.so on arches that have it +if (ls "$dir"/lib*/ld*.so* && [ -d "$dir/boot" ] || ls "$dir"/usr/lib*/ld*.so*) >/dev/null 2>/dev/null; then + if [ -e "$dir/etc/os-release" ]; then + short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')" + long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')" + elif [ -e "$dir/etc/debian_version" ]; then + short="Debian" + long="$(printf "Debian GNU/Linux (%s)\n" "$(cat "$dir/etc/debian_version")")" + # RPM derived distributions may also have a redhat-release or + # mandrake-release, so check their files first. + elif [ -e "$dir/etc/altlinux-release" ]; then + short="ALTLinux" + long="$(cat "$dir/etc/altlinux-release")" + elif [ -e "$dir/etc/magic-release" ]; then + short="Magic" + long="$(cat "$dir/etc/magic-release")" + elif [ -e "$dir/etc/blackPanther-release" ]; then + short="blackPanther" + long="$(cat "$dir/etc/blackPanther-release")" + elif [ -e "$dir/etc/ark-release" ]; then + short="Ark" + long="$(cat "$dir/etc/ark-release")" + elif [ -e "$dir/etc/arch-release" ]; then + short="Arch" + long="$(cat "$dir/etc/arch-release")" + elif [ -e "$dir/etc/asplinux-release" ]; then + short="ASPLinux" + long="$(cat "$dir/etc/asplinux-release")" + elif [ -e "$dir/etc/lvr-release" ]; then + short="LvR" + long="$(cat "$dir/etc/lvr-release")" + elif [ -e "$dir/etc/caos-release" ]; then + short="cAos" + long="$(cat "$dir/etc/caos-release")" + elif [ -e "$dir/etc/aurox-release" ]; then + short="Aurox" + long="$(cat "$dir/etc/aurox-release")" + elif [ -e "$dir/etc/engarde-release" ]; then + short="EnGarde" + long="$(cat "$dir/etc/engarde-release")" + elif [ -e "$dir/etc/vine-release" ]; then + short="Vine" + long="$(cat "$dir/etc/vine-release")" + elif [ -e "$dir/etc/whitebox-release" ]; then + short="WhiteBox" + long="$(cat "$dir/etc/whitebox-release")" + elif [ -e "$dir/etc/pld-release" ]; then + short="PLD" + long="$(cat "$dir/etc/pld-release")" + elif [ -e "$dir/etc/startcom-release" ]; then + short="StartCom" + long="$(cat "$dir/etc/startcom-release")" + elif [ -e "$dir/etc/trustix-release" ]; then + short="Trustix" + long="$(cat "$dir/etc/trustix-release")" + elif [ -e "$dir/etc/openna-release" ]; then + short="OpenNA" + long="$(cat "$dir/etc/openna-release")" + elif [ -e "$dir/etc/mageia-release" ]; then + short="Mageia" + long="$(cat "$dir/etc/mageia-release")" + elif [ -e "$dir/etc/conectiva-release" ]; then + short="Conectiva" + long="$(cat "$dir/etc/conectiva-release")" + elif [ -e "$dir/etc/mandrake-release" ]; then + short="Mandrake" + long="$(cat "$dir/etc/mandrake-release")" + elif [ -e "$dir/etc/fedora-release" ]; then + short="Fedora" + long="$(cat "$dir/etc/fedora-release")" + elif [ -e "$dir/etc/redhat-release" ]; then + short="RedHat" + long="$(cat "$dir/etc/redhat-release")" + elif [ -e "$dir/etc/SuSE-release" ]; then + short="SuSE" + long="$(head -n 1 "$dir/etc/SuSE-release")" + elif [ -e "$dir/etc/gentoo-release" ]; then + short="Gentoo" + long="$(cat "$dir/etc/gentoo-release")" + elif [ -e "$dir/etc/cobalt-release" ]; then + short="Cobalt" + long="$(cat "$dir/etc/cobalt-release")" + elif [ -e "$dir/etc/yellowdog-release" ]; then + short="YellowDog" + long="$(cat "$dir/etc/yellowdog-release")" + elif [ -e "$dir/etc/turbolinux-release" ]; then + short="Turbolinux" + long="$(cat "$dir/etc/turbolinux-release")" + elif [ -e "$dir/etc/pardus-release" ]; then + short="Pardus" + long="$(cat "$dir/etc/pardus-release")" + elif [ -e "$dir/etc/kanotix-version" ]; then + short="Kanotix" + long="$(cat "$dir/etc/kanotix-version")" + elif [ -e "$dir/etc/slackware-version" ]; then + short="Slackware" + long="$(printf "Slackware Linux (%s)\n" "$(cat "$dir/etc/slackware-version")")" + elif [ -e "$dir/sbin/pkgtool" ]; then + short="Slackware" + long="Slackware Linux" + elif grep -qs OpenLinux "$dir/etc/issue"; then + short="Caldera" + long="Caldera OpenLinux" + elif [ -e "$dir/etc/frugalware-release" ]; then + short="Frugalware Linux" + long="$(cat "$dir/etc/frugalware-release")" + elif [ -e "$dir/etc/kdemar-release" ]; then + short="K-DEMar" + long="$(printf "K-DEMar GNU/Linux (%s)\n" "$(cat "$dir/etc/kdemar-release")")" + elif [ -e "$dir/etc/lfs-release" ]; then + short="LFS" + long="$(printf "Linux From Scratch (%s)\n" "$(cat "$dir/etc/lfs-release")")" + elif [ -e "$dir/etc/meego-release" ]; then + short="MeeGo" + long="$(head -1 "$dir/etc/meego-release")" + elif [ -e "$dir/etc/4MLinux-version" ]; then + short="4MLinux" + long="4MLinux $(head -1 "$dir/etc/4MLinux-version")" + elif [ -e "$dir/etc/devuan_version" ]; then + short="Devuan" + long="$(printf "Devuan GNU/Linux (%s)\n" "$(cat "$dir/etc/devuan_version")")" + else + short="Linux" + long="unknown Linux distribution" + fi + + label="$(count_next_label "$short")" + result "$partition:$long:$label:linux" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/m68k/10macos6-9 b/os-probes/mounted/m68k/10macos6-9 new file mode 100755 index 0000000..646c7a7 --- /dev/null +++ b/os-probes/mounted/m68k/10macos6-9 @@ -0,0 +1,22 @@ +#!/bin/sh +# Probe for OS 9 via System suitcase check. +. /usr/share/os-prober/common.sh + +set -e + +partition="$1" +dir="$2" +fstype="$3" + +case "$fstype" in + hfs) debug "Partition is HFS" ;; + hfsplus) debug "Partition is HFS+ (Mac OS 9 only, we hope)" ;; +esac + +if [ -e "$dir/System Folder/System" ]; then + label="$(count_next_label MacOS)" + result "${partition}:Macintosh System 6/7, OS 8/9:${label}:chain" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/powerpc/10macos6-9 b/os-probes/mounted/powerpc/10macos6-9 new file mode 100755 index 0000000..2415a04 --- /dev/null +++ b/os-probes/mounted/powerpc/10macos6-9 @@ -0,0 +1,22 @@ +#!/bin/sh +# Probe for OS 9 via System suitcase check. +. /usr/share/os-prober/common.sh + +set -e + +partition="$1" +dir="$2" +fstype="$3" + +case "$fstype" in + hfs) debug "Partition is HFS" ;; + hfsplus) debug "Partition is HFS+ (Mac OS 9 only, we hope)" ;; +esac + +if [ -e "$dir/System Folder/System" ]; then + label="$(count_next_label MacOS)" + result "${partition}:Macintosh System 6/7, OS 8/9:${label}:macos" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/powerpc/20macosx b/os-probes/mounted/powerpc/20macosx new file mode 100755 index 0000000..2fc7e85 --- /dev/null +++ b/os-probes/mounted/powerpc/20macosx @@ -0,0 +1,32 @@ +#!/bin/sh -e +# Detects Mac OS X. I don't yet know how Mac OS <= 9 fits into this. +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +debug() { + if [ -z "$OS_PROBER_DISABLE_DEBUG" ]; then + logger -t macosx-prober "debug: $@" + fi +} + +# Weed out stuff that doesn't apply to us +case "$type" in + hfsplus) debug "$1 is an HFS+ partition" ;; + *) debug "$1 is not an HFS+ partition: exiting"; exit 1 ;; +esac + +# Could use a better test than this. +# /System/Library/CoreServices/SystemVersion.plist has version information, +# but I don't think it exists on Mac OS <= 9, and it's XML so parsing in +# shell will be nasty. + +if [ -e "$2/mach_kernel" ]; then + label="$(count_next_label MacOSX)" + result "$1:Mac OS X:$label:macosx" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/sparc/80solaris b/os-probes/mounted/sparc/80solaris new file mode 100755 index 0000000..8fbe34c --- /dev/null +++ b/os-probes/mounted/sparc/80solaris @@ -0,0 +1,19 @@ +#!/bin/sh +# Attempt to check if solaris is installed in this system +# looking at the /etc/system parameters file and /etc/vfstab. + +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +if [ -f "$dir/etc/system" ] && [ -f "$dir/etc/vfstab" ]; then + label="$(count_next_label Solaris)" + result "$partition:Solaris/SPARC:$label:chain" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/05efi b/os-probes/mounted/x86/05efi new file mode 100755 index 0000000..93309ce --- /dev/null +++ b/os-probes/mounted/x86/05efi @@ -0,0 +1,71 @@ +#!/bin/sh +# Detects all Microsoft OSes on a collection of partitions. + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# This file is for UEFI platform only +if [ ! -d /sys/firmware/efi ] || [ -f /var/lib/partman/ignore_uefi ]; then + debug "Not on UEFI platform" + exit 1 +fi + +# Weed out stuff that doesn't apply to us +case "$type" in + vfat) debug "$1 is a FAT32 partition" ;; + msdos) debug "$1 is a FAT16 partition" ;; + fat) debug "$1 is a FAT partition (mounted by GRUB)" ;; + *) debug "$1 is $type partition: exiting"; exit 1 ;; +esac + +if type udevadm > /dev/null 2>&1; then + udevinfo () { + udevadm info "$@" + } +fi + +if type udevinfo > /dev/null 2>&1; then + # Skip virtual devices + if udevinfo -q path -n $partition | grep -q /virtual/; then + debug "$1 is virtual device: exiting" + exit 1 + fi + + eval "$(udevinfo -q property -n "$partition" | grep -E '^ID_PART_ENTRY_(TYPE|SCHEME)=')" + debug "$partition partition scheme is $ID_PART_ENTRY_SCHEME" + debug "$partition partition type is $ID_PART_ENTRY_TYPE" + + if [ -z "$ID_PART_ENTRY_TYPE" -o -z "$ID_PART_ENTRY_SCHEME" -o \ + \( "$ID_PART_ENTRY_SCHEME" != gpt -a "$ID_PART_ENTRY_SCHEME" != msdos \) -o \ + \( "$ID_PART_ENTRY_SCHEME" = gpt -a "$ID_PART_ENTRY_TYPE" != c12a7328-f81f-11d2-ba4b-00a0c93ec93b \) -o \ + \( "$ID_PART_ENTRY_SCHEME" = msdos -a "$ID_PART_ENTRY_TYPE" != 0xef \) ]; then + debug "$partition is not a ESP partition: exiting" + exit 1 + fi +else + debug "udevinfo and udevadm missing - cannot check partition type" +fi + +efi=$(item_in_dir efi "$mpoint") +if [ -z "$efi" ]; then + debug "$mpoint does not have /EFI directory: exiting" + exit 1 +fi + +ret=1 +for test in /usr/lib/os-probes/mounted/efi/*; do + debug "running subtest $test" + if [ -f "$test" ] && [ -x "$test" ]; then + entry=$("$test" "$mpoint/$efi") + if [ -n "$entry" ]; then + debug "bootloader $entry found by subtest $test" + ret=0 + result "${partition}@/$efi/${entry}:efi" + fi + fi +done + +exit $ret diff --git a/os-probes/mounted/x86/10freedos b/os-probes/mounted/x86/10freedos new file mode 100755 index 0000000..94388f3 --- /dev/null +++ b/os-probes/mounted/x86/10freedos @@ -0,0 +1,23 @@ +#!/bin/sh + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + vfat) debug "$1 is a FAT32 partition" ;; + msdos) debug "$1 is a FAT16 partition" ;; + fat) debug "$1 is a FAT partition (mounted by GRUB)" ;; + *) debug "$1 is not a FAT partition: exiting"; exit 1 ;; +esac + +if item_in_dir -q kernel.sys "$2" && item_in_dir -q command.com "$2"; then + label="$(count_next_label FreeDOS)" + result "$1:FreeDOS:$label:chain" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/10qnx b/os-probes/mounted/x86/10qnx new file mode 100755 index 0000000..8d40398 --- /dev/null +++ b/os-probes/mounted/x86/10qnx @@ -0,0 +1,21 @@ +#!/bin/sh + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + qnx4) debug "$partition is a QNX4 partition" ;; + *) debug "$partition is not a QNX4 partition: exiting"; exit 1 ;; +esac + +if [ -e "$mpoint/.boot" ]; then + label="$(count_next_label QNX)" + result "$partition:QNX:$label:chain" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/20microsoft b/os-probes/mounted/x86/20microsoft new file mode 100755 index 0000000..06bb807 --- /dev/null +++ b/os-probes/mounted/x86/20microsoft @@ -0,0 +1,117 @@ +#!/bin/sh +# Detects all Microsoft OSes on a collection of partitions. + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# This script looks for legacy BIOS bootloaders only. Skip if running UEFI +if [ -d /sys/firmware/efi ] && [ ! -f /var/lib/partman/ignore_uefi ]; then + debug "Skipping legacy bootloaders on UEFI system" + exit 1 +fi + +# Weed out stuff that doesn't apply to us +case "$type" in + ntfs|ntfs-3g) debug "$1 is a NTFS partition" ;; + vfat) debug "$1 is a FAT32 partition" ;; + msdos) debug "$1 is a FAT16 partition" ;; + fat) debug "$1 is a FAT partition (mounted by GRUB)" ;; + fuse|fuseblk) debug "$1 is a FUSE partition" ;; # might be ntfs-3g + *) debug "$1 is not a MS partition: exiting"; exit 1 ;; +esac + +found= +# Vista (previously Longhorn) +if item_in_dir -q bootmgr "$2"; then + # there might be different boot directories in different case as: + # boot Boot BOOT + for boot in $(item_in_dir boot "$2"); do + bcd=$(item_in_dir bcd "$2/$boot") + if [ -n "$bcd" ]; then + if grep -aqs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then + long="Windows 10" + elif grep -aqs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then + long="Windows 8" + elif grep -aqs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then + long="Windows 7" + elif grep -aqs "W.i.n.d.o.w.s. .V.i.s.t.a" "$2/$boot/$bcd"; then + long="Windows Vista" + 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" + 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" + 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" + elif grep -aqs "W.i.n.d.o.w.s. .S.e.t.u.p" "$2/$boot/$bcd"; then + long="Windows Recovery Environment" + else + long="Windows Vista" + fi + short=Windows + + found=true + + break + fi + done +fi + +# 2000/XP/NT4.0 +if [ -z "$found" ] && item_in_dir -q ntldr "$2" && item_in_dir -q ntdetect.com "$2"; then + long="Windows NT/2000/XP" + short=Windows + ini=$(item_in_dir boot.ini "$2") + if [ -n "$ini" ]; then + multicount="$(grep -e "^multi" "$2/$ini" | wc -l)" + scsicount="$(grep -e "^scsi" "$2/$ini" | wc -l)" + msoscount="$(expr "${multicount}" + "${scsicount}")" + if [ "$msoscount" -eq 1 ]; then + # We need to remove a Carriage Return at the end of + # the line... + defaultmspart="$(grep -e "^default=" "$2/$ini" | cut -d '=' -f2 | tr -d '\r')" + # Escape any backslashes in defaultmspart + grepexp="^$(echo "$defaultmspart" | sed -e 's/\\/\\\\/')=" + # Colons not allowed; replace by spaces + # Accented characters (non UTF-8) cause debconf to + # hang, so we fall back to the default if the name + # contains any weird characters. + long="$(grep -e "$grepexp" "$2/$ini" | cut -d '"' -f2 | \ + tr ':' ' ' | LC_ALL=C grep -v '[^a-zA-Z0-9 &()/_-]')" + if [ -z "$long" ]; then + long="Windows NT/2000/XP" + fi + else + long="Windows NT/2000/XP" + fi + + found=true + fi +fi + +# MS-DOS +if [ -z "$found" ] && item_in_dir -q dos "$2"; then + long="MS-DOS 5.x/6.x/Win3.1" + short=MS-DOS + + found=true +fi + +# 95/98/Me +if [ -z "$found" ] && item_in_dir -q windows "$2" && + item_in_dir -q win.com "$2"/"$(item_in_dir windows "$2")"; then + long="Windows 95/98/Me" + short=Windows9xMe + + found=true +fi + +if [ -z "$found" ]; then + exit 1 +fi + +label="$(count_next_label "$short")" +result "${partition}:${long}:${label}:chain" +exit 0 diff --git a/os-probes/mounted/x86/30utility b/os-probes/mounted/x86/30utility new file mode 100755 index 0000000..af48d30 --- /dev/null +++ b/os-probes/mounted/x86/30utility @@ -0,0 +1,33 @@ +#!/bin/sh +# Detects utility (hw vendor recovery) partitions. + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + vfat) debug "$1 is a FAT32 partition" ;; + msdos) debug "$1 is a FAT16 partition" ;; + fat) debug "$1 is a FAT partition (mounted by GRUB)" ;; + *) debug "$1 is not a FAT partition: exiting"; exit 1 ;; +esac + +# Dell Utility partitions have partition type 0xde, but no idea how to +# cleanly detect that from shell +if item_in_dir -q dellbio.bin "$2" && \ + (item_in_dir -q delldiag.exe "$2" || item_in_dir -q delldiag.com "$2"); then + long="Dell Utility Partition" + short=DellUtility +elif item_in_dir -q f11.sys "$2"; then + long="Acronis Secure Zone" + short=AcroneZone +else + exit 1 +fi + +label="$(count_next_label "$short")" +result "${partition}:${long}:${label}:chain" +exit 0 diff --git a/os-probes/mounted/x86/70hurd b/os-probes/mounted/x86/70hurd new file mode 100755 index 0000000..af29ff5 --- /dev/null +++ b/os-probes/mounted/x86/70hurd @@ -0,0 +1,16 @@ +#!/bin/sh +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +if [ -d "$dir/servers" ] && [ -d "$dir/hurd" ]; then + label="$(count_next_label Hurd)" + result "$partition:GNU/Hurd:$label:hurd" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/80minix b/os-probes/mounted/x86/80minix new file mode 100755 index 0000000..e01f669 --- /dev/null +++ b/os-probes/mounted/x86/80minix @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + minix|minix2|ext2) ;; + *) exit 1 ;; +esac + +if [ -f "$dir/minix" ] || [ -e "$dir/boot/image_big" ]; then + if [ -e "$dir/boot/image_latest" ]; then + boot="minix" + else + boot="chain" + fi + + label="$(count_next_label Minix)" + result "$partition:Minix:$label:$boot" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/83haiku b/os-probes/mounted/x86/83haiku new file mode 100755 index 0000000..6de7a1d --- /dev/null +++ b/os-probes/mounted/x86/83haiku @@ -0,0 +1,35 @@ +#!/bin/sh +# Detects Haiku on BeFS partitions. + +. /usr/share/os-prober/common.sh + +partition="$1" +mpoint="$2" +type="$3" + +# Weed out stuff that doesn't apply to us +case "$type" in + befs|befs_be) debug "$partition is a BeFS partition" ;; + *) debug "$partition is not a BeFS partition: exiting"; exit 1 ;; +esac + +if head -c 512 "$partition" | grep -qs "system.haiku_loader"; then + debug "Stage 1 bootloader found" +else + debug "Stage 1 bootloader not found: exiting" + exit 1 +fi + +if system="$(item_in_dir "system" "$mpoint")" && + item_in_dir -q "haiku_loader" "$mpoint/$system" && + (item_in_dir -q "kernel_x86" "$mpoint/$system" || + item_in_dir -q "kernel_x86_64" "$mpoint/$system") +then + debug "Stage 2 bootloader and kernel found" + label="$(count_next_label Haiku)" + result "$partition:Haiku:$label:chain" + exit 0 +else + debug "Stage 2 bootloader and kernel not found: exiting" + exit 1 +fi diff --git a/os-probes/mounted/x86/90solaris b/os-probes/mounted/x86/90solaris new file mode 100755 index 0000000..0e9148c --- /dev/null +++ b/os-probes/mounted/x86/90solaris @@ -0,0 +1,19 @@ +#!/bin/sh +# Attempt to check if solaris is installed in this system +# looking at the /etc/system parameters file and /etc/vfstab. + +set -e + +. /usr/share/os-prober/common.sh + +partition="$1" +dir="$2" +type="$3" + +if [ -f "$dir/etc/system" ] && [ -f "$dir/etc/vfstab" ]; then + label="$(count_next_label Solaris)" + result "$partition:Solaris/IA32:$label:chain" + exit 0 +else + exit 1 +fi diff --git a/os-probes/mounted/x86/efi/10elilo b/os-probes/mounted/x86/efi/10elilo new file mode 100755 index 0000000..d815b52 --- /dev/null +++ b/os-probes/mounted/x86/efi/10elilo @@ -0,0 +1,24 @@ +#!/bin/sh +# Detects ELILO bootloader on a EFI System Partition + +. /usr/share/os-prober/common.sh + +efi="$1" + +found= + +elilo=`find $1 -name "elilo.efi"` +if [ -n "$elilo" ]; then + bdir="${elilo%/*}" + bdir="${elilo##*/}" + long="ELILO Boot Manager" + short="ELILO" + path=${bdir}/elilo.efi + found=true +fi + +if [ -n "$found" ]; then + label="$(count_next_label "$short")" + result "${path}:${long}:${label}" +fi +exit 0 diff --git a/os-probes/mounted/x86/efi/20microsoft b/os-probes/mounted/x86/efi/20microsoft new file mode 100755 index 0000000..9532081 --- /dev/null +++ b/os-probes/mounted/x86/efi/20microsoft @@ -0,0 +1,28 @@ +#!/bin/sh +# Detects Microsoft bootloader on a EFI System Partition + +. /usr/share/os-prober/common.sh + +efi="$1" + +found= +for microsoft in $(item_in_dir microsoft "$efi"); do + for boot in $(item_in_dir boot "$efi/$microsoft"); do + bcd=$(item_in_dir bcd "$efi/$microsoft/$boot") + bootmgfw=$(item_in_dir bootmgfw.efi "$efi/$microsoft/$boot") + if [ -n "$bcd" -a -n "$bootmgfw" ]; then + long="Windows Boot Manager" + short=Windows + path="$microsoft/$boot/$bootmgfw" + found=true + break + fi + done +done + + +if [ -n "$found" ]; then + label="$(count_next_label "$short")" + result "${path}:${long}:${label}" +fi +exit 0