summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesse Morgan <morganjm@amazon.com>2012-11-08 18:21:12 -0800
committerJesse Morgan <morganjm@amazon.com>2012-11-08 18:21:12 -0800
commit4b1a8982664434c1aa187a428685f63ff8747c99 (patch)
tree12a5ae6631c84e0f15a412c02d9185def4f9926f
parentab4f19246099f00d13ee83dc003ee32b6bff8798 (diff)
Progress on setup.py. Add README file.
-rw-r--r--README.txt28
-rw-r--r--setup.py23
2 files changed, 49 insertions, 2 deletions
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