Merge pull request #274 from jk-ozlabs/target-var

Updates to target filesystem for pb-plugin usage
diff --git a/README b/README
index 2e84fbb..81b1f6c 100644
--- a/README
+++ b/README
@@ -11,7 +11,7 @@
 1. Install Ubuntu 14.04 or Debian 7.5 64-bit.
 2. Install the packages necessary for the build:
 > sudo apt-get install cscope ctags libz-dev libexpat-dev \
-  python language-pack-en \
+  python language-pack-en texinfo \
   build-essential g++ git bison flex unzip \
   libxml-simple-perl libxml-sax-perl libxml2-dev libxml2-utils xsltproc
 3. Continue with the clone, environment setup, and build as noted above.
diff --git a/buildroot b/buildroot
index 3b9de68..d4eae63 160000
--- a/buildroot
+++ b/buildroot
@@ -1 +1 @@
-Subproject commit 3b9de683199998918af02d7a5102d5a11c834bd0
+Subproject commit d4eae63a40d6e621b47b9cffd5e936562a64a0e1
diff --git a/openpower/configs/firestone_defconfig b/openpower/configs/firestone_defconfig
index 7f9e791..3324aef 100644
--- a/openpower/configs/firestone_defconfig
+++ b/openpower/configs/firestone_defconfig
@@ -39,7 +39,9 @@
 BR2_GENERATE_LOCALE="en_US.UTF-8"
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_ROOTFS_OVERLAY="overlay"
+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 8bf7fca..6b70137 100644
--- a/openpower/configs/garrison_defconfig
+++ b/openpower/configs/garrison_defconfig
@@ -39,7 +39,9 @@
 BR2_GENERATE_LOCALE="en_US.UTF-8"
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_ROOTFS_OVERLAY="overlay"
+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 0d83ffa..5c8169a 100644
--- a/openpower/configs/habanero_defconfig
+++ b/openpower/configs/habanero_defconfig
@@ -39,7 +39,9 @@
 BR2_GENERATE_LOCALE="en_US.UTF-8"
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_ROOTFS_OVERLAY="overlay"
+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 24372b6..fef2c26 100644
--- a/openpower/configs/openpower_mambo_defconfig
+++ b/openpower/configs/openpower_mambo_defconfig
@@ -27,7 +27,9 @@
 BR2_GENERATE_LOCALE="en_US.UTF-8"
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_ROOTFS_OVERLAY="overlay"
+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 e2b1aed..69e66d7 100644
--- a/openpower/configs/palmetto_defconfig
+++ b/openpower/configs/palmetto_defconfig
@@ -38,7 +38,9 @@
 BR2_GENERATE_LOCALE="en_US.UTF-8"
 BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y
 BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_ROOTFS_OVERLAY="overlay"
+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/device_table.txt b/openpower/device_table.txt
new file mode 100644
index 0000000..450aab6
--- /dev/null
+++ b/openpower/device_table.txt
@@ -0,0 +1,23 @@
+# See package/makedevs/README for details
+#
+# This device table is used to assign proper ownership and permissions
+# on various files. It doesn't create any device file, as it is used
+# in both static device configurations (where /dev/ is static) and in
+# dynamic configurations (where devtmpfs, mdev or udev are used).
+#
+# <name>				<type>	<mode>	<uid>	<gid>	<major>	<minor>	<start>	<inc>	<count>
+/dev					d	755	0	0	-	-	-	-	-
+/etc					d	755	0	0	-	-	-	-	-
+/root					d	700	0	0	-	-	-	-	-
+/var/www				d	755	33	33	-	-	-	-	-
+/etc/random-seed			f	600	0	0	-	-	-	-	-
+/etc/shadow				f	600	0	0	-	-	-	-	-
+/etc/passwd				f	644	0	0	-	-	-	-	-
+/etc/network/if-up.d			d	755	0	0	-	-	-	-	-
+/etc/network/if-pre-up.d		d	755	0	0	-	-	-	-	-
+/etc/network/if-post-up.d		d	755	0	0	-	-	-	-	-
+/etc/network/if-down.d			d	755	0	0	-	-	-	-	-
+/etc/network/if-pre-down.d		d	755	0	0	-	-	-	-	-
+/etc/network/if-post-down.d		d	755	0	0	-	-	-	-	-
+# uncomment this to allow starting x as non-root
+#/usr/X11R6/bin/Xfbdev		     	f	4755	0	0	-	-	-	-	-
diff --git a/openpower/overlay/etc/fstab b/openpower/overlay/etc/fstab
new file mode 100644
index 0000000..d373dc6
--- /dev/null
+++ b/openpower/overlay/etc/fstab
@@ -0,0 +1,6 @@
+# <file system>	<mount pt>	<type>	<options>	<dump>	<pass>
+/dev/root	/		ext2	rw,noauto	0	1
+proc		/proc		proc	defaults	0	0
+devpts		/dev/pts	devpts	defaults,gid=5,mode=620	0	0
+tmpfs		/dev/shm	tmpfs	mode=0777	0	0
+sysfs		/sys		sysfs	defaults	0	0
diff --git a/openpower/overlay/etc/inittab b/openpower/overlay/etc/inittab
new file mode 100644
index 0000000..235c835
--- /dev/null
+++ b/openpower/overlay/etc/inittab
@@ -0,0 +1,34 @@
+# /etc/inittab
+#
+# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
+#
+# Note: BusyBox init doesn't support runlevels.  The runlevels field is
+# completely ignored by BusyBox init. If you want runlevels, use
+# sysvinit.
+#
+# Format for each entry: <id>:<runlevels>:<action>:<process>
+#
+# id        == tty to run on, or empty for /dev/console
+# runlevels == ignored
+# action    == one of sysinit, respawn, askfirst, wait, and once
+# process   == program to run
+
+# Startup the system
+null::sysinit:/bin/mount -t proc proc /proc
+null::sysinit:/bin/mount -o remount,rw / # REMOUNT_ROOTFS_RW
+null::sysinit:/bin/mkdir -p /dev/pts
+null::sysinit:/bin/mkdir -p /dev/shm
+null::sysinit:/bin/mount -a
+null::sysinit:/bin/hostname -F /etc/hostname
+# now run any rc scripts
+null::sysinit:/etc/init.d/rcS
+
+# Stuff to do for the 3-finger salute
+::ctrlaltdel:/sbin/reboot
+
+# Stuff to do before rebooting
+null::shutdown:/etc/init.d/rcK
+null::shutdown:/bin/umount -a -r
+null::shutdown:/sbin/swapoff -a
+
+null::restart:/usr/sbin/kexec-restart
diff --git a/openpower/overlay/etc/locale b/openpower/overlay/etc/locale
new file mode 100644
index 0000000..6556836
--- /dev/null
+++ b/openpower/overlay/etc/locale
@@ -0,0 +1 @@
+LANG=en_US.utf-8
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