]>
git.ipfire.org Git - thirdparty/lldpd.git/blob - fabfile.py
1 from fabric
.api
import *
10 env
.shell
= "/bin/sh -c"
11 env
.command_prefixes
= [ 'export PATH=$HOME/.virtualenvs/hyde/bin:$PATH',
12 'export VIRTUAL_ENV=$HOME/.virtualenvs/hyde' ]
15 return local('python ../hyde/h %s' % args
)
18 """Generate dev content"""
22 """Serve dev content"""
23 _hyde('serve -a 0.0.0.0')
26 """Build production content"""
27 # Generate the website from scratch
28 local("rm -rf deploy")
29 conf
= "site-production.yaml"
30 _hyde('gen -c %s' % conf
)
32 # Compute hash for media files
34 for p
in [ 'media/js/*.js',
36 files
= glob
.glob("%s/%s" % (env
.lcwd
, p
))
40 md5
.update(file(f
).read())
41 md5
= md5
.hexdigest()[:8]
42 f
= f
[len(env
.lcwd
)+1:]
43 print "[+] MD5 hash for %s is %s" % (f
, md5
)
45 root
, ext
= os
.path
.splitext(f
)
46 newname
= "%s.%s%s" % (root
, md5
, ext
)
48 local("cp %s %s" % (f
, newname
))
50 local(r
"find . -name '*.html' -type f -print0 | xargs -r0 sed -i "
52 r
"s@\([\"']\)\([^\"']*\
)%s\
1@\
1\
2%s\
1@g"
56 tempdir = tempfile.mkdtemp()
59 local("git clone %s -b gh-pages ." % lldpdir)
60 local("rsync -ac --exclude=.git %s/deploy/ ." % lldpdir)
62 local("git diff --stat HEAD")
63 answer = prompt("More diff?", default="yes")
64 if answer.lower().startswith("y"):
65 local("git diff --word-diff HEAD")
66 answer = prompt("Keep?", default="yes")
67 if answer.lower().startswith("y"):
68 local('git commit
-a
-m
"Update generated copy of website"')
69 local('git push origin
')
71 shutil.rmtree(tempdir)
74 """Push production content to remote locations"""
75 local("git push origin gh-pages")
76 local("git push origin website")