Begin aggressive refactor

pull/57/merge
Jesus Alvarez 9 years ago
parent 3307a0a08a
commit 46d58c1fce
  1. 1
      .gitignore
  2. 211
      build.sh
  3. 43
      conf.sh
  4. 58
      lib.sh
  5. 0
      packages/spl-git
  6. 0
      packages/spl-lts
  7. 0
      packages/spl-utils-git
  8. 0
      packages/spl-utils-lts
  9. 0
      packages/zfs-git
  10. 0
      packages/zfs-lts
  11. 0
      packages/zfs-utils-git
  12. 0
      packages/zfs-utils-lts
  13. 10
      src/HEADER.sh
  14. 42
      src/spl-utils/PKGBUILD.sh
  15. 1
      src/spl-utils/spl-utils.hostid
  16. 44
      src/spl/PKGBUILD.sh
  17. 35
      src/spl/spl.install.sh
  18. 59
      src/zfs-utils/PKGBUILD.sh
  19. 391
      src/zfs-utils/zfs-utils.bash-completion-r1
  20. 92
      src/zfs-utils/zfs-utils.initcpio.hook
  21. 104
      src/zfs-utils/zfs-utils.initcpio.install
  22. 47
      src/zfs/PKGBUILD.sh
  23. 31
      src/zfs/zfs.install.sh

1
.gitignore vendored

