E2FSPROGS_POST_INSTALL_TARGET_HOOKS += E2FSPROGS_TARGET_E2FSCK_SYMLINKS
endif
-# Remove busybox tune2fs and e2label, since we want the e2fsprogs full
-# blown variants to take precedence, but they are not installed in the
-# same location.
+# If BusyBox is included, its configuration may supply its own variant
+# of ext2-related tools. Since Buildroot desires having full blown
+# variants take precedence (in this case, e2fsprogs), we want to remove
+# BusyBox's variant of e2fsprogs provided binaries. e2fsprogs targets
+# /usr/{bin,sbin} where BusyBox targets /{bin,sbin}. We will attempt to
+# remove BusyBox-generated ext2-related tools from /{bin,sbin}. We need
+# to do this in the pre-install stage to ensure we do not accidentally
+# remove e2fsprogs's binaries in usr-merged environments (ie. if they
+# are removed, they would be re-installed in this package's install
+# stage).
ifeq ($(BR2_PACKAGE_BUSYBOX),y)
E2FSPROGS_DEPENDENCIES += busybox
$(RM) -f $(TARGET_DIR)/sbin/tune2fs
$(RM) -f $(TARGET_DIR)/sbin/e2label
endef
-E2FSPROGS_POST_INSTALL_TARGET_HOOKS += E2FSPROGS_REMOVE_BUSYBOX_APPLETS
+E2FSPROGS_PRE_INSTALL_TARGET_HOOKS += E2FSPROGS_REMOVE_BUSYBOX_APPLETS
endif
define E2FSPROGS_TARGET_TUNE2FS_SYMLINK