about summary refs log tree commit diff
path: root/pkgs/os-specific
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2012-02-25 19:57:34 +0000
committerShea Levy <shea@shealevy.com>2012-02-25 19:57:34 +0000
commitea195b2507b9068d966009d27c0e90b57d88f30d (patch)
tree287b4453ffa21139715bb1c1c57e6d01d1045295 /pkgs/os-specific
parent38e3d7bc86d2a48dd4d653fd3f142f422c075563 (diff)
parent385f242a400749b3923d51fff5a86403e6dab0dc (diff)
svn merge ^/nixpkgs/trunk
svn path=/nixpkgs/branches/stdenv-updates/; revision=32564
Diffstat (limited to 'pkgs/os-specific')
-rw-r--r--pkgs/os-specific/linux/acpi-call/default.nix8
-rw-r--r--pkgs/os-specific/linux/bbswitch/default.nix7
-rw-r--r--pkgs/os-specific/linux/mcelog/default.nix33
-rw-r--r--pkgs/os-specific/linux/qemu-kvm/default.nix2
-rw-r--r--pkgs/os-specific/linux/qemu-kvm/qemu-img-fix-corrupt-vdi.patch27
-rwxr-xr-xpkgs/os-specific/linux/rfkill/rfkill-hook.sh19
-rw-r--r--pkgs/os-specific/linux/rfkill/udev.nix49
7 files changed, 135 insertions, 10 deletions
diff --git a/pkgs/os-specific/linux/acpi-call/default.nix b/pkgs/os-specific/linux/acpi-call/default.nix
index 3fececf6c6db4..301a8054557cc 100644
--- a/pkgs/os-specific/linux/acpi-call/default.nix
+++ b/pkgs/os-specific/linux/acpi-call/default.nix
@@ -10,16 +10,14 @@ stdenv.mkDerivation {
   };
   
   preBuild = ''
-    kernelVersion=$(cd ${kernel}/lib/modules && ls)
     sed -e 's/break/true/' -i test_off.sh
     sed -e 's@/bin/bash@.bin/sh@' -i test_off.sh
-    sed -e "s@/lib/modules/\$(.*)@${kernel}/lib/modules/$kernelVersion@" -i Makefile
+    sed -e "s@/lib/modules/\$(.*)@${kernel}/lib/modules/${kernel.version}@" -i Makefile
   '';
  
   installPhase = ''
-    kernelVersion=$(cd ${kernel}/lib/modules && ls)
-    mkdir -p $out/lib/modules/$kernelVersion/misc
-    cp acpi_call.ko $out/lib/modules/$kernelVersion/misc
+    mkdir -p $out/lib/modules/${kernel.version}/misc
+    cp acpi_call.ko $out/lib/modules/${kernel.version}/misc
     mkdir -p $out/bin
     cp test_off.sh $out/bin/test_discrete_video_off.sh
   '';
