diff --git a/Makefile.am b/Makefile.am index c44d64df0187..32ac50f78ae2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,261 +1,262 @@ ACLOCAL_AMFLAGS = -I config SUBDIRS = include if BUILD_LINUX SUBDIRS += rpm endif if CONFIG_USER SUBDIRS += etc man scripts lib tests cmd contrib if BUILD_LINUX SUBDIRS += udev endif endif if CONFIG_KERNEL SUBDIRS += module extradir = $(prefix)/src/zfs-$(VERSION) extra_HEADERS = zfs.release.in zfs_config.h.in if BUILD_LINUX kerneldir = $(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) nodist_kernel_HEADERS = zfs.release zfs_config.h module/$(LINUX_SYMBOLS) endif endif AUTOMAKE_OPTIONS = foreign EXTRA_DIST = autogen.sh copy-builtin EXTRA_DIST += config/config.awk config/rpm.am config/deb.am config/tgz.am EXTRA_DIST += AUTHORS CODE_OF_CONDUCT.md COPYRIGHT LICENSE META NEWS NOTICE EXTRA_DIST += README.md RELEASES.md EXTRA_DIST += module/lua/README.zfs module/os/linux/spl/README.md # Include all the extra licensing information for modules EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE EXTRA_DIST += module/icp/algs/skein/THIRDPARTYLICENSE.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.gladman.descrip EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/aes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.cryptogams.descrip EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl EXTRA_DIST += module/icp/asm-x86_64/modes/THIRDPARTYLICENSE.openssl.descrip EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2 EXTRA_DIST += module/os/linux/spl/THIRDPARTYLICENSE.gplv2.descrip EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash EXTRA_DIST += module/zfs/THIRDPARTYLICENSE.cityhash.descrip @CODE_COVERAGE_RULES@ GITREV = include/zfs_gitrev.h PHONY = gitrev gitrev: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh $(GITREV) all: gitrev # Double-colon rules are allowed; there are multiple independent definitions. maintainer-clean-local:: -$(RM) $(GITREV) distclean-local:: -$(RM) -R autom4te*.cache build -find . \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS \ -o -name .pc -o -name .hg -o -name .git \) -prune -o \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ -o -name '.*.rej' -o -size 0 -o -name '*%' -o -name '.*.cmd' \ -o -name 'core' -o -name 'Makefile' -o -name 'Module.symvers' \ -o -name '*.order' -o -name '*.markers' -o -name '*.gcda' \ -o -name '*.gcno' \) \ -type f -print | xargs $(RM) all-local: -[ -x ${top_builddir}/scripts/zfs-tests.sh ] && \ ${top_builddir}/scripts/zfs-tests.sh -c dist-hook: $(AM_V_GEN)$(top_srcdir)/scripts/make_gitrev.sh -D $(distdir) $(GITREV) $(SED) ${ac_inplace} -e 's/Release:[[:print:]]*/Release: $(RELEASE)/' \ $(distdir)/META if BUILD_LINUX # For compatibility, create a matching spl-x.y.z directly which contains # symlinks to the updated header and object file locations. These # compatibility links will be removed in the next major release. if CONFIG_KERNEL install-data-hook: rm -rf $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ mkdir $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ cd $(DESTDIR)$(prefix)/src/spl-$(VERSION) && \ ln -s ../zfs-$(VERSION)/include/spl include && \ ln -s ../zfs-$(VERSION)/$(LINUX_VERSION) $(LINUX_VERSION) && \ ln -s ../zfs-$(VERSION)/zfs_config.h.in spl_config.h.in && \ ln -s ../zfs-$(VERSION)/zfs.release.in spl.release.in && \ cd $(DESTDIR)$(prefix)/src/zfs-$(VERSION)/$(LINUX_VERSION) && \ ln -fs zfs_config.h spl_config.h && \ ln -fs zfs.release spl.release endif endif PHONY += codecheck codecheck: cstyle shellcheck checkbashisms flake8 mancheck testscheck vcscheck PHONY += checkstyle checkstyle: codecheck commitcheck PHONY += commitcheck commitcheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ ${top_srcdir}/scripts/commitcheck.sh; \ fi PHONY += cstyle cstyle: @find ${top_srcdir} -name build -prune \ -o -type f -name '*.[hc]' \ ! -name 'zfs_config.*' ! -name '*.mod.c' \ ! -name 'opt_global.h' ! -name '*_if*.h' \ ! -path './module/zstd/lib/*' \ -exec ${top_srcdir}/scripts/cstyle.pl -cpP {} \+ filter_executable = -exec test -x '{}' \; -print PHONY += shellcheck shellcheck: @if type shellcheck > /dev/null 2>&1; then \ shellcheck --exclude=SC1090 --exclude=SC1117 --format=gcc \ $$(find ${top_srcdir}/scripts/*.sh -type f) \ $$(find ${top_srcdir}/cmd/zed/zed.d/*.sh -type f) \ $$(find ${top_srcdir}/cmd/zpool/zpool.d/* \ -type f ${filter_executable}); \ else \ echo "skipping shellcheck because shellcheck is not installed"; \ fi PHONY += checkabi storeabi checkabi: lib $(MAKE) -C lib checkabi storeabi: lib $(MAKE) -C lib storeabi PHONY += checkbashisms checkbashisms: @if type checkbashisms > /dev/null 2>&1; then \ checkbashisms -n -p -x \ $$(find ${top_srcdir} \ -name '.git' -prune \ -o -name 'build' -prune \ -o -name 'tests' -prune \ -o -name 'config' -prune \ -o -name 'zed-functions.sh*' -prune \ -o -name 'zfs-import*' -prune \ -o -name 'zfs-mount*' -prune \ -o -name 'zfs-zed*' -prune \ -o -name 'smart' -prune \ -o -name 'paxcheck.sh' -prune \ -o -name 'make_gitrev.sh' -prune \ -o -name '90zfs' -prune \ + -o -path '*initramfs/hooks' -prune \ -o -type f ! -name 'config*' \ ! -name 'libtool' \ - -exec sh -c 'awk "NR==1 && /#!.*bin\/sh.*/ {print FILENAME;}" "{}"' \;); \ + -exec awk 'FNR==1 && /^#!.*bin\/sh/ {print FILENAME}' {} \+); \ else \ echo "skipping checkbashisms because checkbashisms is not installed"; \ fi PHONY += mancheck mancheck: @if type mandoc > /dev/null 2>&1; then \ find ${top_srcdir}/man/man8 -type f -name '*[1-9]*' \ -exec mandoc -Tlint -Werror {} \+; \ else \ echo "skipping mancheck because mandoc is not installed"; \ fi if BUILD_LINUX stat_fmt = -c '%A %n' else stat_fmt = -f '%Sp %N' endif PHONY += testscheck testscheck: @find ${top_srcdir}/tests/zfs-tests -type f \ \( -name '*.ksh' -not ${filter_executable} \) -o \ \( -name '*.kshlib' ${filter_executable} \) -o \ \( -name '*.shlib' ${filter_executable} \) -o \ \( -name '*.cfg' ${filter_executable} \) | \ xargs -r stat ${stat_fmt} | \ awk '{c++; print} END {if(c>0) exit 1}' PHONY += vcscheck vcscheck: @if git rev-parse --git-dir > /dev/null 2>&1; then \ git ls-files . --exclude-standard --others | \ awk '{c++; print} END {if(c>0) exit 1}' ; \ fi PHONY += lint lint: cppcheck paxcheck CPPCHECKDIRS = cmd lib module PHONY += cppcheck cppcheck: $(CPPCHECKDIRS) @if test -n "$(CPPCHECK)"; then \ set -e ; for dir in $(CPPCHECKDIRS) ; do \ $(MAKE) -C $$dir cppcheck ; \ done \ else \ echo "skipping cppcheck because cppcheck is not installed"; \ fi PHONY += paxcheck paxcheck: @if type scanelf > /dev/null 2>&1; then \ ${top_srcdir}/scripts/paxcheck.sh ${top_builddir}; \ else \ echo "skipping paxcheck because scanelf is not installed"; \ fi PHONY += flake8 flake8: @if type flake8 > /dev/null 2>&1; then \ flake8 ${top_srcdir}; \ else \ echo "skipping flake8 because flake8 is not installed"; \ fi PHONY += ctags ctags: $(RM) tags find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs ctags -a PHONY += etags etags: $(RM) TAGS find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hcS]' -print | xargs etags -a PHONY += cscopelist cscopelist: find $(top_srcdir) -name '.?*' -prune \ -o -type f -name '*.[hc]' -print >cscope.files PHONY += tags tags: ctags etags PHONY += pkg pkg-dkms pkg-kmod pkg-utils pkg: @DEFAULT_PACKAGE@ pkg-dkms: @DEFAULT_PACKAGE@-dkms pkg-kmod: @DEFAULT_PACKAGE@-kmod pkg-utils: @DEFAULT_PACKAGE@-utils include config/rpm.am include config/deb.am include config/tgz.am .PHONY: $(PHONY) diff --git a/contrib/initramfs/hooks/zfs.in b/contrib/initramfs/hooks/zfs.in index 414852625650..7e401d1e87e1 100755 --- a/contrib/initramfs/hooks/zfs.in +++ b/contrib/initramfs/hooks/zfs.in @@ -1,117 +1,56 @@ #!/bin/sh # # Add OpenZFS filesystem capabilities to an initrd, usually for a native ZFS root. # -# This hook installs udev rules for OpenZFS. -PREREQ="udev" - -# These prerequisites are provided by the zfsutils package. The zdb utility is -# not strictly required, but it can be useful at the initramfs recovery prompt. -COPY_EXEC_LIST="@sbindir@/zdb @sbindir@/zpool @sbindir@/zfs" -COPY_EXEC_LIST="$COPY_EXEC_LIST @mounthelperdir@/mount.zfs @udevdir@/vdev_id" -COPY_EXEC_LIST="$COPY_EXEC_LIST @udevdir@/zvol_id" -COPY_FILE_LIST="/etc/hostid @sysconfdir@/zfs/zpool.cache" -COPY_FILE_LIST="$COPY_FILE_LIST @initconfdir@/zfs" -COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/zfs-functions" -COPY_FILE_LIST="$COPY_FILE_LIST @sysconfdir@/zfs/vdev_id.conf" -COPY_FILE_LIST="$COPY_FILE_LIST @udevruledir@/60-zvol.rules" -COPY_FILE_LIST="$COPY_FILE_LIST @udevruledir@/69-vdev.rules" - -# These prerequisites are provided by the base system. -COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/dirname /bin/hostname /sbin/blkid" -COPY_EXEC_LIST="$COPY_EXEC_LIST /usr/bin/env" -COPY_EXEC_LIST="$COPY_EXEC_LIST $(which systemd-ask-password)" - -# Explicitly specify all kernel modules because automatic dependency resolution -# is unreliable on many systems. -BASE_MODULES="zlib_deflate spl zavl zcommon znvpair zunicode zlua zfs icp" -CRPT_MODULES="sun-ccm sun-gcm sun-ctr" -MANUAL_ADD_MODULES_LIST="$BASE_MODULES" - -# Generic result code. -RC=0 +if [ "$1" = "prereqs" ]; then + echo "udev" + exit +fi -case $1 in -prereqs) - echo "$PREREQ" - exit 0 - ;; -esac +. /usr/share/initramfs-tools/hook-functions -for ii in $COPY_EXEC_LIST -do - if [ ! -x "$ii" ] - then - echo "Error: $ii is not executable." - RC=2 - fi +for req in "@sbindir@/zpool" "@sbindir@/zfs" "@mounthelperdir@/mount.zfs"; do + copy_exec "$req" || { + echo "$req not available!" >&2 + exit 2 + } done -if [ "$RC" -ne 0 ] -then - exit "$RC" +copy_exec "@sbindir@/zdb" +copy_exec "@udevdir@/vdev_id" +copy_exec "@udevdir@/zvol_id" +if command -v systemd-ask-password > /dev/null; then + copy_exec "$(command -v systemd-ask-password)" fi -. /usr/share/initramfs-tools/hook-functions - -mkdir -p "$DESTDIR/etc/" - -# ZDB uses pthreads for some functions, but the library dependency is not -# automatically detected. The `find` utility and extended `cp` options are -# used here because libgcc_s.so could be in a subdirectory of /lib for -# multi-arch installations. -cp --target-directory="$DESTDIR" --parents $(find /lib/ -type f -name libgcc_s.so.1) +# We use pthreads, but i-t from buster doesn't automatically +# copy this indirect dependency: this can be removed when buster finally dies. +for libgcc in $(find /lib/ -type f -name libgcc_s.so.[1-9]); do + copy_exec "$libgcc" +done -if [ @LIBFETCH_DYNAMIC@ != 0 ] -then - for l in $(find /lib/ -name @LIBFETCH_SONAME@) - do - copy_exec "$l" +if [ @LIBFETCH_DYNAMIC@ != 0 ]; then + for libfetch in $(find /lib/ -name @LIBFETCH_SONAME@); do + copy_exec "$libfetch" done fi -for ii in $COPY_EXEC_LIST -do - copy_exec "$ii" -done +copy_file config "/etc/hostid" +copy_file cache "@sysconfdir@/zfs/zpool.cache" +copy_file config "@initconfdir@/zfs" +copy_file config "@sysconfdir@/zfs/zfs-functions" +copy_file config "@sysconfdir@/zfs/vdev_id.conf" +copy_file rule "@udevruledir@/60-zvol.rules" +copy_file rule "@udevruledir@/69-vdev.rules" -for ii in $COPY_FILE_LIST -do - dir=$(dirname "$ii") - [ -d "$dir" ] && mkdir -p "$DESTDIR/$dir" - [ -f "$ii" ] && cp -p "$ii" "$DESTDIR/$ii" -done +manual_add_modules zfs -for ii in $MANUAL_ADD_MODULES_LIST -do - manual_add_modules "$ii" -done - -if [ -f "/etc/hostname" ] -then - cp -p "/etc/hostname" "$DESTDIR/etc/" +if [ -f "/etc/hostname" ]; then + copy_file config "/etc/hostname" else - hostname >"$DESTDIR/etc/hostname" + hostname="$(mktemp -t hostname.XXXXXXXXXX)" + hostname > "$hostname" + copy_file config "$hostname" "/etc/hostname" + rm -f "$hostname" fi - -for ii in zfs zfs.conf spl spl.conf -do - if [ -f "/etc/modprobe.d/$ii" ]; then - if [ ! -d "$DESTDIR/etc/modprobe.d" ]; then - mkdir -p $DESTDIR/etc/modprobe.d - fi - cp -p "/etc/modprobe.d/$ii" $DESTDIR/etc/modprobe.d/ - fi -done - -# With pull request #1476 (not yet merged) comes a verbose warning -# if /usr/bin/net doesn't exist or isn't executable. Just create -# a dummy... -[ ! -d "$DESTDIR/usr/bin" ] && mkdir -p "$DESTDIR/usr/bin" -if [ ! -x "$DESTDIR/usr/bin/net" ]; then - touch "$DESTDIR/usr/bin/net" - chmod +x "$DESTDIR/usr/bin/net" -fi - -exit 0 diff --git a/contrib/initramfs/hooks/zfsunlock.in b/contrib/initramfs/hooks/zfsunlock.in index d451726545db..4776087d9a76 100644 --- a/contrib/initramfs/hooks/zfsunlock.in +++ b/contrib/initramfs/hooks/zfsunlock.in @@ -1,18 +1,10 @@ #!/bin/sh -PREREQ="dropbear" - -prereqs() { - echo "$PREREQ" -} - -case "$1" in - prereqs) - prereqs - exit 0 - ;; -esac +if [ "$1" = "prereqs" ]; then + echo "dropbear" + exit +fi . /usr/share/initramfs-tools/hook-functions copy_exec /usr/share/initramfs-tools/zfsunlock /usr/bin/zfsunlock