makefile to automate some tasks
authorAlexander Solovyov <alexander@solovyov.net>
Thu, 27 Jan 2011 10:41:47 +0100
changeset 178 88a20499b498
parent 177 c7517e6c7698
child 179 038e81e5332c
makefile to automate some tasks
Makefile
contrib/updatepkg.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile	Thu Jan 27 10:41:47 2011 +0100
@@ -0,0 +1,12 @@
+.PHONY: help docs arch
+
+help:
+	@echo "Use \`make <target>\` with one of targets:"
+	@echo "  docs  build docs"
+	@echo "  arch  update archlinux pkgbuild"
+
+docs:
+	cd docs && make
+
+arch:
+	python contrib/updatepkg.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/contrib/updatepkg.py	Thu Jan 27 10:41:47 2011 +0100
@@ -0,0 +1,25 @@
+#!/usr/bin/env python
+
+import os, sys, re, hashlib
+
+ROOT = os.path.join(os.path.dirname(__file__), '..')
+PKGBUILD = os.path.join(ROOT, 'contrib', 'PKGBUILD')
+VER = re.compile('^pkgver=[\d\.]+$', re.M)
+MD5 = re.compile("^md5sums=\('[0-9a-f]+'\)$", re.M)
+
+sys.path.insert(0, ROOT)
+
+if __name__ == '__main__':
+    import opster
+    dist = os.path.join(ROOT, 'dist', 'opster-%s.tar.gz' % opster.__version__)
+    if not os.path.exists(dist):
+        print 'dist .tar.gz is not built yet, exiting'
+        sys.exit(1)
+
+    pkg = open(PKGBUILD).read()
+    pkg = VER.sub('pkgver=%s' % opster.__version__, pkg)
+    md5 = hashlib.md5(open(dist).read()).hexdigest()
+    pkg = MD5.sub("md5sums=('%s')" % md5, pkg)
+    open(PKGBUILD, 'w').write(pkg)
+
+    print 'PKGBUILD updated'