mirror of
https://github.com/SebastianWendel/nixpkgs.git
synced 2024-09-21 04:49:01 +02:00
* vmTools: don't use klibc anymore. Just use utillinux/bash/etc.
svn path=/nixpkgs/trunk/; revision=22209
This commit is contained in:
parent
3e958eea23
commit
6dddd07402
|
@ -7,8 +7,6 @@ rec {
|
||||||
|
|
||||||
inherit (linuxPackages_2_6_32) kernel;
|
inherit (linuxPackages_2_6_32) kernel;
|
||||||
|
|
||||||
klibcShrunk = pkgs.klibcShrunk.override { klibc = klibc_15; };
|
|
||||||
|
|
||||||
kvm = pkgs.kvm76;
|
kvm = pkgs.kvm76;
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,23 +16,50 @@ rec {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
mountCifs = (makeStaticBinaries stdenv).mkDerivation {
|
initrdUtils = runCommand "initrd-utils"
|
||||||
name = "mount.cifs";
|
{ buildInputs = [ nukeReferences ];
|
||||||
src = fetchurl {
|
allowedReferences = [ "out" modulesClosure ]; # prevent accidents like glibc being included in the initrd
|
||||||
url = http://nixos.org/tarballs/mount_cifs-20090330.c;
|
}
|
||||||
sha256 = "1d9v3qzic3d12vna8g7d1zsl1piwm20f6xhck319rbfkrdg0smnl";
|
''
|
||||||
};
|
|
||||||
buildInputs = [nukeReferences];
|
|
||||||
buildCommand = ''
|
|
||||||
ensureDir $out/bin
|
ensureDir $out/bin
|
||||||
gcc -Wall $src -o $out/bin/mount.cifs
|
ensureDir $out/lib
|
||||||
strip $out/bin/mount.cifs
|
|
||||||
nuke-refs $out/bin/mount.cifs
|
# Copy what we need from Glibc.
|
||||||
'';
|
cp -p ${glibc}/lib/ld-linux*.so.? $out/lib
|
||||||
allowedReferences = []; # prevent accidents like glibc being included in the initrd
|
cp -p ${glibc}/lib/libc.so.* $out/lib
|
||||||
};
|
cp -p ${glibc}/lib/librt.so.* $out/lib
|
||||||
|
cp -p ${glibc}/lib/libdl.so.* $out/lib
|
||||||
|
|
||||||
|
# Copy some utillinux stuff.
|
||||||
|
cp ${utillinux}/bin/mount ${utillinux}/bin/umount $out/bin
|
||||||
|
cp -pd ${utillinux}/lib/libblkid*.so.* $out/lib
|
||||||
|
cp -pd ${utillinux}/lib/libuuid*.so.* $out/lib
|
||||||
|
|
||||||
|
# Copy some coreutils.
|
||||||
|
cp ${coreutils}/bin/basename $out/bin
|
||||||
|
cp ${coreutils}/bin/mkdir $out/bin
|
||||||
|
cp ${coreutils}/bin/mknod $out/bin
|
||||||
|
cp ${coreutils}/bin/cat $out/bin
|
||||||
|
cp ${coreutils}/bin/chroot $out/bin
|
||||||
|
cp ${coreutils}/bin/sleep $out/bin
|
||||||
|
cp ${coreutils}/bin/ln $out/bin
|
||||||
|
|
||||||
|
# Copy some other tools.
|
||||||
|
cp ${bash}/bin/bash $out/bin
|
||||||
|
cp ${module_init_tools}/sbin/insmod $out/bin/insmod
|
||||||
|
cp ${pkgs.nettools}/sbin/ifconfig $out/bin
|
||||||
|
cp ${pkgs.sysvinit}/sbin/halt $out/bin
|
||||||
|
|
||||||
|
# Run patchelf to make the programs refer to the copied libraries.
|
||||||
|
for i in $out/bin/* $out/lib/*; do if ! test -L $i; then nuke-refs $i; fi; done
|
||||||
|
|
||||||
|
for i in $out/bin/*; do
|
||||||
|
echo "patching $i..."
|
||||||
|
patchelf --set-interpreter $out/lib/ld-linux*.so.? --set-rpath $out/lib $i || true
|
||||||
|
done
|
||||||
|
''; # */
|
||||||
|
|
||||||
|
|
||||||
createDeviceNodes = dev:
|
createDeviceNodes = dev:
|
||||||
''
|
''
|
||||||
mknod ${dev}/null c 1 3
|
mknod ${dev}/null c 1 3
|
||||||
|
@ -46,10 +71,10 @@ rec {
|
||||||
|
|
||||||
|
|
||||||
stage1Init = writeScript "vm-run-stage1" ''
|
stage1Init = writeScript "vm-run-stage1" ''
|
||||||
#! ${klibcShrunk}/bin/sh.shared -e
|
#! ${initrdUtils}/bin/bash -e
|
||||||
echo START
|
echo START
|
||||||
|
|
||||||
export PATH=${klibcShrunk}/bin:${mountCifs}/bin
|
export PATH=${initrdUtils}/bin
|
||||||
|
|
||||||
mkdir /etc
|
mkdir /etc
|
||||||
echo -n > /etc/fstab
|
echo -n > /etc/fstab
|
||||||
|
@ -84,14 +109,14 @@ rec {
|
||||||
args="CIFSMaxBufSize=4194304"
|
args="CIFSMaxBufSize=4194304"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
echo "loading module $i with args $args"
|
echo "loading module $(basename $i .ko)"
|
||||||
insmod $i $args
|
insmod $i $args
|
||||||
done
|
done
|
||||||
|
|
||||||
mount -t tmpfs none /dev
|
mount -t tmpfs none /dev
|
||||||
${createDeviceNodes "/dev"}
|
${createDeviceNodes "/dev"}
|
||||||
|
|
||||||
ipconfig 10.0.2.15:::::eth0:none
|
ifconfig eth0 up 10.0.2.15
|
||||||
|
|
||||||
mkdir /fs
|
mkdir /fs
|
||||||
|
|
||||||
|
@ -109,7 +134,7 @@ rec {
|
||||||
n=.
|
n=.
|
||||||
echo "mounting host filesystem..."
|
echo "mounting host filesystem..."
|
||||||
while true; do
|
while true; do
|
||||||
if mount.cifs //10.0.2.4/qemu /fs/hostfs -o guest,username=nobody; then
|
if mount -t cifs //10.0.2.4/qemu /fs/hostfs -o guest,username=nobody; then
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
n=".$n"
|
n=".$n"
|
||||||
|
@ -144,7 +169,7 @@ rec {
|
||||||
mount -o remount,ro dummy /fs
|
mount -o remount,ro dummy /fs
|
||||||
|
|
||||||
echo DONE
|
echo DONE
|
||||||
reboot
|
halt -d -p -f
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
||||||
|
@ -247,7 +272,7 @@ rec {
|
||||||
createRootFS = ''
|
createRootFS = ''
|
||||||
mkdir /mnt
|
mkdir /mnt
|
||||||
${e2fsprogs}/sbin/mke2fs -F /dev/vda
|
${e2fsprogs}/sbin/mke2fs -F /dev/vda
|
||||||
${klibcShrunk}/bin/mount -t ext2 /dev/vda /mnt
|
${utillinux}/bin/mount -t ext2 /dev/vda /mnt
|
||||||
|
|
||||||
if test -e /mnt/.debug; then
|
if test -e /mnt/.debug; then
|
||||||
exec ${bash}/bin/sh
|
exec ${bash}/bin/sh
|
||||||
|
@ -403,7 +428,7 @@ rec {
|
||||||
|
|
||||||
# Make the Nix store available in /mnt, because that's where the RPMs live.
|
# Make the Nix store available in /mnt, because that's where the RPMs live.
|
||||||
mkdir -p /mnt/nix/store
|
mkdir -p /mnt/nix/store
|
||||||
${klibcShrunk}/bin/mount -o bind /nix/store /mnt/nix/store
|
${utillinux}/bin/mount -o bind /nix/store /mnt/nix/store
|
||||||
|
|
||||||
echo "installing RPMs..."
|
echo "installing RPMs..."
|
||||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
PATH=/usr/bin:/bin:/usr/sbin:/sbin $chroot /mnt \
|
||||||
|
@ -414,8 +439,8 @@ rec {
|
||||||
|
|
||||||
rm /mnt/.debug
|
rm /mnt/.debug
|
||||||
|
|
||||||
${klibcShrunk}/bin/umount /mnt/nix/store
|
${utillinux}/bin/umount /mnt/nix/store
|
||||||
${klibcShrunk}/bin/umount /mnt
|
${utillinux}/bin/umount /mnt
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {inherit fullName;};
|
passthru = {inherit fullName;};
|
||||||
|
@ -543,9 +568,9 @@ rec {
|
||||||
|
|
||||||
# Make the Nix store available in /mnt, because that's where the .debs live.
|
# Make the Nix store available in /mnt, because that's where the .debs live.
|
||||||
mkdir -p /mnt/inst/nix/store
|
mkdir -p /mnt/inst/nix/store
|
||||||
${klibcShrunk}/bin/mount -o bind /nix/store /mnt/inst/nix/store
|
${utillinux}/bin/mount -o bind /nix/store /mnt/inst/nix/store
|
||||||
${klibcShrunk}/bin/mount -o bind /proc /mnt/proc
|
${utillinux}/bin/mount -o bind /proc /mnt/proc
|
||||||
${klibcShrunk}/bin/mount -o bind /dev /mnt/dev
|
${utillinux}/bin/mount -o bind /dev /mnt/dev
|
||||||
|
|
||||||
# Misc. files/directories assumed by various packages.
|
# Misc. files/directories assumed by various packages.
|
||||||
echo "initialising Dpkg DB..."
|
echo "initialising Dpkg DB..."
|
||||||
|
@ -582,10 +607,10 @@ rec {
|
||||||
|
|
||||||
rm /mnt/.debug
|
rm /mnt/.debug
|
||||||
|
|
||||||
${klibcShrunk}/bin/umount /mnt/inst/nix/store
|
${utillinux}/bin/umount /mnt/inst/nix/store
|
||||||
${klibcShrunk}/bin/umount /mnt/proc
|
${utillinux}/bin/umount /mnt/proc
|
||||||
${klibcShrunk}/bin/umount /mnt/dev
|
${utillinux}/bin/umount /mnt/dev
|
||||||
${klibcShrunk}/bin/umount /mnt
|
${utillinux}/bin/umount /mnt
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {inherit fullName;};
|
passthru = {inherit fullName;};
|
||||||
|
|
|
@ -14,7 +14,7 @@ rec {
|
||||||
buildPatchelfRPM = buildRPM {
|
buildPatchelfRPM = buildRPM {
|
||||||
name = "patchelf-rpm";
|
name = "patchelf-rpm";
|
||||||
src = patchelf.src;
|
src = patchelf.src;
|
||||||
diskImage = diskImages.fedora8i386;
|
diskImage = diskImages.fedora12i386;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
{stdenv, fetchurl, perl, bison, mktemp, linuxHeaders}:
|
|
||||||
|
|
||||||
assert stdenv.isLinux;
|
|
||||||
|
|
||||||
let version = "1.5"; in
|
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
|
||||||
name = "klibc-${version}";
|
|
||||||
|
|
||||||
src = fetchurl {
|
|
||||||
url = "mirror://kernel/linux/libs/klibc/klibc-${version}.tar.bz2";
|
|
||||||
sha256 = "1izhf8kscjymsvsvhcqw9awnmp94vwv70zdj09srg9bkpjj0n017";
|
|
||||||
};
|
|
||||||
|
|
||||||
makeFlags = ["V=1" "prefix=$out" "SHLIBDIR=$out/lib"];
|
|
||||||
|
|
||||||
preBuild = ''
|
|
||||||
makeFlags=$(eval "echo $makeFlags")
|
|
||||||
|
|
||||||
mkdir linux
|
|
||||||
cp -prsd ${linuxHeaders}/include linux/
|
|
||||||
chmod -R u+w linux/include/
|
|
||||||
''; # */
|
|
||||||
|
|
||||||
# Install static binaries as well.
|
|
||||||
postInstall = ''
|
|
||||||
dir=$out/lib/klibc/bin.static
|
|
||||||
mkdir $dir
|
|
||||||
cp $(find $(find . -name static) -type f ! -name "*.g" -a ! -name ".*") $dir/
|
|
||||||
cp usr/dash/sh $dir/
|
|
||||||
'';
|
|
||||||
|
|
||||||
buildInputs = [perl bison mktemp];
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
source $stdenv/setup
|
|
||||||
|
|
||||||
preBuild() {
|
|
||||||
mkdir -p linux/include
|
|
||||||
cp -prd $kernel/lib/modules/*/build/include/* linux/include/
|
|
||||||
chmod -R u+w linux/include/
|
|
||||||
}
|
|
||||||
|
|
||||||
makeFlagsArray=(V=1 prefix=$out SHLIBDIR=$out/lib)
|
|
||||||
|
|
||||||
genericBuild
|
|
|
@ -6574,13 +6574,6 @@ let
|
||||||
linuxHeaders = glibc.kernelHeaders;
|
linuxHeaders = glibc.kernelHeaders;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Old version; needed in vmtools for insmod. Should use
|
|
||||||
# module_init_tools instead.
|
|
||||||
klibc_15 = makeOverridable (import ../os-specific/linux/klibc/1.5.nix) {
|
|
||||||
inherit fetchurl stdenv perl bison mktemp;
|
|
||||||
linuxHeaders = glibc.kernelHeaders;
|
|
||||||
};
|
|
||||||
|
|
||||||
klibcShrunk = makeOverridable (import ../os-specific/linux/klibc/shrunk.nix) {
|
klibcShrunk = makeOverridable (import ../os-specific/linux/klibc/shrunk.nix) {
|
||||||
inherit stdenv klibc;
|
inherit stdenv klibc;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue