diff --git a/.travis.yml b/.travis.yml index ea06d90..de2028b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,9 @@ python: install: - pip install -r requirements.txt - pip install -r tests/requirements.txt -script: make +script: + - make pylint + - make test after_success: coveralls notifications: diff --git a/Makefile b/Makefile index e1c5b97..8b85306 100644 --- a/Makefile +++ b/Makefile @@ -1,23 +1,69 @@ +NAME = $(shell cat bundle.json | sed -n 's/"name"//p' | tr -d '", :') +VERSION = $(shell cat bundle.json | sed -n 's/"version"//p' | tr -d '", :') -FILES = README.md bundle.json route.py requirements.txt -DIRS = data ip +PROJECT = sanji-bundle-$(NAME) -all: pylint test +DISTDIR = $(PROJECT)-$(VERSION) +ARCHIVE = $(CURDIR)/$(DISTDIR).tar.gz + +SANJI_VER ?= 1.0 +INSTALL_DIR = $(DESTDIR)/usr/lib/sanji-$(SANJI_VER)/$(NAME) +STAGING_DIR = $(CURDIR)/staging +PROJECT_STAGING_DIR = $(STAGING_DIR)/$(DISTDIR) + +TARGET_FILES = \ + bundle.json \ + requirements.txt \ + route.py \ + data/route.json.factory \ + ip/__init__.py \ + ip/addr.py \ + ip/route.py +DIST_FILES= \ + $(TARGET_FILES) \ + README.md \ + Makefile \ + tests/requirements.txt \ + tests/test_route.py \ + tests/data/route.json.factory \ + tests/test_e2e/bundle.json \ + tests/test_e2e/view_routes.py +INSTALL_FILES=$(addprefix $(INSTALL_DIR)/,$(TARGET_FILES)) +STAGING_FILES=$(addprefix $(PROJECT_STAGING_DIR)/,$(DIST_FILES)) + + +all: + +clean: + rm -rf $(DISTDIR)*.tar.gz $(STAGING_DIR) + @rm -rf .coverage + @find ./ -name *.pyc | xargs rm -rf + +distclean: clean pylint: flake8 -v --exclude=.git,__init__.py . test: - nosetests --with-coverage --cover-erase --cover-package=route -v + nosetests --with-coverage --cover-erase --cover-package=$(NAME) -v -deb: - mkdir -p deb - cp -a debian deb/ - cp -a debian.mk deb/Makefile - cp -a README.md $(FILES) $(DIRS) deb/ - (cd deb; \ - dpkg-buildpackage -us -uc -rfakeroot;) +dist: $(ARCHIVE) -clean: - rm -rf deb +$(ARCHIVE): distclean $(STAGING_FILES) + @mkdir -p $(STAGING_DIR) + cd $(STAGING_DIR) && \ + tar zcf $@ $(DISTDIR) + +$(PROJECT_STAGING_DIR)/%: % + @mkdir -p $(dir $@) + @cp -a $< $@ + +install: $(INSTALL_FILES) + +$(INSTALL_DIR)/%: % + @mkdir -p $(dir $@) + @cp -a $< $@ + +uninstall: + -rm $(addprefix $(INSTALL_DIR)/,$(TARGET_FILES)) -.PHONY: pylint test +.PHONY: clean dist pylint test diff --git a/build-deb/Makefile b/build-deb/Makefile new file mode 100644 index 0000000..b99c73a --- /dev/null +++ b/build-deb/Makefile @@ -0,0 +1,44 @@ +PROJ_DIR = $(abspath ..) + +NAME = $(shell cat $(PROJ_DIR)/bundle.json | sed -n 's/"name"//p' | tr -d '", :') +VERSION = $(shell cat $(PROJ_DIR)/bundle.json | sed -n 's/"version"//p' | tr -d '", :') + +PROJECT = sanji-bundle-$(NAME) +DEBVERSION = 1 +DIST ?= unstable + +STAGING_DIR = $(abspath $(PROJECT)-$(VERSION)) +UPSTREAM_ARCHIVE = $(PROJECT)-$(VERSION).tar.gz + +FILES = \ + $(STAGING_DIR)/debian/changelog \ + $(STAGING_DIR)/debian/compat \ + $(STAGING_DIR)/debian/control \ + $(STAGING_DIR)/debian/copyright \ + $(STAGING_DIR)/debian/docs \ + $(STAGING_DIR)/debian/postinst \ + $(STAGING_DIR)/debian/README \ + $(STAGING_DIR)/debian/rules \ + $(STAGING_DIR)/debian/source/format + +.PHONY: all build + +all: build + +build: extract-upstream $(FILES) + cd $(STAGING_DIR) && \ + dpkg-buildpackage -us -uc -rfakeroot + +$(STAGING_DIR)/debian/%: $(PROJ_DIR)/build-deb/debian/% + mkdir -p $(dir $@) + cp $< $@ + +extract-upstream: + tar zxf $(PROJ_DIR)/$(UPSTREAM_ARCHIVE) + +changelog: + dch -v $(VERSION)-$(DEBVERSION) -D $(DIST) -M -u low \ + --release-heuristic log + +clean: + rm -rf $(STAGING_DIR) $(PROJECT)-* $(PROJECT)_* diff --git a/build-deb/debian/README b/build-deb/debian/README new file mode 100644 index 0000000..e8881f1 --- /dev/null +++ b/build-deb/debian/README @@ -0,0 +1,6 @@ +The Debian Package route +---------------------------- + +Comments regarding the Package + + -- Aeluin Chen Fri, 12 Jun 2015 16:48:57 +0800 diff --git a/build-deb/debian/changelog b/build-deb/debian/changelog new file mode 100644 index 0000000..6865e44 --- /dev/null +++ b/build-deb/debian/changelog @@ -0,0 +1,17 @@ +sanji-bundle-route (0.9.4-2) unstable; urgency=low + + * Update building policy for debian package. + + -- Aeluin Chen Fri, 12 Jun 2015 16:57:12 +0800 + +sanji-bundle-route (0.9.4-1) unstable; urgency=low + + * Use netifaces to speedup query time. + + -- Aeluin Chen Fri, 05 Jun 2015 18:32:58 +0800 + +sanji-bundle-route (0.9.0) unstable; urgency=low + + * Initial Release. + + -- Aeluin Chen Fri, 05 Jun 2015 18:27:19 +0800 diff --git a/debian/compat b/build-deb/debian/compat similarity index 100% rename from debian/compat rename to build-deb/debian/compat diff --git a/debian/control b/build-deb/debian/control similarity index 68% rename from debian/control rename to build-deb/debian/control index f8f1ade..786f5b0 100644 --- a/debian/control +++ b/build-deb/debian/control @@ -6,13 +6,13 @@ Build-Depends-Indep: python (>= 2.7) Standards-Version: 3.9.3 Section: libs Homepage: http://www.moxa.com -#Vcs-Git: git@github.com:lwindg/sanji-bundle-routes.git -#Vcs-Browser: https://github.com/lwindg/sanji-bundle-routes +#Vcs-Git: +#Vcs-Browser: X-Python-Version: >= 2.5 Package: sanji-bundle-route Section: libs Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, python2.7, python-pip -Description: A sanji library for configure the default route. - +Description: Handle the routing table + diff --git a/debian/copyright b/build-deb/debian/copyright similarity index 100% rename from debian/copyright rename to build-deb/debian/copyright diff --git a/debian/docs b/build-deb/debian/docs similarity index 100% rename from debian/docs rename to build-deb/debian/docs diff --git a/debian/postinst b/build-deb/debian/postinst similarity index 86% rename from debian/postinst rename to build-deb/debian/postinst index dcbc2e2..8715f6a 100644 --- a/debian/postinst +++ b/build-deb/debian/postinst @@ -1,5 +1,5 @@ #!/bin/sh -# postinst script for sanji-bundle-route +# postinst script for route # # see: dh_installdeb(1) @@ -20,9 +20,9 @@ set -e case "$1" in configure) - pip install -r /tmp/packages/bundle-requirements.txt || \ + pip install -r /tmp/packages/requirements.txt || \ pip install --no-index --find-links file:/tmp/packages \ - -r /tmp/packages/bundle-requirements.txt + -r /tmp/packages/requirements.txt rm -rf /tmp/packages ;; diff --git a/debian/rules b/build-deb/debian/rules similarity index 53% rename from debian/rules rename to build-deb/debian/rules index 2ebce13..e746a10 100755 --- a/debian/rules +++ b/build-deb/debian/rules @@ -9,5 +9,19 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 +DEB_PACKAGE := $(strip $(shell dh_listpackages -i 2>/dev/null || dh_listpackages -i)) +DEB_DESTDIR := $(CURDIR)/debian/$(DEB_PACKAGE) + +DEB_PYPDIR := $(DEB_DESTDIR)/tmp/packages + + %: - dh $@ --with python2 + dh $@ + +override_dh_auto_test: + +override_dh_auto_install: + dh_auto_install + mkdir -p $(DEB_PYPDIR) + cp -a requirements.txt $(DEB_PYPDIR) + pip install -r requirements.txt --download $(DEB_PYPDIR) diff --git a/debian/source/format b/build-deb/debian/source/format similarity index 100% rename from debian/source/format rename to build-deb/debian/source/format diff --git a/debian.mk b/debian.mk deleted file mode 100644 index 4f229d6..0000000 --- a/debian.mk +++ /dev/null @@ -1,33 +0,0 @@ - -# Where to put executable commands/icons/conf on 'make install'? -SANJI_VER = 1.0 -RESOURCE = network/route -LIBDIR = $(DESTDIR)/usr/lib/sanji-$(SANJI_VER)/$(RESOURCE) -TMPDIR = $(DESTDIR)/tmp - -FILES = bundle.json route.py -DIRS = data ip - - -all: - mkdir -p $(CURDIR)/packages - pip install -r $(CURDIR)/packages/requirements.txt --download \ - $(CURDIR)/packages || true - cp -a $(CURDIR)/requirements.txt \ - $(CURDIR)/packages/bundle-requirements.txt - -clean: - # do nothing - -distclean: clean - - -install: all - install -d $(LIBDIR) - install -d $(TMPDIR) - install $(FILES) $(LIBDIR) - cp -a $(DIRS) $(LIBDIR) - cp -a packages $(TMPDIR) - -uninstall: - -rm $(addprefix $(LIBDIR)/,$(FILES)) diff --git a/debian/README b/debian/README deleted file mode 100644 index 2999cb0..0000000 --- a/debian/README +++ /dev/null @@ -1,6 +0,0 @@ -The Debian Package sanji-bundle-route ----------------------------- - -Comments regarding the Package - - -- Aeluin Chen Tue, 02 Dec 2014 17:02:46 +0800 diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 064ab9e..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -sanji-bundle-route (1.0.0) unstable; urgency=low - - * Initial Release. - - -- Aeluin Chen Tue, 02 Dec 2014 17:02:46 +0800