From aaebb1b66ed84a14a7dcbd070afab3c5334880ac Mon Sep 17 00:00:00 2001 From: Iacopo Isimbaldi Date: Mon, 11 Jan 2016 23:14:23 +0100 Subject: Updated zfs.install and hook Dropped "mkinitcpio-dkms" dep, replaced by zfs hook --- .SRCINFO | 11 +- PKGBUILD | 18 +- zfs-utils.bash-completion-r1 | 391 ------------------------------------------- zfs-utils.initcpio.hook | 100 ----------- zfs-utils.initcpio.install | 104 ------------ zfs.bash-completion-r1 | 391 +++++++++++++++++++++++++++++++++++++++++++ zfs.initcpio.hook | 100 +++++++++++ zfs.initcpio.install | 110 ++++++++++++ zfs.install | 35 +--- 9 files changed, 623 insertions(+), 637 deletions(-) delete mode 100644 zfs-utils.bash-completion-r1 delete mode 100644 zfs-utils.initcpio.hook delete mode 100644 zfs-utils.initcpio.install create mode 100644 zfs.bash-completion-r1 create mode 100644 zfs.initcpio.hook create mode 100644 zfs.initcpio.install diff --git a/.SRCINFO b/.SRCINFO index d725d81..9f95c86 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,5 +1,5 @@ # Generated by mksrcinfo v8 -# Sat Jan 9 16:21:11 UTC 2016 +# Mon Jan 11 22:24:44 UTC 2016 pkgbase = zfs-dkms pkgver = 0.6.5.4 pkgrel = 1 @@ -8,12 +8,12 @@ pkgbase = zfs-dkms arch = x86_64 license = CDDL source = https://github.com/zfsonlinux/zfs/releases/download/zfs-0.6.5.4/zfs-0.6.5.4.tar.gz - source = zfs-utils.bash-completion-r1 - source = zfs-utils.initcpio.install - source = zfs-utils.initcpio.hook + source = zfs.bash-completion-r1 + source = zfs.initcpio.install + source = zfs.initcpio.hook sha256sums = 780862ec2301ccace412a324787e9df762cff6046e73e2ac0ebdce9e2bd59b0f sha256sums = b60214f70ffffb62ffe489cbfabd2e069d14ed2a391fac0e36f914238394b540 - sha256sums = 1e20071fa61a33874505dae0f2d71bb560f43e7faaea735cbde770ea10c133df + sha256sums = 70930eee5b0f55ba587220b9530170d91ef1eea98a37de9ae38f963dee410b3a sha256sums = 250f1232c464a81cc9c8b8ee05f21d752ebeebbc8614fae1c6d0bc600e816ac1 pkgname = zfs-dkms @@ -22,7 +22,6 @@ pkgname = zfs-dkms depends = spl-dkms=0.6.5.4 depends = zfs-utils=0.6.5.4-1 depends = dkms - optdepends = mkinitcpio-dkms: Generate initramfs with zfs modules automatically provides = zfs conflicts = zfs-git conflicts = zfs-lts diff --git a/PKGBUILD b/PKGBUILD index 31e5806..32c2c7f 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -11,12 +11,12 @@ license=('CDDL') arch=("i686" "x86_64") url="http://zfsonlinux.org/" source=("https://github.com/zfsonlinux/zfs/releases/download/zfs-${pkgver}/zfs-${pkgver}.tar.gz" - "zfs-utils.bash-completion-r1" - "zfs-utils.initcpio.install" - "zfs-utils.initcpio.hook") + "zfs.bash-completion-r1" + "zfs.initcpio.install" + "zfs.initcpio.hook") sha256sums=('780862ec2301ccace412a324787e9df762cff6046e73e2ac0ebdce9e2bd59b0f' 'b60214f70ffffb62ffe489cbfabd2e069d14ed2a391fac0e36f914238394b540' - '1e20071fa61a33874505dae0f2d71bb560f43e7faaea735cbde770ea10c133df' + '70930eee5b0f55ba587220b9530170d91ef1eea98a37de9ae38f963dee410b3a' '250f1232c464a81cc9c8b8ee05f21d752ebeebbc8614fae1c6d0bc600e816ac1') build() { @@ -39,7 +39,6 @@ build() { package_zfs-dkms() { pkgdesc="Kernel modules for the Zettabyte File System." depends=("spl-dkms=${pkgver}" "zfs-utils=${pkgver}-${pkgrel}" "dkms") - optdepends=("mkinitcpio-dkms: Generate initramfs with zfs modules automatically") provides=("zfs") conflicts=("zfs-git" "zfs-lts") install=zfs.install @@ -71,7 +70,10 @@ package_zfs-utils() { cp -r "${pkgdir}"/{lib,usr} rm -r "${pkgdir}"/lib - 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.bash-completion-r1 "${pkgdir}"/usr/share/bash-completion/completions/zfs + install -D -m644 "${srcdir}"/zfs.initcpio.hook "${pkgdir}"/usr/lib/initcpio/hooks/zfs + install -D -m644 "${srcdir}"/zfs.bash-completion-r1 "${pkgdir}"/usr/share/bash-completion/completions/zfs + + mkdir -p "${pkgdir}"/usr/lib/initcpio/install + sed -e "s|##VERMARKER##|${pkgver}|" "${srcdir}"/zfs.initcpio.install > "${pkgdir}"/usr/lib/initcpio/install/zfs + chmod 644 "${pkgdir}"/usr/lib/initcpio/install/zfs } diff --git a/zfs-utils.bash-completion-r1 b/zfs-utils.bash-completion-r1 deleted file mode 100644 index b1aded3..0000000 --- a/zfs-utils.bash-completion-r1 +++ /dev/null @@ -1,391 +0,0 @@ -# Copyright (c) 2013, Aneurin Price - -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation -# files (the "Software"), to deal in the Software without -# restriction, including without limitation the rights to use, -# copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following -# conditions: - -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. - -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. - -#if [[ -w /dev/zfs ]]; then - __ZFS_CMD="zfs" - __ZPOOL_CMD="zpool" -#else -# __ZFS_CMD="sudo zfs" -# __ZPOOL_CMD="sudo zpool" -#fi - -__zfs_get_commands() -{ - $__ZFS_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | cut -f1 -d '|' | uniq -} - -__zfs_get_properties() -{ - $__ZFS_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all name space -} - -__zfs_get_editable_properties() -{ - $__ZFS_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' -} - -__zfs_get_inheritable_properties() -{ - $__ZFS_CMD get 2>&1 | awk '$3 == "YES" {print $1}' -} - -__zfs_list_datasets() -{ - $__ZFS_CMD list -H -o name -t filesystem,volume -} - -__zfs_list_filesystems() -{ - $__ZFS_CMD list -H -o name -t filesystem -} - -__zfs_match_snapshot() -{ - local base_dataset=${cur%@*} - if [[ $base_dataset != $cur ]] - then - $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset - else - $__ZFS_CMD list -H -o name -t filesystem,volume | awk '{print $1"@"}' - fi -} - -__zfs_match_explicit_snapshot() -{ - local base_dataset=${cur%@*} - if [[ $base_dataset != $cur ]] - then - $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset - fi -} - -__zfs_match_multiple_snapshots() -{ - local existing_opts=$(expr "$cur" : '\(.*\)[%,]') - if [[ $existing_opts ]] - then - local base_dataset=${cur%@*} - if [[ $base_dataset != $cur ]] - then - local cur=${cur##*,} - if [[ $cur =~ ^%|%.*% ]] - then - # correct range syntax is start%end - return 1 - fi - local range_start=$(expr "$cur" : '\(.*%\)') - $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g' - fi - else - __zfs_match_explicit_snapshot; __zfs_list_datasets - fi -} - -__zfs_list_volumes() -{ - $__ZFS_CMD list -H -o name -t volume -} - -__zfs_argument_chosen() -{ - local word property - for word in $(seq $((COMP_CWORD-1)) -1 2) - do - local prev="${COMP_WORDS[$word]}" - if [[ ${COMP_WORDS[$word-1]} != -[tos] ]] - then - if [[ "$prev" == [^,]*,* ]] || [[ "$prev" == *[@:]* ]] - then - return 0 - fi - for property in $@ - do - if [[ $prev == "$property" ]] - then - return 0 - fi - done - fi - done - return 1 -} - -__zfs_complete_ordered_arguments() -{ - local list1=$1 - local list2=$2 - local cur=$3 - local extra=$4 - if __zfs_argument_chosen $list1 - then - COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur")) - else - COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur")) - fi -} - -__zfs_complete_multiple_options() -{ - local options=$1 - local cur=$2 - - COMPREPLY=($(compgen -W "$options" -- "${cur##*,}")) - local existing_opts=$(expr "$cur" : '\(.*,\)') - if [[ $existing_opts ]] - then - COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" ) - fi -} - -__zfs_complete_switch() -{ - local options=$1 - if [[ ${cur:0:1} == - ]] - then - COMPREPLY=($(compgen -W "-{$options}" -- "$cur")) - return 0 - else - return 1 - fi -} - -__zfs_complete() -{ - local cur prev cmd cmds - COMPREPLY=() - # Don't split on colon - _get_comp_words_by_ref -n : -c cur -p prev -w COMP_WORDS -i COMP_CWORD - cmd="${COMP_WORDS[1]}" - - if [[ ${prev##*/} == zfs ]] - then - cmds=$(__zfs_get_commands) - COMPREPLY=($(compgen -W "$cmds -?" -- "$cur")) - return 0 - fi - - case "${cmd}" in - clone) - case "${prev}" in - -o) - COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) - ;; - *) - if ! __zfs_complete_switch "o,p" - then - if __zfs_argument_chosen - then - COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur")) - else - COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) - fi - fi - ;; - esac - ;; - get) - case "${prev}" in - -d) - COMPREPLY=($(compgen -W "" -- "$cur")) - ;; - -t) - __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" - ;; - -s) - __zfs_complete_multiple_options "local default inherited temporary none" "$cur" - ;; - -o) - __zfs_complete_multiple_options "name property value source received all" "$cur" - ;; - *) - if ! __zfs_complete_switch "H,r,p,d,o,t,s" - then - if __zfs_argument_chosen $(__zfs_get_properties) - then - COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) - else - __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" - fi - fi - ;; - esac - ;; - inherit) - if ! __zfs_complete_switch "r" - then - __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur - fi - ;; - list) - case "${prev}" in - -d) - COMPREPLY=($(compgen -W "" -- "$cur")) - ;; - -t) - __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" - ;; - -o) - __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" - ;; - -s|-S) - COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "$cur")) - ;; - *) - if ! __zfs_complete_switch "H,r,d,o,t,s,S" - then - COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) - fi - ;; - esac - ;; - promote) - COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) - ;; - rollback) - if ! __zfs_complete_switch "r,R,f" - then - COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) - fi - ;; - send) - if ! __zfs_complete_switch "d,n,P,p,R,v,i,I" - then - COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) - fi - ;; - snapshot) - case "${prev}" in - -o) - COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) - ;; - *) - if ! __zfs_complete_switch "o,r" - then - COMPREPLY=($(compgen -W "$(__zfs_list_datasets | awk '{print $1"@"}')" -- "$cur")) - fi - ;; - esac - ;; - set) - __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur - ;; - upgrade) - case "${prev}" in - -a|-V|-v) - COMPREPLY=($(compgen -W "" -- "$cur")) - ;; - *) - if ! __zfs_complete_switch "a,V,v,r" - then - COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) - fi - ;; - esac - ;; - destroy) - if ! __zfs_complete_switch "d,f,n,p,R,r,v" - then - __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur - fi - ;; - *) - COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) - ;; - esac - __ltrim_colon_completions "$cur" - return 0 -} - -__zpool_get_commands() -{ - $__ZPOOL_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq -} - -__zpool_get_properties() -{ - $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all -} - -__zpool_get_editable_properties() -{ - $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' -} - -__zpool_list_pools() -{ - $__ZPOOL_CMD list -H -o name -} - -__zpool_complete() -{ - local cur prev cmd cmds - COMPREPLY=() - cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - cmd="${COMP_WORDS[1]}" - - if [[ ${prev##*/} == zpool ]] - then - cmds=$(__zpool_get_commands) - COMPREPLY=($(compgen -W "$cmds" -- "$cur")) - return 0 - fi - - case "${cmd}" in - get) - __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur - return 0 - ;; - import) - if [[ $prev == -d ]] - then - _filedir -d - else - COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur")) - fi - return 0 - ;; - set) - __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur - return 0 - ;; - add|attach|clear|create|detach|offline|online|remove|replace) - local pools="$(__zpool_list_pools)" - if __zfs_argument_chosen $pools - then - _filedir - else - COMPREPLY=($(compgen -W "$pools" -- "$cur")) - fi - return 0 - ;; - *) - COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur")) - return 0 - ;; - esac - -} - -complete -F __zfs_complete zfs -complete -F __zpool_complete zpool diff --git a/zfs-utils.initcpio.hook b/zfs-utils.initcpio.hook deleted file mode 100644 index 3a92894..0000000 --- a/zfs-utils.initcpio.hook +++ /dev/null @@ -1,100 +0,0 @@ -ZPOOL_FORCE="" -ZPOOL_IMPORT_FLAGS="" - -zfs_get_bootfs () { - for zfs_dataset in $(/usr/bin/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 () { - local node=$1 - 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 - if ! zfs_get_bootfs ; then - echo "ZFS: Cannot find bootfs." - return 1 - fi - fi - fi - - local pool="${ZFS_DATASET%%/*}" - 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" - else - 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 - 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 -} - -run_hook() { - # Force import the pools, useful if the pool has not properly been exported - # using 'zpool export ' - [[ $zfs_force == 1 ]] && ZPOOL_FORCE='-f' - [[ "$zfs_import_dir" != "" ]] && ZPOOL_IMPORT_FLAGS="$ZPOOL_IMPORT_FLAGS -d $zfs_import_dir" - - if [ "$root" = 'zfs' ]; then - mount_handler='zfs_mount_handler' - fi - - 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 - - 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 - sleep 1 - done -} - - -run_latehook () { - /usr/bin/zpool import -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 deleted file mode 100644 index c128d10..0000000 --- a/zfs-utils.initcpio.install +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/bash - -build() { - map add_module \ - zavl \ - znvpair \ - zunicode \ - zcommon \ - zfs \ - zpios \ - spl \ - splat \ - zlib_deflate - - map add_binary \ - arcstat.py \ - dbufstat.py \ - fsck.zfs \ - mount.zfs \ - zdb \ - zed \ - zfs \ - zhack \ - zinject \ - zpios \ - zpool \ - zstreamdump \ - ztest \ - splat \ - hostid \ - /lib/udev/vdev_id \ - /lib/udev/zvol_id - - map add_file \ - /lib/udev/rules.d/60-zvol.rules \ - /lib/udev/rules.d/69-vdev.rules \ - /lib/udev/rules.d/90-zfs.rules - - 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 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: diff --git a/zfs.bash-completion-r1 b/zfs.bash-completion-r1 new file mode 100644 index 0000000..b1aded3 --- /dev/null +++ b/zfs.bash-completion-r1 @@ -0,0 +1,391 @@ +# Copyright (c) 2013, Aneurin Price + +# Permission is hereby granted, free of charge, to any person +# obtaining a copy of this software and associated documentation +# files (the "Software"), to deal in the Software without +# restriction, including without limitation the rights to use, +# copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the +# Software is furnished to do so, subject to the following +# conditions: + +# The above copyright notice and this permission notice shall be +# included in all copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +# OTHER DEALINGS IN THE SOFTWARE. + +#if [[ -w /dev/zfs ]]; then + __ZFS_CMD="zfs" + __ZPOOL_CMD="zpool" +#else +# __ZFS_CMD="sudo zfs" +# __ZPOOL_CMD="sudo zpool" +#fi + +__zfs_get_commands() +{ + $__ZFS_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | cut -f1 -d '|' | uniq +} + +__zfs_get_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all name space +} + +__zfs_get_editable_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' +} + +__zfs_get_inheritable_properties() +{ + $__ZFS_CMD get 2>&1 | awk '$3 == "YES" {print $1}' +} + +__zfs_list_datasets() +{ + $__ZFS_CMD list -H -o name -t filesystem,volume +} + +__zfs_list_filesystems() +{ + $__ZFS_CMD list -H -o name -t filesystem +} + +__zfs_match_snapshot() +{ + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset + else + $__ZFS_CMD list -H -o name -t filesystem,volume | awk '{print $1"@"}' + fi +} + +__zfs_match_explicit_snapshot() +{ + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset + fi +} + +__zfs_match_multiple_snapshots() +{ + local existing_opts=$(expr "$cur" : '\(.*\)[%,]') + if [[ $existing_opts ]] + then + local base_dataset=${cur%@*} + if [[ $base_dataset != $cur ]] + then + local cur=${cur##*,} + if [[ $cur =~ ^%|%.*% ]] + then + # correct range syntax is start%end + return 1 + fi + local range_start=$(expr "$cur" : '\(.*%\)') + $__ZFS_CMD list -H -o name -t snapshot -d 1 $base_dataset | sed 's$.*@$'$range_start'$g' + fi + else + __zfs_match_explicit_snapshot; __zfs_list_datasets + fi +} + +__zfs_list_volumes() +{ + $__ZFS_CMD list -H -o name -t volume +} + +__zfs_argument_chosen() +{ + local word property + for word in $(seq $((COMP_CWORD-1)) -1 2) + do + local prev="${COMP_WORDS[$word]}" + if [[ ${COMP_WORDS[$word-1]} != -[tos] ]] + then + if [[ "$prev" == [^,]*,* ]] || [[ "$prev" == *[@:]* ]] + then + return 0 + fi + for property in $@ + do + if [[ $prev == "$property" ]] + then + return 0 + fi + done + fi + done + return 1 +} + +__zfs_complete_ordered_arguments() +{ + local list1=$1 + local list2=$2 + local cur=$3 + local extra=$4 + if __zfs_argument_chosen $list1 + then + COMPREPLY=($(compgen -W "$list2 $extra" -- "$cur")) + else + COMPREPLY=($(compgen -W "$list1 $extra" -- "$cur")) + fi +} + +__zfs_complete_multiple_options() +{ + local options=$1 + local cur=$2 + + COMPREPLY=($(compgen -W "$options" -- "${cur##*,}")) + local existing_opts=$(expr "$cur" : '\(.*,\)') + if [[ $existing_opts ]] + then + COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" ) + fi +} + +__zfs_complete_switch() +{ + local options=$1 + if [[ ${cur:0:1} == - ]] + then + COMPREPLY=($(compgen -W "-{$options}" -- "$cur")) + return 0 + else + return 1 + fi +} + +__zfs_complete() +{ + local cur prev cmd cmds + COMPREPLY=() + # Don't split on colon + _get_comp_words_by_ref -n : -c cur -p prev -w COMP_WORDS -i COMP_CWORD + cmd="${COMP_WORDS[1]}" + + if [[ ${prev##*/} == zfs ]] + then + cmds=$(__zfs_get_commands) + COMPREPLY=($(compgen -W "$cmds -?" -- "$cur")) + return 0 + fi + + case "${cmd}" in + clone) + case "${prev}" in + -o) + COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "o,p" + then + if __zfs_argument_chosen + then + COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur")) + else + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + fi + ;; + esac + ;; + get) + case "${prev}" in + -d) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + -t) + __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" + ;; + -s) + __zfs_complete_multiple_options "local default inherited temporary none" "$cur" + ;; + -o) + __zfs_complete_multiple_options "name property value source received all" "$cur" + ;; + *) + if ! __zfs_complete_switch "H,r,p,d,o,t,s" + then + if __zfs_argument_chosen $(__zfs_get_properties) + then + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + else + __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" + fi + fi + ;; + esac + ;; + inherit) + if ! __zfs_complete_switch "r" + then + __zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur + fi + ;; + list) + case "${prev}" in + -d) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + -t) + __zfs_complete_multiple_options "filesystem volume snapshot all" "$cur" + ;; + -o) + __zfs_complete_multiple_options "$(__zfs_get_properties)" "$cur" + ;; + -s|-S) + COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "H,r,d,o,t,s,S" + then + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + fi + ;; + esac + ;; + promote) + COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) + ;; + rollback) + if ! __zfs_complete_switch "r,R,f" + then + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + ;; + send) + if ! __zfs_complete_switch "d,n,P,p,R,v,i,I" + then + COMPREPLY=($(compgen -W "$(__zfs_match_snapshot)" -- "$cur")) + fi + ;; + snapshot) + case "${prev}" in + -o) + COMPREPLY=($(compgen -W "$(__zfs_get_editable_properties)" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "o,r" + then + COMPREPLY=($(compgen -W "$(__zfs_list_datasets | awk '{print $1"@"}')" -- "$cur")) + fi + ;; + esac + ;; + set) + __zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" $cur + ;; + upgrade) + case "${prev}" in + -a|-V|-v) + COMPREPLY=($(compgen -W "" -- "$cur")) + ;; + *) + if ! __zfs_complete_switch "a,V,v,r" + then + COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) + fi + ;; + esac + ;; + destroy) + if ! __zfs_complete_switch "d,f,n,p,R,r,v" + then + __zfs_complete_multiple_options "$(__zfs_match_multiple_snapshots)" $cur + fi + ;; + *) + COMPREPLY=($(compgen -W "$(__zfs_match_explicit_snapshot) $(__zfs_list_datasets)" -- "$cur")) + ;; + esac + __ltrim_colon_completions "$cur" + return 0 +} + +__zpool_get_commands() +{ + $__ZPOOL_CMD 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq +} + +__zpool_get_properties() +{ + $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all +} + +__zpool_get_editable_properties() +{ + $__ZPOOL_CMD get 2>&1 | awk '$2 == "YES" {print $1"="}' +} + +__zpool_list_pools() +{ + $__ZPOOL_CMD list -H -o name +} + +__zpool_complete() +{ + local cur prev cmd cmds + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + cmd="${COMP_WORDS[1]}" + + if [[ ${prev##*/} == zpool ]] + then + cmds=$(__zpool_get_commands) + COMPREPLY=($(compgen -W "$cmds" -- "$cur")) + return 0 + fi + + case "${cmd}" in + get) + __zfs_complete_ordered_arguments "$(__zpool_get_properties)" "$(__zpool_list_pools)" $cur + return 0 + ;; + import) + if [[ $prev == -d ]] + then + _filedir -d + else + COMPREPLY=($(compgen -W "$(__zpool_list_pools) -d" -- "$cur")) + fi + return 0 + ;; + set) + __zfs_complete_ordered_arguments "$(__zpool_get_editable_properties)" "$(__zpool_list_pools)" $cur + return 0 + ;; + add|attach|clear|create|detach|offline|online|remove|replace) + local pools="$(__zpool_list_pools)" + if __zfs_argument_chosen $pools + then + _filedir + else + COMPREPLY=($(compgen -W "$pools" -- "$cur")) + fi + return 0 + ;; + *) + COMPREPLY=($(compgen -W "$(__zpool_list_pools)" -- "$cur")) + return 0 + ;; + esac + +} + +complete -F __zfs_complete zfs +complete -F __zpool_complete zpool diff --git a/zfs.initcpio.hook b/zfs.initcpio.hook new file mode 100644 index 0000000..3a92894 --- /dev/null +++ b/zfs.initcpio.hook @@ -0,0 +1,100 @@ +ZPOOL_FORCE="" +ZPOOL_IMPORT_FLAGS="" + +zfs_get_bootfs () { + for zfs_dataset in $(/usr/bin/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 () { + local node=$1 + 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 + if ! zfs_get_bootfs ; then + echo "ZFS: Cannot find bootfs." + return 1 + fi + fi + fi + + local pool="${ZFS_DATASET%%/*}" + 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" + else + 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 + 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 +} + +run_hook() { + # Force import the pools, useful if the pool has not properly been exported + # using 'zpool export ' + [[ $zfs_force == 1 ]] && ZPOOL_FORCE='-f' + [[ "$zfs_import_dir" != "" ]] && ZPOOL_IMPORT_FLAGS="$ZPOOL_IMPORT_FLAGS -d $zfs_import_dir" + + if [ "$root" = 'zfs' ]; then + mount_handler='zfs_mount_handler' + fi + + 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 + + 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 + sleep 1 + done +} + + +run_latehook () { + /usr/bin/zpool import -N -a $ZPOOL_FORCE +} + +# vim:set ts=4 sw=4 ft=sh et: diff --git a/zfs.initcpio.install b/zfs.initcpio.install new file mode 100644 index 0000000..e192c3b --- /dev/null +++ b/zfs.initcpio.install @@ -0,0 +1,110 @@ +#!/bin/bash + +build() { + echo -en "Build spl module for ${KERNELVERSION} kernel... " + $(which dkms) install -m spl -v ##VERMARKER## -k ${KERNELVERSION} -q + echo -en "Done.\nBuild zfs module for ${KERNELVERSION} kernel... " + $(which dkms) install -m zfs -v ##VERMARKER## -k ${KERNELVERSION} -q + echo "Done." + + map add_module \ + zavl \ + znvpair \ + zunicode \ + zcommon \ + zfs \ + zpios \ + spl \ + splat \ + zlib_deflate + + map add_binary \ + arcstat.py \ + dbufstat.py \ + fsck.zfs \ + mount.zfs \ + zdb \ + zed \ + zfs \ + zhack \ + zinject \ + zpios \ + zpool \ + zstreamdump \ + ztest \ + splat \ + hostid \ + /lib/udev/vdev_id \ + /lib/udev/zvol_id + + map add_file \ + /lib/udev/rules.d/60-zvol.rules \ + /lib/udev/rules.d/69-vdev.rules \ + /lib/udev/rules.d/90-zfs.rules + + 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 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: diff --git a/zfs.install b/zfs.install index b8d2f40..28e3d16 100644 --- a/zfs.install +++ b/zfs.install @@ -4,41 +4,20 @@ post_install() { ==> To build and install your modules run: dkms install zfs/${1%%[_-]*} -k [KERNEL] ==> To do this automatically at startup run: systemctl enable dkms.service EOF - check_initramfs "install" } pre_upgrade() { - pre_remove "$2" + if [ "${1%%[-_]*}" != "${2%%[-_]*}" ]; then + pre_remove "$2" + fi } post_upgrade() { - post_install "$1" + if [ "${1%%[-_]*}" != "${2%%[-_]*}" ]; then + post_install "$1" + fi } pre_remove() { - [ -n "${1%%[-_]*}" ] && dkms remove zfs/${1%%[-_]*} --all &>/dev/null || true -} - -post_remove() { - check_initramfs "remove" -} - -check_initramfs() { - if grep -v '#' /etc/mkinitcpio.conf | grep zfs >/dev/null; then - if [[ $1 == 'remove' ]]; then - echo '==> The ZFS packages have been removed, but "zfs" remains in the "hooks"' - echo '==> list in mkinitcpio.conf! You will need to remove "zfs" from the ' - echo '==> "hooks" list and then regenerate the initial ramdisk.' - elif grep -v '#' /etc/mkinitcpio.conf | grep dkms >/dev/null; then - echo '==> Generating initial ramdisk automatically (mkinitcpio-dkms found)' - for preset in /etc/mkinitcpio.d/*.preset; do - mkinitcpio -p "$(basename "$preset" .preset)" - done - else - echo '==> The ZFS packages are installed/updated, you need to (re)generate initial ramdisk yourself' - echo '==> After modules are built and installed, run: mkinitcpio -p [PRESET]' - echo '==> To do it automatically, you can also install mkinitcpio-dkms package' - echo '==> and add "dkms" to HOOKSs (before zfs)' - fi - fi + [ -n "${1%%[-_]*}" ] && dkms remove zfs/${1%%[-_]*} --all -q || true } -- cgit v1.2.1 From 9255857b6e7e5d630492d2853458fb64fd49c049 Mon Sep 17 00:00:00 2001 From: Iacopo Isimbaldi Date: Mon, 11 Jan 2016 23:56:21 +0100 Subject: Bump to pkgrel 3 Removed unused files --- .SRCINFO | 6 +++--- PKGBUILD | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.SRCINFO b/.SRCINFO index 9f95c86..3dd15bd 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,8 +1,8 @@ # Generated by mksrcinfo v8 -# Mon Jan 11 22:24:44 UTC 2016 +# Mon Jan 11 22:56:11 UTC 2016 pkgbase = zfs-dkms pkgver = 0.6.5.4 - pkgrel = 1 + pkgrel = 3 url = http://zfsonlinux.org/ arch = i686 arch = x86_64 @@ -20,7 +20,7 @@ pkgname = zfs-dkms pkgdesc = Kernel modules for the Zettabyte File System. install = zfs.install depends = spl-dkms=0.6.5.4 - depends = zfs-utils=0.6.5.4-1 + depends = zfs-utils=0.6.5.4-3 depends = dkms provides = zfs conflicts = zfs-git diff --git a/PKGBUILD b/PKGBUILD index 32c2c7f..6d4bf7f 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -6,7 +6,7 @@ pkgbase="zfs-dkms" pkgname=("zfs-dkms" "zfs-utils") pkgver=0.6.5.4 -pkgrel=1 +pkgrel=3 license=('CDDL') arch=("i686" "x86_64") url="http://zfsonlinux.org/" @@ -50,7 +50,6 @@ package_zfs-dkms() { tar -xzf "zfs-${pkgver}.tar.gz" -C "${dkmsdir}" --strip-components 1 cd "${dkmsdir}" - ./autogen.sh scripts/dkms.mkconf -v ${pkgver} -f dkms.conf -n zfs chmod g-w,o-w -R . } @@ -65,6 +64,7 @@ package_zfs-utils() { # Remove uneeded files rm -r "${pkgdir}"/etc/init.d rm -r "${pkgdir}"/usr/lib/dracut + rm -r "${pkgdir}"/usr/share/initramfs-tools # move module tree /lib -> /usr/lib cp -r "${pkgdir}"/{lib,usr} -- cgit v1.2.1