From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-796904-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id B330D138C9D
	for <garchives@archives.gentoo.org>; Wed, 29 Apr 2015 19:04:14 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id B2EB0E084F;
	Wed, 29 Apr 2015 19:04:13 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 3F840E084F
	for <gentoo-commits@lists.gentoo.org>; Wed, 29 Apr 2015 19:04:13 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 3D801340C03
	for <gentoo-commits@lists.gentoo.org>; Wed, 29 Apr 2015 19:04:12 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id B99659AA
	for <gentoo-commits@lists.gentoo.org>; Wed, 29 Apr 2015 19:04:07 +0000 (UTC)
From: "Richard Farina" <zerochaos@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Richard Farina" <zerochaos@gentoo.org>
Message-ID: <1430328705.d8f76f80288f19c0d2d90e9c4999879ad0c61d1e.zerochaos@gentoo>
Subject: [gentoo-commits] proj/genkernel:aufs commit in: defaults/
X-VCS-Repository: proj/genkernel
X-VCS-Files: defaults/initrd.scripts defaults/linuxrc
X-VCS-Directories: defaults/
X-VCS-Committer: zerochaos
X-VCS-Committer-Name: Richard Farina
X-VCS-Revision: d8f76f80288f19c0d2d90e9c4999879ad0c61d1e
X-VCS-Branch: aufs
Date: Wed, 29 Apr 2015 19:04:07 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 6a371966-67fe-4fae-bed4-96703e314d85
X-Archives-Hash: 76632c9fcea85b8e1ef1c7eb87019db4

commit:     d8f76f80288f19c0d2d90e9c4999879ad0c61d1e
Author:     Fernando Reyes (likewhoa) <design <AT> missionaccomplish <DOT> com>
AuthorDate: Fri May 30 02:02:30 2014 +0000
Commit:     Richard Farina <zerochaos <AT> gentoo <DOT> org>
CommitDate: Wed Apr 29 17:31:45 2015 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d8f76f80

