summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-12-01 13:13:02 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2011-12-01 13:13:02 +0000
commit159c90e1e485f9fe9c3ad8093ed70e5b99ca63ac (patch)
tree2a35589c79ac15eaf54d37619a78cbfccdd27ba9
parent71aa6dc4b72374aa84b4c1bb4067a2b7841e4322 (diff)
downloadmorph-159c90e1e485f9fe9c3ad8093ed70e5b99ca63ac.tar.gz
create cachedir at startup if it does not exist
We don't create it if running as root, since that would mean a typo creates a directory in a place that may be awkward. Anyone running builds as root can go create the directory themselves.
-rwxr-xr-xmorph3
-rwxr-xr-xtests/build-chunk.script3
-rwxr-xr-xtests/build-stratum.script3
-rwxr-xr-xtests/build-system.script3
-rwxr-xr-xtests/missing-ref.script2
5 files changed, 3 insertions, 11 deletions
diff --git a/morph b/morph
index 9e61ac16..96987fa8 100755
--- a/morph
+++ b/morph
@@ -58,6 +58,9 @@ class Morph(cliapp.Application):
tempdir = morphlib.tempdir.Tempdir()
builder = morphlib.builder.Builder(tempdir, self.msg, self.settings)
+ if not os.path.exists(self.settings['cachedir']) and os.getuid() != 0:
+ os.mkdir(self.settings['cachedir'])
+
while len(args) >= 3:
repo, ref, filename = args[:3]
args = args[3:]
diff --git a/tests/build-chunk.script b/tests/build-chunk.script
index 8058edff..732c54f5 100755
--- a/tests/build-chunk.script
+++ b/tests/build-chunk.script
@@ -20,7 +20,6 @@
set -e
cache="$DATADIR/build-chunk-cache"
-mkdir "$cache"
./morph --no-default-configs build repo farrokh hello.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path
@@ -30,5 +29,3 @@ do
tar -tf "$chunk" | LC_ALL=C sort | sed '/^\.\/./s:^\./::'
echo
done
-rm -rf "$cache"
-
diff --git a/tests/build-stratum.script b/tests/build-stratum.script
index cdb4d016..ead14e5d 100755
--- a/tests/build-stratum.script
+++ b/tests/build-stratum.script
@@ -20,10 +20,7 @@
set -e
cache="$DATADIR/build-stratum-cache"
-mkdir "$cache"
./morph --no-default-configs build repo farrokh hello-stratum.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path
tar -tf "$cache/"*.stratum.* | LC_ALL=C sort | sed '/^\.\/./s:^\./::'
-rm -rf "$cache"
-
diff --git a/tests/build-system.script b/tests/build-system.script
index b1f36532..f081d1e8 100755
--- a/tests/build-system.script
+++ b/tests/build-system.script
@@ -20,10 +20,7 @@
set -e
cache="$DATADIR/build-system-cache"
-mkdir "$cache"
./morph --no-default-configs build repo farrokh hello-system.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path
find "$cache" -name '*.system.*' -type f | wc -l
-rm -rf "$cache"
-
diff --git a/tests/missing-ref.script b/tests/missing-ref.script
index 1a5dabca..3d5ebc98 100755
--- a/tests/missing-ref.script
+++ b/tests/missing-ref.script
@@ -20,9 +20,7 @@
set -e
cache="$DATADIR/build-chunk-cache"
-mkdir "$cache"
./morph --no-default-configs build repo non-existent-branch hello.morph \
--git-base-url="file://$DATADIR" \
--cachedir="$cache" --keep-path
-rm -rf "$cache"