Skip to content

Commit

Permalink
Update building policy for debian package.
Browse files Browse the repository at this point in the history
  • Loading branch information
lwindg committed Jun 12, 2015
1 parent c4e1ba3 commit 499aa52
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 67 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
74 changes: 60 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
44 changes: 44 additions & 0 deletions build-deb/Makefile
Original file line number Diff line number Diff line change
@@ -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)_*
6 changes: 6 additions & 0 deletions build-deb/debian/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The Debian Package route
----------------------------

Comments regarding the Package

-- Aeluin Chen <[email protected]> Fri, 12 Jun 2015 16:48:57 +0800
17 changes: 17 additions & 0 deletions build-deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sanji-bundle-route (0.9.4-2) unstable; urgency=low

* Update building policy for debian package.

-- Aeluin Chen <[email protected]> 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 <[email protected]> Fri, 05 Jun 2015 18:32:58 +0800

sanji-bundle-route (0.9.0) unstable; urgency=low

* Initial Release.

-- Aeluin Chen <[email protected]> Fri, 05 Jun 2015 18:27:19 +0800
File renamed without changes.
8 changes: 4 additions & 4 deletions debian/control → build-deb/debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Build-Depends-Indep: python (>= 2.7)
Standards-Version: 3.9.3
Section: libs
Homepage: http://www.moxa.com
#Vcs-Git: [email protected]: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

File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions debian/postinst → build-deb/debian/postinst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# postinst script for sanji-bundle-route
# postinst script for route
#
# see: dh_installdeb(1)

Expand All @@ -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
;;

Expand Down
16 changes: 15 additions & 1 deletion debian/rules → build-deb/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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)
File renamed without changes.
33 changes: 0 additions & 33 deletions debian.mk

This file was deleted.

6 changes: 0 additions & 6 deletions debian/README

This file was deleted.

5 changes: 0 additions & 5 deletions debian/changelog

This file was deleted.

0 comments on commit 499aa52

Please sign in to comment.