about summary refs log tree commit diff
path: root/pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh')
-rw-r--r--pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh43
1 files changed, 43 insertions, 0 deletions
diff --git a/pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh b/pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh
new file mode 100644
index 000000000000..f2c96dfe30d0
--- /dev/null
+++ b/pkgs/build-support/vm/rpm/fill-disk-with-rpms.sh
@@ -0,0 +1,43 @@
+source $stdenv/setup
+
+size=$(($size * 1024 * 1024))
+
+image=$out/image
+ensureDir $out
+
+echo "building image \`$fullName'"
+echo "$name" > $out/name
+echo "$fullName" > $out/full-name
+
+echo "creating sparse file of $size bytes in $image..."
+dd if=/dev/zero of=$image bs=1 seek=$((size - 1)) count=1
+
+echo "creating e2fs file system in $image..."
+$e2fsprogs/sbin/mke2fs -F $image
+
+echo "initialising file system through UML..."
+echo $PATH > path
+echo $rpm > rpm
+echo $sysvinit > sysvinit
+echo $rpms > rpms
+echo $postInstall > post-install
+ln -s $worker $NIX_BUILD_TOP/worker # work around a stupid bug (no dots allowed in kernel arguments?)
+
+# UML requires an existing $HOME.
+mkdir dummy
+export HOME=$(pwd)/dummy
+
+# Run UML.
+touch log
+tail -n +0 -f log & # show UML output as it appears
+tailPid=$!
+
+linux ubd0=$image root=/dev/root rootflags=/ rootfstype=hostfs \
+  init="$SHELL $NIX_BUILD_TOP/worker $NIX_BUILD_TOP" con=null || true
+  
+echo image is $image
+
+sleep 1 # drain `tail', hacky
+kill $!
+
+if ! test -e success; then exit 1; fi