From 36892eaa48ff6db64fa663c0adac5b3de7fed1dc Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Wed, 23 Sep 2020 12:44:16 +0000 Subject: [PATCH] - make /sbin/e2fsck and /sbin/fsck_ext2fs visible in pkg catalog/"pkg which", so that "pkg which /sbin/e2fsck" yields the proper result. * this entails symlinking from $PREFIX/sbin to /sbin, and the pkg-install script will attempt to replace the symlinks by hard links if possible. pkg 1.15.4 cannot deal with packaged hard links and will fail. * Note that it is unavoidable that these be in /sbin because /usr/local or /usr may not be mounted and consequently ext2 file systems could not be fsck-ed or mounted from /etc/fstab. There will be no port option to avoid /sbin installs for now. We have too many options already and the testing effort increases exponentially. - make sure pkg-message appears on both install and upgrade - clean up and document/comment pkg-install so that armchair experts will not pester me with meaningless change requests - bugfix/change: logic of mke2fs.conf upgrade handling to present less work for users on port/package upgrades - bump PORTREVISION PR: 249284 (related) --- sysutils/e2fsprogs/Makefile | 26 ++++++++++++--- sysutils/e2fsprogs/pkg-install | 59 ++++++++++++++++++---------------- sysutils/e2fsprogs/pkg-message | 5 +++ sysutils/e2fsprogs/pkg-plist | 2 ++ 4 files changed, 61 insertions(+), 31 deletions(-) diff --git a/sysutils/e2fsprogs/Makefile b/sysutils/e2fsprogs/Makefile index e976d8d55ddf..8be707803f81 100644 --- a/sysutils/e2fsprogs/Makefile +++ b/sysutils/e2fsprogs/Makefile @@ -3,7 +3,7 @@ PORTNAME= e2fsprogs PORTVERSION= 1.45.6 -PORTREVISION?= 3 +PORTREVISION?= 4 CATEGORIES?= sysutils MASTER_SITES= KERNEL_ORG/linux/kernel/people/tytso/${PORTNAME}/v${PORTVERSION} @@ -252,7 +252,8 @@ post-build: && ${MAKE_CMD} e2fsck V=1 \ LIBS="-static-libgcc -lc -Bstatic ../lib/libsupport.a ../lib/libext2fs.a ../lib/libcom_err.a \ ${_staticlibs} /usr/lib/libexecinfo.a /usr/lib/libelf.a \ - ${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a " + ${LOCALBASE}/lib/libblkid.a ${LOCALBASE}/lib/libuuid.a ${libintl} ../lib/libe2p.a " \ + && ${STRIP_CMD} e2fsck # Regression check: avoid a port (not upstream!) regression from 1.40.5, # check that e2fsck isn't dynalinked against anything but libc.so: @${ECHO_CMD} -n "===> checking that e2fsck depends on no shared objects outside /lib: " @@ -292,7 +293,24 @@ post-build: .endif post-install: - ${INSTALL_PROGRAM} ${WRKSRC}/fsck_ext2fs ${STAGEDIR}${PREFIX}/sbin/ + # pkg workaround time again; + # the whole purpose of this dance is to move the necessities for + # /etc/fstab fsck'ing into /sbin, and symlink to these guys + # in the regular hierarchy, normally $PREFIX/sbin. Hard links may + # crash the install if /usr[/local] is a separate file system from /, + # and pkg 1.15.4 can't automatically unroll or install relative symlinks. + ${MKDIR} ${STAGEDIR}/sbin + ${MV} -f ${STAGEDIR}${PREFIX}/sbin/e2fsck ${STAGEDIR}/sbin/ # from INSTALL_TARGET + ${INSTALL_PROGRAM} ${WRKSRC}/fsck_ext2fs ${STAGEDIR}/sbin/ # from port + # according to TPH 6.1.1 Handling Symbolic Links, these are to be absolute, + # yet stage-qa warns about these on 2020-09-16: + ${LN} -fs /sbin/fsck_ext2fs ${STAGEDIR}${PREFIX}/sbin/ + ${LN} -fs /sbin/e2fsck ${STAGEDIR}${PREFIX}/sbin/ + # these are made hardlinks to symlinks - -P avoids following them to /sbin: + ${LN} -fP ${STAGEDIR}${PREFIX}/sbin/e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext2 + ${LN} -fP ${STAGEDIR}${PREFIX}/sbin/e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext3 + ${LN} -fP ${STAGEDIR}${PREFIX}/sbin/e2fsck ${STAGEDIR}${PREFIX}/sbin/fsck.ext4 + # now the remainder of the usual post-install jobs: ${INSTALL_MAN} ${FILESDIR}/fsck_ext2fs.8 ${STAGEDIR}${PREFIX}/man/man8/ .if ${PORT_OPTIONS:MDOCS} ${MKDIR} ${STAGEDIR}${DOCSDIR} @@ -300,7 +318,7 @@ post-install: ${INSTALL_DATA} ${WRKSRC}/${i} ${STAGEDIR}${DOCSDIR} .endfor .endif -# remove or relocate files installed by other ports already, or shadowing system files: + # remove or relocate files installed by other ports already, or shadowing system files: cd ${STAGEDIR}${PREFIX} && \ ${XARGS} <${FILESDIR}/unwanted ${RM} && \ ${RMDIR} include/e2fsprogs/blkid include/e2fsprogs/ss share/ss diff --git a/sysutils/e2fsprogs/pkg-install b/sysutils/e2fsprogs/pkg-install index eaf8242f192a..ab1e42d59f23 100644 --- a/sysutils/e2fsprogs/pkg-install +++ b/sysutils/e2fsprogs/pkg-install @@ -1,41 +1,44 @@ #!/bin/sh -set -e +set -eu PKGNAME="$1" MODE="$2" # PRE-INSTALL, POST-INSTALL, DEINSTALL, POST-DEINSTALL case "$MODE" in POST-INSTALL) - # install fsck tool and wrapper. - err=0 - for i in e2fsck fsck_ext2fs ; do - ln -f ${PKG_PREFIX}/sbin/${i} /sbin 2>/dev/null \ - || cp -p ${PKG_PREFIX}/sbin/${i} /sbin \ - || err=1 - done - if test $err = 1 ; then - echo '========================================================================' - echo 'Warning: cannot install fsck to /sbin!' - echo 'Requesting ext2fs to be checked from /etc/fstab can cause boot failures!' - echo '========================================================================' - echo '' + # try to replace the e2fsck and its wrapper, fsck_ext2fs, + # symbolic links by hard links if possible (pkg ships them as symlinks) + d1=${PKG_ROOTDIR}/sbin/ ; dev1=$(stat -Lf %Xd "$d1") + d2=${PKG_ROOTDIR}${PKG_PREFIX}/sbin/ ; dev2=$(stat -Lf %Xd "$d2") + if [ "$dev1" = "$dev2" ] && [ "$(realpath "$d1")" != "$(realpath "$d2")"; then + for i in e2fsck fsck_ext2fs ; do + ln -fhP ${d1}${i} ${d2}${i} + done + for i in ext2 ext3 ext4 ; do + ln -fhP ${d2}e2fsck ${d2}fsck.$i + done fi # - # install configuration file and update + # install configuration file and update config files from + # old "ext4dev" to current "ext4" name. # - if test -f ${PKG_PREFIX}/etc/mke2fs.conf; then + if test -s ${PKG_PREFIX}/etc/mke2fs.conf; then if cmp -s ${PKG_PREFIX}/etc/mke2fs.conf.dist \ - ${PKG_PREFIX}/etc/mke2fs.conf; then + ${PKG_PREFIX}/etc/mke2fs.conf; then true else - if grep -q ext4dev ${PKG_PREFIX}/etc/mke2fs.conf ; then + rc=0 + grep -q ext4dev ${PKG_PREFIX}/etc/mke2fs.conf || rc=$? + case $rc in + 1) # ext4dev not found (old name) cp -f -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \ ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-new echo "===========================================================================" echo "Warning: installing mke2fs.conf in ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-new" echo "Check to see if you need to update your ${PKG_PREFIX}/etc/mke2fs.conf" echo "===========================================================================" - else + ;; + 0) # ext4dev found (old name) mv ${PKG_PREFIX}/etc/mke2fs.conf \ ${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-old cp -f -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \ @@ -45,17 +48,19 @@ POST-INSTALL) echo "${PKG_PREFIX}/etc/mke2fs.conf.e2fsprogs-old. Please check to see" echo "if you have any local customizations that you wish to preserve." echo "===========================================================================" - fi - echo " " + ;; + *) # grep failed + exit $rc + ;; + esac fi else - cp -f -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \ + # missing -> install + cp -p ${PKG_PREFIX}/etc/mke2fs.conf.dist \ ${PKG_PREFIX}/etc/mke2fs.conf fi ;; DEINSTALL) - rm -f /sbin/fsck_ext2fs /sbin/e2fsck \ - || echo "Could not remove /sbin/fsck_ext2fs /sbin/e2fsck. Please remove manually." if cmp -s ${PKG_PREFIX}/etc/mke2fs.conf \ ${PKG_PREFIX}/etc/mke2fs.conf.dist then @@ -64,13 +69,13 @@ DEINSTALL) echo "If and only if you are deleting e2fsprogs forever," echo "remember to delete ${PKG_PREFIX}/etc/mke2fs.conf." fi + # e2fsck.conf is no longer part of the distribution, but still supported, + # => no pkg-list @sample line possible + # and no reference e2fsck.conf.sample or e2fsck.conf.dist is available if test -f ${PKG_PREFIX}/etc/e2fsck.conf then echo "If and only if you are deleting e2fsprogs forever," echo "remember to delete ${PKG_PREFIX}/etc/e2fsck.conf." fi ;; -PRE-INSTALL|POST-DEINSTALL) - true - ;; esac diff --git a/sysutils/e2fsprogs/pkg-message b/sysutils/e2fsprogs/pkg-message index e58b0a0d7e07..68a7a422b142 100644 --- a/sysutils/e2fsprogs/pkg-message +++ b/sysutils/e2fsprogs/pkg-message @@ -1,3 +1,8 @@ +[ +{ message: <