diff --git a/.braids.json b/.braids.json index d059867..bdfc8f5 100644 --- a/.braids.json +++ b/.braids.json @@ -16,6 +16,11 @@ "branch": "master", "revision": "ea6aeca101aa866895617ddb007ccb703c2ffa6d" }, + "zfs-utils": { + "url": "https://aur.archlinux.org/zfs-utils.git", + "branch": "master", + "revision": "bc1ae3304485ac89aeab2804c7e3c6f2bd3459b6" + }, "zfsbootmenu": { "url": "https://aur.archlinux.org/zfsbootmenu.git", "branch": "master", diff --git a/zfs-utils/.SRCINFO b/zfs-utils/.SRCINFO new file mode 100644 index 0000000..c8690b1 --- /dev/null +++ b/zfs-utils/.SRCINFO @@ -0,0 +1,26 @@ +pkgbase = zfs-utils + pkgdesc = Userspace utilities for the Zettabyte File System. + pkgver = 2.1.6 + pkgrel = 1 + url = https://zfsonlinux.org/ + arch = i686 + arch = x86_64 + arch = aarch64 + license = CDDL + optdepends = python: for arcstat/arc_summary/dbufstat + source = https://github.com/zfsonlinux/zfs/releases/download/zfs-2.1.6/zfs-2.1.6.tar.gz + source = https://github.com/zfsonlinux/zfs/releases/download/zfs-2.1.6/zfs-2.1.6.tar.gz.asc + source = zfs.initcpio.install + source = zfs.initcpio.hook + validpgpkeys = 4F3BA9AB6D1F8D683DC2DFB56AD860EED4598027 + validpgpkeys = C33DF142657ED1F7C328A2960AB9E991C6AF658B + sha256sums = 15339014f8d2131348eb937bf8893849806b6d2645ea607a18c7f117749dbd7a + sha256sums = SKIP + sha256sums = da1cdc045d144d2109ec7b5d97c53a69823759d8ecff410e47c3a66b69e6518d + sha256sums = 9c20256093997f7cfa9e7eb5d85d4a712d528a6ff19ef35b83ad03fb1ceae3bc + b2sums = 615fe7a2128af77c6c855ea52b6503a78f0c992ea845b02875ac19aa9dd155c5d4110b668da91c463f96a54767ab92e67e5303572337352484c055c0a0ff9e46 + b2sums = SKIP + b2sums = 570e995bba07ea0fb424dff191180b8017b6469501964dc0b70fd51e338a4dad260f87cc313489866cbfd1583e4aac2522cf7309c067cc5314eb83c37fe14ff3 + b2sums = e14366cbf680e3337d3d478fe759a09be224c963cc5207bee991805312afc49a49e6691f11e5b8bbe8dde60e8d855bd96e7f4f48f24a4c6d4a8c1bab7fc2bba0 + +pkgname = zfs-utils diff --git a/zfs-utils/PKGBUILD b/zfs-utils/PKGBUILD new file mode 100644 index 0000000..675ece6 --- /dev/null +++ b/zfs-utils/PKGBUILD @@ -0,0 +1,70 @@ +# Maintainer: Eli Schwartz +# Contributor: Iacopo Isimbaldi + +# All my PKGBUILDs are managed at https://github.com/eli-schwartz/pkgbuilds + +pkgname=zfs-utils +pkgver=2.1.6 +pkgrel=1 +pkgdesc="Userspace utilities for the Zettabyte File System." +arch=("i686" "x86_64" "aarch64") +url="https://zfsonlinux.org/" +license=('CDDL') +optdepends=('python: for arcstat/arc_summary/dbufstat') +source=("https://github.com/zfsonlinux/zfs/releases/download/zfs-${pkgver}/zfs-${pkgver}.tar.gz"{,.asc} + "zfs.initcpio.install" + "zfs.initcpio.hook") +sha256sums=('15339014f8d2131348eb937bf8893849806b6d2645ea607a18c7f117749dbd7a' + 'SKIP' + 'da1cdc045d144d2109ec7b5d97c53a69823759d8ecff410e47c3a66b69e6518d' + '9c20256093997f7cfa9e7eb5d85d4a712d528a6ff19ef35b83ad03fb1ceae3bc') +b2sums=('615fe7a2128af77c6c855ea52b6503a78f0c992ea845b02875ac19aa9dd155c5d4110b668da91c463f96a54767ab92e67e5303572337352484c055c0a0ff9e46' + 'SKIP' + '570e995bba07ea0fb424dff191180b8017b6469501964dc0b70fd51e338a4dad260f87cc313489866cbfd1583e4aac2522cf7309c067cc5314eb83c37fe14ff3' + 'e14366cbf680e3337d3d478fe759a09be224c963cc5207bee991805312afc49a49e6691f11e5b8bbe8dde60e8d855bd96e7f4f48f24a4c6d4a8c1bab7fc2bba0') +validpgpkeys=('4F3BA9AB6D1F8D683DC2DFB56AD860EED4598027' # Tony Hutter (GPG key for signing ZFS releases) + 'C33DF142657ED1F7C328A2960AB9E991C6AF658B') # Brian Behlendorf + +prepare() { + cd "${srcdir}"/zfs-${pkgver} + + # pyzfs is not built, but build system tries to check for python anyway + ln -sf /bin/true python3-fake + + autoreconf -fi +} + +build() { + cd "${srcdir}"/zfs-${pkgver} + + ./configure --prefix=/usr \ + --sysconfdir=/etc \ + --sbindir=/usr/bin \ + --with-mounthelperdir=/usr/bin \ + --with-udevdir=/usr/lib/udev \ + --libexecdir=/usr/lib/zfs \ + --with-python="$PWD/python3-fake" \ + --enable-pyzfs=no \ + --enable-systemd \ + --with-config=user + make +} + +package() { + cd "${srcdir}"/zfs-${pkgver} + + make DESTDIR="${pkgdir}" install + install -D -m644 contrib/bash_completion.d/zfs "${pkgdir}"/usr/share/bash-completion/completions/zfs + + # Remove uneeded files + rm -r "${pkgdir}"/etc/init.d + rm -r "${pkgdir}"/etc/sudoers.d #??? + # We're experimenting with dracut in [extra], so start installing this. + #rm -r "${pkgdir}"/usr/lib/dracut + rm -r "${pkgdir}"/usr/lib/modules-load.d + rm -r "${pkgdir}"/usr/share/initramfs-tools + rm -r "${pkgdir}"/usr/share/zfs + + install -D -m644 "${srcdir}"/zfs.initcpio.hook "${pkgdir}"/usr/lib/initcpio/hooks/zfs + install -D -m644 "${srcdir}"/zfs.initcpio.install "${pkgdir}"/usr/lib/initcpio/install/zfs +} diff --git a/zfs-utils/zfs.initcpio.hook b/zfs-utils/zfs.initcpio.hook new file mode 100644 index 0000000..e0f4cfb --- /dev/null +++ b/zfs-utils/zfs.initcpio.hook @@ -0,0 +1,119 @@ +# +# WARNING: This script is parsed by ash in busybox at boot time, not bash! +# http://linux.die.net/man/1/ash +# https://wiki.ubuntu.com/DashAsBinSh +# http://www.jpsdomain.org/public/2008-JP_bash_vs_dash.pdf +# +ZPOOL_FORCE="" +ZPOOL_IMPORT_FLAGS="" + +zfs_get_bootfs () { + for zfs_dataset in $(zpool list -H -o bootfs); do + case ${zfs_dataset} in + "" | "-") + # skip this line/dataset + ;; + "no pools available") + return 1 + ;; + *) + ZFS_DATASET=${zfs_dataset} + return 0 + ;; + esac + done + return 1 +} + +zfs_mount_handler () { + if [ "${ZFS_DATASET}" = "bootfs" ] ; then + if ! zfs_get_bootfs ; then + # Lets import everything and try again + zpool import ${ZPOOL_IMPORT_FLAGS} -N -a ${ZPOOL_FORCE} + if ! zfs_get_bootfs ; then + die "ZFS: Cannot find bootfs." + fi + fi + fi + + local pool="${ZFS_DATASET%%/*}" + local rwopt_exp="${rwopt:-ro}" + + if ! zpool list -H "${pool}" >/dev/null 2>&1; then + if [ ! "${rwopt_exp}" = "rw" ]; then + msg "ZFS: Importing pool ${pool} readonly." + ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -o readonly=on" + else + msg "ZFS: Importing pool ${pool}." + fi + + if ! zpool import ${ZPOOL_IMPORT_FLAGS} -N "${pool}" ${ZPOOL_FORCE} ; then + die "ZFS: Unable to import pool ${pool}." + fi + fi + + local node="$1" + local tab_file="${node}/etc/fstab" + local zfs_datasets="$(zfs list -H -o name -t filesystem -r ${ZFS_DATASET})" + + # Mount the root, and any child datasets + for dataset in ${zfs_datasets}; do + mountpoint=$(zfs get -H -o value mountpoint "${dataset}") + case ${mountpoint} in + "none") + # skip this line/dataset. + ;; + "legacy") + if [ -f "${tab_file}" ]; then + if findmnt -snero source -F "${tab_file}" -S "${dataset}" > /dev/null 2>&1; then + opt=$(findmnt -snero options -F "${tab_file}" -S "${dataset}") + mnt=$(findmnt -snero target -F "${tab_file}" -S "${dataset}") + mount -t zfs -o "${opt}" "${dataset}" "${node}${mnt}" + fi + fi + ;; + *) + mount -t zfs -o "zfsutil,${rwopt_exp}" "${dataset}" "${node}${mountpoint}" + ;; + esac + done +} + +run_hook() { + # Force import the pools, useful if the pool has not properly been exported using 'zpool export ' + [ ! "${zfs_force}" = "" ] && ZPOOL_FORCE="-f" + + # Add import directory to import command flags + [ ! "${zfs_import_dir}" = "" ] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -d ${zfs_import_dir}" + + # Wait 15 seconds for ZFS devices to show up + [ "${zfs_wait}" = "" ] && ZFS_WAIT="15" || ZFS_WAIT="${zfs_wait}" + + [ "${root}" = "zfs" ] && mount_handler="zfs_mount_handler" + + case ${zfs} in + "") + # skip this line/dataset + ;; + auto|bootfs) + ZFS_DATASET="bootfs" + mount_handler="zfs_mount_handler" + ;; + *) + ZFS_DATASET="${zfs}" + mount_handler="zfs_mount_handler" + ;; + esac + + # Allow up to n seconds for zfs device to show up + for i in $(seq 1 ${ZFS_WAIT}); do + [ -c "/dev/zfs" ] && break + sleep 1 + done +} + +run_latehook () { + zpool import -N -a ${ZPOOL_FORCE} +} + +# vim:set ts=4 sw=4 ft=sh et: diff --git a/zfs-utils/zfs.initcpio.install b/zfs-utils/zfs.initcpio.install new file mode 100644 index 0000000..589b46b --- /dev/null +++ b/zfs-utils/zfs.initcpio.install @@ -0,0 +1,102 @@ +#!/bin/bash + +build() { + map add_module \ + zavl \ + znvpair \ + zunicode \ + zcommon \ + zfs \ + spl + + map add_binary \ + fsck.zfs \ + mount.zfs \ + seq \ + zdb \ + zed \ + zfs \ + zhack \ + zinject \ + zpool \ + zstreamdump \ + /lib/udev/vdev_id \ + /lib/udev/zvol_id \ + findmnt + + map add_file \ + /lib/udev/rules.d/60-zvol.rules \ + /lib/udev/rules.d/69-vdev.rules \ + /lib/udev/rules.d/90-zfs.rules \ + /lib/libgcc_s.so.1 + + map add_dir \ + /etc/zfs/zed.d + + add_runscript + + # allow mount(8) to "autodetect" ZFS + echo 'zfs' >>"${BUILDROOT}/etc/filesystems" + + [[ -f /etc/zfs/zpool.cache ]] && add_file "/etc/zfs/zpool.cache" + [[ -f /etc/modprobe.d/zfs.conf ]] && add_file "/etc/modprobe.d/zfs.conf" + [[ -f /etc/hostid ]] && add_file "/etc/hostid" +} + +help() { + cat< + + To force importing of a ZFS pool: + + zfs_force=1 + + If set to 1, this will use "zpool import -f" when attempting to import + pools. + + To change the seconds of time to wait for ZFS devices to show up at boot: + + zfs_wait=30 + + To search for devices in a directory other than "/dev": + + zfs_import_dir=/dev/disk/by-uuid + or + zfs_import_dir=/dev/disk/by-partuuid + or + zfs_import_dir=/dev/disk/by-path + etc. + + Following initcpio convention, the 'rw' option must be specified to load the + pool as read/write. Pools are loaded as read only by default. + +Examples: + + To use bootfs on your pool, use + + zfs=bootfs rw + + This will setup your root using tank/root zfs pool. + + zfs=tank/root rw + +If you want to set properties for zfs-on-linux module, you should add them to +/etc/modprobe.d/zfs.conf and then rebuild initcpio. + +HELPEOF +} + +# vim: set ts=4 sw=4 ft=sh et: