[emacs] Update submodule + rework install script

This commit is contained in:
nemunaire 2015-06-29 15:21:03 +02:00
parent 7a0ca44f5d
commit 8e69908166
2 changed files with 70 additions and 42 deletions

@ -1 +1 @@
Subproject commit 6efad95dbab78f4bbed3c95b96abb766c1a7a392 Subproject commit 5998ca087f2475a5c5c01f30334320af750e6fd0

View File

@ -1,12 +1,21 @@
#!/bin/sh #!/bin/sh
if [ ${0:0:1} == "/" ] die() {
then echo "$1" >&2
SOURCE=$(dirname $0)/ exit 1
else }
SOURCE=$(dirname `pwd`/$0)/
fi in_list() {
DESTINATION=~ for i in $1
do
[ "$i" == "$2" ] && return 0
done
return 1
}
cd $(dirname "$0")
[ -n "${DESTDIR}" ] || DESTDIR=~
if [ "$1" == "install" ] || [ "$1" == "link" ] || [ "$1" == "links" ] if [ "$1" == "install" ] || [ "$1" == "link" ] || [ "$1" == "links" ]
then then
@ -14,8 +23,9 @@ then
BIN="ln -s" BIN="ln -s"
elif [ "$1" == "update" ] || [ "$1" == "pull" ] elif [ "$1" == "update" ] || [ "$1" == "pull" ]
then then
cd $SOURCE git stash &&
git pull --recurse-submodules=yes `git remote | head -n 1` git pull --recurse-submodules=yes --rebase `git remote | head -n 1` &&
git stash pop
exit $? exit $?
elif [ "$1" == "remove" ] || [ "$1" == "uninstall" ] elif [ "$1" == "remove" ] || [ "$1" == "uninstall" ]
then then
@ -42,39 +52,57 @@ else
exit 0 exit 0
fi fi
cd "$SOURCE" git submodule update --init --recursive || die "Unable to update submodules"
git submodule init &&
git submodule update --recursive IGNORE_FILES=".
..
.git
.gitmodules
install.sh"
TMPERR=`mktemp` TMPERR=`mktemp`
for f in `ls -a "$SOURCE"` install_dir() {
do for f in `ls -a "$1"`
if [ "$f" != "." ] && [ "$f" != ".." ] && [ "$f" != ".git" ] && do
[ "$f" != ".gitmodules" ] && [ "$f" != "install.sh" ] if ! in_list "$IGNORE_FILES" "$f"
then then
if [ "$REMOVE" -eq 0 ]; then if [ "$REMOVE" -eq 0 ]; then
echo -ne "Removing $f ...\t" echo -ne "Removing $1/$f ...\t"
if [ -L "$DESTINATION/$f" ]; then if [ -L "${DESTDIR}/$1/$f" ]; then
$BIN "$DESTINATION/$f" >&2 2> "$TMPERR" $BIN "${DESTDIR}/$1/$f" >&2 2> "$TMPERR"
if [ $? == 0 ]; then echo -e "\e[32mdone\e[0m"; else echo -e "\e[31;01mfail\e[0m"; fi if [ $? == 0 ]; then echo -e "\e[32mdone\e[0m"; else echo -e "\e[31;01mfail\e[0m"; fi
cat "$TMPERR" cat "$TMPERR"
else else
echo -e "Not installed" echo -e "Not installed"
fi fi
else else
echo -ne "Installing $f ...\t" echo -ne "Installing $1/$f ...\t"
if [ ${#f} -lt 9 ]; then echo -en "\t"; fi
if [ -L "$DESTINATION/$f" ] # Alignment
[ $((${#f} + ${#1})) -lt 8 ] && echo -en "\t"; [ $((${#f} + ${#1})) -lt 16 ] && echo -en "\t"
if [ -L "${DESTDIR}/$1/$f" ]
then then
echo -e "\e[36mAlready installed\e[0m" echo -e "\e[36mAlready installed\e[0m"
elif [ -e "$DESTINATION/$f" ] elif [ -d "${DESTDIR}/$1/$f" ] && [ -d "$1/$f" ]
then
echo -e "\e[33mExistant directory\e[0m"
install_dir "$1/$f"
elif [ -e "${DESTDIR}/$1/$f" ]
then then
echo -e "\e[35mAlready exists\e[0m" echo -e "\e[35mAlready exists\e[0m"
else else
$BIN "$SOURCE/$f" "$DESTINATION/$f" >&2 2> "$TMPERR" if $BIN "$(pwd)/$1/$f" "${DESTDIR}/$1/$f" >&2 2> "$TMPERR"
if [ $? == 0 ]; then echo -e "\e[32mdone\e[0m"; else echo -e "\e[31;01mfail\e[0m"; fi then
echo -e "\e[32mdone\e[0m"
else
echo -e "\e[31;01mfail\e[0m"
fi
cat "$TMPERR" cat "$TMPERR"
fi fi
fi fi
fi fi
done done
}
install_dir .
rm "${TMPERR}"