From 60d5ee12ecbc69281cc6447637fc15c5bdcc9336 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Thu, 8 Nov 2012 18:21:12 -0800 Subject: Progress on setup.py. Add README file. --- README.txt | 28 ++++++++++++++++++++++++++++ setup.py | 23 +++++++++++++++++++++-- 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 README.txt diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..5b86774 --- /dev/null +++ b/README.txt @@ -0,0 +1,28 @@ +dotfiles +================================================================================ + +This is my collection of dotfiles. They are organized like this: + +base/ Files I want on every host. +host-overrides/ + jesterpm.net/ These files override those in base/ on hosts + with domains ending in jesterpm.net + + host-specific/ Files in this directory are typically + sourced from files in base to provide + host (or domain) specific extensions. + + bismuth.jesterpm.net/ These files override those in jesterpm.net/ + on bismuth.jesterpm.net in + +setup.py A script to setup links to the dot files. + + +setup.py +------------------------------------------------------------------------------- +The setup scripts makes the following links: + + * For every file X in base/, ~/.X is linked to base/X + +If a file already exists, it is deleted unless the --nice flag is given. + diff --git a/setup.py b/setup.py index 9c4e9a5..412afc9 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ class Usage(Exception): self.msg = msg """ Create links to dotfiles """ -def makeDots(home, nice): +def makeDots(home, nice = False, pretend = False): # First make a map of dot files to files in the repository. dotfiles = getMap("base/") @@ -30,7 +30,26 @@ def makeDots(home, nice): hostname = socket.getfqdn().split(".") for i in range(len(hostname)): name = string.join(hostname[-(i+1):], ".") - dotfiles = getMap("host-overrides/" + name, dotfiles) + dotfiles = dotfiles + getMap("host-overrides/" + name) + + if pretend: + print "I would make these links:" + else: + print "I am making these links:" + + for dst, src in dotfiles: + realDest = home + "/" + dst + if not pretend: + makeLink(src, realDest, nice) + + print "%s/.%s => %s" % (home, dst, src) + +def getMap(directory): + dots = dict() + for filename in LISTOFFILES: + if FILEXISTS: # directory + "/" + filename + "/.nolink" + dots += getChildMap(directory, filename) + dots["." + filename] = directory + "/" + filename -- cgit v1.2.3