From 3218d7181246e04fa05225c73c9bf14acffcb0e1 Mon Sep 17 00:00:00 2001 From: Thomas Schneider Date: Sun, 26 Feb 2017 17:07:18 +0100 Subject: Rewrite setup script in Python Signed-off-by: Thomas Schneider --- setup.py | 20 ++++++++++++++++++++ setup.zsh | 17 ----------------- 2 files changed, 20 insertions(+), 17 deletions(-) create mode 100755 setup.py delete mode 100755 setup.zsh diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..173a898 --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import os +import sys +from glob import glob + +os.chdir(os.path.dirname(__file__)) +exit = 0 + +for f in glob('dot.*'): + dst = os.path.expanduser('~/' + f[3:]) + src = os.path.join(os.getcwd(), f) + try: + os.symlink(src, dst) + except FileExistsError: + if not os.path.samefile(src, dst): + print(dst + " exists and does not link do " + dst) + exit = 1 + +sys.exit(exit) diff --git a/setup.zsh b/setup.zsh deleted file mode 100755 index 233a942..0000000 --- a/setup.zsh +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env zsh - -[[ $PWD = ~/.dotfiles ]] || exit 1 - -if [[ $(uname -s) = FreeBSD ]]; then - if [[ -x /compat/linux/bin/ln ]]; then - LN=/compat/linux/bin/ln - else - echo "On FreeBSD and no GNU ln found, exiting" - exit 1 - fi -fi -LN=${LN:-ln} - -for i in dot.*; do - ${LN} -Ts .dotfiles/${i} ~/${i#dot} -done -- cgit v1.2.3