Permalink
Browse files

initial commit of turnkey-pylib structure

  • Loading branch information...
0 parents commit da8b9639e6d0598f6444cf48e80d9936bfbeea32 @alonswartz alonswartz committed Mar 5, 2010
Showing with 146 additions and 0 deletions.
  1. +5 −0 .gitignore
  2. +1 −0 INSTALL
  3. +1 −0 debian/.gitignore
  4. +1 −0 debian/compat
  5. +13 −0 debian/control
  6. +23 −0 debian/copyright
  7. +33 −0 debian/rules
  8. +69 −0 setup.py
5 .gitignore
@@ -0,0 +1,5 @@
+*.pyc
+build
+tmp
+tags
+
1 INSTALL
@@ -0,0 +1 @@
+python setup.py install -O2
1 debian/.gitignore
@@ -0,0 +1 @@
+changelog
1 debian/compat
@@ -0,0 +1 @@
+5
13 debian/control
@@ -0,0 +1,13 @@
+Source: turnkey-pylib
+Section: python
+Priority: optional
+Maintainer: Alon Swartz <alon@sterilesecurity.com>
+Build-Depends: debhelper (>> 4.2.0), python (>= 2.4)
+Standards-Version: 3.6.1
+
+Package: turnkey-pylib
+Architecture: any
+Depends: python (>= 2.4)
+Suggests: python-profiler
+Description: TurnKey Linux standard Python library
+
23 debian/copyright
@@ -0,0 +1,23 @@
+Author: Alon Swartz <alon@turnkeylinux.org>
+
+License:
+
+ Copyright (C) 2010 Alon Swartz <alon@turnkeylinux.org>
+
+ 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.
+
33 debian/rules
@@ -0,0 +1,33 @@
+#! /usr/bin/make -f
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+progname=$(shell awk '/^Source/ {print $$2}' debian/control)
+prefix=debian/$(progname)/usr
+
+build:
+ mkdir -p $(prefix)
+
+clean:
+ dh_clean
+
+install: build
+ dh_clean -k
+ python setup.py install -O2 --prefix $(prefix)
+
+ # delete sources / unoptimized modules
+ rm $$(find $(prefix) -type f |grep '\.pyc\?$$')
+
+binary-indep: build install
+
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdeb -a
+ dh_gencontrol -a
+ dh_md5sums -a
+ dh_builddeb -a
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
69 setup.py
@@ -0,0 +1,69 @@
+import re
+import os.path
+import commands
+
+from distutils.core import setup
+
+class ExecError(Exception):
+ pass
+
+def _getoutput(command):
+ status, output = commands.getstatusoutput(command)
+ if status != 0:
+ raise ExecError()
+ return output
+
+def get_version():
+ if not os.path.exists("debian/changelog"):
+ version = _getoutput("autoversion HEAD")
+ return version
+ else:
+ output = _getoutput("dpkg-parsechangelog")
+ version = [ line.split(" ")[1]
+ for line in output.split("\n")
+ if line.startswith("Version:") ][0]
+ return version
+
+def parse_control(control):
+ """parse control fields -> dict"""
+ d = {}
+ for line in control.split("\n"):
+ if not line or line[0] == " ":
+ continue
+ line = line.strip()
+ i = line.index(':')
+ key = line[:i]
+ val = line[i + 2:]
+ d[key] = val
+
+ return d
+
+def parse_email(email):
+ m = re.match(r'(.*)\s*<(.*)>', email.strip())
+ if m:
+ name, address = m.groups()
+ else:
+ name = ""
+ address = email
+
+ return name.strip(), address.strip()
+
+def main():
+ control_fields = parse_control(file("debian/control").read())
+ maintainer = control_fields['Maintainer']
+ maintainer_name, maintainer_email = parse_email(maintainer)
+
+ setup(packages = [''],
+ package_dir = {'': 'pylib'},
+
+ # non-essential meta-data
+ name=control_fields['Source'],
+ version=get_version(),
+ maintainer=maintainer_name,
+ maintainer_email=maintainer_email,
+ description=control_fields['Description'])
+
+if __name__=="__main__":
+ main()
+
+

0 comments on commit da8b963

Please sign in to comment.