summaryrefslogtreecommitdiff
path: root/recipes/unionfs
diff options
context:
space:
mode:
authorDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
committerDenys Dmytriyenko <denis@denix.org>2009-03-17 14:32:59 -0400
commit709c4d66e0b107ca606941b988bad717c0b45d9b (patch)
tree37ee08b1eb308f3b2b6426d5793545c38396b838 /recipes/unionfs
parentfa6cd5a3b993f16c27de4ff82b42684516d433ba (diff)
rename packages/ to recipes/ per earlier agreement
See links below for more details: http://thread.gmane.org/gmane.comp.handhelds.openembedded/21326 http://thread.gmane.org/gmane.comp.handhelds.openembedded/21816 Signed-off-by: Denys Dmytriyenko <denis@denix.org> Acked-by: Mike Westerhof <mwester@dls.net> Acked-by: Philip Balister <philip@balister.org> Acked-by: Khem Raj <raj.khem@gmail.com> Acked-by: Marcin Juszkiewicz <hrw@openembedded.org> Acked-by: Koen Kooi <koen@openembedded.org> Acked-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
Diffstat (limited to 'recipes/unionfs')
-rw-r--r--recipes/unionfs/files/gcc2-hack.patch28
-rw-r--r--recipes/unionfs/unionfs-1.0.11/make.patch112
-rw-r--r--recipes/unionfs/unionfs-1.0.13/make.patch16
-rw-r--r--recipes/unionfs/unionfs-modules.inc38
-rw-r--r--recipes/unionfs/unionfs-modules_1.0.11.bb4
-rw-r--r--recipes/unionfs/unionfs-modules_1.0.13.bb11
-rw-r--r--recipes/unionfs/unionfs-utils.inc23
-rw-r--r--recipes/unionfs/unionfs-utils_1.0.11.bb2
-rw-r--r--recipes/unionfs/unionfs-utils_1.0.13.bb2
-rw-r--r--recipes/unionfs/unionfs.inc12
-rwxr-xr-xrecipes/unionfs/unionroot-utils/mount.unionroot99
-rwxr-xr-xrecipes/unionfs/unionroot-utils/umount.unionroot86
-rw-r--r--recipes/unionfs/unionroot-utils_0.1.1.bb42
-rwxr-xr-xrecipes/unionfs/unionroot/init.unionroot25
-rwxr-xr-xrecipes/unionfs/unionroot/init.unionroot.old90
-rw-r--r--recipes/unionfs/unionroot_0.1.1.bb37
16 files changed, 627 insertions, 0 deletions
diff --git a/recipes/unionfs/files/gcc2-hack.patch b/recipes/unionfs/files/gcc2-hack.patch
new file mode 100644
index 0000000000..7c1f4dd32e
--- /dev/null
+++ b/recipes/unionfs/files/gcc2-hack.patch
@@ -0,0 +1,28 @@
+
+#
+# Patch managed by http://www.mn-logistik.de/unsupported/pxa250/patcher
+#
+
+--- unionfs-1.0.3/fist.h~gcc2 2004-11-10 09:38:58.000000000 -0500
++++ unionfs-1.0.3/fist.h 2004-11-14 05:11:47.601022344 -0500
+@@ -212,11 +212,20 @@
+ } while (0)
+
+ /* Call if you encounter a bug. */
++
++#if __GNUC__ < 3
++#define FISTBUG(arg...) \
++do { \
++ printk("<0>FISTBUG " ##arg); \
++ (*((char *)0))=0; \
++} while (0)
++#else
+ #define FISTBUG(fmt, args...) \
+ do { \
+ printk("<0>FISTBUG at %s:%s:%d " fmt, __FILE__, __FUNCTION__, __LINE__, ##args); \
+ (*((char *)0))=0; \
+ } while (0);
++#endif
+
+ /* The if (0 ...) is so that we can make sure that you don't pass this
+ * define a non-pointer. gcc should optimize it away. */
diff --git a/recipes/unionfs/unionfs-1.0.11/make.patch b/recipes/unionfs/unionfs-1.0.11/make.patch
new file mode 100644
index 0000000000..4fb2755089
--- /dev/null
+++ b/recipes/unionfs/unionfs-1.0.11/make.patch
@@ -0,0 +1,112 @@
+
+#
+# Patch managed by http://www.holgerschurig.de/patcher.html
+#
+
+Index: unionfs-1.0.11/Makefile
+===================================================================
+--- unionfs-1.0.11.orig/Makefile 2005-03-23 22:25:47.000000000 -0500
++++ unionfs-1.0.11/Makefile 2005-03-24 20:27:27.386361872 -0500
+@@ -3,14 +3,20 @@
+ #
+
+ # this should point to where your kernel headers are
+-KVERS=$(shell uname -r)
++KVERS:=$(shell uname -r)
+ MODDIR= /lib/modules/$(KVERS)
+ LINUXSRC = /lib/modules/$(KVERS)/build
+ TOPINC = -I${LINUXSRC}/include
+ # This is where the make install target will put stuff
+-PREFIX = /usr/local
++DESTDIR =
++prefix = /usr/local
+ MANDIR = ${PREFIX}/man
+-MODPREFIX=
++sbindir = ${prefix}/sbin
++mandir = ${prefix}/man
++man4dir = ${mandir}/man4
++man8dir = ${mandir}/man8
++moduledir = /lib/modules/${KERNELVER}
++
+ VERSION = 1.0.11
+ TAROPTS = czvf
+ COMPEXT = .gz
+@@ -29,6 +35,7 @@
+ endif
+
+ CC = gcc
++LD = ld
+ KERNELVERSION=$(shell echo $(KVERS) | cut -d. -f1,2)
+ ifeq ($(KERNELVERSION),2.4)
+ CFLAGS = -D__KERNEL__ -DMODULE -I. ${TOPINC} -Wall -Wno-unused-label -Werror -fno-strict-aliasing ${EXTRACFLAGS} ${UNIONFS_DEBUG_CFLAG} ${UNIONFS_OPT_CFLAG}
+@@ -51,13 +58,15 @@
+ @echo "******************************************************************************"
+ @echo ""
+
+-unionfs2.6:
++unionfs2.6: unionfs.ko
++
++unionfs.ko:
+ make -C ${LINUXSRC} SUBDIRS=$(PWD) FISTDEVMK=$(PWD)/fistdev.mk modules
+
+ unionfs2.4: ${obj-m}
+
+ ${obj-m}: ${unionfs-objs}
+- ld -o ${obj-m} -r ${unionfs-objs}
++ ${LD} -o ${obj-m} -r ${unionfs-objs}
+
+ unionctl: unionctl.c
+ ${CC} -o $@ $? ${UCFLAGS}
+@@ -88,28 +97,37 @@
+ utils: ${BINS}
+
+ install-utils: utils
+- mkdir -p ${PREFIX}/sbin
+- cp unionctl ${PREFIX}/sbin
+- cp uniondbg ${PREFIX}/sbin
+- mkdir -p ${MANDIR}/man4
+- mkdir -p ${MANDIR}/man8
+- cp man/unionfs.4 ${MANDIR}/man4
+- cp man/unionctl.8 ${MANDIR}/man8
+- cp man/uniondbg.8 ${MANDIR}/man8
++ mkdir -p ${DESTDIR}${sbindir}
++ cp unionctl ${DESTDIR}${sbindir}
++ cp uniondbg ${DESTDIR}${sbindir}
++ mkdir -p ${DESTDIR}${man4dir}
++ mkdir -p ${DESTDIR}${man8dir}
++ cp man/unionfs.4 ${DESTDIR}${man4dir}
++ cp man/unionctl.8 ${DESTDIR}${man8dir}
++ cp man/uniondbg.8 ${DESTDIR}${man8dir}
+
+ install-mod: unionfs$(KERNELVERSION)
+ mkdir -p ${MODPREFIX}/${MODDIR}/kernel/fs
+- if [ -f unionfs.ko ] ; then cp unionfs.ko ${MODPREFIX}/${MODDIR}/kernel/fs ; else cp unionfs.o ${MODPREFIX}/${MODDIR}/kernel/fs ; fi
++ mkdir -p ${DESTDIR}${moduledir}/kernel/fs
++ifeq (${KERNELVERSION},2.4)
++ cp unionfs.o ${DESTDIR}${moduledir}/kernel/fs
++else
++ cp unionfs.ko ${DESTDIR}${moduledir}/kernel/fs
++endif
+
+ install: install-utils install-mod
+
+ uninstall:
+- if [ -f unionfs.ko ] ; then rm ${MODPREFIX}/${MODDIR}/kernel/fs/unionfs.ko ; else rm ${MODPREFIX}/${MODDIR}/kernel/fs/unionfs.o ; fi
+- rm ${MANDIR}/man8/unionctl.8
+- rm ${MANDIR}/man8/uniondbg.8
+- rm ${MANDIR}/man4/unionfs.4
+- rm ${PREFIX}/sbin/unionctl
+- rm ${PREFIX}/sbin/uniondbg
++ifeq (${KERNELVERSION},2.4)
++ rm ${MODPREFIX}${DESTDIR}${moduledir}/kernel/fs/unionfs.o
++else
++ rm ${MODPREFIX}${DESTDIR}${moduledir}/kernel/fs/unionfs.ko
++endif
++ rm ${DESTDIR}${man8dir}/unionctl.8
++ rm ${DESTDIR}${man8dir}/uniondbg.8
++ rm ${DESTDIR}${man4dir}/unionfs.4
++ rm ${DESTDIR}${sbindir}/unionctl
++ rm ${DESTDIR}${sbindir}/uniondbg
+
+ release: unionfs-${VERSION}.tar${COMPEXT}
+
diff --git a/recipes/unionfs/unionfs-1.0.13/make.patch b/recipes/unionfs/unionfs-1.0.13/make.patch
new file mode 100644
index 0000000000..e2ab28b429
--- /dev/null
+++ b/recipes/unionfs/unionfs-1.0.13/make.patch
@@ -0,0 +1,16 @@
+
+#
+# Patch managed by http://www.holgerschurig.de/patcher.html
+#
+
+--- unionfs-1.0.13/Makefile~make
++++ unionfs-1.0.13/Makefile
+@@ -59,7 +59,7 @@
+ unionfs2.4: ${obj-m}
+
+ ${obj-m}: ${unionfs-objs}
+- ld -o ${obj-m} -r ${unionfs-objs}
++ ${CC} -o ${obj-m} -r ${unionfs-objs}
+
+ unionctl: unionctl.c usercommon.c
+ ${CC} -o $@ $^ ${UCFLAGS}
diff --git a/recipes/unionfs/unionfs-modules.inc b/recipes/unionfs/unionfs-modules.inc
new file mode 100644
index 0000000000..5e87288e48
--- /dev/null
+++ b/recipes/unionfs/unionfs-modules.inc
@@ -0,0 +1,38 @@
+unionutils = "unionctl uniondbg"
+
+include unionfs.inc
+inherit module
+
+SECTION = "kernel/modules"
+
+EXTRA_OEMAKE = "'CC=${KERNEL_CC}' 'LD=${KERNEL_LD}' \
+ 'KERNELVER=${KERNEL_VERSION}' \
+ 'LINUXSRC=${STAGING_KERNEL_DIR}' \
+ 'CROSS_COMPILE=${TARGET_PREFIX}' \
+ 'OS=${TARGET_OS}' \
+ ${@get_flags(d, bb)}"
+
+KCFLAGS = "-D__KERNEL__ -DMODULE -DFISTGEN \
+ -DUNIONFS_UNSUPPORTED -DNODEBUG \
+ -I. -I${STAGING_KERNEL_DIR}/include \
+ -DUNIONFS_VERSION=\"${PV}\" \
+ ${CFLAGS}"
+
+def get_flags(d, bb):
+ ret = ""
+ if bb.data.getVar('KERNEL_OBJECT_SUFFIX', d, 1) == '.ko':
+ return "'EXTRA_CFLAGS=%s'" % bb.data.getVar('KCFLAGS', d, 1)
+ return "'CFLAGS=%s'" % bb.data.getVar('KCFLAGS', d, 1)
+
+do_compile () {
+ unset LDFLAGS
+ oe_runmake unionfs${KERNEL_OBJECT_SUFFIX}
+}
+
+do_install () {
+ install -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/fs
+ install -m 0644 unionfs${KERNEL_OBJECT_SUFFIX} ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/fs/
+
+ install -d ${D}${mandir}/man4
+ install -m 0644 man/unionfs.4 ${D}${mandir}/man4/
+}
diff --git a/recipes/unionfs/unionfs-modules_1.0.11.bb b/recipes/unionfs/unionfs-modules_1.0.11.bb
new file mode 100644
index 0000000000..c9ca1d130d
--- /dev/null
+++ b/recipes/unionfs/unionfs-modules_1.0.11.bb
@@ -0,0 +1,4 @@
+require unionfs-modules.inc
+require unionfs.inc
+
+SRC_URI += "file://make.patch;patch=1"
diff --git a/recipes/unionfs/unionfs-modules_1.0.13.bb b/recipes/unionfs/unionfs-modules_1.0.13.bb
new file mode 100644
index 0000000000..6a7d880720
--- /dev/null
+++ b/recipes/unionfs/unionfs-modules_1.0.13.bb
@@ -0,0 +1,11 @@
+PR = "r1"
+PARALLEL_MAKE = ""
+
+require unionfs-modules.inc
+
+KERNEL_MAJMIN = "${@base_read_file('${STAGING_KERNEL_DIR}/kernel-abiversion')[:3]}"
+
+do_compile() {
+ unset LDFLAGS
+ oe_runmake unionfs${KERNEL_MAJMIN}
+}
diff --git a/recipes/unionfs/unionfs-utils.inc b/recipes/unionfs/unionfs-utils.inc
new file mode 100644
index 0000000000..6620e91613
--- /dev/null
+++ b/recipes/unionfs/unionfs-utils.inc
@@ -0,0 +1,23 @@
+unionutils = "unionctl uniondbg"
+
+include unionfs.inc
+
+SECTION = "kernel/userland"
+
+do_compile () {
+ oe_runmake ${unionutils}
+}
+
+do_install () {
+ install -d ${D}${sbindir}
+ install -m 0755 ${unionutils} ${D}${sbindir}/
+
+ install -d ${D}${mandir}/man8
+ for m in ${unionutils}; do
+ install -m 0644 man/$m.8 ${D}${mandir}/man8/ || exit 1
+ done
+}
+
+FILES_${PN} = "${sbindir}/unionctl"
+FILES_${PN}-dev = "${sbindir}/uniondbg"
+
diff --git a/recipes/unionfs/unionfs-utils_1.0.11.bb b/recipes/unionfs/unionfs-utils_1.0.11.bb
new file mode 100644
index 0000000000..6bea01a892
--- /dev/null
+++ b/recipes/unionfs/unionfs-utils_1.0.11.bb
@@ -0,0 +1,2 @@
+require unionfs-utils.inc
+require unionfs.inc
diff --git a/recipes/unionfs/unionfs-utils_1.0.13.bb b/recipes/unionfs/unionfs-utils_1.0.13.bb
new file mode 100644
index 0000000000..f22be6c391
--- /dev/null
+++ b/recipes/unionfs/unionfs-utils_1.0.13.bb
@@ -0,0 +1,2 @@
+require unionfs-utils.inc
+
diff --git a/recipes/unionfs/unionfs.inc b/recipes/unionfs/unionfs.inc
new file mode 100644
index 0000000000..e336fd3e07
--- /dev/null
+++ b/recipes/unionfs/unionfs.inc
@@ -0,0 +1,12 @@
+DESCRIPTION = "A stackable unification file system, which can appear to \
+merge the contents of several directories (branches), while keeping their \
+physical content separate."
+HOMEPAGE = "http://www.fsl.cs.sunysb.edu/project-unionfs.html"
+LICENSE = "GPL"
+
+SRC_URI = "ftp://ftp.fsl.cs.sunysb.edu/pub/unionfs/OLD/unionfs-1.x/unionfs-${PV}.tar.gz"
+S = "${WORKDIR}/unionfs-${PV}"
+FILESPATH = "${FILE_DIRNAME}/unionfs-${PV}:${FILE_DIRNAME}/unionfs:${FILE_DIRNAME}/files:${FILE_DIRNAME}"
+
+export UCFLAGS = '${CFLAGS} -DNODEBUG -DUNIONFS_VERSION=\\"${PV}\\"'
+CFLAGS = "${BUILD_OPTIMIZATION}"
diff --git a/recipes/unionfs/unionroot-utils/mount.unionroot b/recipes/unionfs/unionroot-utils/mount.unionroot
new file mode 100755
index 0000000000..ac0f9a08f1
--- /dev/null
+++ b/recipes/unionfs/unionroot-utils/mount.unionroot
@@ -0,0 +1,99 @@
+#!/bin/sh
+
+#set -x
+
+ROOTMOUNTPT=/media/realroot
+REALMOUNT=/bin/mount.busybox
+UNIONMOUNT=$0
+INCDIRS="^/media/\|^/mnt/"
+DEVICE="\/dev\/"
+
+newargs=""
+
+ONESHIFTARGS='aVhvfFilnsrw'
+TWOSHIFTARGS="pLUtOo"
+IGNOREARGS='--bind --move'
+
+resolvelink () {
+ if test -h $1; then
+ echo `readlink $1`
+ else
+ echo $1
+ fi
+}
+
+# Retrieves arguments/mount-point
+for var in $@; do
+ if [ -z "$SKIP" ]; then
+ if echo $var | grep -q "^-.*"; then
+ # argument is an option
+ if echo $var | grep -q "[$TWOSHIFTARGS]"; then
+ SKIP="yes"
+ fi
+ # mount -a
+ if echo $var | grep -q "^-[^- ]*a"; then
+ DO_FSTAB="yes"
+ fi
+ ARGS="$ARGS $var"
+ else
+ if [ -z "$MOUNT_POINT" ]; then
+ # argument apears to be the mountpoint
+ MOUNT_POINT=$var
+ else
+ # A mountpoint was found earlier, so the other non-option
+ # must be the real mountpoint, and the first non-option is a device
+ DEV_PATH="$MOUNT_POINT"
+ MOUNT_POINT="$var"
+ fi
+ fi
+ else
+ ARGS="$ARGS $var"
+ unset SKIP
+ fi
+done
+
+# Parse fstab if -a is used
+if ! [ -z "$DO_FSTAB" ]; then
+ # FIXME: This doesn't handle -t or -O
+ awk '/^[^ #]/ {print "-t " $3 " -o " $4 " " $1 " " $2}' /etc/fstab |
+ while read line; do
+ ${UNIONMOUNT} $line
+ done
+ exit 0
+fi
+
+# Get mount-point for device name, if device name is given
+if echo "$MOUNT_POINT" | grep -q "^${DEVICE}"; then
+ MOUNT_POINT_TEMP=`echo $MOUNT_POINT | sed -e "s/\//\\\\\\\\\//g"`
+ NEW_MOUNT_POINT=`awk "/$MOUNT_POINT_TEMP/ {print "'$2'"}" /etc/fstab`
+ if ! [ -z "$NEW_MOUNT_POINT" ]; then
+ MOUNT_POINT=$NEW_MOUNT_POINT
+ fi
+fi
+
+# Mount anything but /media/* and / with the real mount
+if ! (echo "$MOUNT_POINT" | grep -q "$INCDIRS" || [ "$MOUNT_POINT" = "/" ]); then
+ exec ${REALMOUNT} $@
+fi
+
+# Replace requests to mount '/' (from init scripts and such)
+# with mount ROOTMOUNTPT (the real-root mount point for the
+# unionfs'd system).
+packagedir=""
+if ([ "$MOUNT_POINT" = "/" ] || [ "$MOUNT_POINT" = "${ROOTMOUNTPT}" ]); then
+ MOUNT_POINT=${ROOTMOUNTPT}
+else
+ # FIXME: A hard-coded path is bad - see ipkg-link
+ PACKAGE_DIR="/packages"
+ x=a
+fi
+
+# Finally, mount and union-mount
+#echo "<<DEBUG>> Running command: [${REALMOUNT} $ARGS $DEV_PATH $MOUNT_POINT]"
+if ${REALMOUNT} $ARGS $DEV_PATH $MOUNT_POINT; then
+ if mkdir -p $MOUNT_POINT$PACKAGE_DIR; then
+ #echo "<<DEBUG>> Running command: [unionctl /. --add --after ${ROOTMOUNTPT} --mode rw `resolvelink $MOUNT_POINT`$PACKAGE_DIR]"
+ #unionctl /. --add --after ${ROOTMOUNTPT} --mode rw `resolvelink $MOUNT_POINT`$PACKAGE_DIR
+ unionctl /. --add `resolvelink $MOUNT_POINT`$PACKAGE_DIR
+ fi
+fi
diff --git a/recipes/unionfs/unionroot-utils/umount.unionroot b/recipes/unionfs/unionroot-utils/umount.unionroot
new file mode 100755
index 0000000000..df0eccb353
--- /dev/null
+++ b/recipes/unionfs/unionroot-utils/umount.unionroot
@@ -0,0 +1,86 @@
+#!/bin/sh
+
+#set -x
+
+ROOTMOUNTPT=/media/realroot
+REALUMOUNT=/bin/umount.busybox
+UNIONUMOUNT=$0
+INCDIRS="^/media/\|^/mnt/"
+DEVICE="\/dev\/"
+
+newargs=""
+
+ONESHIFTARGS='adflnrv'
+TWOSHIFTARGS="tO"
+
+resolvelink () {
+ if test -h $1; then
+ echo `readlink $1`
+ else
+ echo $1
+ fi
+}
+
+# Retrieves arguments/mount-point
+for var in $@; do
+ if [ -z "$SKIP" ]; then
+ if echo $var | grep -q "^-.*"; then
+ if echo $var | grep -q "[$TWOSHIFTARGS]"; then
+ SKIP="yes"
+ fi
+ if echo $var | grep -q "^-[^- ]*a"; then
+ DO_FSTAB="yes"
+ fi
+ ARGS="$ARGS $var"
+ else
+ if [ -z "$MOUNT_POINT" ]; then
+ MOUNT_POINT=$var
+ else
+ # This really shouldn't happen when unmounting
+ DEV_PATH="$MOUNT_POINT"
+ MOUNT_POINT="$var"
+ fi
+ fi
+ else
+ ARGS="$ARGS $var"
+ unset SKIP
+ fi
+done
+
+# Parse fstab if -a is used
+if ! [ -z "$DO_FSTAB" ]; then
+ # FIXME: This doesn't handle -t or -O
+ awk '/^[^ #]/ {print $1}' /etc/fstab |
+ while read line; do
+ ${UNIONUMOUNT} $line
+ done
+ exit 0
+fi
+
+# Get mount-point for device name, if device name is given
+if echo "$MOUNT_POINT" | grep -q "^${DEVICE}"; then
+ MOUNT_POINT_TEMP=`echo $MOUNT_POINT | sed -e "s/\//\\\\\\\\\//g"`
+ NEW_MOUNT_POINT=`awk "/$MOUNT_POINT_TEMP/ {print "'$2'"}" /etc/fstab`
+ if ! [ -z "$NEW_MOUNT_POINT" ]; then
+ MOUNT_POINT=$NEW_MOUNT_POINT
+ fi
+fi
+
+if ! (echo "$MOUNT_POINT" | grep -q "$INCDIRS"||[ "$MOUNT_POINT" = "/" ]); then
+ exec ${REALMOUNT} $@
+fi
+
+# Replace requests to mount '/' (from init scripts and such)
+# with mount ROOTMOUNTPT (the real-root mount point for the
+# unionfs'd system).
+packagedir=""
+if ([ "$MOUNT_POINT" = "/" ]||[ "$MOUNT_POINT" = "${ROOTMOUNTPT}" ]); then
+ MOUNT_POINT=${ROOTMOUNTPT}
+else
+ PACKAGE_DIR="/packages"
+fi
+
+# Finally, umount and union-umount
+unionctl /. --remove `resolvelink $MOUNT_POINT`$PACKAGE_DIR
+exec ${REALUMOUNT} $ARGS $MOUNT_POINT
+
diff --git a/recipes/unionfs/unionroot-utils_0.1.1.bb b/recipes/unionfs/unionroot-utils_0.1.1.bb
new file mode 100644
index 0000000000..0da9c9a731
--- /dev/null
+++ b/recipes/unionfs/unionroot-utils_0.1.1.bb
@@ -0,0 +1,42 @@
+LICENSE = "GPL"
+
+DESCRIPTION = "Tools for administering a system that utilises unionroot."
+DEPENDS = "ipkg-collateral unionroot busybox"
+RDEPENDS = "ipkg-collateral unionroot busybox"
+SECTION = "base"
+PRIORITY = "optional"
+
+PR = "2"
+
+SRC_URI = "file://mount.unionroot \
+ file://umount.unionroot"
+
+do_install () {
+ install -d ${D}${base_bindir}
+ install -m 0755 ${WORKDIR}/mount.unionroot ${D}${base_bindir}/
+ install -m 0755 ${WORKDIR}/umount.unionroot ${D}${base_bindir}/
+}
+
+pkg_postinst () {
+ update-alternatives --install /bin/mount mount /bin/mount.unionroot 100
+ update-alternatives --install /bin/umount umount /bin/umount.unionroot 100
+
+ # Alter /etc/ipkg.conf
+ mv $D/${sysconfdir}/ipkg.conf $D/${sysconfdir}/ipkg.conf.old
+ awk 'BEGIN { print "# Altered by unionroot" }
+ { if ( $3 == "/" )
+ {
+ print $1 " " $2 " /media/realroot"
+ }
+ else
+ {
+ print $0
+ }
+ }' $D/${sysconfdir}/ipkg.conf.old > $D/${sysconfdir}/ipkg.conf
+}
+
+pkg_prerm () {
+ update-alternatives --remove mount /bin/mount.unionroot
+ update-alternatives --remove umount /bin/umount.unionroot
+}
+
diff --git a/recipes/unionfs/unionroot/init.unionroot b/recipes/unionfs/unionroot/init.unionroot
new file mode 100755
index 0000000000..bfd86886a0
--- /dev/null
+++ b/recipes/unionfs/unionroot/init.unionroot
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+PATH=/usr/bin:/usr/sbin:/bin:/sbin
+INIT=/sbin/init.sysvinit
+ROOTBACKUP=/media/realroot
+UNION=/media/union
+
+if ! which unionctl; then
+ echo >&2 "ERROR: Package unionfs-utils not installed!"
+ exec ${INIT} $@
+fi
+
+# For shutdown
+if ! [ -z "$@" ]; then
+ exec ${INIT} $@
+fi
+
+mount.busybox /proc
+insmod /lib/modules/`uname -r`/kernel/fs/unionfs.o
+mount.busybox -t unionfs -o dirs=/.=rw,setattr=all none ${UNION}
+umount.busybox /proc
+
+cd ${UNION}
+pivot_root . ./${ROOTBACKUP}
+exec chroot . ${INIT}
diff --git a/recipes/unionfs/unionroot/init.unionroot.old b/recipes/unionfs/unionroot/init.unionroot.old
new file mode 100755
index 0000000000..7ac227eb38
--- /dev/null
+++ b/recipes/unionfs/unionroot/init.unionroot.old
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+INIT=/sbin/init.sysvinit
+#OVERLAYS=/media/ram /media/cf /media/card
+ROOTBACKUP=/media/realroot
+UNION=/media/union
+PATH=/usr/bin:/usr/sbin:/bin:/sbin
+
+if ! test -e ${INIT}; then
+ echo >&2 "ERROR: ${INIT} not found"
+ exit 1
+fi
+
+if test x"$*" != "x"; then
+ exec ${INIT} $*
+fi
+
+if ! which unionctl; then
+ exec ${INIT}
+fi
+
+nodupmount () {
+ opts=""
+ type=""
+ while true; do
+ if test "$1" = "-o"; then
+ shift
+ opts="-o $1"
+ shift
+ elif test "$1" = "-t"; then
+ shift
+ type="$1"
+ shift
+ else
+ break
+ fi
+ done
+ if test x"$2" = "x"; then
+ mountpt="$1"
+ else
+ device="$1"
+ mountpt="$2"
+ fi
+ mountmatch="^[^ ]+ $mountpt $type"
+ # echo "NOTE: grep -E -q \"$mountmatch\" /proc/mounts"
+ if grep -E -q "$mountmatch" /proc/mounts; then
+ return 0;
+ fi
+ if test x"$type" != "x"; then
+ type="-t $type"
+ fi
+ echo >&2 "NOTE: executing mount $type $opts $device $mountpt"
+ mkdir -p $mountpt
+ /bin/mount.busybox $type $opts $device $mountpt
+ ret="$?"
+ if test "$ret" = "0"; then
+ wemounted="$wemounted $mountpt"
+ fi
+ return $ret
+}
+
+#set -x
+wemounted=""
+(
+ set -e
+ /bin/mount.busybox /proc
+ insmod /lib/modules/`uname -r`/kernel/fs/unionfs.o
+ nodupmount -t unionfs -o dirs=/.=rw,setattr=all none ${UNION}
+# nodupmount -o bind / ${UNION}/${ROOTBACKUP}
+# for OVERLAY in ${OVERLAYS}; do
+# nodupmount ${OVERLAY}
+# union-ctl /. --add --mode rw ${OVERLAY}
+# nodupmount -o bind ${OVERLAY} ${UNION}/${OVERLAY}
+# done
+ /bin/umount.busybox /proc
+# nodupmount -o bind /proc ${UNION}/proc
+# nodupmount -o bind / ${ROOTBACKUP}
+) || (
+ echo >&2 "ERROR: unable to setup mounts for chroot";
+ if test x"$wemounted" != "x"; then
+ # cleanup
+ for mount in $wemounted; do
+ /bin/umount.busybox $mount
+ done
+ fi
+ exec ${INIT}
+)
+cd ${UNION}
+pivot_root . ./${ROOTBACKUP}
+exec chroot . ${INIT}
diff --git a/recipes/unionfs/unionroot_0.1.1.bb b/recipes/unionfs/unionroot_0.1.1.bb
new file mode 100644
index 0000000000..4047c2f3c7
--- /dev/null
+++ b/recipes/unionfs/unionroot_0.1.1.bb
@@ -0,0 +1,37 @@
+LICENSE = "GPL"
+
+DESCRIPTION = "Provides an init script that changes the root file-system to unionfs."
+DEPENDS = "busybox base-files"
+RDEPENDS = "busybox base-files"
+SECTION = "base"
+PRIORITY = "optional"
+
+SRC_URI = "file://init.unionroot"
+
+inherit update-alternatives
+
+ALTERNATIVE_NAME = "init"
+ALTERNATIVE_LINK = "/sbin/init"
+ALTERNATIVE_PATH = "/sbin/init.unionroot"
+ALTERNATIVE_PRIORITY = "100"
+
+do_install () {
+ install -d ${D}${base_sbindir}
+ install -m 0755 ${WORKDIR}/init.unionroot ${D}${base_sbindir}/
+}
+
+pkg_postinst () {
+ # Alter /etc/fstab
+ mv $D/${sysconfdir}/fstab $D/${sysconfdir}/fstab.old
+ awk 'BEGIN { print "# Altered by unionroot" }
+ { if ( $2 == "/" )
+ {
+ print $1 "\t/media/realroot\t" $3 "\t" $4 "\t" $5 "\t" $6
+ }
+ else
+ {
+ print $0
+ }
+ }' $D/${sysconfdir}/fstab.old > $D/${sysconfdir}/fstab
+}
+