/stdhome

To get this branch, use:
bzr branch http://bzr.ed.am/stdhome
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash

CURRENT=
if [ -d ~/.stdhome.orig -a ! -d ~/.stdhome.dev ]; then
	CURRENT=on
elif [ ! -d ~/.stdhome.orig -a -d ~/.stdhome.dev ]; then
	CURRENT=off
fi

if [ -z "$CURRENT" ]; then
	echo "Can't determine current state" >&2
	exit 1
fi

if [ "$CURRENT" == "off" ]; then
	echo "Dev environment is off" >&2
	exit 1
fi

# revno?
REVNO=
if [ -n "$1" ]; then
	if [ $(( 0 + $1 )) -gt 0 ]; then
		REVNO=$(( 0 + $1 ))
	fi
fi

# check/create reset dir
if [ ! -d ~/.stdhome.dev.reset/home -a ! -d ~/.stdhome/home ]; then
	echo "No ~/.stdhome.dev/home and nothing to copy it from"
	exit 1
fi
if [ ! -d ~/.stdhome.dev.reset/home ]; then
	echo copying dev environment to initial snapshot
	rm -rf ~/.stdhome.dev.reset
	cp -a ~/.stdhome ~/.stdhome.dev.reset
fi

# update repo
echo updating repo snapshot
cd ~/.stdhome.dev.reset/home
bzr up
cd

# reset repos
echo resetting repo
rm -rf ~/.stdhome
cp -a ~/.stdhome{.dev.reset,}

# revert stage
if [ -n "$REVNO" ]; then
	echo applying revno $REVNO
	/usr/local/bin/stdhome stage-revert
	cd ~/.stdhome/home
	bzr up -r $REVNO
	cd
fi

# reset "home" dir
echo resetting homedir
rm -rf ~/tmp/stdhome-dev
cp -a ~/.stdhome/home ~/tmp/stdhome-dev