@ -2,4 +2,3 @@
*/*.tar.*
*.log
testing/
src/

@ -4,6 +4,8 @@
#
# This script requires clean-chroot-manager (https://github.com/graysky2/clean-chroot-manager)
#
# Defaults, don't edit these.
AZB_UPDATE_PKGBUILDS=""
AZB_UPDPKGSUMS=0
@ -13,15 +15,19 @@ AZB_USE_TEST=0
AZB_CHROOT_UPDATE=""
AZB_SIGN=""
AZB_CLEANUP=0
AZB_MODE_DEF=0
AZB_MODE_GIT=0
AZB_MODE_LTS=0
source ./lib.sh
source ./conf.sh
trap 'trap_abort' INT QUIT TERM HUP
trap 'trap_exit' EXIT
usage() {
echo "build.sh - A build script for archzfs"
echo
@ -38,6 +44,7 @@ usage() {
echo
echo "Modes:"
echo
echo " def Use default packages."
echo " git Use the git packages."
echo " lts Use the lts packages."
echo
@ -58,28 +65,37 @@ usage() {
echo " build.sh lts update-test test -u :: Update PKGBUILDs (use testing versions), update the chroot, and make all of the packages"
}
sed_escape_input_string() {
echo "$1" | sed -e 's/[]\/$*.^|[]/\\&/g'
build_def_sources() {
for PKG in ${AZB_DEF_PKG_LIST}; do
msg "Building source for $PKG";
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "mkaurball -f"
run_cmd "cd - > /dev/null"
done
}
build_git_sources() {
for PKG in $AZB_GIT_PKG_LIST; do
for PKG in ${AZB_GIT_PKG_LIST}; do
msg "Building source for $PKG";
run_cmd "cd \"$PWD/$PKG\""
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "mkaurball -f"
run_cmd "cd - > /dev/null"
done
}
build_lts_sources() {
for PKG in $AZB_LTS_PKG_LIST; do
for PKG in ${AZB_LTS_PKG_LIST}; do
msg "Building source for $PKG";
run_cmd "cd \"$PWD/$PKG\""
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "mkaurball -f"
run_cmd "cd - > /dev/null"
done
}
sign_packages() {
FILES=$(find $PWD -iname "*.pkg.tar.xz")
debug "Found FILES: ${FILES}"
@ -92,6 +108,7 @@ sign_packages() {
done
}
get_new_pkgver() {
# Sets NEW_{SPL,ZFS}_PKGVER with an updated PKGVER pulled from the git repo
full_kernel_git_version
@ -131,6 +148,7 @@ get_new_pkgver() {
cd ../
}
check_git_repo() {
# Checks the current path for a git repo
[[ `cat PKGBUILD` =~ git\+([[:alpha:]\/:\.]+)\/([[:alpha:]]+)\.git ]] &&
@ -162,140 +180,48 @@ check_git_repo() {
}
update_git_pkgbuilds() {
# Get variables from the existing PKGBUILDs
AZB_CURRENT_SPL_PKGVER=$(grep "pkgver=" spl-git/PKGBUILD | cut -d= -f2)
AZB_CURRENT_SPL_UTILS_PKGVER=$(grep "pkgver=" spl-utils-git/PKGBUILD | cut -d= -f2)
AZB_CURRENT_ZFS_PKGVER=$(grep "pkgver=" zfs-git/PKGBUILD | cut -d= -f2)
AZB_CURRENT_ZFS_UTILS_PKGVER=$(grep "pkgver=" zfs-utils-git/PKGBUILD | cut -d= -f2)
AZB_CURRENT_SPL_GIT_COMMIT=$(grep "#commit=" spl-git/PKGBUILD | cut -d= -f3 | sed "s/..$//g")
AZB_CURRENT_ZFS_GIT_COMMIT=$(grep "#commit=" zfs-git/PKGBUILD | cut -d= -f3 | sed "s/..$//g")
AZB_CURRENT_PKGREL=$(grep "pkgrel=" spl-git/PKGBUILD | cut -d= -f2)
AZB_CURRENT_X32_KERNEL_VERSION=$(grep -m1 "_kernel_version_x32=" spl-git/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X64_KERNEL_VERSION=$(grep -m1 "_kernel_version_x64=" spl-git/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X32_KERNEL_VERSION_FULL=$(grep -m1 "_kernel_version_x32_full=" spl-git/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X64_KERNEL_VERSION_FULL=$(grep -m1 "_kernel_version_x64_full=" spl-git/PKGBUILD | cut -d\" -f2)
update_def_pkgbuilds() {
# Calculate what the new pkgver would be for the git packages
get_new_pkgver
full_kernel_version
debug "AZB_NEW_SPL_PKGVER: $AZB_NEW_SPL_X64_PKGVER"
debug "AZB_NEW_ZFS_PKGVER: $AZB_NEW_ZFS_X64_PKGVER"
debug "AZB_CURRENT_SPL_PKGVER: $AZB_CURRENT_SPL_PKGVER"
debug "AZB_CURRENT_SPL_UTILS_PKGVER: $AZB_CURRENT_SPL_UTILS_PKGVER"
debug "AZB_CURRENT_ZFS_PKGVER: $AZB_CURRENT_ZFS_PKGVER"
debug "AZB_CURRENT_ZFS_UTILS_PKGVER: $AZB_CURRENT_ZFS_UTILS_PKGVER"
debug "AZB_CURRENT_SPL_GIT_COMMIT: $AZB_CURRENT_SPL_GIT_COMMIT"
debug "AZB_CURRENT_ZFS_GIT_COMMIT: $AZB_CURRENT_ZFS_GIT_COMMIT"
debug "AZB_CURRENT_PKGREL: $AZB_CURRENT_PKGREL"
debug "AZB_CURRENT_X32_KERNEL_VERSION: $AZB_CURRENT_X32_KERNEL_VERSION"
debug "AZB_CURRENT_X64_KERNEL_VERSION: $AZB_CURRENT_X64_KERNEL_VERSION"
debug "AZB_CURRENT_X32_KERNEL_VERSION_FULL: $AZB_CURRENT_X32_KERNEL_VERSION_FULL"
debug "AZB_CURRENT_X64_KERNEL_VERSION_FULL: $AZB_CURRENT_X64_KERNEL_VERSION_FULL"
# Change the top level AZB_GIT_PKGREL
run_cmd "find *-git -iname \"PKGBUILD\" -print | xargs sed -i \"s/pkgrel=$AZB_CURRENT_PKGREL/pkgrel=$AZB_GIT_PKGREL/g\""
# Change _kernel_version_*
run_cmd "find *-git -type f -print | xargs sed -i \
\"s/_kernel_version_x32=\\\"$AZB_CURRENT_X32_KERNEL_VERSION\\\"/_kernel_version_x32=\\\"$AZB_GIT_KERNEL_X32_VERSION\\\"/g\""
run_cmd "find *-git -type f -iname \"PKGBUILD\" -print | xargs sed -i \
\"s/_kernel_version_x64=\\\"$AZB_CURRENT_X64_KERNEL_VERSION\\\"/_kernel_version_x64=\\\"$AZB_GIT_KERNEL_X64_VERSION\\\"/g\""
run_cmd "find *-git -type f -print | xargs sed -i \
\"s/_kernel_version_x32_full=\\\"$AZB_CURRENT_X32_KERNEL_VERSION_FULL\\\"/_kernel_version_x32_full=\\\"$AZB_GIT_KERNEL_X32_VERSION_FULL\\\"/g\""
run_cmd "find *-git -type f -print | xargs sed -i \
\"s/_kernel_version_x64_full=\\\"$AZB_CURRENT_X64_KERNEL_VERSION_FULL\\\"/_kernel_version_x64_full=\\\"$AZB_GIT_KERNEL_X64_VERSION_FULL\\\"/g\""
# Replace the linux version in the top level PKGVER
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_SPL_PKGVER/pkgver=$AZB_NEW_SPL_X64_PKGVER/g\" spl-git/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_SPL_UTILS_PKGVER/pkgver=$AZB_NEW_SPL_X64_PKGVER/g\" spl-utils-git/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_ZFS_PKGVER/pkgver=$AZB_NEW_ZFS_X64_PKGVER/g\" zfs-git/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_ZFS_UTILS_PKGVER/pkgver=$AZB_NEW_ZFS_X64_PKGVER/g\" zfs-utils-git/PKGBUILD"
# Replace the git commit id
run_cmd "find zfs*git -iname \"PKGBUILD\" -print | xargs sed -i \
\"s/#commit=$AZB_CURRENT_ZFS_GIT_COMMIT/#commit=$AZB_GIT_ZFS_COMMIT/g\""
run_cmd "find spl*git -iname \"PKGBUILD\" -print | xargs sed -i \
\"s/#commit=$AZB_CURRENT_SPL_GIT_COMMIT/#commit=$AZB_GIT_SPL_COMMIT/g\""
# Update the sums of the files
for PKG in $AZB_GIT_PKG_LIST; do
run_cmd "updpkgsums $PKG/PKGBUILD"
done
# $AZB_GIT_ZFS_COMMIT
# $AZB_GIT_SPL_COMMIT
}
update_lts_pkgbuilds() {
# Get variables from the existing PKGBUILDs
AZB_CURRENT_SPL_PKGVER=$(grep "pkgver=" spl-lts/PKGBUILD | cut -d= -f2)
AZB_CURRENT_SPL_UTILS_PKGVER=$(grep "pkgver=" spl-utils-lts/PKGBUILD | cut -d= -f2)
AZB_CURRENT_ZFS_PKGVER=$(grep "pkgver=" zfs-lts/PKGBUILD | cut -d= -f2)
AZB_CURRENT_ZFS_UTILS_PKGVER=$(grep "pkgver=" zfs-utils-lts/PKGBUILD | cut -d= -f2)
AZB_CURRENT_PKGREL=$(grep "pkgrel=" spl-lts/PKGBUILD | cut -d= -f2)
AZB_CURRENT_X32_KERNEL_VERSION=$(grep -m1 "_kernel_version_x32=" spl-lts/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X64_KERNEL_VERSION=$(grep -m1 "_kernel_version_x64=" spl-lts/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X32_KERNEL_VERSION_FULL=$(grep -m1 "_kernel_version_x32_full=" spl-lts/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_X64_KERNEL_VERSION_FULL=$(grep -m1 "_kernel_version_x64_full=" spl-lts/PKGBUILD | cut -d\" -f2)
AZB_CURRENT_ZOL_VERSION=$(grep 'spl-[[:digit:]\.]\+"' spl-lts/PKGBUILD | head -1 | \grep -o -m1 '[[:digit:]\.]\+')
update_git_pkgbuilds() {
# Calculate what the new pkgver would be for the git packages
get_new_pkgver
debug "AZB_NEW_SPL_PKGVER: $AZB_NEW_SPL_X64_PKGVER"
debug "AZB_NEW_ZFS_PKGVER: $AZB_NEW_ZFS_X64_PKGVER"
# Replace the git commit id
# $AZB_GIT_ZFS_COMMIT
# $AZB_GIT_SPL_COMMIT
}
# Set the AZB_LTS_KERNEL* variables
full_kernel_lts_version
update_lts_pkgbuilds() {
# Set the AZB_LTS_KERNEL* variables
full_kernel_version
AZB_NEW_LTS_PKGVER=${AZB_ZOL_VERSION}_${AZB_LTS_KERNEL_X64_VERSION_CLEAN}
debug "AZB_NEW_LTS_PKGVER: $AZB_NEW_LTS_PKGVER"
debug "AZB_CURRENT_SPL_PKGVER: $AZB_CURRENT_SPL_PKGVER"
debug "AZB_CURRENT_SPL_UTILS_PKGVER: $AZB_CURRENT_SPL_UTILS_PKGVER"
debug "AZB_CURRENT_ZFS_PKGVER: $AZB_CURRENT_ZFS_PKGVER"
debug "AZB_CURRENT_ZFS_UTILS_PKGVER: $AZB_CURRENT_ZFS_UTILS_PKGVER"
debug "AZB_CURRENT_PKGREL: $AZB_CURRENT_PKGREL"
debug "AZB_CURRENT_X32_KERNEL_VERSION: $AZB_CURRENT_X32_KERNEL_VERSION"
debug "AZB_CURRENT_X64_KERNEL_VERSION: $AZB_CURRENT_X64_KERNEL_VERSION"
debug "AZB_CURRENT_X32_KERNEL_VERSION_FULL: $AZB_CURRENT_X32_KERNEL_VERSION_FULL"
debug "AZB_CURRENT_X64_KERNEL_VERSION_FULL: $AZB_CURRENT_X64_KERNEL_VERSION_FULL"
# Change the top level AZB_LTS_PKGREL
run_cmd "find *-lts -iname \"PKGBUILD\" -print | xargs sed -i \"s/pkgrel=$AZB_CURRENT_PKGREL/pkgrel=$AZB_LTS_PKGREL/g\""
# Change _kernel_version_*
run_cmd "find *-lts -type f -print | xargs sed -i \
\"s/_kernel_version_x32=\\\"$AZB_CURRENT_X32_KERNEL_VERSION\\\"/_kernel_version_x32=\\\"$AZB_LTS_KERNEL_X32_VERSION\\\"/g\""
run_cmd "find *-lts -type f -print | xargs sed -i \
\"s/_kernel_version_x64=\\\"$AZB_CURRENT_X64_KERNEL_VERSION\\\"/_kernel_version_x64=\\\"$AZB_LTS_KERNEL_X64_VERSION\\\"/g\""
run_cmd "find *-lts -type f -print | xargs sed -i \
\"s/_kernel_version_x32_full=\\\"$AZB_CURRENT_X32_KERNEL_VERSION_FULL\\\"/_kernel_version_x32_full=\\\"$AZB_LTS_KERNEL_X32_VERSION_FULL\\\"/g\""
run_cmd "find *-lts -type f -print | xargs sed -i \
\"s/_kernel_version_x64_full=\\\"$AZB_CURRENT_X64_KERNEL_VERSION_FULL\\\"/_kernel_version_x64_full=\\\"$AZB_LTS_KERNEL_X64_VERSION_FULL\\\"/g\""
# Replace the linux version in the top level PKGVER
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_SPL_PKGVER/pkgver=$AZB_NEW_LTS_PKGVER/g\" spl-lts/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_SPL_UTILS_PKGVER/pkgver=$AZB_NEW_LTS_PKGVER/g\" spl-utils-lts/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_ZFS_PKGVER/pkgver=$AZB_NEW_LTS_PKGVER/g\" zfs-lts/PKGBUILD"
run_cmd "sed -i \"s/pkgver=$AZB_CURRENT_ZFS_UTILS_PKGVER/pkgver=$AZB_NEW_LTS_PKGVER/g\" zfs-utils-lts/PKGBUILD"
# Replace the ZOL Version
run_cmd "find *-lts -type f -print | xargs sed -i \"s/$AZB_CURRENT_ZOL_VERSION/$AZB_ZOL_VERSION/g\""
return 0
}
update_lts_pkgsums() {
# Update the sums of the files
for PKG in $AZB_LTS_PKG_LIST; do
run_cmd "updpkgsums $PKG/PKGBUILD"
done
}
if [[ $# -lt 1 ]]; then
usage;
exit 0;
fi
ARGS=("$@")
for (( a = 0; a < $#; a++ )); do
if [[ ${ARGS[$a]} == "git" ]]; then
if [[ ${ARGS[$a]} == "def" ]]; then
AZB_MODE_DEF=1
elif [[ ${ARGS[$a]} == "git" ]]; then
AZB_MODE_GIT=1
elif [[ ${ARGS[$a]} == "lts" ]]; then
AZB_MODE_LTS=1
@ -309,9 +235,6 @@ for (( a = 0; a < $#; a++ )); do
AZB_UPDATE_TEST_PKGBUILDS=1
elif [[ ${ARGS[$a]} == "sign" ]]; then
AZB_SIGN=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
elif [[ ${ARGS[$a]} == "-u" ]]; then
AZB_CHROOT_UPDATE="-u"
elif [[ ${ARGS[$a]} == "-U" ]]; then
@ -322,9 +245,13 @@ for (( a = 0; a < $#; a++ )); do
DRY_RUN=1
elif [[ ${ARGS[$a]} == "-d" ]]; then
DEBUG=1
elif [[ ${ARGS[$a]} == "-h" ]]; then
usage;
exit 0;
fi
done
if [[ $AZB_CLEANUP == 1 && $# -gt 1 ]]; then
echo -e "\n"
error "-C should be used by itself!"
@ -333,7 +260,8 @@ if [[ $AZB_CLEANUP == 1 && $# -gt 1 ]]; then
exit 0;
fi
if [[ $AZB_MODE_GIT == 0 && $AZB_MODE_LTS == 0 && $AZB_CLEANUP == 0 ]]; then
if [[ ${AZB_MODE_GIT} == 0 && ${AZB_MODE_LTS} == 0 && $AZB_CLEANUP == 0 ]]; then
echo -e "\n"
error "A build mode must be selected!"
echo -e "\n"
@ -341,30 +269,49 @@ if [[ $AZB_MODE_GIT == 0 && $AZB_MODE_LTS == 0 && $AZB_CLEANUP == 0 ]]; then
exit 0;
fi
msg "build.sh started..."
if [[ $AZB_UPDPKGSUMS == 1 && $AZB_MODE_LTS == 1 ]]; then
if [[ $AZB_UPDPKGSUMS == 1 && ${AZB_MODE_LTS} == 1 ]]; then
update_lts_pkgsums
fi
if [[ $AZB_UPDATE_PKGBUILDS == 1 && $AZB_MODE_GIT == 1 ]]; then
if [[ ${AZB_UPDATE_PKGBUILDS} == 1 && ${AZB_MODE_DEF} == 1 ]]; then
debug "Updating default pkgbuilds"
update_def_pkgbuilds
elif [[ ${AZB_UPDATE_PKGBUILDS} == 1 && ${AZB_MODE_GIT} == 1 ]]; then
debug "Updating git pkgbuilds"
update_git_pkgbuilds
elif [[ $AZB_UPDATE_PKGBUILDS == 1 && $AZB_MODE_LTS == 1 ]]; then
elif [[ ${AZB_UPDATE_PKGBUILDS} == 1 && ${AZB_MODE_LTS} == 1 ]]; then
debug "Updating lts pkgbuilds"
update_lts_pkgbuilds
fi
if [ -n "$AZB_CHROOT_UPDATE" ]; then
msg "Updating the i686 and x86_64 clean chroots..."
run_cmd "sudo ccm32 u"
run_cmd "sudo ccm64 u"
fi
if [[ $AZB_BUILD == 1 && $AZB_MODE_GIT == 1 ]]; then
for PKG in $AZB_GIT_PKG_LIST; do
if [[ ${AZB_BUILD} == 1 && ${AZB_MODE_GIT} == 1 ]]; then
for PKG in ${AZB_GIT_PKG_LIST}; do
msg "Building $PKG..."
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "sudo ccm32 s"
run_cmd "sudo ccm64 s"
run_cmd "cd - > /dev/null"
done
build_def_sources
sign_packages
run_cmd "find . -iname \"*.log\" -print -exec rm {} \\;"
elif [[ ${AZB_BUILD} == 1 && ${AZB_MODE_GIT} == 1 ]]; then
for PKG in ${AZB_GIT_PKG_LIST}; do
msg "Building $PKG..."
run_cmd "cd \"$PWD/$PKG\""
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "sudo ccm32 s"
run_cmd "sudo ccm64 s"
run_cmd "cd - > /dev/null"
@ -372,10 +319,10 @@ if [[ $AZB_BUILD == 1 && $AZB_MODE_GIT == 1 ]]; then
build_git_sources
sign_packages
run_cmd "find . -iname \"*.log\" -print -exec rm {} \\;"
elif [[ $AZB_BUILD == 1 && $AZB_MODE_LTS == 1 ]]; then
for PKG in $AZB_LTS_PKG_LIST; do
elif [[ ${AZB_BUILD} == 1 && ${AZB_MODE_LTS} == 1 ]]; then
for PKG in ${AZB_LTS_PKG_LIST}; do
msg "Building $PKG..."
run_cmd "cd \"$PWD/$PKG\""
run_cmd "cd \"$PWD/packages/$PKG\""
run_cmd "sudo ccm32 s"
run_cmd "sudo ccm64 s"
run_cmd "cd - > /dev/null"
@ -385,10 +332,12 @@ elif [[ $AZB_BUILD == 1 && $AZB_MODE_LTS == 1 ]]; then
run_cmd "find . -iname \"*.log\" -print -exec rm {} \\;"
fi
if [[ $AZB_SIGN -eq 1 ]]; then
sign_packages
fi
if [[ $AZB_CLEANUP -eq 1 ]]; then
msg "Cleaning up work files..."
run_cmd "find . \( -iname \"*.log\" -o -iname \"*.pkg.tar.xz*\" -o -iname \"*.src.tar.gz\" \) -print -exec rm -rf {} \\;"

@ -1,23 +1,41 @@
# ZFSonLinux stable version (LTS packages)
AZB_ZOL_VERSION="0.6.5.6"
# Kernel versions for default ZFS packages
AZB_DEF_PKGREL="1"
AZB_DEF_KERNEL_VERSION="4.5"
AZB_DEF_KERNEL_PKGREL_X32="1"
AZB_DEF_KERNEL_PKGREL_X64="1"
AZB_DEF_KERNEL_VERSION_X32="${AZB_DEF_KERNEL_VERSION}-${AZB_DEF_KERNEL_PKGREL_X32}"
AZB_DEF_KERNEL_VERSION_X64="${AZB_DEF_KERNEL_VERSION}-${AZB_DEF_KERNEL_PKGREL_X64}"
# Kernel version for GIT packages
AZB_GIT_SPL_COMMIT="5079f5b3"
AZB_GIT_ZFS_COMMIT="21f21fe8"
AZB_GIT_PKGREL="1"
AZB_GIT_KERNEL_VERSION="4.5"
AZB_GIT_KERNEL_X32_PKGREL="1"
AZB_GIT_KERNEL_X64_PKGREL="1"
AZB_GIT_KERNEL_X32_VERSION="${AZB_GIT_KERNEL_VERSION}-${AZB_GIT_KERNEL_X32_PKGREL}"
AZB_GIT_KERNEL_X64_VERSION="${AZB_GIT_KERNEL_VERSION}-${AZB_GIT_KERNEL_X64_PKGREL}"
AZB_DEF_GIT_SPL_COMMIT="5079f5b3"
AZB_DEF_GIT_ZFS_COMMIT="21f21fe8"
AZB_DEF_GIT_PKGREL="1"
AZB_DEF_GIT_KERNEL_VERSION="4.5"
AZB_DEF_GIT_KERNEL_PKGREL_X32="1"
AZB_DEF_GIT_KERNEL_PKGREL_X64="1"
AZB_DEF_GIT_KERNEL_VERSION_X32="${AZB_DEF_GIT_KERNEL_VERSION}-${AZB_DEF_GIT_KERNEL_PKGREL_X32}"
AZB_DEF_GIT_KERNEL_VERSION_X64="${AZB_DEF_GIT_KERNEL_VERSION}-${AZB_DEF_GIT_KERNEL_PKGREL_X64}"
# Kernel versions for LTS packages
AZB_LTS_PKGREL="1"
AZB_LTS_KERNEL_VERSION="4.4.7"
AZB_LTS_KERNEL_X32_PKGREL="1"
AZB_LTS_KERNEL_X64_PKGREL="1"
AZB_LTS_KERNEL_X32_VERSION="${AZB_LTS_KERNEL_VERSION}-${AZB_LTS_KERNEL_X32_PKGREL}"
AZB_LTS_KERNEL_X64_VERSION="${AZB_LTS_KERNEL_VERSION}-${AZB_LTS_KERNEL_X64_PKGREL}"
AZB_LTS_KERNEL_PKGREL_X32="1"
AZB_LTS_KERNEL_PKGREL_X64="1"
AZB_LTS_KERNEL_VERSION_X32="${AZB_LTS_KERNEL_VERSION}-${AZB_LTS_KERNEL_PKGREL_X32}"
AZB_LTS_KERNEL_VERSION_X64="${AZB_LTS_KERNEL_VERSION}-${AZB_LTS_KERNEL_PKGREL_X64}"
# Kernel versions for GIT LTS packages
AZB_DEF_LTS_SPL_COMMIT="5079f5b3"
AZB_DEF_LTS_ZFS_COMMIT="21f21fe8"
AZB_DEF_LTS_PKGREL="1"
AZB_DEF_LTS_KERNEL_VERSION="4.5"
AZB_DEF_LTS_KERNEL_PKGREL_X32="1"
AZB_DEF_LTS_KERNEL_PKGREL_X64="1"
AZB_DEF_LTS_KERNEL_VERSION_X32="${AZB_DEF_LTS_KERNEL_VERSION}-${AZB_DEF_LTS_KERNEL_PKGREL_X32}"
AZB_DEF_LTS_KERNEL_VERSION_X64="${AZB_DEF_LTS_KERNEL_VERSION}-${AZB_DEF_LTS_KERNEL_PKGREL_X64}"
# Archiso Configuration
AZB_ARCHISO_PKGREL="1"
@ -51,5 +69,6 @@ AZB_GPG_SIGN_KEY='0EE7A126'
# Package backup directory (for adding packages to demz-repo-archiso)
AZB_PACKAGE_BACKUP_DIR="/data/pacman/repo/archive_archzfs"
AZB_DEF_PKG_LIST="spl-utils spl zfs-utils zfs"
AZB_GIT_PKG_LIST="spl-utils-git spl-git zfs-utils-git zfs-git"
AZB_LTS_PKG_LIST="spl-utils-lts spl-lts zfs-utils-lts zfs-lts"

@ -117,57 +117,23 @@ package_version_from_syncdb() {
return $?
}
full_kernel_git_version() {
full_kernel_version() {
# Determine if the kernel version has the format 3.14 or 3.14.1
if [[ ${AZB_GIT_KERNEL_VERSION} =~ ^[[:digit:]]+\.[[:digit:]]+\.([[:digit:]]+) ]]; then
debug "full_kernel_git_version: Have kernel with minor version!"
if [[ ${AZB_KERNEL_VERSION} =~ ^[[:digit:]]+\.[[:digit:]]+\.([[:digit:]]+) ]]; then
debug "full_kernel_version: Have kernel with minor version!"
fi
debug "full_kernel_git_version: BASH_REMATCH[1] == '${BASH_REMATCH[1]}'"
debug "full_kernel_version: BASH_REMATCH[1] == '${BASH_REMATCH[1]}'"
if [[ ${BASH_REMATCH[1]} != "" ]]; then
AZB_GIT_KERNEL_X32_VERSION_FULL=${AZB_GIT_KERNEL_X32_VERSION}
AZB_GIT_KERNEL_X64_VERSION_FULL=${AZB_GIT_KERNEL_X64_VERSION}
AZB_GIT_KERNEL_X32_VERSION_CLEAN=$(echo ${AZB_GIT_KERNEL_X32_VERSION} | sed s/-/_/g)
AZB_GIT_KERNEL_X64_VERSION_CLEAN=$(echo ${AZB_GIT_KERNEL_X64_VERSION} | sed s/-/_/g)
AZB_KERNEL_VERSION_FULL_X32=${AZB_KERNEL_VERSION_X32}
AZB_KERNEL_VERSION_FULL_X64=${AZB_KERNEL_VERSION_X64}
AZB_KERNEL_VERSION_CLEAN_X32=$(echo ${AZB_KERNEL_VERSION_X32} | sed s/-/_/g)
AZB_KERNEL_VERSION_CLEAN_X64=$(echo ${AZB_KERNEL_VERSION_X64} | sed s/-/_/g)
else
debug "full_kernel_git_version: Have kernel without minor version!'"
# Kernel version has the format 3.14, so add a 0.
AZB_GIT_KERNEL_X32_VERSION_FULL=${AZB_GIT_KERNEL_VERSION}.0-${AZB_GIT_KERNEL_X32_PKGREL}
AZB_GIT_KERNEL_X64_VERSION_FULL=${AZB_GIT_KERNEL_VERSION}.0-${AZB_GIT_KERNEL_X64_PKGREL}
AZB_GIT_KERNEL_X32_VERSION_CLEAN=$(echo ${AZB_GIT_KERNEL_X32_VERSION_FULL} | sed s/-/_/g)
AZB_GIT_KERNEL_X64_VERSION_CLEAN=$(echo ${AZB_GIT_KERNEL_X64_VERSION_FULL} | sed s/-/_/g)
fi
}
full_kernel_lts_version() {
# Determine if the kernel version has the format 3.14 or 3.14.1
[[ ${AZB_LTS_KERNEL_VERSION} =~ ^[[:digit:]]+\.[[:digit:]]+\.([[:digit:]]+) ]]
if [[ ${BASH_REMATCH[1]} != "" ]]; then
AZB_LTS_KERNEL_X32_VERSION_FULL=${AZB_LTS_KERNEL_X32_VERSION}
AZB_LTS_KERNEL_X64_VERSION_FULL=${AZB_LTS_KERNEL_X64_VERSION}
AZB_LTS_KERNEL_X32_VERSION_CLEAN=$(echo ${AZB_LTS_KERNEL_X32_VERSION} | sed s/-/_/g)
AZB_LTS_KERNEL_X64_VERSION_CLEAN=$(echo ${AZB_LTS_KERNEL_X64_VERSION} | sed s/-/_/g)
else
# Kernel version has the format 3.14, so add a 0.
AZB_LTS_KERNEL_X32_VERSION_FULL=${AZB_LTS_KERNEL_VERSION}.0-${AZB_LTS_KERNEL_X32_PKGREL}
AZB_LTS_KERNEL_X64_VERSION_FULL=${AZB_LTS_KERNEL_VERSION}.0-${AZB_LTS_KERNEL_X64_PKGREL}
AZB_LTS_KERNEL_X32_VERSION_CLEAN=$(echo ${AZB_LTS_KERNEL_X32_VERSION_FULL} | sed s/-/_/g)
AZB_LTS_KERNEL_X64_VERSION_CLEAN=$(echo ${AZB_LTS_KERNEL_X64_VERSION_FULL} | sed s/-/_/g)
fi
}
full_kernel_archiso_version() {
# Determine if the archiso kernel version has the format 3.14 or 3.14.1
[[ ${AZB_KERNEL_ARCHISO_VERSION} =~ ^[[:digit:]]+\.[[:digit:]]+\.([[:digit:]]+) ]]
if [[ ${BASH_REMATCH[1]} != "" ]]; then
AZB_KERNEL_ARCHISO_X32_VERSION_FULL=${AZB_KERNEL_ARCHISO_X32_VERSION}
AZB_KERNEL_ARCHISO_X32_VERSION_CLEAN=$(echo ${AZB_KERNEL_ARCHISO_X32_VERSION} | sed s/-/_/g)
AZB_KERNEL_ARCHISO_X64_VERSION_FULL=${AZB_KERNEL_ARCHISO_X64_VERSION}
AZB_KERNEL_ARCHISO_X64_VERSION_CLEAN=$(echo ${AZB_KERNEL_ARCHISO_X64_VERSION} | sed s/-/_/g)
else
# Kernel version has the format 3.14, so add a 0.
AZB_KERNEL_ARCHISO_X32_VERSION_FULL=${AZB_KERNEL_ARCHISO_VERSION}.0-${AZB_KERNEL_ARCHISO_X32_PKGREL}
AZB_KERNEL_ARCHISO_X32_VERSION_CLEAN=${AZB_KERNEL_ARCHISO_VERSION}.0_${AZB_KERNEL_ARCHISO_X32_PKGREL}
AZB_KERNEL_ARCHISO_X64_VERSION_FULL=${AZB_KERNEL_ARCHISO_VERSION}.0-${AZB_KERNEL_ARCHISO_X64_PKGREL}
AZB_KERNEL_ARCHISO_X64_VERSION_CLEAN=${AZB_KERNEL_ARCHISO_VERSION}.0_${AZB_KERNEL_ARCHISO_X64_PKGREL}
AZB_KERNEL_VERSION_FULL_X32=${AZB_KERNEL_VERSION}.0-${AZB_KERNEL_PKGREL_X32}
AZB_KERNEL_VERSION_FULL_X64=${AZB_KERNEL_VERSION}.0-${AZB_KERNEL_PKGREL_X64}
AZB_KERNEL_VERSION_CLEAN_X32=$(echo ${AZB_KERNEL_VERSION_FULL_X32} | sed s/-/_/g)
AZB_KERNEL_VERSION_CLEAN_X64=$(echo ${AZB_KERNEL_VERSION_FULL_X64} | sed s/-/_/g)
fi
}

@ -0,0 +1,10 @@
#!/bin/bash
cat << EOF > ${AZB_PKGBUILD_PATH}
# Maintainer: Jesus Alvarez <jeezusjr at gmail dot com>
#
# This PKGBUILD was generated by the archzfs build scripts located at
#
# http://github.com/archzfs/archzfs
#
EOF

@ -0,0 +1,42 @@
#!/bin/bash
cat << EOF > ${AZB_PKGBUILD_PATH}
${AZB_HEADER}
pkgname="${AZB_SPL_UTILS_PKGNAME}"
pkgver=${AZB_PKGVER}
pkgrel=${AZB_PKGREL}
pkgdesc="Solaris Porting Layer kernel module support files."
arch=("i686" "x86_64")
url="http://zfsonlinux.org/"
source=("http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/spl-${AZB_ZOL_VERSION}.tar.gz"
"spl-utils.hostid")
sha256sums=('${AZB_SPL_SRC_HASH}'
'${AZB_SPL_HOSTID_HASH}')
groups=("${AZB_ARCHZFS_PACKAGE_GROUP}")
license=("GPL")
provides=("${AZB_SPL_UTILS_PKGNAME}")
build() {
cd "\${srcdir}/spl-${AZB_ZOL_VERSION}"
./autogen.sh
_at_enable=""
[ "\${CARCH}" == "i686" ] && _at_enable="--enable-atomic-spinlocks"
./configure --prefix=/usr \\
--libdir=/usr/lib \\
--sbindir=/usr/bin \\
--with-config=user \\
\${_at_enable}
make
}
package() {
cd "\${srcdir}/spl-${AZB_ZOL_VERSION}"
make DESTDIR="\${pkgdir}" install
install -D -m644 "\${srcdir}"/spl-utils.hostid "\${pkgdir}"/etc/hostid
}
EOF

@ -0,0 +1 @@
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>

@ -0,0 +1,44 @@
#!/bin/bash
cat << EOF > ${AZB_PKGBUILD_PATH}
${AZB_HEADER}
pkgname="${AZB_SPL_PKGNAME}"
pkgver=${AZB_PKGVER}
pkgrel=${AZB_PKGREL}
pkgdesc="Solaris Porting Layer kernel modules."
depends=("${AZB_SPL_UTILS_PKGNAME}")
arch=("i686" "x86_64")
url="http://zfsonlinux.org/"
source=("http://archive.zfsonlinux.org/downloads/zfsonlinux/spl/spl-${AZB_ZOL_VERSION}.tar.gz")
sha256sums=('${AZB_ZFS_SRC_HASH}}')
groups=("${AZB_ARCHZFS_PACKAGE_GROUP}")
license=("GPL")
install=spl.install
provides=("${AZF_SPL_PKGNAME}")
build() {
cd "\${srcdir}/spl-${AZB_ZOL_VERSION}"
./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/${AZB_KERNEL_VERSION_FULL}/build \\
--with-config=kernel \\
\${_at_enable}
make
}
package() {
cd "\${srcdir}/spl-${AZB_ZOL_VERSION}"
make DESTDIR="\${pkgdir}" install
mv "\${pkgdir}/lib" "\${pkgdir}/usr/"
sed -i "s+\${srcdir}++" \${pkgdir}/usr/src/spl-*/${AZB_KERNEL_VERSION_FULL}/Module.symvers
}
EOF

