From fd7b7b8bc665c1a633c751ee1ef030d961de81e3 Mon Sep 17 00:00:00 2001 From: Alon Swartz Date: Mon, 15 Mar 2010 15:19:26 +0200 Subject: [PATCH] Initialized project 'ebsmount' from template --- .gitignore | 1 + Makefile | 81 +++++++++++++++++++++++++++++++++++++++++++++++ debian/.gitignore | 1 + debian/compat | 1 + debian/conffiles | 0 debian/control | 12 +++++++ debian/copyright | 23 ++++++++++++++ debian/postinst | 4 +++ debian/preinst | 4 +++ debian/rules | 33 +++++++++++++++++++ ebsmount.py | 51 +++++++++++++++++++++++++++++ 11 files changed, 211 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 debian/.gitignore create mode 100644 debian/compat create mode 100644 debian/conffiles create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/postinst create mode 100755 debian/preinst create mode 100755 debian/rules create mode 100755 ebsmount.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..ed6dabe --- /dev/null +++ b/Makefile @@ -0,0 +1,81 @@ +# standard Python project Makefile +progname = $(shell awk '/^Source/ {print $$2}' debian/control) +name= + +prefix = /usr/local +PATH_BIN = $(prefix)/bin +PATH_INSTALL_LIB = $(prefix)/lib/$(progname) +PATH_DIST := $(progname)-$(shell date +%F) + +all: help + +debug: + $(foreach v, $V, $(warning $v = $($v))) + @true + +dist: clean + -mkdir -p $(PATH_DIST) + + -cp -a .git .gitignore $(PATH_DIST) + -cp -a *.sh *.c *.py Makefile pylib/ libexec* $(PATH_DIST) + + tar jcvf $(PATH_DIST).tar.bz2 $(PATH_DIST) + rm -rf $(PATH_DIST) + +### Extendable targets + +# target: help +help: + @echo '=== Targets:' + @echo 'install [ prefix=path/to/usr ] # default: prefix=$(value prefix)' + @echo 'uninstall [ prefix=path/to/usr ]' + @echo + @echo 'clean' + @echo + @echo 'dist # create distribution tarball' + +# DRY macros +truepath = $(shell echo $1 | sed -e 's/^debian\/$(progname)//') +libpath = $(call truepath,$(PATH_INSTALL_LIB))/$$(basename $1) +subcommand = $(progname)-$$(echo $1 | sed 's|.*/||; s/^cmd_//; s/_/-/g; s/.py$$//') +echo-do = echo $1; $1 + +# first argument: code we execute if there is just one executable module +# second argument: code we execute if there is more than on executable module +define with-py-executables + @modules=$$(find -maxdepth 1 -type f -name '*.py' -perm -100); \ + modules_len=$$(echo $$modules | wc -w); \ + if [ $$modules_len = 1 ]; then \ + module=$$modules; \ + $(call echo-do, $1); \ + elif [ $$modules_len -gt 1 ]; then \ + for module in $$modules; do \ + $(call echo-do, $2); \ + done; \ + fi; +endef + +# target: install +install: + @echo + @echo \*\* CONFIG: prefix = $(prefix) \*\* + @echo + + install -d $(PATH_BIN) $(PATH_INSTALL_LIB) + cp *.py $(PATH_INSTALL_LIB) + + $(call with-py-executables, \ + ln -fs $(call libpath, $$module) $(PATH_BIN)/$(progname), \ + ln -fs $(call libpath, $$module) $(PATH_BIN)/$(call subcommand, $$module)) + +# target: uninstall +uninstall: + rm -rf $(PATH_INSTALL_LIB) + + $(call with-py-executables, \ + rm -f $(PATH_BIN)/$(progname), \ + rm -f $(PATH_BIN)/$(call subcommand, $$module)) + +# target: clean +clean: + rm -f *.pyc *.pyo _$(progname) diff --git a/debian/.gitignore b/debian/.gitignore new file mode 100644 index 0000000..6d10dce --- /dev/null +++ b/debian/.gitignore @@ -0,0 +1 @@ +changelog diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..e69de29 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..05f3aad --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: ebsmount +Section: misc +Priority: optional +Maintainer: Alon Swartz +Build-Depends: debhelper (>> 4.2.0) +Standards-Version: 3.6.1 + +Package: ebsmount +Architecture: all +Depends: python (>= 2.4) +Section: misc +Description: Example diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..caf6a0a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,23 @@ +Author: Liraz Siri + +License: + + Copyright (C) 2010 Liraz Siri + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian and Ubuntu systems, the complete text of the GNU General Public +License can be found in /usr/share/common-licenses/GPL file. + diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000..5e4f0ec --- /dev/null +++ b/debian/postinst @@ -0,0 +1,4 @@ +#!/bin/sh + +#DEBHELPER# +exit 0 diff --git a/debian/preinst b/debian/preinst new file mode 100755 index 0000000..5e4f0ec --- /dev/null +++ b/debian/preinst @@ -0,0 +1,4 @@ +#!/bin/sh + +#DEBHELPER# +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..dc5ca8f --- /dev/null +++ b/debian/rules @@ -0,0 +1,33 @@ +#! /usr/bin/make -f + +progname=$(shell awk '/^Source/ {print $$2}' debian/control) +buildroot=debian/$(progname) +prefix=$(buildroot)/usr + +clean: + dh_clean + +build: + mkdir -p $(prefix) + +install: + dh_testroot + dh_clean -k + dh_testdir + dh_installdirs + dh_install + $(MAKE) install prefix=$(prefix) + +binary-indep: install + dh_testdir + dh_testroot + dh_installdocs + dh_installdeb + dh_gencontrol + dh_md5sums + dh_builddeb + +binary-arch: install + +binary: binary-indep binary-arch +.PHONY: clean binary-indep binary-arch binary install diff --git a/ebsmount.py b/ebsmount.py new file mode 100755 index 0000000..0cc3eff --- /dev/null +++ b/ebsmount.py @@ -0,0 +1,51 @@ +#!/usr/bin/python +"""Example command template + +Options: + -q --quiet don't print anything + -f=FOO print FOO + --fatal fatal error + +""" +import sys +import getopt + +def usage(e=None): + if e: + print >> sys.stderr, "error: " + str(e) + + print >> sys.stderr, "Syntax: %s [args]" % sys.argv[0] + print >> sys.stderr, __doc__.strip() + sys.exit(1) + +def fatal(s): + print >> sys.stderr, "error: " + str(s) + sys.exit(1) + +def main(): + try: + opts, args = getopt.gnu_getopt(sys.argv[1:], 'qf:h', ['fatal']) + except getopt.GetoptError, e: + usage(e) + + opt_quiet = False + for opt, val in opts: + if opt == '-h': + usage() + + if opt in ('-q', '--quiet'): + opt_quiet = True + + elif opt == '-f': + print "printing foo: " + val + + elif opt == '--fatal': + fatal("fatal condition") + + if not opt_quiet: + print "printing args: " + `args` + + +if __name__=="__main__": + main() +