diff options
author | Jan Houben | 2018-11-10 19:44:47 -0500 |
---|---|---|
committer | Jan Houben | 2018-11-10 19:44:47 -0500 |
commit | f85d859de36052f8a85a4e57f979e4cd1537996b (patch) | |
tree | c668a04040a171abf979c20a93287ab060dff552 | |
parent | 893f94629951734fb5e4e5e11e183045998c11f8 (diff) | |
download | aur-f85d859de36052f8a85a4e57f979e4cd1537996b.tar.gz |
Import from zfs-utils-common-git
-rw-r--r-- | .SRCINFO | 28 | ||||
-rw-r--r-- | .gitignore | 4 | ||||
-rw-r--r-- | PKGBUILD | 66 | ||||
-rw-r--r-- | zfs-utils.initcpio.hook | 172 | ||||
-rw-r--r-- | zfs-utils.initcpio.install | 24 | ||||
-rw-r--r-- | zfs-utils.initcpio.zfsencryptssh.install | 39 | ||||
-rw-r--r-- | zfs-utils.install | 18 |
7 files changed, 251 insertions, 100 deletions
@@ -1,28 +1,30 @@ -# Generated by mksrcinfo v8 -# Wed Apr 20 06:24:36 UTC 2016 pkgbase = zfs-utils-git pkgdesc = Kernel module support files for the Zettabyte File System. - pkgver = 0.6.5.6_r0_g21f21fe_4.5.1_1 + pkgver = 2018.11.07.r4820.gd8244d34b pkgrel = 1 url = http://zfsonlinux.org/ - arch = i686 + install = zfs-utils.install arch = x86_64 - groups = archzfs-git + groups = archzfs-linux-git license = CDDL makedepends = git - depends = spl-git provides = zfs-utils + provides = spl-utils conflicts = zfs-utils - conflicts = zfs-utils-lts - replaces = zfs-utils - source = git+https://github.com/zfsonlinux/zfs.git#commit=21f21fe8 + conflicts = spl-utils + replaces = spl-utils-common-git + backup = etc/zfs/zed.d/zed.rc + backup = etc/default/zfs + source = git+https://github.com/zfsonlinux/zfs.git#commit=d8244d34bdc3e7b864e0152b55477fa61dae3e90 source = zfs-utils.bash-completion-r1 source = zfs-utils.initcpio.install source = zfs-utils.initcpio.hook - md5sums = SKIP - md5sums = 9ddb0c8a94861f929d0fa741fdc49950 - md5sums = 9ef4841abb85dee611828cc7e6f5c6fe - md5sums = 62ba32c6853c315ff231c396cf8bfdbb + source = zfs-utils.initcpio.zfsencryptssh.install + sha256sums = SKIP + sha256sums = b60214f70ffffb62ffe489cbfabd2e069d14ed2a391fac0e36f914238394b540 + sha256sums = 6e5e905a322d0426acdcbc05c5651ec78ee7b874b96d3c429c80f68b061170c5 + sha256sums = ae1cda85de0ad8b9ec8158a66d02485f3d09c37fb13b1567367220a720bcc9a5 + sha256sums = 29080a84e5d7e36e63c4412b98646043724621245b36e5288f5fed6914da5b68 pkgname = zfs-utils-git diff --git a/.gitignore b/.gitignore index de967fb8c0a5..b18b49395bde 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ -zfs/ -*.tar.gz *.tar.xz +*.tar.gz *.sig *.log +zfs/ @@ -1,64 +1,64 @@ -# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com> -# Contributor: Kyle Fuller <inbox at kylefuller dot co dot uk> +# Maintainer: Jan Houben <jan@nexttrex.de> +# Contributor: Jesus Alvarez <jeezusjr at gmail dot com> # # This PKGBUILD was generated by the archzfs build scripts located at # -# http://github.com/demizer/archzfs -# -# The build script generates and updates the pkgver and _kernel* variables. +# http://github.com/archzfs/archzfs # pkgname="zfs-utils-git" -pkgver=0.6.5.6_r0_g21f21fe_4.5.1_1 +_commit='d8244d34bdc3e7b864e0152b55477fa61dae3e90' + +pkgver=2018.11.07.r4820.gd8244d34b pkgrel=1 -license=('CDDL') pkgdesc="Kernel module support files for the Zettabyte File System." -depends=("spl-git") makedepends=("git") -arch=("i686" "x86_64") +arch=("x86_64") url="http://zfsonlinux.org/" -source=("git+https://github.com/zfsonlinux/zfs.git#commit=21f21fe8" +source=("git+https://github.com/zfsonlinux/zfs.git#commit=${_commit}" "zfs-utils.bash-completion-r1" "zfs-utils.initcpio.install" - "zfs-utils.initcpio.hook") -groups=("archzfs-git") -md5sums=('SKIP' - '9ddb0c8a94861f929d0fa741fdc49950' - '9ef4841abb85dee611828cc7e6f5c6fe' - '62ba32c6853c315ff231c396cf8bfdbb') -replaces=("zfs-utils") -provides=("zfs-utils") -conflicts=("zfs-utils" "zfs-utils-lts") + "zfs-utils.initcpio.hook" + "zfs-utils.initcpio.zfsencryptssh.install") +sha256sums=("SKIP" + "b60214f70ffffb62ffe489cbfabd2e069d14ed2a391fac0e36f914238394b540" + "6e5e905a322d0426acdcbc05c5651ec78ee7b874b96d3c429c80f68b061170c5" + "ae1cda85de0ad8b9ec8158a66d02485f3d09c37fb13b1567367220a720bcc9a5" + "29080a84e5d7e36e63c4412b98646043724621245b36e5288f5fed6914da5b68") +license=("CDDL") +groups=("archzfs-linux-git") +provides=("zfs-utils" "spl-utils") +install=zfs-utils.install +conflicts=("zfs-utils" "spl-utils") +replaces=("spl-utils-common-git") +backup=('etc/zfs/zed.d/zed.rc' 'etc/default/zfs') build() { cd "${srcdir}/zfs" ./autogen.sh - - ./configure --prefix=/usr \ - --sysconfdir=/etc \ - --sbindir=/usr/bin \ - --with-mounthelperdir=/usr/bin \ - --libdir=/usr/lib \ - --datadir=/usr/share \ - --includedir=/usr/include \ - --with-udevdir=/lib/udev \ - --libexecdir=/usr/lib/zfs \ - --with-config=user + ./configure --prefix=/usr --sysconfdir=/etc --sbindir=/usr/bin --with-mounthelperdir=/usr/bin \ + --libdir=/usr/lib --datadir=/usr/share --includedir=/usr/include \ + --with-udevdir=/lib/udev --libexecdir=/usr/lib/zfs-${pkgver} \ + --with-config=user --enable-systemd make } package() { cd "${srcdir}/zfs" make DESTDIR="${pkgdir}" install - # Remove uneeded files rm -r "${pkgdir}"/etc/init.d rm -r "${pkgdir}"/usr/lib/dracut - # move module tree /lib -> /usr/lib cp -r "${pkgdir}"/{lib,usr} rm -r "${pkgdir}"/lib - + # Autoload the zfs module at boot + mkdir -p "${pkgdir}/etc/modules-load.d" + printf "%s\n" "zfs" > "${pkgdir}/etc/modules-load.d/zfs.conf" + # fix permissions + chmod 750 ${pkgdir}/etc/sudoers.d + # Install the support files install -D -m644 "${srcdir}"/zfs-utils.initcpio.hook "${pkgdir}"/usr/lib/initcpio/hooks/zfs install -D -m644 "${srcdir}"/zfs-utils.initcpio.install "${pkgdir}"/usr/lib/initcpio/install/zfs + install -D -m644 "${srcdir}"/zfs-utils.initcpio.zfsencryptssh.install "${pkgdir}"/usr/lib/initcpio/install/zfsencryptssh install -D -m644 "${srcdir}"/zfs-utils.bash-completion-r1 "${pkgdir}"/usr/share/bash-completion/completions/zfs } diff --git a/zfs-utils.initcpio.hook b/zfs-utils.initcpio.hook index 3a928944db92..b47cc2849c9e 100644 --- a/zfs-utils.initcpio.hook +++ b/zfs-utils.initcpio.hook @@ -1,8 +1,14 @@ +# +# 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 $(/usr/bin/zpool list -H -o bootfs); do + for zfs_dataset in $(zpool list -H -o bootfs); do case ${zfs_dataset} in "" | "-") # skip this line/dataset @@ -19,82 +25,168 @@ zfs_get_bootfs () { return 1 } +zfs_decrypt_fs() { + dataset=$1 + + # check if 'zfs load-key' is available + zfs 2>&1 | grep load-key > /dev/null || return 0 + + # check if dataset is encrypted + [ "$(zfs get -H -o value encryption "${dataset}")" != "off" ] || return 0 + + # check if key is already loaded + [ "$(zfs get -H -o value keystatus "${dataset}")" != "available" ] || return 0 + + # get the encryption root + encryptionroot=$(zfs get -H -o value encryptionroot "${dataset}") + + # export encription root to be used by other hooks (SSH) + echo "${encryptionroot}" > /.encryptionroot + + # loop until we get the correct password or key is unlocked by another vector (SSH for instance) + while [ "$(zfs get -H -o value keystatus "${encryptionroot}")" != "available" ] && + ! eval zfs load-key "${encryptionroot}"; do + sleep 2 + done + + if [ -f /.encryptionroot ]; then + rm /.encryptionroot + fi +} + zfs_mount_handler () { - local node=$1 - if [ "$ZFS_DATASET" = "bootfs" ] ; then + if [ "${ZFS_DATASET}" = "bootfs" ] ; then if ! zfs_get_bootfs ; then # Lets import everything and try again - /usr/bin/zpool import $ZPOOL_IMPORT_FLAGS -N -a $ZPOOL_FORCE + zpool import ${ZPOOL_IMPORT_FLAGS} -N -a ${ZPOOL_FORCE} if ! zfs_get_bootfs ; then - echo "ZFS: Cannot find bootfs." - return 1 + err "ZFS: Cannot find bootfs." + exit 1 fi fi fi local pool="${ZFS_DATASET%%/*}" - local rwopt_exp=${rwopt:-ro} + local rwopt_exp="${rwopt:-ro}" - if ! "/usr/bin/zpool" list -H $pool 2>&1 > /dev/null ; then - if [ "$rwopt_exp" != "rw" ]; then - msg "ZFS: Importing pool $pool readonly." - ZPOOL_IMPORT_FLAGS="$ZPOOL_IMPORT_FLAGS -o readonly=on" + if ! zpool list -H "${pool}" 2>1 > /dev/null ; 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." + msg "ZFS: Importing pool ${pool}." fi - if ! "/usr/bin/zpool" import $ZPOOL_IMPORT_FLAGS -N $pool $ZPOOL_FORCE ; then - echo "ZFS: Unable to import pool $pool." - return 1 + if ! zpool import ${ZPOOL_IMPORT_FLAGS} -N "${pool}" ${ZPOOL_FORCE} ; then + err "ZFS: Unable to import pool ${pool}." + exit 1 fi fi - local mountpoint=$("/usr/bin/zfs" get -H -o value mountpoint $ZFS_DATASET) - if [ "$mountpoint" = "legacy" ] ; then - mount -t zfs -o ${rwopt_exp} "$ZFS_DATASET" "$node" - else - mount -o zfsutil,${rwopt_exp} -t zfs "$ZFS_DATASET" "$node" - fi + local node="$1" + local rootmnt=$(zfs get -H -o value mountpoint "${ZFS_DATASET}") + 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}") + zfs_decrypt_fs "${dataset}" + mount -t zfs -o "${opt}" "${dataset}" "${node}${mnt}" + fi + fi + ;; + *) + zfs_decrypt_fs "${dataset}" + mount -t zfs -o "zfsutil,${rwopt_exp}" "${dataset}" "${node}/${mountpoint##${rootmnt}}" + ;; + esac + done +} + +set_flags() { + # Force import the pools, useful if the pool has not properly been exported using 'zpool export <pool>' + [ ! "${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}" + [ "${zfs_import_dir}" = "" ] && [ -f /etc/zfs/zpool.cache.org ] && ZPOOL_IMPORT_FLAGS="${ZPOOL_IMPORT_FLAGS} -c /etc/zfs/zpool.cache.org" } run_hook() { - # Force import the pools, useful if the pool has not properly been exported - # using 'zpool export <pool>' - [[ $zfs_force == 1 ]] && ZPOOL_FORCE='-f' - [[ "$zfs_import_dir" != "" ]] && ZPOOL_IMPORT_FLAGS="$ZPOOL_IMPORT_FLAGS -d $zfs_import_dir" + set_flags - if [ "$root" = 'zfs' ]; then - mount_handler='zfs_mount_handler' - fi + # Wait 15 seconds for ZFS devices to show up + [ "${zfs_wait}" = "" ] && ZFS_WAIT="15" || ZFS_WAIT="${zfs_wait}" - case $zfs in + case ${root} in + # root=zfs + "zfs") + mount_handler="zfs_mount_handler" + ;; + # root=ZFS=... syntax (grub) + "ZFS="*) + mount_handler="zfs_mount_handler" + ZFS_DATASET="${root#*[=]}" + ;; + esac + + case ${zfs} in "") # skip this line/dataset ;; auto|bootfs) - ZFS_DATASET='bootfs' + ZFS_DATASET="bootfs" mount_handler="zfs_mount_handler" + local pool="[a-zA-Z][^ ]*" ;; *) - ZFS_DATASET=$zfs + ZFS_DATASET="${zfs}" mount_handler="zfs_mount_handler" + local pool="${ZFS_DATASET%%/*}" ;; esac - if [ ! -f "/etc/hostid" ] ; then - echo "ZFS: No hostid found on kernel command line or /etc/hostid. ZFS pools may not import correctly." - fi - - # Allow up to 10 seconds for zfs device to show up - for i in 1 2 3 4 5 6 7 8 9 10; do - [ -c "/dev/zfs" ] && break + # Allow at least n seconds for zfs device to show up. Especially + # when using zfs_import_dir instead of zpool.cache, the listing of + # available pools can be slow, so this loop must be top-tested to + # ensure we do one 'zpool import' pass after the timer has expired. + sleep ${ZFS_WAIT} & pid=$! + local break_after=0 + while :; do + kill -0 $pid > /dev/null 2>&1 || break_after=1 + if [ -c "/dev/zfs" ]; then + zpool import ${ZPOOL_IMPORT_FLAGS} | awk " + BEGIN { pool_found=0; online=0; unavail=0 } + /^ ${pool} .*/ { pool_found=1 } + /^\$/ { pool_found=0 } + /UNAVAIL/ { if (pool_found == 1) { unavail=1 } } + /ONLINE/ { if (pool_found == 1) { online=1 } } + END { if (online == 1 && unavail != 1) + { exit 0 } + else + { exit 1 } + }" && break + fi + [ $break_after == 1 ] && break sleep 1 done + kill $pid > /dev/null 2>&1 } - run_latehook () { - /usr/bin/zpool import -N -a $ZPOOL_FORCE + set_flags + # only run zpool import, if flags were set (cache file found / zfs_import_dir specified) + [ ! "${ZPOOL_IMPORT_FLAGS}" = "" ] && zpool import ${ZPOOL_IMPORT_FLAGS} -N -a ${ZPOOL_FORCE} } # vim:set ts=4 sw=4 ft=sh et: diff --git a/zfs-utils.initcpio.install b/zfs-utils.initcpio.install index c128d1006371..8b646a101a04 100644 --- a/zfs-utils.initcpio.install +++ b/zfs-utils.initcpio.install @@ -7,34 +7,31 @@ build() { zunicode \ zcommon \ zfs \ - zpios \ - spl \ - splat \ - zlib_deflate + spl map add_binary \ arcstat.py \ dbufstat.py \ fsck.zfs \ mount.zfs \ + seq \ zdb \ zed \ zfs \ zhack \ zinject \ - zpios \ zpool \ zstreamdump \ ztest \ - splat \ - hostid \ /lib/udev/vdev_id \ - /lib/udev/zvol_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/udev/rules.d/90-zfs.rules \ + /lib/libgcc_s.so.1 map add_dir \ /etc/zfs/zed.d @@ -42,11 +39,10 @@ build() { add_runscript # allow mount(8) to "autodetect" ZFS - echo 'zfs' >>"$BUILDROOT/etc/filesystems" + echo 'zfs' >>"${BUILDROOT}/etc/filesystems" - [[ -f /etc/zfs/zpool.cache ]] && add_file "/etc/zfs/zpool.cache" + [[ -f /etc/zfs/zpool.cache ]] && cp "/etc/zfs/zpool.cache" "${BUILDROOT}/etc/zfs/zpool.cache.org" [[ -f /etc/modprobe.d/zfs.conf ]] && add_file "/etc/modprobe.d/zfs.conf" - [[ -f /etc/hostid ]] && add_file "/etc/hostid" } help() { @@ -73,6 +69,10 @@ Command Line Setup: 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 diff --git a/zfs-utils.initcpio.zfsencryptssh.install b/zfs-utils.initcpio.zfsencryptssh.install new file mode 100644 index 000000000000..e0ef04beabfe --- /dev/null +++ b/zfs-utils.initcpio.zfsencryptssh.install @@ -0,0 +1,39 @@ +#!/bin/bash + +make_etc_passwd() { + echo 'root:x:0:0:root:/root:/bin/zfsdecrypt_shell' > "${BUILDROOT}"/etc/passwd + echo '/bin/zfsdecrypt_shell' > "${BUILDROOT}"/etc/shells +} + +make_zfsdecrypt_shell() { + decrypt_shell='#!/bin/sh +if [ -f "/.encryptionroot" ]; then + # source zfs hook functions + . /hooks/zfs + # decrypt bootfs + zfs_decrypt_fs "$(cat /.encryptionroot)" + # kill pending decryption attempt to allow the boot process to continue + killall zfs +else + echo "ZFS is not ready yet. Please wait!" +fi' + printf '%s' "$decrypt_shell" > "${BUILDROOT}"/bin/zfsdecrypt_shell + chmod a+x "${BUILDROOT}"/bin/zfsdecrypt_shell +} + +build () +{ + make_etc_passwd + make_zfsdecrypt_shell +} + +help () +{ + cat<<HELPEOF +This hook is meant to be used in conjunction with mkinitcpio-dropbear, +mkinitcpio-netconf and/ormkinitcpio-ppp. This will provide a way to unlock +your encrypted ZFS root filesystem remotely. +HELPEOF +} + +# vim: set ts=4 sw=4 ft=sh et: diff --git a/zfs-utils.install b/zfs-utils.install new file mode 100644 index 000000000000..914ed46bf477 --- /dev/null +++ b/zfs-utils.install @@ -0,0 +1,18 @@ +post_upgrade() { + + # If upgrading from 2017.12.08.r3208.4e9b15696-1 or older + # display zfs-import warning + if [[ $(vercmp $2 2017.12.08.r3208.4e9b15696-1) -le 0 ]]; then + echo '>>> WARNING: A new systemd unit file was added to archzfs!' + echo '>>> You may need enable zfs-import.target' + echo '>>> See https://github.com/archzfs/archzfs/issues/186' + fi + + # If upgrading from 2018.02.02.r3272.1b66810ba-1 or older + # display encryption format change warning + if [[ $(vercmp $2 2018.02.02.r3272.1b66810ba-1) -le 0 ]]; then + echo '>>> WARNING: The on-disk format for encrypted datasets has changed!' + echo '>>> All encrypted datasets will mount read only and need to be migrated.' + echo '>>> See https://github.com/archzfs/archzfs/issues/222' + fi +} |