@ -0,0 +1,35 @@
#!/bin/bash
cat << EOF > ${AZB_SPL_INSTALL_PATH}
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 SPL module dependencies"
depmod -v ${AZB_KERNEL_VERSION_FULL}
}
EOF

@ -0,0 +1,59 @@
#!/bin/bash
cat << EOF > ${AZB_PKGBUILD_PATH}
${AZB_HEADER}
pkgname="${AZB_ZFS_UTILS_PKGNAME}"
pkgver=${AZB_PKGVER}
pkgrel=${AZB_PKGREL}
pkgdesc="Kernel module support files for the Zettabyte File System."
depends=("${AZB_SPL_PKGNAME}")
arch=("i686" "x86_64")
url="http://zfsonlinux.org/"
source=("http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-${AZB_ZOL_VERSION}.tar.gz"
"zfs-utils.bash-completion-r1"
"zfs-utils.initcpio.install"
"zfs-utils.initcpio.hook"
)
sha256sums=('${AZB_ZFS_SRC_HASH}'
'${AZB_ZFS_BASH_COMPLETION_HASH}'
'${AZB_ZFS_INITCPIO_INSTALL_HASH}'
'${AZB_ZFS_INITCPIO_HOOK_HASH}')
license=("CDDL")
groups=("${AZB_ARCHZFS_PACKAGE_GROUP}")
provides=("${AZB_ZFS_UTILS_PKGNAME}")
build() {
cd "\${srcdir}/zfs-${AZB_ZOL_VERSION}"
./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-${AZB_ZOL_VERSION} \\
--with-config=user
make
}
package() {
cd "\${srcdir}/zfs-${AZB_ZOL_VERSION}"
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
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
}
EOF

