Source

trac-dvbcronrecording-plugin / GNUmakefile

PKG = dvbcronrecording
SPECNAME = trac-$(PKG)-plugin

prefix=/usr
run: builds install
all: builds install restart
upd up: rpm update restart

msg msgchk:
	cd src && python setup.py copy_catalog
	cd src && python setup.py extract_messages
	cd src && python setup.py update_catalog
	cd src && python setup.py compile_catalog
	grep -B 2 'msgstr.*""' src/*/*/*/LC_MESSAGES/*.po | sed -e 's/^--$$//'
msgfmt:
	cd src && python setup.py copy_catalog
	cd src && python setup.py compile_catalog
	
# builds: msgfmt
builds: msgfmt
	: cd src && python setup.py --help build 
	cd src && python setup.py build --build-base=$(BUILDDIR)
	
install:
	: cd src && python setup.py --help install 
	cd src && sudo python setup.py build --build-base=$(BUILDDIR) \
	    install --prefix=$(prefix) --root=/
	
clean:
	cd src && sudo python setup.py clean --build-base=$(BUILDDIR)
	
tests unittest:
	cd src && python setup.py build --build-base=$(BUILDDIR) \
	   test $(CHECK)
check:
	PYTHONPATH=src \
	python src/tests/computer_test.py -vv $(CHECK)
test_%:        # run a single unittest by giving the function name
	@ for filename in src/tests/*_test.py ; do : \
	;  class=`basename $$filename .py` \
	;  echo  "grep 'def $@' $$filename" \
	;  func1=`grep "def $@" $$filename \
	    | sed -e "s/.*def  *//" -e "s/[(].*//" -e q` \
	;  test -n "$$func1" && break \
	; done \
	; if test -n "$$func1" ; then : \
	;   echo "PYTHONPATH=src  \\" \
	;   echo "python $$filename $$class.$$func1" \
	;   echo "" \
	;         PYTHONPATH=src \
	          python $$filename "$$class.$$func1" \
	; else : \
	;   echo "not found $@ in src/tests"; exit 1 \
	; fi
testlist:      # show available unittest function names (for test_%)
	@ for filename in src/tests/*_test.py ; do : \
	;  class=`basename $$filename .py` \
	;  echo "$$class:" \
	;  cat $$filename \
	     | sed -e "/^ *def test_/!d" -e "s/.*def  *//" -e "s/[(].*//" \
	           -e "s/^/  /" \
	; done 
help:          # shows this help
	@ cat $(MAKEFILE_LIST) | sed -e "/^[.a-z][-a-z0-9 _%]*:/!d" -e "s|: |:        |"

genchecks:
	PYTHONPATH=src \
	python src/tests/computer_test.py ... 
checks:
	PYTHONPATH=src \
	python src/tests/computer_tests.py -vv $(CHECK)


RPMROOT=$(shell pwd)/rpm
BUILDDIR = $(RPMROOT)/build
RPMTEMP = '--define=_tmpath $(RPMROOT)/tmp'
RPMBUILD =  rpmbuild '--define=_topdir $(RPMROOT)' \
                     '--define=_builddir $(BUILDDIR)' \
                $(RPMBUILDOPTIONS)

# setuptools sdist is broken for package_data in 0.6c11 vs python 2.6.5, known bug!
# It does simply not work - so use "make dist" instead of "setup.py sdist"
sdist:
	test -d $(RPMROOT)/SOURCES || mkdir -p $(RPMROOT)/SOURCES
	cd src && python setup.py sdist --dist-dir $(RPMROOT)/SOURCES -v -v 
dist: msgfmt
	: cd src && \
	: python setup.py sdist --build-base=$(BUILDDIR) \
	   --dist-dir SOURCES -v -v $X
	test -d $(RPMROOT)/SOURCES || mkdir -p $(RPMROOT)/SOURCES
	cd src && tar czvf $(RPMROOT)/SOURCES/$(PKG).tgz *.py *.cfg *.txt *.spec $(PKG)/
	ls -l $(RPMROOT)/SOURCES/$(PKG).tgz
	@ version=`cat src/$(SPECNAME).spec | sed -e '/define _version/!d' -e 's/.*_version //'` \
	; echo mv $(RPMROOT)/SOURCES/$(PKG).tgz $(RPMROOT)/SOURCES/$(PKG)-$$version.tgz \
	;      mv $(RPMROOT)/SOURCES/$(PKG).tgz $(RPMROOT)/SOURCES/$(PKG)-$$version.tgz

rpm: dist
	test -d $(RPMROOT)/RPMS || mkdir $(RPMROOT)/RPMS
	test -d $(RPMROOT)/SRPMS || mkdir $(RPMROOT)/SRPMS
	test -d $(RPMROOT)/BUILD || mkdir $(RPMROOT)/BUILD
	test -d $(RPMROOT)/SPECS || mkdir $(RPMROOT)/SPECS
	- test -d $(BUILDDIR)/$(PKG) && rm -rf $(BUILDDIR)/*
	cp src/$(SPECNAME).spec $(RPMROOT)/SPECS/$(SPECNAME).spec
	revision=`LANG=C hg summary| sed -e '/parent:/!d' -e 's/parent: *//' -e 's/:.*//'` \
	; if [ -n "$$revision" ]; then set -x \
	;   sed -i -e "s/revision 0/revision $$revision/"  $(RPMROOT)/SPECS/$(SPECNAME).spec \
	; else today=`date +%Y%m%d` \
	;   sed -i -e "s/revision 0/revision 0.$$today/"  $(RPMROOT)/SPECS/$(SPECNAME).spec \
	; fi
	$(RPMBUILD) -ba $(RPMROOT)/SPECS/$(SPECNAME).spec

update:
	@ spec="$(RPMROOT)/SPECS/$(SPECNAME).spec" \
	; version=`cat "$$spec" | sed -e '/define _version/!d' -e 's/.*_version *//'` \
	; package=`cat "$$spec" | sed -e '/Name:/!d' -e 's/Name: *//'` \
	; rev=`cat "$$spec" | sed -e '/define revision/!d' -e 's/.*revision *//' -e 's/ .*//'` \
	; echo rpm -U --force $(RPMROOT)/RPMS/noarch/$$package-$$version.$$rev*.noarch.rpm \
	;      rpm -U --force $(RPMROOT)/RPMS/noarch/$$package-$$version.$$rev*.noarch.rpm
	   
trac restart:
	sudo /sbin/service tracd restart

OSC_ROOT = /my/own/osc
OSC_PROJECT = home:guidod:trac12
OSC_PACKAGE = trac-dvbcronrecording-plugin
OSC = $(OSC_ROOT)/$(OSC_PROJECT)/$(OSC_PACKAGE)
osc: dist
	@ version=`cat src/$(SPECNAME).spec | sed -e '/define _version/!d' -e 's/.*_version //'` \
	; tarball="$(RPMROOT)/SOURCES/$(PKG)-$$version.tgz" \
	; specpath="$(RPMROOT)/SPECS/$(SPECNAME).spec" \
	; if [ -f "$$tarball" ]; then set -x \
	;    (cd $(OSC) && osc rm *.tgz) \
	;    cp -v "$$tarball" $(OSC)/ \
	;    (cd $(OSC) && osc add `basename "$$tarball"` \
	;    cp -v "$$specpath" $(OSC)/$(SPECNAME).spec \
	;    (cd $(OSC) && osc ci -m "update $$version") \
	; else : \
	;    echo "failed to find $$tarball" \
	; fi	  

.PHONY: osc trac restart update install dist sdist msgfmt
	
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.