Restructure the setup_aufs function, it had redundant code and moved
the call to it further down the pipe.

 defaults/initrd.scripts | 181 +++++++++++++++++++++++-------------------------
 defaults/linuxrc        |   2 +-
 2 files changed, 89 insertions(+), 94 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index a9ec5ab..14800e4 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -302,115 +302,110 @@ create_changefs() {
 }
 
 setup_aufs() {
-	if [ "${USE_AUFS_NORMAL}" -eq '1' ]
+        # Directory used for rw changes in union mount filesystem
+	UNION=/union
+	MEMORY=/memory
+	# Mountpoint for the changesdev
+	CHANGESMNT=${NEW_ROOT}/mnt/changesdev
+	if [ -z "$UID" ]
 	then
-		# Directory used for rw changes in union mount filesystem
-		UNION=/union
-		MEMORY=/memory
-		# Mountpoint for the changesdev
-		CHANGESMNT=${NEW_ROOT}/mnt/changesdev
-		if [ -z "$UID" ]
-		then
-			CHANGES=${MEMORY}/aufs_changes/default
-		else
-			CHANGES=${MEMORY}/aufs_changes/${UID}
-		fi
+		CHANGES=${MEMORY}/aufs_changes/default
+	else
+		CHANGES=${MEMORY}/aufs_changes/${UID}
+	fi
 
-		mkdir -p ${MEMORY}
-		mkdir -p ${UNION}
-		mkdir -p ${CHANGESMNT}
-		for i in dev mnt ${CDROOT_PATH} mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
-		do
-			mkdir -p "${NEW_ROOT}/${i}"
-			chmod 755 "${NEW_ROOT}/${i}"
-		done
-		[ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3
-		[ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1
+	mkdir -p ${MEMORY}
+	mkdir -p ${UNION}
+	mkdir -p ${CHANGESMNT}
+	for i in dev mnt ${CDROOT_PATH} mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
+	do
+		mkdir -p "${NEW_ROOT}/${i}"
+		chmod 755 "${NEW_ROOT}/${i}"
+	done
+	[ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3
+	[ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1
 
-		bootstrapCD
-		if [ -n "${AUFS}" ]
+	bootstrapCD
+	if [ -n "${AUFS}" ]
+	then
+		if [ "${AUFS}" = "detect" ]
 		then
-			if [ "${AUFS}" = "detect" ]
+			CHANGESMNT="${NEW_ROOT}${CDROOT_PATH}"
+			CHANGESDEV=${REAL_ROOT}
+		else
+			CHANGESDEV=${AUFS}
+			good_msg "mounting ${CHANGESDEV} to ${MEMORY} for aufs support"
+			mount -t auto ${CHANGESDEV} ${CHANGESMNT}
+			ret=$?
+			if [ "${ret}" -ne 0 ]
 			then
-				CHANGESMNT="${NEW_ROOT}${CDROOT_PATH}"
-				CHANGESDEV=${REAL_ROOT}
-			else
-				CHANGESDEV=${AUFS}
-				good_msg "mounting ${CHANGESDEV} to ${MEMORY} for aufs support"
-				mount -t auto ${CHANGESDEV} ${CHANGESMNT}
+				bad_msg "mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
+				unset AUFS
+			fi
+		fi
+		# Check and attempt to create the changesfile
+		if [ ! -e ${CHANGESMNT}/${AUFS_CHANGESFILE} ] && [ -n "${AUFS}" ]
+		then
+			create_changefs
+			mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
+		elif [ -n "${AUFS}" ]
+		then
+			local nbpass=0
+			while [ 1 ]
+			do
+				mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
 				ret=$?
 				if [ "${ret}" -ne 0 ]
 				then
-					bad_msg "mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
-					unset AUFS
-				fi
-			fi
-			# Check and attempt to create the changesfile
-			if [ ! -e ${CHANGESMNT}/${AUFS_CHANGESFILE} ] && [ -n "${AUFS}" ]
-			then
-				create_changefs
-				mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
-			elif [ -n "${AUFS}" ]
-			then
-				local nbpass=0
-				while [ 1 ]
-				do
-					mount -t auto ${CHANGESMNT}/${AUFS_CHANGESFILE} ${MEMORY}
-					ret=$?
-					if [ "${ret}" -ne 0 ]
+					if [ ${nbpass} -eq 0 ]
 					then
-						if [ ${nbpass} -eq 0 ]
-						then
-							bad_msg "mounting of changes file failed, Running e2fsck"
-							e2fsck ${CHANGESMNT}/${AUFS_CHANGESFILE}
-							nbpass=$((${nbpass} + 1))
-						else
-							bad_msg "mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
-							bad_msg "your ${AUFS_CHANGESFILE} might be messed up, and I couldn't fix it"
-							bad_msg "moving ${AUFS_CHANGESFILE} to ${AUFS_CHANGESFILE}.bad"
-							mv ${CHANGESMNT}/${AUFS_CHANGESFILE} ${CHANGESMNT}/${AUFS_CHANGESFILE}.bad
-							bad_msg "try to fix it yourself with e2fsck later on, sorry for disturbing"
-							break
-						fi
+						bad_msg "mounting of changes file failed, Running e2fsck"
+						e2fsck ${CHANGESMNT}/${AUFS_CHANGESFILE}
+						nbpass=$((${nbpass} + 1))
 					else
-						if [ ${nbpass} -eq 1 ]
-						then
-							good_msg "e2fsck ran successfully. Please check your files after bootup"
-						fi
+						bad_msg "mount of ${CHANGESDEV} failed, falling back to ramdisk based aufs"
+						bad_msg "your ${AUFS_CHANGESFILE} might be messed up, and I couldn't fix it"
+						bad_msg "moving ${AUFS_CHANGESFILE} to ${AUFS_CHANGESFILE}.bad"
+						mv ${CHANGESMNT}/${AUFS_CHANGESFILE} ${CHANGESMNT}/${AUFS_CHANGESFILE}.bad
+						bad_msg "try to fix it yourself with e2fsck later on, sorry for disturbing"
 						break
 					fi
-				done
-			fi
-			# mount tmpfs only in the case when changes= boot parameter was
-			# empty or we were not able to mount the storage device
-			if [ "${CDROOT}" -eq '1' -a ! -f ${CHANGESMNT}/${AUFS_CHANGESFILE}  ]
-			then
-				umount ${MEMORY}
-				bad_msg "failed to find ${AUFS_CHANGESFILE} file on ${CHANGESDEV}"
-				bad_msg "create an ext2 ${AUFS_CHANGESFILE} file on this device if you wish to use it for aufs"
-				bad_msg "falling back to ramdisk based aufs for safety"
-				mount -t tmpfs tmpfs ${MEMORY}
-				XINO=${MEMORY}
-			else
-				XINO=${MEMORY}/xino
-				mkdir -p ${XINO}
-				mount -t tmpfs tmpfs ${XINO}
-			fi
-		else
-			good_msg "Mounting ramdisk to $MEMORY for aufs support..."
-			mount -t tmpfs tmpfs ${MEMORY}
-			XINO=${MEMORY}
+				else
+					if [ ${nbpass} -eq 1 ]
+					then
+						good_msg "e2fsck ran successfully. Please check your files after bootup"
+					fi
+					break
+				fi
+			done
 		fi
-
-		mkdir -p ${CHANGES}
-		mount -t aufs -n -o nowarn_perm,udba=none,xino=${XINO}/.aufs.xino,br:${CHANGES}=rw aufs ${UNION}
-		ret=$?
-		if [ "${ret}" -ne 0 ]
+		# mount tmpfs only in the case when changes= boot parameter was
+		# empty or we were not able to mount the storage device
+		if [ "${CDROOT}" -eq '1' -a ! -f ${CHANGESMNT}/${AUFS_CHANGESFILE}  ]
 		then
-			bad_msg "Can't setup union ${UNION} in directory!"
-			USE_AUFS_NORMAL=0
+			umount ${MEMORY}
+			bad_msg "failed to find ${AUFS_CHANGESFILE} file on ${CHANGESDEV}"
+			bad_msg "create an ext2 ${AUFS_CHANGESFILE} file on this device if you wish to use it for aufs"
+			bad_msg "falling back to ramdisk based aufs for safety"
+			mount -t tmpfs tmpfs ${MEMORY}
+			XINO=${MEMORY}
+		else
+			XINO=${MEMORY}/xino
+			mkdir -p ${XINO}
+			mount -t tmpfs tmpfs ${XINO}
 		fi
 	else
+		good_msg "Mounting ramdisk to $MEMORY for aufs support..."
+		mount -t tmpfs tmpfs ${MEMORY}
+		XINO=${MEMORY}
+	fi
+
+	mkdir -p ${CHANGES}
+	mount -t aufs -n -o nowarn_perm,udba=none,xino=${XINO}/.aufs.xino,br:${CHANGES}=rw aufs ${UNION}
+	ret=$?
+	if [ "${ret}" -ne 0 ]
+	then
+		bad_msg "Can't setup union ${UNION} in directory!"
 		USE_AUFS_NORMAL=0
 	fi
 }

diff --git a/defaults/linuxrc b/defaults/linuxrc
index 5d4d2a1..894ec45 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -457,9 +457,9 @@ rundebugshell "before setting up the root filesystem"
 
 if [ "${CDROOT}" = '1' ]
 then
-	setup_aufs
 	if [ "${USE_AUFS_NORMAL}" -eq '1' ]
 	then
+                setup_aufs
 		CHROOT=${UNION}
 	else
 		CHROOT=${NEW_ROOT}