Symlink submodules as a whole instead of each file. Fixes #6.

This commit is contained in:
David Tomaschik
2019-04-29 15:59:58 -07:00
parent 1a592beaea
commit 19d78117cb

View File

@@ -48,17 +48,39 @@ prerequisites() {
install_dotfile_dir() { install_dotfile_dir() {
local SRCDIR="${1}" local SRCDIR="${1}"
local dotfile local dotfile
local submodule_prune="$(git submodule status -- "${SRCDIR}" 2>/dev/null | \
awk '{print $2}' | \
while read submod ; do
echo -n " -o -path ${BASEDIR}/${submod}"
done)"
find "${SRCDIR}" \( -name .git -o \ find "${SRCDIR}" \( -name .git -o \
-path "${SRCDIR}/private_dotfiles" -o \ -path "${SRCDIR}/private_dotfiles" -o \
-name install.sh -o \ -name install.sh -o \
-name README.md -o \ -name README.md -o \
-name .gitignore \) \ -name .gitignore \
${submodule_prune} \) \
-prune -o ${FINDTYPE} f -print | \ -prune -o ${FINDTYPE} f -print | \
while read dotfile ; do while read dotfile ; do
local TARGET="${HOME}/.${dotfile#${SRCDIR}/}" local TARGET="${HOME}/.${dotfile#${SRCDIR}/}"
mkdir -p `dirname "${TARGET}"` mkdir -p $(dirname "${TARGET}")
ln -s -f "${dotfile}" "${TARGET}" ln -s -f "${dotfile}" "${TARGET}"
done done
git submodule status -- "${SRCDIR}" 2>/dev/null | \
awk '{print $2}' | \
while read submodule ; do
local FULLNAME="${BASEDIR}/${submodule}"
local TARGET="${HOME}/.${FULLNAME#${SRCDIR}/}"
mkdir -p $(dirname "${TARGET}")
if test -L "${TARGET}" ; then
if [ "$(readlink "${TARGET}")" != "${FULLNAME}" ] ; then
echo "${TARGET} points to $(readlink "${TARGET}") not ${FULLNAME}!" >/dev/stderr
fi
elif test -d "${TARGET}" ; then
echo "rm -rf ${TARGET}" >/dev/stderr
else
ln -s -f "${FULLNAME}" "${TARGET}"
fi
done
} }
install_basic_dir() { install_basic_dir() {