From 35cc272d0742cdc5838bfed3f86ee73386f30f7f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 18 Sep 2008 09:43:31 +0000 Subject: [PATCH] * Handle symlinks such as /dev/disk/by-label/bla. Previously Grub installation barfed. svn path=/nixpkgs/trunk/; revision=12877 --- pkgs/tools/misc/grub/default.nix | 12 +++++++++- pkgs/tools/misc/grub/symlink.patch | 37 ++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/misc/grub/symlink.patch diff --git a/pkgs/tools/misc/grub/default.nix b/pkgs/tools/misc/grub/default.nix index 398b57e623e..31ee5e70e8b 100644 --- a/pkgs/tools/misc/grub/default.nix +++ b/pkgs/tools/misc/grub/default.nix @@ -17,16 +17,26 @@ stdenv.mkDerivation { sha256 = "12akcbp1a31pxzsxm01scgir0fqkk8qqqwhs44vzgs2chzzigyvd"; }; + patches = [ + # Properly handle the case of symlinks such as + # /dev/disk/by-label/bla. The symlink resolution code in + # grub-install isn't smart enough. + ./symlink.patch + ]; + # Autoconf/automake required for the splashimage patch. buildInputs = [autoconf automake]; - preConfigure = '' + prePatch = '' unpackFile $gentooPatches rm patch/400_all_grub-0.97-reiser4-20050808-gentoo.patch for i in patch/*.patch; do echo "applying patch $i" patch -p1 < $i || patch -p0 < $i done + ''; + + preConfigure = '' autoreconf ''; } diff --git a/pkgs/tools/misc/grub/symlink.patch b/pkgs/tools/misc/grub/symlink.patch new file mode 100644 index 00000000000..ac38be04618 --- /dev/null +++ b/pkgs/tools/misc/grub/symlink.patch @@ -0,0 +1,37 @@ +diff -rc grub-0.97-orig/util/grub-install.in grub-0.97/util/grub-install.in +*** grub-0.97-orig/util/grub-install.in 2008-09-18 11:32:13.000000000 +0200 +--- grub-0.97/util/grub-install.in 2008-09-18 11:36:40.000000000 +0200 +*************** +*** 194,217 **** + # Usage: resolve_symlink file + # Find the real file/device that file points at + resolve_symlink () { +! tmp_fname=$1 +! # Resolve symlinks +! while test -L $tmp_fname; do +! tmp_new_fname=`ls -al $tmp_fname | sed -n 's%.*-> \(.*\)%\1%p'` +! if test -z "$tmp_new_fname"; then +! echo "Unrecognized ls output" 2>&1 +! exit 1 +! fi +! +! # Convert relative symlinks +! case $tmp_new_fname in +! /*) tmp_fname="$tmp_new_fname" +! ;; +! *) tmp_fname="`echo $tmp_fname | sed 's%/[^/]*$%%'`/$tmp_new_fname" +! ;; +! esac +! done +! echo "$tmp_fname" + } + + # Usage: find_device file +--- 194,200 ---- + # Usage: resolve_symlink file + # Find the real file/device that file points at + resolve_symlink () { +! readlink -f $1 + } + + # Usage: find_device file