mirror of https://github.com/archzfs/archzfs
parent
8b701935fb
commit
3ba7648e42
@ -0,0 +1,67 @@ |
||||
# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com> |
||||
# Contributor: Kyle Fuller <inbox at kylefuller dot co dot uk> |
||||
|
||||
pkgname="spl-git" |
||||
pkgver=0.6.2_3.14 |
||||
pkgrel=1 |
||||
|
||||
# Used incase the i686 and x86_64 linux packages get out of sync with the |
||||
# PKGREL. This occurred on January 31, 2014 where i686 was versioned at |
||||
# 3.12.9-1 and x86_64 was versioned at 3.12.9-2. |
||||
_kernel_version_x32="3.14-4" |
||||
_kernel_version_x64="3.14-4" |
||||
|
||||
[[ $CARCH == "i686" ]] && _kernel_version=$_kernel_version_x32 || |
||||
_kernel_version=$_kernel_version_x64 |
||||
|
||||
# If _kernel_version does not have a minor version, we need to add "0" as the |
||||
# minor version for the kernel module path. Kernel modules for linux versions |
||||
# with no minor version (i.e. 3.14) are kept in /usr/lib/modules/3.14.0-4-ARCH |
||||
[[ $_kernel_version =~ ^[:digit:]+\.[:digit:]+\.([:digit:]+)\-[:digit:]+ ]] |
||||
if [[ ${BASH_REMATCH[1]} == "" ]]; then |
||||
[[ $_kernel_version =~ ^([[:digit:]\.]+)\-([[:digit:]]+) ]] && |
||||
_kernel_version_base=${BASH_REMATCH[1]}; |
||||
_kernel_version_pkgrel=${BASH_REMATCH[2]} |
||||
_kernel_version=${_kernel_version_base}.0-${_kernel_version_pkgrel} |
||||
fi |
||||
|
||||
pkgdesc="Solaris Porting Layer kernel modules." |
||||
depends=("spl-utils-git" "linux=$LINUX_VERSION") |
||||
makedepends=("git", "linux-headers=$LINUX_VERSION") |
||||
arch=("i686" "x86_64") |
||||
url="http://zfsonlinux.org/" |
||||
source=("git+https://github.com/zfsonlinux/zfs.git") |
||||
groups=("archzfs") |
||||
md5sums=('SKIP') |
||||
license=("GPL") |
||||
install=spl.install |
||||
provides=("spl") |
||||
conflicts=("spl") |
||||
|
||||
pkgver() { |
||||
cd "${srcdir}/spl" |
||||
# cutting off 'spl-' prefix that presents in the git tag |
||||
echo $(git describe --long | \ |
||||
sed -r 's/^spl-//;s/([^-]*-g)/r\1/;s/-/./g')_${_kernver} |
||||
} |
||||
|
||||
build() { |
||||
cd "$srcdir/spl" |
||||
./autogen.sh |
||||
|
||||
_at_enable="" |
||||
[ "${CARCH}" == "i686" ] && _at_enable="--enable-atomic-spinlocks" |
||||
|
||||
./configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/bin \ |
||||
--with-linux=/usr/lib/modules/$MOD_BASENAME/build \ |
||||
--with-config=kernel ${_at_enable} |
||||
make |
||||
} |
||||
|
||||
package() { |
||||
cd "${srcdir}/spl" |
||||
make DESTDIR="${pkgdir}" install |
||||
|
||||
mv "${pkgdir}/lib" "${pkgdir}/usr/" |
||||
sed -i "s+${srcdir}++" ${pkgdir}/usr/src/spl-*/${_kernfullpkgver}-ARCH/Module.symvers |
||||
} |
@ -0,0 +1,39 @@ |
||||
post_install() { |
||||
check_hostid |
||||
run_depmod |
||||
} |
||||
|
||||
post_remove() { |
||||
run_depmod |
||||
} |
||||
|
||||
post_upgrade() { |
||||
check_hostid |
||||
run_depmod |
||||
} |
||||
|
||||
check_hostid() { |
||||
# Check /etc/hostid to see if it set to the sentinel value, see |
||||
# https://wiki.archlinux.org/index.php/ZFS for more information. |
||||
HOSTID=$(hostid) |
||||
if [ "0x$HOSTID" == "0xffffffff" ]; then |
||||
# Generate a new hostid |
||||
: >/etc/hostid |
||||
HOSTID=$(hostid) |
||||
# hostid is 4 byte little endian |
||||
printf $(echo -n $HOSTID | sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/') >/etc/hostid |
||||
fi |
||||
} |
||||
|
||||
run_depmod() { |
||||
echo ">>> Updating module dependencies. Please wait ..." |
||||
# `uname -r` returns the current running kernel version, we need the |
||||
# currently installed kernel version. |
||||
KERNEL_VERSION=$(pacman -Qi linux | sed -n 2p | cut -d: -f2) |
||||
# For cases when the kernel version is 3.8, 3.9 |
||||
LINUX_VER=$(echo $KERNEL_VERSION | cut -d- -f1) |
||||
if [ $(grep -o "\." <<<"$LINUX_VER" | wc -l) -eq 1 ]; then |
||||
KERNEL_VERSION="${LINUX_VER}.0-${KERNEL_VERSION:(-1)}" |
||||
fi |
||||
depmod $(basename $(find /usr/lib/modules -type d -iname $KERNEL_VERSION\*)) |
||||
} |
@ -0,0 +1,45 @@ |
||||
# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com> |
||||
# Contributor: Kyle Fuller <inbox at kylefuller dot co dot uk> |
||||
|
||||
pkgname="spl-utils-git" |
||||
# |
||||
# This script doesn't use bash variables for the version number because AUR |
||||
# doesn't properly parse bash variables. We use a custom build script to |
||||
# automatically change the appropriate variables before building in a clean |
||||
# chroot environment (using systemd-ndspawn). |
||||
# |
||||
# The build script can be found at |
||||
# https://github.com/demizer/archzfs/blob/master/build.sh |
||||
# |
||||
pkgver= |
||||
pkgrel=1 |
||||
pkgdesc="Solaris Porting Layer kernel module support files." |
||||
arch=("i686" "x86_64") |
||||
url="http://zfsonlinux.org/" |
||||
source=("git+https://github.com/zfsonlinux/zfs.git" |
||||
"spl-utils.hostid") |
||||
groups=("archzfs") |
||||
md5sums=() |
||||
license=("GPL") |
||||
provides=("spl-utils") |
||||
conflicts=("spl-utils") |
||||
|
||||
build() { |
||||
cd "$srcdir/spl" |
||||
./autogen.sh |
||||
if [[ $CARCH == "i686" ]]; then |
||||
./configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/bin \ |
||||
--with-config=user |
||||
else |
||||
./configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/bin \ |
||||
--with-config=user |
||||
fi |
||||
make |
||||
} |
||||
|
||||
package() { |
||||
cd "$srcdir/spl" |
||||
make DESTDIR="$pkgdir" install |
||||
|
||||
install -D -m644 "$srcdir"/spl-utils.hostid "$pkgdir"/etc/hostid |
||||
} |
@ -0,0 +1,83 @@ |
||||
# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com> |
||||
# Contributor: Kyle Fuller <inbox at kylefuller dot co dot uk> |
||||
# See http://github.com/demizer/archzfs for build scripts. |
||||
|
||||
pkgname="zfs-git" |
||||
pkgver=0.6.2_3.14 |
||||
pkgrel=2 |
||||
|
||||
# Used incase the i686 and x86_64 linux packages get out of sync with the |
||||
# PKGREL. This occurred on January 31, 2014 where i686 was versioned at |
||||
# 3.12.9-1 and x86_64 was versioned at 3.12.9-2. |
||||
_kernel_version_x32="3.14-4" |
||||
_kernel_version_x64="3.14-4" |
||||
|
||||
[[ $CARCH == "i686" ]] && _kernel_version=$_kernel_version_x32 || |
||||
_kernel_version=$_kernel_version_x64 |
||||
|
||||
# If _kernel_version does not have a minor version, we need to add "0" as the |
||||
# minor version for the kernel module path. Kernel modules for linux versions |
||||
# with no minor version (i.e. 3.14) are kept in /usr/lib/modules/3.14.0-4-ARCH |
||||
[[ $_kernel_version =~ ^[:digit:]+\.[:digit:]+\.([:digit:]+)\-[:digit:]+ ]] |
||||
if [[ ${BASH_REMATCH[1]} == "" ]]; then |
||||
[[ $_kernel_version =~ ^([[:digit:]\.]+)\-([[:digit:]]+) ]] && |
||||
_kernel_version_base=${BASH_REMATCH[1]}; |
||||
_kernel_version_pkgrel=${BASH_REMATCH[2]} |
||||
_kernel_version=${_kernel_version_base}.0-${_kernel_version_pkgrel} |
||||
fi |
||||
|
||||
pkgdesc="Kernel modules for the Zettabyte File System." |
||||
depends=("spl=0.6.2_3.14-2" "zfs-utils" "linux=$LINUX_VERSION") |
||||
makedepends=("linux-headers=$LINUX_VERSION") |
||||
arch=("i686" "x86_64") |
||||
url="http://zfsonlinux.org/" |
||||
source=(http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-0.6.2.tar.gz |
||||
http://demizerone.com/patches/20140411-zfs-git-master.patch) |
||||
groups=("archzfs") |
||||
md5sums=('0b183b0abdd5be287046ad9ce4f899fd' |
||||
'b7632a5a80d474272d1de046b6da5f81') |
||||
license=("CDDL") |
||||
install=zfs.install |
||||
|
||||
prepare() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
patch -Np1 < ../20140411-zfs-git-master.patch |
||||
} |
||||
|
||||
build() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
./autogen.sh |
||||
if [[ $CARCH == "i686" ]]; then |
||||
./configure --prefix=/usr \ |
||||
--sysconfdir=/etc \ |
||||
--sbindir=/usr/bin \ |
||||
--libdir=/usr/lib \ |
||||
--datadir=/usr/share \ |
||||
--includedir=/usr/include \ |
||||
--with-udevdir=/lib/udev \ |
||||
--libexecdir=/usr/lib/zfs-0.6.2 \ |
||||
--with-config=kernel \ |
||||
--with-linux=/usr/lib/modules/$MOD_BASENAME/build |
||||
else |
||||
./configure --prefix=/usr \ |
||||
--sysconfdir=/etc \ |
||||
--sbindir=/usr/bin \ |
||||
--libdir=/usr/lib \ |
||||
--datadir=/usr/share \ |
||||
--includedir=/usr/include \ |
||||
--with-udevdir=/lib/udev \ |
||||
--libexecdir=/usr/lib/zfs-0.6.2 \ |
||||
--with-config=kernel \ |
||||
--with-linux=/usr/lib/modules/$MOD_BASENAME/build |
||||
fi |
||||
make |
||||
} |
||||
|
||||
package() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
make DESTDIR="$pkgdir" install |
||||
|
||||
# move module tree /lib -> /usr/lib |
||||
cp -r "$pkgdir"/{lib,usr} |
||||
rm -r "$pkgdir"/lib |
||||
} |
@ -0,0 +1,35 @@ |
||||
post_install() { |
||||
check_initramfs |
||||
} |
||||
|
||||
post_remove() { |
||||
check_initramfs 'remove' |
||||
} |
||||
|
||||
post_upgrade() { |
||||
check_initramfs |
||||
} |
||||
|
||||
check_initramfs() { |
||||
echo ">>> Updating module dependencies. Please wait ..." |
||||
# `uname -r` returns the current running kernel version, we need the |
||||
# currently installed kernel version. |
||||
KERNEL_VERSION=$(pacman -Qi linux | sed -n 2p | cut -d: -f2) |
||||
# For cases when the kernel version is 3.8, 3.9 |
||||
LINUX_VER=$(echo $KERNEL_VERSION | cut -d- -f1) |
||||
if [ $(grep -o "\." <<<"$LINUX_VER" | wc -l) -eq 1 ]; then |
||||
KERNEL_VERSION="${LINUX_VER}.0-${KERNEL_VERSION:(-1)}" |
||||
fi |
||||
depmod $(basename $(find /usr/lib/modules -type d -iname $KERNEL_VERSION\*)) |
||||
MK_CONF=$(grep -v '#' /etc/mkinitcpio.conf | grep zfs >/dev/null; echo $?); |
||||
if [[ $MK_CONF == '0' ]]; 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.' |
||||
else |
||||
echo ">>> Generating initial ramdisk, using mkinitcpio. Please wait..." |
||||
mkinitcpio -p linux |
||||
fi |
||||
fi |
||||
} |
@ -0,0 +1,89 @@ |
||||
# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com> |
||||
# Contributor: Kyle Fuller <inbox at kylefuller dot co dot uk> |
||||
|
||||
pkgname="zfs-utils-git" |
||||
|
||||
# |
||||
# This script doesn't use bash variables for the version number because AUR |
||||
# doesn't properly parse bash variables. We use a custom build script to |
||||
# automatically change the appropriate variables before building in a clean |
||||
# chroot environment (using systemd-ndspawn). |
||||
# |
||||
# The build script can be found at |
||||
# https://github.com/demizer/archzfs/blob/master/build.sh |
||||
# |
||||
|
||||
pkgver=0.6.2_3.14 |
||||
pkgrel=2 |
||||
pkgdesc="Kernel module support files for the Zettabyte File System." |
||||
depends=("spl") |
||||
arch=("i686" "x86_64") |
||||
url="http://zfsonlinux.org/" |
||||
source=(http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-0.6.2.tar.gz |
||||
zfs-utils.bash-completion |
||||
zfs-utils.initcpio.install |
||||
zfs-utils.initcpio.hook |
||||
zfs-utils.service |
||||
http://demizerone.com/patches/20140411-zfs-git-master.patch) |
||||
groups=("archzfs") |
||||
md5sums=('0b183b0abdd5be287046ad9ce4f899fd' |
||||
'3e1c4a29c4f7d590e6a3041f2c61d6ff' |
||||
'ebea2b1e593a9a19efa0f7ae7451bbc7' |
||||
'b567a95a34759f196bf4be8061a895e5' |
||||
'1f16ea8592509edb8efa4d7da25f8182' |
||||
'b7632a5a80d474272d1de046b6da5f81') |
||||
license=("CDDL") |
||||
|
||||
prepare() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
patch -Np1 < ../20140411-zfs-git-master.patch |
||||
} |
||||
|
||||
build() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
./autogen.sh |
||||
if [[ $CARCH == "i686" ]]; then |
||||
./configure --prefix=/usr \ |
||||
--sysconfdir=/etc \ |
||||
--sbindir=/usr/bin \ |
||||
--libdir=/usr/lib \ |
||||
--datadir=/usr/share \ |
||||
--includedir=/usr/include \ |
||||
--with-udevdir=/lib/udev \ |
||||
--libexecdir=/usr/lib/zfs-0.6.2 \ |
||||
--with-config=user |
||||
else |
||||
./configure --prefix=/usr \ |
||||
--sysconfdir=/etc \ |
||||
--sbindir=/usr/bin \ |
||||
--libdir=/usr/lib \ |
||||
--datadir=/usr/share \ |
||||
--includedir=/usr/include \ |
||||
--with-udevdir=/lib/udev \ |
||||
--libexecdir=/usr/lib/zfs-0.6.2 \ |
||||
--with-config=user |
||||
fi |
||||
make |
||||
} |
||||
|
||||
package() { |
||||
cd "$srcdir/zfs-0.6.2" |
||||
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 |
||||
|
||||
# Fixup path |
||||
mv "$pkgdir"/sbin/mount.zfs "$pkgdir"/usr/bin/ |
||||
rm -r "$pkgdir"/sbin |
||||
|
||||
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.service "$pkgdir"/usr/lib/systemd/system/zfs.service |
||||
install -D -m644 "$srcdir"/zfs-utils.bash-completion "$pkgdir"/usr/share/bash-completion/completions/zfs |
||||
} |
@ -0,0 +1,232 @@ |
||||
# Copyright (c) 2010, Aneurin Price <aneurin.price@gmail.com> |
||||
|
||||
# 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. |
||||
|
||||
__zfs_get_commands() |
||||
{ |
||||
zfs 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq |
||||
} |
||||
|
||||
__zfs_get_properties() |
||||
{ |
||||
zfs get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all |
||||
} |
||||
|
||||
__zfs_get_editable_properties() |
||||
{ |
||||
zfs get 2>&1 | awk '$2 == "YES" {printf("%s=\n", $1)}' |
||||
} |
||||
|
||||
__zfs_get_inheritable_properties() |
||||
{ |
||||
zfs get 2>&1 | awk '$3 == "YES" {print $1}' |
||||
} |
||||
|
||||
__zfs_list_datasets() |
||||
{ |
||||
zfs list -H -o name |
||||
} |
||||
|
||||
__zfs_list_filesystems() |
||||
{ |
||||
zfs list -H -o name -t filesystem |
||||
} |
||||
|
||||
__zfs_list_snapshots() |
||||
{ |
||||
zfs list -H -o name -t snapshot |
||||
} |
||||
|
||||
__zfs_list_volumes() |
||||
{ |
||||
zfs list -H -o name -t volume |
||||
} |
||||
|
||||
__zfs_argument_chosen() |
||||
{ |
||||
for word in $(seq $((COMP_CWORD-1)) -1 2) |
||||
do |
||||
local prev="${COMP_WORDS[$word]}" |
||||
for property in $@ |
||||
do |
||||
if [ "x$prev" = "x$property" ] |
||||
then |
||||
return 0 |
||||
fi |
||||
done |
||||
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() |
||||
{ |
||||
local cur prev cmd cmds |
||||
COMPREPLY=() |
||||
cur="${COMP_WORDS[COMP_CWORD]}" |
||||
prev="${COMP_WORDS[COMP_CWORD-1]}" |
||||
cmd="${COMP_WORDS[1]}" |
||||
cmds=$(__zfs_get_commands) |
||||
|
||||
if [ "${prev##*/}" = "zfs" ] |
||||
then |
||||
COMPREPLY=($(compgen -W "$cmds -?" -- "$cur")) |
||||
return 0 |
||||
fi |
||||
|
||||
case "${cmd}" in |
||||
clone) |
||||
__zfs_complete_ordered_arguments "$(__zfs_list_snapshots)" "$(__zfs_list_filesystems) $(__zfs_list_volumes)" $cur |
||||
return 0 |
||||
;; |
||||
get) |
||||
__zfs_complete_ordered_arguments "$(__zfs_get_properties)" "$(__zfs_list_datasets)" "$cur" "-H -r -p" |
||||
return 0 |
||||
;; |
||||
inherit) |
||||
__zfs_complete_ordered_arguments "$(__zfs_get_inheritable_properties)" "$(__zfs_list_datasets)" $cur |
||||
return 0 |
||||
;; |
||||
list) |
||||
if [ "x$prev" = "x-o" ] |
||||
then |
||||
COMPREPLY=($(compgen -W "$(__zfs_get_properties)" -- "${cur##*,}")) |
||||
local existing_opts=$(expr "$cur" : '\(.*,\)') |
||||
if [ ! "x$existing_opts" = "x" ] |
||||
then |
||||
COMPREPLY=( "${COMPREPLY[@]/#/${existing_opts}}" ) |
||||
fi |
||||
else |
||||
COMPREPLY=($(compgen -W "$(__zfs_list_datasets) -H -r -o" -- "$cur")) |
||||
fi |
||||
return 0 |
||||
;; |
||||
promote) |
||||
COMPREPLY=($(compgen -W "$(__zfs_list_filesystems)" -- "$cur")) |
||||
return 0 |
||||
;; |
||||
rollback|send) |
||||
COMPREPLY=($(compgen -W "$(__zfs_list_snapshots)" -- "$cur")) |
||||
return 0 |
||||
;; |
||||
snapshot) |
||||
COMPREPLY=($(compgen -W "$(__zfs_list_filesystems) $(__zfs_list_volumes)" -- "$cur")) |
||||
return 0 |
||||
;; |
||||
set) |
||||
__zfs_complete_ordered_arguments "$(__zfs_get_editable_properties)" "$(__zfs_list_filesystems) $(__zfs_list_volumes)" $cur |
||||
return 0 |
||||
;; |
||||
*) |
||||
COMPREPLY=($(compgen -W "$(__zfs_list_datasets)" -- "$cur")) |
||||
return 0 |
||||
;; |
||||
esac |
||||
|
||||
} |
||||
|
||||
__zpool_get_commands() |
||||
{ |
||||
zpool 2>&1 | awk '/^\t[a-z]/ {print $1}' | uniq |
||||
} |
||||
|
||||
__zpool_get_properties() |
||||
{ |
||||
zpool get 2>&1 | awk '$2 == "YES" || $2 == "NO" {print $1}'; echo all |
||||
} |
||||
|
||||
__zpool_get_editable_properties() |
||||
{ |
||||
zpool get 2>&1 | awk '$2 == "YES" {printf("%s=\n", $1)}' |
||||
} |
||||
|
||||
__zpool_list_pools() |
||||
{ |
||||
zpool 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]}" |
||||
cmds=$(__zpool_get_commands) |
||||
|
||||
if [ "${prev##*/}" = "zpool" ] |
||||
then |
||||
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 [ "x$prev" = "x-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 -o filenames -F __zpool_complete zpool |
@ -0,0 +1,99 @@ |
||||
ZPOOL_FORCE="" |
||||
|
||||
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 -N -a $ZPOOL_FORCE |
||||
if ! zfs_get_bootfs ; then |
||||
echo "ZFS: Cannot find bootfs." |
||||
return 1 |
||||
fi |
||||
fi |
||||
fi |
||||
|
||||
local pool="${ZFS_DATASET%%/*}" |
||||
local zpool_import_flags="" |
||||
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="-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() { |
||||
case $zfs_force in |
||||
1|[Yy][Ee][Ss]|[Oo][Nn]|[Tt][Rr][Uu][Ee]) |
||||
ZPOOL_FORCE='-f' |
||||
;; |
||||
esac |
||||
|
||||
if [ "$root" = 'zfs' ]; then |
||||
mount_handler='zfs_mount_handler' |
||||
fi |
||||
|
||||
case $zfs in |
||||
auto|bootfs) |
||||
ZFS_DATASET='bootfs' |
||||
mount_handler="zfs_mount_handler" |
||||
;; |
||||
*) |
||||
ZFS_DATASET=$zfs |
||||
mount_handler="zfs_mount_handler" |
||||
;; |
||||
esac |
||||
|
||||
if [ -n "$spl_hostid" ]; then |
||||
echo "The spl_hostid kernel parameter is now deprecated. Please add \ |
||||
your hostid to /etc/hostid manually. For more information see the comments \ |
||||
section at the ZFS AUR page or the ArchWiki ZFS page." |
||||
fi |
||||
|
||||
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 |
||||
} |
||||
|
||||
# vim:set ts=4 sw=4 ft=sh et: |
@ -0,0 +1,82 @@ |
||||
#!/bin/bash |
||||
|
||||
build() { |
||||
|
||||
map add_module \ |
||||
zavl \ |
||||
znvpair \ |
||||
zunicode \ |
||||
zcommon \ |
||||
zfs \ |
||||
zpios \ |
||||
spl \ |
||||
splat \ |
||||
zlib_deflate |
||||
|
||||
map add_binary \ |
||||
fsck.zfs \ |
||||
zdb \ |
||||
zfs \ |
||||
zhack \ |
||||
zinject \ |
||||
zpios \ |
||||
zpool \ |
||||
zstreamdump \ |
||||
ztest \ |
||||
splat \ |
||||
hostid \ |
||||
mount.zfs \ |
||||
/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 |
||||
|
||||
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/hostid ]] && add_file "/etc/hostid" |
||||
} |
||||
|
||||
help() { |
||||
cat<<HELPEOF |
||||
This hook allows you to use ZFS as your root filesystem. |
||||
|
||||
Command Line Setup: |
||||
|
||||
You can append the following arguments to your kernel parameters list. See |
||||
https://wiki.archlinux.org/index.php/Kernel_parameters for more information. |
||||
|
||||
To use ZFS as your boot filesystem: |
||||
|
||||
zfs=bootfs or zfs=auto or root=zfs |
||||
|
||||
To use a pool or dataset: |
||||
|
||||
zfs=<pool/dataset> |
||||
|
||||
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. |
||||
|
||||
Examples: |
||||
|
||||
To use bootfs on your pool, use |
||||
|
||||
zfs=bootfs |
||||
|
||||
This will setup your root using tank/root zfs pool. |
||||
|
||||
zfs=tank/root |
||||
HELPEOF |
||||
} |
||||
|
||||
# vim: set ts=4 sw=4 ft=sh et: |
@ -0,0 +1,19 @@ |
||||
[Unit] |
||||
Description=Zettabyte File System (ZFS) |
||||
Documentation=man:zfs(8) man:zpool(8) |
||||
DefaultDependencies=no |
||||
After=cryptsetup.target |
||||
Before=local-fs.target |
||||
Conflicts=shutdown.target umount.target |
||||
|
||||
[Service] |
||||
Type=oneshot |
||||
RemainAfterExit=yes |
||||
ExecStart=/usr/bin/modprobe zfs |
||||
ExecStart=/usr/bin/zpool import -c /etc/zfs/zpool.cache -aN |
||||
ExecStart=/usr/bin/zfs mount -a |
||||
ExecStart=/usr/bin/zfs share -a |
||||
ExecStop=/usr/bin/zfs umount -a |
||||
|
||||
[Install] |
||||
WantedBy=local-fs.target |
Loading…
Reference in new issue