summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-09-25 14:20:27 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-09-25 14:20:27 -0400
commitc701d6cb21e1e83a82ebdefe180f2d6233087f4a (patch)
tree3e7a7503cd7e84c8d2ee8aaffe264301fb591ebf /pkgs/build-support
parent6aa5f2db8f4c0df18364c8a70218a52a1b2c97cf (diff)
parent6cd28a468aec0005052ee01eaf8510735948a2dd (diff)
downloadnixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar.gz
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar.bz2
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar.lz
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar.xz
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.tar.zst
nixlib-c701d6cb21e1e83a82ebdefe180f2d6233087f4a.zip
Merge remote-tracking branch 'upstream/master' into staging
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/emacs/wrapper.nix2
-rw-r--r--pkgs/build-support/setup-hooks/auto-patchelf.sh27
-rw-r--r--pkgs/build-support/vm/default.nix16
3 files changed, 13 insertions, 32 deletions
diff --git a/pkgs/build-support/emacs/wrapper.nix b/pkgs/build-support/emacs/wrapper.nix
index 4e780b104b08..e161daffbd37 100644
--- a/pkgs/build-support/emacs/wrapper.nix
+++ b/pkgs/build-support/emacs/wrapper.nix
@@ -21,7 +21,7 @@ set which contains `emacsWithPackages`. For example, to override
 `emacsPackagesNg.emacsWithPackages`,
 ```
 let customEmacsPackages =
-      emacsPackagesNg.overrideScope (super: self: {
+      emacsPackagesNg.overrideScope' (self: super: {
         # use a custom version of emacs
         emacs = ...;
         # use the unstable MELPA version of magit
diff --git a/pkgs/build-support/setup-hooks/auto-patchelf.sh b/pkgs/build-support/setup-hooks/auto-patchelf.sh
index 32fdb1000e27..7c165627f72e 100644
--- a/pkgs/build-support/setup-hooks/auto-patchelf.sh
+++ b/pkgs/build-support/setup-hooks/auto-patchelf.sh
@@ -7,21 +7,7 @@ gatherLibraries() {
 addEnvHooks "$targetOffset" gatherLibraries
 
 isExecutable() {
-    [ "$(file -b -N --mime-type "$1")" = application/x-executable ]
-}
-
-findElfs() {
-    find "$1" -type f -exec "$SHELL" -c '
-        while [ -n "$1" ]; do
-            mimeType="$(file -b -N --mime-type "$1")"
-            if [ "$mimeType" = application/x-executable \
-              -o "$mimeType" = application/x-pie-executable \
-              -o "$mimeType" = application/x-sharedlib ]; then
-                echo "$1"
-            fi
-            shift
-        done
-    ' -- {} +
+    readelf -h "$1" 2> /dev/null | grep -q '^ *Type: *EXEC\>'
 }
 
 # We cache dependencies so that we don't need to search through all of them on
@@ -167,9 +153,14 @@ autoPatchelf() {
     # findDependency outside of this, the dependency cache needs to be rebuilt
     # from scratch, so keep this in mind if you want to run findDependency
     # outside of this function.
-    findElfs "$prefix" | while read -r elffile; do
-        autoPatchelfFile "$elffile"
-    done
+    while IFS= read -r -d $'\0' file; do
+      isELF "$file" || continue
+      if isExecutable "$file"; then
+          # Skip if the executable is statically linked.
+          readelf -l "$file" | grep -q "^ *INTERP\\>" || continue
+      fi
+      autoPatchelfFile "$file"
+    done < <(find "$prefix" -type f -print0)
 }
 
 # XXX: This should ultimately use fixupOutputHooks but we currently don't have
diff --git a/pkgs/build-support/vm/default.nix b/pkgs/build-support/vm/default.nix
index 6e98099460f8..03b3fb1f9f27 100644
--- a/pkgs/build-support/vm/default.nix
+++ b/pkgs/build-support/vm/default.nix
@@ -3,9 +3,8 @@
 , img ? pkgs.stdenv.hostPlatform.platform.kernelTarget
 , storeDir ? builtins.storeDir
 , rootModules ?
-    [ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" "sym53c8xx" "virtio_scsi" "ahci "]
+    [ "virtio_pci" "virtio_mmio" "virtio_blk" "virtio_balloon" "virtio_rng" "ext4" "unix" "9p" "9pnet_virtio" "crc32c_generic" ]
       ++ pkgs.lib.optional (pkgs.stdenv.isi686 || pkgs.stdenv.isx86_64) "rtc_cmos"
-, config
 }:
 
 with pkgs;
@@ -197,17 +196,9 @@ rec {
     ${qemuBinary qemu} \
       -nographic -no-reboot \
       -device virtio-rng-pci \
-      ${if "$diskInterface" == "scsi" then '' \
-        \ # FIXME: /dev/sda is not created within the VM
-        -device lsi53c895a \
-        -device scsi-hd,drive=hd,id=scsi1,bootindex=1 \
-        ''${diskImage:+-drive file=$diskImage,media=disk,if=none,id=hd,cache=unsafe,werror=report} \
-      '' else '' \
-        -drive file=$diskImage,media=disk,if=none,id=hd \
-        -device virtio-blk-pci,scsi=off,drive=hd,id=virtio0,bootindex=1 \
-      \''}
       -virtfs local,path=${storeDir},security_model=none,mount_tag=store \
       -virtfs local,path=$TMPDIR/xchg,security_model=none,mount_tag=xchg \
+      ''${diskImage:+-drive file=$diskImage,if=virtio,cache=unsafe,werror=report} \
       -kernel ${kernel}/${img} \
       -initrd ${initrd}/initrd \
       -append "console=${qemuSerialDevice} panic=1 command=${stage2Init} out=$out mountDisk=$mountDisk loglevel=4" \
@@ -307,13 +298,12 @@ rec {
      `run-vm' will be left behind in the temporary build directory
      that allows you to boot into the VM and debug it interactively. */
 
-  runInLinuxVM = drv: lib.overrideDerivation drv ({ memSize ? 512, QEMU_OPTS ? "", args, builder, ...  } @ moreArgs : {
+  runInLinuxVM = drv: lib.overrideDerivation drv ({ memSize ? 512, QEMU_OPTS ? "", args, builder, ... }: {
     requiredSystemFeatures = [ "kvm" ];
     builder = "${bash}/bin/sh";
     args = ["-e" (vmRunCommand qemuCommandLinux)];
     origArgs = args;
     origBuilder = builder;
-    diskInterface = "${moreArgs.diskInterface}";
     QEMU_OPTS = "${QEMU_OPTS} -m ${toString memSize}";
     passAsFile = []; # HACK fix - see https://github.com/NixOS/nixpkgs/issues/16742
   });