target: Don't symlink outside of /var

We will want to share /var with petitboot plugins, but most of the
directories in /var are actually symlinks to outside of var (to /tmp).

This change replaces the symlinks with actual directories. Since we're
running in an initramfs, we don't need to put everything in /tmp.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
diff --git a/openpower/configs/firestone_defconfig b/openpower/configs/firestone_defconfig
index f9f333d..3324aef 100644
--- a/openpower/configs/firestone_defconfig
+++ b/openpower/configs/firestone_defconfig
@@ -41,6 +41,7 @@
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
 BR2_ROOTFS_OVERLAY="../openpower/overlay"
 BR2_ROOTFS_DEVICE_TABLE="../openpower/device_table.txt"
+BR2_ROOTFS_POST_BUILD_SCRIPT="../openpower/scripts/fixup-target-var"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_VERSION="4.2"
 BR2_KERNEL_HEADERS_4_2=y
diff --git a/openpower/configs/garrison_defconfig b/openpower/configs/garrison_defconfig
index 42ed4d4..1a827ab 100644
--- a/openpower/configs/garrison_defconfig
+++ b/openpower/configs/garrison_defconfig
@@ -39,6 +39,7 @@
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
 BR2_ROOTFS_OVERLAY="../openpower/overlay"
 BR2_ROOTFS_DEVICE_TABLE="../openpower/device_table.txt"
+BR2_ROOTFS_POST_BUILD_SCRIPT="../openpower/scripts/fixup-target-var"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_VERSION="4.2"
 BR2_KERNEL_HEADERS_4_2=y
diff --git a/openpower/configs/habanero_defconfig b/openpower/configs/habanero_defconfig
index 9f05ea7..5c8169a 100644
--- a/openpower/configs/habanero_defconfig
+++ b/openpower/configs/habanero_defconfig
@@ -41,6 +41,7 @@
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
 BR2_ROOTFS_OVERLAY="../openpower/overlay"
 BR2_ROOTFS_DEVICE_TABLE="../openpower/device_table.txt"
+BR2_ROOTFS_POST_BUILD_SCRIPT="../openpower/scripts/fixup-target-var"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_VERSION="4.2"
 BR2_KERNEL_HEADERS_4_2=y
diff --git a/openpower/configs/openpower_mambo_defconfig b/openpower/configs/openpower_mambo_defconfig
index b921130..fef2c26 100644
--- a/openpower/configs/openpower_mambo_defconfig
+++ b/openpower/configs/openpower_mambo_defconfig
@@ -29,6 +29,7 @@
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
 BR2_ROOTFS_OVERLAY="../openpower/overlay"
 BR2_ROOTFS_DEVICE_TABLE="../openpower/device_table.txt"
+BR2_ROOTFS_POST_BUILD_SCRIPT="../openpower/scripts/fixup-target-var"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_VERSION="4.2"
 BR2_KERNEL_HEADERS_4_2=y
diff --git a/openpower/configs/palmetto_defconfig b/openpower/configs/palmetto_defconfig
index 8f5c108..69e66d7 100644
--- a/openpower/configs/palmetto_defconfig
+++ b/openpower/configs/palmetto_defconfig
@@ -40,6 +40,7 @@
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
 BR2_ROOTFS_OVERLAY="../openpower/overlay"
 BR2_ROOTFS_DEVICE_TABLE="../openpower/device_table.txt"
+BR2_ROOTFS_POST_BUILD_SCRIPT="../openpower/scripts/fixup-target-var"
 BR2_LINUX_KERNEL=y
 BR2_LINUX_KERNEL_VERSION="4.2"
 BR2_KERNEL_HEADERS_4_2=y
diff --git a/openpower/scripts/fixup-target-var b/openpower/scripts/fixup-target-var
new file mode 100755
index 0000000..171b916
--- /dev/null
+++ b/openpower/scripts/fixup-target-var
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# replace /var/* symlinks with actual directories
+
+find $TARGET_DIR/var/ -type l |
+while read path
+do
+    target=$(realpath $path)
+    [ -d "$target" ] || continue
+    rm $path
+    mkdir $path
+done