summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gilbert <floppym@gentoo.org>2012-04-22 06:07:32 +0000
committerMike Gilbert <floppym@gentoo.org>2012-04-22 06:07:32 +0000
commit7e17e0249e3ab45b6677ba41589e6d6b8ce5f960 (patch)
treec4d3bb19565f751992c8dff4e06569623395c17f /sys-fs/zfs
parent[dev-util/catalyst] Bump catalyst to the 2.0.8 revision. (diff)
downloadgentoo-2-7e17e0249e3ab45b6677ba41589e6d6b8ce5f960.tar.gz
gentoo-2-7e17e0249e3ab45b6677ba41589e6d6b8ce5f960.tar.bz2
gentoo-2-7e17e0249e3ab45b6677ba41589e6d6b8ce5f960.zip
Add zfs-shutdown init script and linuxrc helper script; Introduce rootfs USE flag; Fix issue with sys-libs/zlib[static-libs] on Gentoo stable. Patch by Richard Yao.
(Portage version: 2.2.0_alpha100/cvs/Linux x86_64)
Diffstat (limited to 'sys-fs/zfs')
-rw-r--r--sys-fs/zfs/ChangeLog8
-rw-r--r--sys-fs/zfs/files/linuxrc18
-rw-r--r--sys-fs/zfs/files/zfs-shutdown57
-rw-r--r--sys-fs/zfs/metadata.xml1
-rw-r--r--sys-fs/zfs/zfs-9999.ebuild38
5 files changed, 113 insertions, 9 deletions
diff --git a/sys-fs/zfs/ChangeLog b/sys-fs/zfs/ChangeLog
index 57eb0a422960..05a898763dfe 100644
--- a/sys-fs/zfs/ChangeLog
+++ b/sys-fs/zfs/ChangeLog
@@ -1,6 +1,12 @@
# ChangeLog for sys-fs/zfs
# Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/ChangeLog,v 1.18 2012/04/21 17:54:52 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/ChangeLog,v 1.19 2012/04/22 06:07:32 floppym Exp $
+
+ 22 Apr 2012; Mike Gilbert <floppym@gentoo.org> +files/linuxrc,
+ +files/zfs-shutdown, metadata.xml, zfs-9999.ebuild:
+ Add zfs-shutdown init script and linuxrc helper script; Introduce rootfs USE
+ flag; Fix issue with sys-libs/zlib[static-libs] on Gentoo stable. Patch by
+ Richard Yao.
21 Apr 2012; Mike Gilbert <floppym@gentoo.org> zfs-9999.ebuild:
Set AUTOTOOLS_AUTORECONF before inherit to generate proper dependencies.
diff --git a/sys-fs/zfs/files/linuxrc b/sys-fs/zfs/files/linuxrc
new file mode 100644
index 000000000000..1e63837fad04
--- /dev/null
+++ b/sys-fs/zfs/files/linuxrc
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+PATH="/usr/sbin:/usr/bin:/sbin:/bin"
+
+j=0
+for i in $(cat /movefs)
+do
+ mkdir "/${j}"
+ mount --move "${i}" "/${j}"
+ j=$(expr $j + 1)
+done
+
+zfs umount -a
+
+for i in $(zpool list -H -o name)
+do
+ zpool export "$i"
+done;
diff --git a/sys-fs/zfs/files/zfs-shutdown b/sys-fs/zfs/files/zfs-shutdown
new file mode 100644
index 000000000000..17791b67cfb1
--- /dev/null
+++ b/sys-fs/zfs/files/zfs-shutdown
@@ -0,0 +1,57 @@
+#!/sbin/runscript
+
+description="Export ZFS Root Filesystem"
+
+copy_binaries() {
+ local destdir=$1
+ shift
+ lddtree "$@" \
+ | tr ')(' '\n' \
+ | awk '/=>/{ if($3 ~ /^\//){print $3}}' \
+ | sort \
+ | uniq \
+ | cpio -p --make-directories --dereference --quiet $destdir
+
+}
+
+depend()
+{
+ need mount-ro
+ keyword -prefix -openvz -vserver -lxc
+}
+
+start()
+{
+
+ ROOTFSTYPE=$(df -TP / | awk 'NR>1{print $2}')
+ TMPDIR='/dev/pivot_root'
+ MOVEFS=$(df -TP -x zfs | awk 'NR>2{print $7}')
+
+ # Make sure that we are dealing with zfs
+ test "${ROOTFSTYPE}" = "zfs" || eerror "rootfs is not zfs" && exit
+
+ # Construct new rootfs
+ mkdir -p "${TMPDIR}"
+ mount -t tmpfs none ${TMPDIR}
+ mkdir "${TMPDIR}/oldroot" "${TMPDIR}/dev"
+ mknod -m 660 "${TMPDIR}/dev/null" c 1 3
+ mknod -m 660 "${TMPDIR}/dev/zfs" c 10 59
+
+ # Make tmpfs root filesystem
+ copy_binaries ${TMPDIR} $(which chroot sh cat mount mkdir zfs zpool)
+
+ # Make directories for temporary mounts
+ for i in $(seq $(echo "$MOVEFS" | wc -w)); do mkdir "${TMPDIR}/${i}"; done;
+
+ # Pass temporary mount information to chroot
+ echo "$MOVEFS" > "${TMPDIR}/movefs"
+
+ # Copy shutdown script
+ cp /usr/share/zfs/linuxrc "${TMPDIR}/linuxrc"
+
+ # Pivot into new root
+ cd "${TMPDIR}"
+ pivot_root . oldroot
+ exec chroot . /linuxrc
+
+}
diff --git a/sys-fs/zfs/metadata.xml b/sys-fs/zfs/metadata.xml
index 93137d2837e1..cb8f3d474b4a 100644
--- a/sys-fs/zfs/metadata.xml
+++ b/sys-fs/zfs/metadata.xml
@@ -12,6 +12,7 @@
</maintainer>
<use>
<flag name="dracut">Install dracut module</flag>
+ <flag name="rootfs">Install zfs-shutdown script to support exporting a pool containing rootfs</flag>
<flag name="test-suite">Install regression test suite</flag>
</use>
</pkgmetadata>
diff --git a/sys-fs/zfs/zfs-9999.ebuild b/sys-fs/zfs/zfs-9999.ebuild
index 4fbe3345f888..b3207ba37456 100644
--- a/sys-fs/zfs/zfs-9999.ebuild
+++ b/sys-fs/zfs/zfs-9999.ebuild
@@ -1,9 +1,12 @@
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/zfs-9999.ebuild,v 1.19 2012/04/21 17:54:52 floppym Exp $
+# $Header: /var/cvsroot/gentoo-x86/sys-fs/zfs/zfs-9999.ebuild,v 1.20 2012/04/22 06:07:32 floppym Exp $
EAPI="4"
+
+AT_M4DIR="config"
AUTOTOOLS_AUTORECONF="1"
+AUTOTOOLS_IN_SOURCE_BUILD="1"
inherit flag-o-matic git-2 linux-mod toolchain-funcs autotools-utils
@@ -15,12 +18,12 @@ EGIT_REPO_URI="git://github.com/zfsonlinux/zfs.git"
LICENSE="CDDL GPL-2"
SLOT="0"
KEYWORDS=""
-IUSE="custom-cflags debug dracut test test-suite static-libs"
+IUSE="custom-cflags debug dracut +rootfs test test-suite static-libs"
DEPEND="
>=sys-kernel/spl-${PV}
sys-apps/util-linux[static-libs?]
- sys-libs/zlib[static-libs?]
+ sys-libs/zlib[static-libs(+)?]
"
RDEPEND="${DEPEND}
!sys-fs/zfs-fuse
@@ -34,14 +37,15 @@ RDEPEND="${DEPEND}
sys-process/procps
virtual/modutils
)
+ rootfs? (
+ app-arch/cpio
+ app-misc/pax-utils
+ )
"
DEPEND+="
test? ( sys-fs/mdadm )
"
-AT_M4DIR="config"
-AUTOTOOLS_IN_SOURCE_BUILD="1"
-
pkg_setup() {
CONFIG_CHECK="!DEBUG_LOCK_ALLOC
!PREEMPT
@@ -49,12 +53,10 @@ pkg_setup() {
BLK_DEV_LOOP
EFI_PARTITION
MODULES
- PREEMPT_NONE
ZLIB_DEFLATE
ZLIB_INFLATE"
kernel_is ge 2 6 26 || die "Linux 2.6.26 or newer required"
check_extra_config
- use x86 && ewarn "32-bit kernels are unsupported by ZFSOnLinux upstream. Do not file bug reports."
}
src_prepare() {
@@ -95,4 +97,24 @@ src_install() {
gen_usr_ldscript -a uutil nvpair zpool zfs
use dracut || rm -rf "${ED}usr/share/dracut"
use test-suite || rm -rf "${ED}usr/libexec"
+
+ if use rootfs
+ then
+ doinitd "${FILESDIR}/zfs-shutdown"
+ exeinto /usr/share/zfs
+ doexe "${FILESDIR}/linuxrc"
+ fi
+
+}
+
+pkg_postinst() {
+
+ use x86 && ewarn "32-bit kernels are unsupported by ZFSOnLinux upstream. Do not file bug reports."
+
+ [ -e "${EROOT}/etc/runlevels/boot/zfs" ] \
+ || ewarn 'You should add zfs to the boot runlevel.'
+
+ use rootfs && ([ -e "${EROOT}/etc/runlevels/shutdown/zfs-shutdown" ] \
+ || ewarn 'You should add zfs-shutdown to the shutdown runlevel.')
+
}