@ -0,0 +1,391 @@
# Copyright (c) 2013, 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.
#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

@ -0,0 +1,92 @@
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 <pool>'
[[ $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
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
}
# vim:set ts=4 sw=4 ft=sh et:

@ -0,0 +1,104 @@
#!/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<<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.
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:

@ -0,0 +1,47 @@
#!/bin/bash
cat << EOF > ${AZB_PKGBUILD_PATH}
${AZB_HEADER}
pkgname="${AZB_ZFS_PKGNAME}"
pkgver=${AZB_PKGVER}
pkgrel=${AZB_PKGREL}
pkgdesc="Kernel modules for the Zettabyte File System."
depends=("${AZB_SPL_PKGNAME}" "${AZB_ZFS_UTILS_PKGNAME}")
arch=("i686" "x86_64")
url="http://zfsonlinux.org/"
source=("http://archive.zfsonlinux.org/downloads/zfsonlinux/zfs/zfs-${AZB_ZOL_VERSION}.tar.gz")
sha256sums=('${AZB_ZFS_SRC_HASH}')
groups=("${AZB_ARCHZFS_PACKAGE_GROUP}")
license=("CDDL")
install=zfs.install
provides=("${AZB_ZFS_PKGNAME}")
build() {
cd "\${srcdir}/zfs-${AZB_ZOL_VERSION}"
./autogen.sh
./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-${AZB_ZOL_VERSION} \\
--with-config=kernel \\
--with-linux=/usr/lib/modules/${AZB_KERNEL_VERSION_FULL}/build
make
}
package() {
cd "\${srcdir}/zfs-${AZB_ZOL_VERSION}"
make DESTDIR="\${pkgdir}" install
cp -r "\${pkgdir}"/{lib,usr}
rm -r "\${pkgdir}"/lib
sed -i "s+\${srcdir}++" \${pkgdir}/usr/src/zfs-*/${AZB_KERNEL_VERSION_FULL}/Module.symvers
}
EOF

@ -0,0 +1,31 @@
#!/bin/bash
cat << EOF > ${AZB_ZFS_INSTALL_PATH}
post_install() {
check_initramfs
}
post_remove() {
check_initramfs 'remove'
}
post_upgrade() {
check_initramfs
}
check_initramfs() {
echo ">>> Updating ZFS module dependencies"
depmod -v ${AZB_KERNEL_VERSION_FULL}
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
}
EOF
Loading…
Cancel
Save