diff --git a/pkgs/os-specific/linux/bbswitch/default.nix b/pkgs/os-specific/linux/bbswitch/default.nix
index a8f8a9d33ef3b..7c5752b4e34ec 100644
--- a/pkgs/os-specific/linux/bbswitch/default.nix
+++ b/pkgs/os-specific/linux/bbswitch/default.nix
@@ -17,14 +17,13 @@ stdenv.mkDerivation {
   preBuild = ''
     kernelVersion=$(cd ${kernel}/lib/modules && ls)
     substituteInPlace Makefile \
-      --replace "\$(shell uname -r)" "$kernelVersion" \
+      --replace "\$(shell uname -r)" "${kernel.version}" \
       --replace "/lib/modules" "${kernel}/lib/modules"
   '';
  
   installPhase = ''
-    kernelVersion=$(cd ${kernel}/lib/modules && ls)
-    ensureDir $out/lib/modules/$kernelVersion/misc
-    cp bbswitch.ko $out/lib/modules/$kernelVersion/misc
+    ensureDir $out/lib/modules/${kernel.version}/misc
+    cp bbswitch.ko $out/lib/modules/${kernel.version}/misc
 
     ensureDir $out/bin
     tee $out/bin/discrete_vga_poweroff << EOF
diff --git a/pkgs/os-specific/linux/mcelog/default.nix b/pkgs/os-specific/linux/mcelog/default.nix
new file mode 100644
index 0000000000000..82c502ede72fe
--- /dev/null
+++ b/pkgs/os-specific/linux/mcelog/default.nix
@@ -0,0 +1,33 @@
+{ stdenv, fetchgit }:
+
+# Shows the machine check exceptions logged by the kernel.
+# E.g. a log is generated when intel processors cpu-throttle.
+
+# The releases of this package are no longer on kernel.org
+# hence we fetch them from github. Apparently, these
+# are also more recent.
+
+let
+
+  rev = "7fa99818367a6d17014b36d6f918ad848cbe7ce2";
+  version = "1.0pre-${rev}"; 
+  sha256 = "15eea3acd76190c7922c71028b31963221a2eefd8afa713879e191a26bc22ae7";
+
+in stdenv.mkDerivation {
+
+  name = "mcelog-${version}";
+
+  src = fetchgit {
+    url = "https://github.com/andikleen/mcelog";
+    inherit sha256;
+    inherit rev;
+  };
+
+  makeFlags = "prefix=$(out) etcprefix=$(out) DOCDIR=$(out)/share/doc";
+
+  meta = {
+    description = "Tool to display logged machine check exceptions";
+    homepage = http://mcelog.org/;
+    license = stdenv.lib.licenses.gpl2;
+  };
+}
\ No newline at end of file
diff --git a/pkgs/os-specific/linux/qemu-kvm/default.nix b/pkgs/os-specific/linux/qemu-kvm/default.nix
index 821084c1b3328..aa92b2f2d0d1f 100644
--- a/pkgs/os-specific/linux/qemu-kvm/default.nix
+++ b/pkgs/os-specific/linux/qemu-kvm/default.nix
@@ -11,7 +11,7 @@ stdenv.mkDerivation rec {
     sha256 = "0gkk96yid3nq8i4z8xbiarj0r9v7b2zavf5mnh0rc7kclzxa7mmf";
   };
 
-  patches = [ ./smb-tmpdir.patch ];
+  patches = [ ./smb-tmpdir.patch ./qemu-img-fix-corrupt-vdi.patch ];
 
   configureFlags = "--audio-drv-list=alsa";
 
diff --git a/pkgs/os-specific/linux/qemu-kvm/qemu-img-fix-corrupt-vdi.patch b/pkgs/os-specific/linux/qemu-kvm/qemu-img-fix-corrupt-vdi.patch
new file mode 100644
index 0000000000000..446a69a146b03
--- /dev/null
+++ b/pkgs/os-specific/linux/qemu-kvm/qemu-img-fix-corrupt-vdi.patch
@@ -0,0 +1,27 @@
+From http://patchwork.ozlabs.org/patch/137186/
+
+diff -ru qemu-kvm-0.15.1-orig/block/vdi.c qemu-kvm-0.15.1/block/vdi.c
+--- qemu-kvm-0.15.1-orig/block/vdi.c	2011-10-19 15:54:48.000000000 +0200
++++ qemu-kvm-0.15.1/block/vdi.c	2012-02-25 18:15:36.114574574 +0100
+@@ -1,7 +1,7 @@
+ /*
+  * Block driver for the Virtual Disk Image (VDI) format
+  *
+- * Copyright (c) 2009 Stefan Weil
++ * Copyright (c) 2009, 2012 Stefan Weil
+  *
+  * This program is free software: you can redistribute it and/or modify
+  * it under the terms of the GNU General Public License as published by
+@@ -767,8 +767,12 @@
+             acb->header_modified = 1;
+         }
+         acb->bmap_last = block_index;
++        /* Copy data to be written to new block and zero unused parts. */
++        memset(block, 0, sector_in_block * SECTOR_SIZE);
+         memcpy(block + sector_in_block * SECTOR_SIZE,
+                acb->buf, n_sectors * SECTOR_SIZE);
++        memset(block + (sector_in_block + n_sectors) * SECTOR_SIZE, 0,
++               (s->block_sectors - n_sectors - sector_in_block) * SECTOR_SIZE);
+         acb->hd_iov.iov_base = (void *)block;
+         acb->hd_iov.iov_len = s->block_size;
+         qemu_iovec_init_external(&acb->hd_qiov, &acb->hd_iov, 1);
diff --git a/pkgs/os-specific/linux/rfkill/rfkill-hook.sh b/pkgs/os-specific/linux/rfkill/rfkill-hook.sh
new file mode 100755
index 0000000000000..d07c729818317
--- /dev/null
+++ b/pkgs/os-specific/linux/rfkill/rfkill-hook.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+# Executes a hook in case of a change to the
+# rfkill state. The hook can be passed as
+# environment variable, or present as executable
+# file.
+
+if [ -z "$RFKILL_STATE" ]; then
+  echo "rfkill-hook: error: RFKILL_STATE variable not set"
+  exit 1
+fi
+
+if [ -x /var/run/current-system/etc/rfkill.hook ]; then
+  exec /var/run/current-system/etc/rfkill.hook
+elif [ ! -z "$RFKILL_HOOK" ]; then
+  exec $RFKILL_HOOK
+else
+  echo "rfkill-hook: $RFKILL_STATE"
+fi
\ No newline at end of file
diff --git a/pkgs/os-specific/linux/rfkill/udev.nix b/pkgs/os-specific/linux/rfkill/udev.nix
new file mode 100644
index 0000000000000..6cf6e4adfa074
--- /dev/null
+++ b/pkgs/os-specific/linux/rfkill/udev.nix
@@ -0,0 +1,49 @@
+{ stdenv }:
+
+# Provides a facility to hook into rfkill changes.
+#
+# Exemplary usage:
+#
+# Add this package to udev.packages, e.g.:
+#   udev.packages = [ pkgs.rfkill_udev ];
+#
+# Add a hook script in the managed etc directory, e.g.:
+#   etc = [
+#     { source = pkgs.writeScript "rtfkill.hook" ''
+#         #!/bin/sh
+#
+#         if [ "$RFKILL_STATE" -eq "1" ]; then
+#           exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
+#         else
+#           exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
+#         fi
+#       '';
+#       target = "rfkill.hook";
+#     }
+
+# Note: this package does not need the binaries
+# in the rfkill package.
+
+stdenv.mkDerivation {
+  name = "rfkill-udev";
+
+  unpackPhase = "true";
+  dontBuild = true;
+
+  installPhase = ''
+    ensureDir "$out/etc/udev/rules.d/";
+    cat > "$out/etc/udev/rules.d/90-rfkill.rules" << EOF
+      SUBSYSTEM=="rfkill", ATTR{type}=="wlan", RUN+="$out/bin/rfkill-hook.sh" 
+    EOF
+
+    ensureDir "$out/bin/";
+    cp ${./rfkill-hook.sh} "$out/bin/rfkill-hook.sh"
+    chmod +x "$out/bin/rfkill-hook.sh";
+  '';
+
+  meta = {
+    homepage = http://wireless.kernel.org/en/users/Documentation/rfkill;
+    description = "Rules+hook for udev to catch rfkill state changes";
+    platforms = stdenv.lib.platforms.linux;
+  };
+}
\ No newline at end of file