Commits

Kirill Simonov  committed 30474d2

Updated the deb build script.

  • Participants
  • Parent commits 12cd275

Comments (0)

Files changed (10)

File tool/data/pkg/debian/control

-Source: htsql
-Section: non-free/python
+Source: ${NAME}
+Section: database
 Priority: optional
 Maintainer: Clark C. Evans <cce@clarkevans.com>
 Build-Depends: python-all, debhelper (>= 7.4.3), python-setuptools (>= 0.6b3)
-Homepage: http://htsql.org
-Vcs-Browser: https://bitbucket.org/prometheus/htsql
+Homepage: http://htsql.org/
+Vcs-Browser: https://bitbucket.org/prometheus/htsql/
 Standards-Version: 3.9.2
 X-Python-Version: >= 2.6
 
-Package: htsql
+Package: ${NAME}
 Architecture: all
-Depends: python (>=2.6), python-yaml, python-pkg-resources, ${misc:Depends}
-Suggests: python-psycopg2, python-mysqldb
-Description: navigational query language for relational databases
- ***********************************************************
-   HTSQL -- A Query Language for the Accidental Programmer
- ***********************************************************
+Depends: ${DEPENDS}
+Suggests: ${SUGGESTS}
+Description: ${DESCRIPTION_HEAD}
+ HTSQL is a comprehensive navigational query language for relational
+ databases.  HTSQL is designed for data analysts and other accidental
+ programmers who have complex business inquiries to solve and need a
+ productive tool to write and share database queries.  HTSQL is free
+ and open source software.  For more information, please see
+ http://htsql.org/.
  .
- HTSQL ("Hyper Text Structured Query Language") is a high-level query
- language for relational databases.   The target audience for HTSQL is
- the accidental programmer -- one who is not a SQL expert, yet needs a
- usable, comprehensive query tool for data access and reporting.  
- .
- HTSQL is also a web service which takes a request via HTTP, translates
- it into a SQL query, executes the query against a relational database,
- and returns the results in a format requested by the user agent (JSON,
- CSV, HTML, etc.).
- .
- Use of HTSQL with open source databases (PostgreSQL, MySQL, SQLite) is
- royalty free under BSD-style conditions.  Use of HTSQL with proprietary
- database systems (Oracle, Microsoft SQL) requires a commercial license.
- See ``LICENSE`` for details.
+ ${DESCRIPTION_TAIL}
 

File tool/data/pkg/debian/copyright

 Format: http://dep.debian.net/deps/dep5
-Upstream-Name: HTSQL
-Source: https://bitbucket.org/prometheus/htsql
+Upstream-Name: ${SOURCE_NAME}
+Source: http://pypi.python.org/pypi/${SOURCE_NAME}/
 
 Files: *
 Copyright: Copyright (c) 2006-2012, Prometheus Research, LLC
-License: 
- This software is released through a "BSD" style license for use with
- open source databases (such as MySQL, PostgreSQL, SQLite). A commercial
- license is needed for use with a commercial database system, such as
- Oracle, IBM's DB2, or Microsoft SQL Server.
- .
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions 
- are met:
- .
- 1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- .
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- .
- THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS "AS IS" AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY, AGAINST INFRINGEMENT, TITLE AND
- FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
- AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- .
- If this software is used in conjunction with a database system, said
- database system must be published under a license approved by the Open
- Source Initiative or released in the public domain.
+License: AGPL-3
+

File tool/data/pkg/debian/docs

 README
 NEWS
 AUTHORS
-doc/

File tool/data/pkg/debian/htsql-ctl.1

-.\" DO NOT MODIFY THIS FILE!  It was generated by help2man 1.40.4.
-.TH HTSQL-CTL "1" "htsql-ctl 2.2" "User Commands"
-.SH NAME
-htsql-ctl \- command line administrative utility for HTSQL
-.SH SYNOPSIS
-.B htsql-ctl
-\fI<routine> \fR[\fIoptions\fR] [\fIarguments\fR]
-.SH DESCRIPTION
-HTSQL\-CTL \- HTSQL command\-line administrative application
-Copyright \(co 2006\-2012, Prometheus Research, LLC
-.PP
-Run `htsql\-ctl help` for general usage and list of routines.
-Run `htsql\-ctl help <routine>` for help on a specific routine.
-.SS "Available routines:"
-.TP
-help
-: describe the usage of the application and its routines
-.TP
-version
-: display the version of the application
-.TP
-extension
-: list and describe HTSQL extensions
-.TP
-serve
-: start an HTTP server handling HTSQL requests
-.TP
-shell
-: start an HTSQL shell
-.TP
-get
-: execute and render an HTSQL query
-.TP
-post
-: execute and render an HTSQL query with POST data

File tool/data/pkg/debian/htsql.doc-base

 Document: htsql
-Title: HTSQL Tutorial and Reference
+Title: HTSQL Documentation
 Author: Clark C. Evans & Kirill Siminov
-Abstract: Tutorial, reference, and other guides for 
+Abstract: Overview, tutorial, reference, and other guides for
  the HTSQL language and implementation.
 Section: Data Management
 
 Format: HTML
-Index: /usr/share/doc/htsql/doc/index.html
+Index: /usr/share/doc/htsql/doc/html/index.html
 Files: /usr/share/doc/htsql/doc/

File tool/data/pkg/debian/htsql.docs

+README
+NEWS
+AUTHORS
+doc/

File tool/data/pkg/debian/htsql.manpages

+doc/man/htsql-ctl.1

File tool/data/pkg/debian/manpages

-debian/htsql-ctl.1

File tool/data/pkg/debian/moves.yaml

+#
+# Copyright (c) 2006-2012, Prometheus Research, LLC
+#
+
+---
+code:
+files:
+  debian/changelog: changelog
+  debian/compat: compat
+  debian/control: control
+  debian/copyright: copyright
+  debian/docs: docs
+  debian/rules: rules
+  debian/source/format: source/format
+variables:
+  name:
+  source-name:
+  depends:
+  suggests:
+  description-head:
+  description-tail:
+
+---
+code: htsql
+files:
+  debian/docs: htsql.docs
+  debian/htsql.doc-base: htsql.doc-base
+  debian/manpages: htsql.manpages
+variables:
+  name: htsql
+  source-name: HTSQL
+  depends: python (>=2.6), python-yaml, python-pkg-resources, ${misc:Depends}
+  suggests: htsql-pgsql, htsql-mysql
+  description-head:
+    a database query language (core & SQLite backend)
+  description-tail:
+    This package provides HTSQL core and SQLite backend.
+
+---
+code: htsql-pgsql
+variables:
+  name: htsql-pgsql
+  source-name: HTSQL-PGSQL
+  depends: htsql, python-psycopg2
+  description-head:
+    a database query language (PostgreSQL backend)
+  description-tail:
+    This package provides HTSQL backend for PostgreSQL.
+
+---
+code: htsql-mysql
+variables:
+  name: htsql-mysql
+  source-name: HTSQL-MYSQL
+  depends: htsql, python-mysqldb
+  description-head:
+    a database query language (MySQL backend)
+  description-tail:
+    This package provides HTSQL backend for MySQL.
+
 from job import job, log, debug, fatal, warn, run, ls, cp, rmtree, mktree, pipe
 from vm import LinuxBenchVM, WindowsBenchVM, DATA_ROOT, CTL_DIR
 from dist import pipe_python, setup_py
-import os, re, StringIO, pprint
+import os, re, shutil
 import setuptools
 import yaml
 
         assert os.path.isdir(dst)
         for filename in sorted(self.files):
             parts = self.files[filename]
+            origin = None
             if parts is None:
                 parts = []
             elif isinstance(parts, str):
+                origin = parts
                 parts = [parts]
             assert isinstance(parts, list) and all(isinstance(part, str)
                                                    for part in parts)
                 part = open(part).read()
                 part = self.substitute(part)
                 stream.write(part)
+            stream.close()
+            if origin:
+                shutil.copystat(os.path.join(src, origin), filename)
 
     def substitute(self, data):
         def replace(match):
 load_moves = Move.load
 
 
+def get_version():
+    return yaml.load(pipe_python("-c 'import setup, yaml;"
+                                 " print yaml.dump(setup.get_version())'"))
+
+def get_addons():
+    return yaml.load(pipe_python("-c 'import setup, yaml;"
+                                 " print yaml.dump(setup.get_addons())'"))
+
+
 @job
 def pkg_src():
     """create a source package
         rmtree("./build/pkg/src")
     if os.path.exists("./build/tmp"):
         rmtree("./build/tmp")
-    version = yaml.load(pipe_python("-c 'import setup, yaml;"
-                                    " print yaml.dump(setup.get_version())'"))
-    all_addons = yaml.load(pipe_python("-c 'import setup, yaml;"
-                                       " print yaml.dump(setup.get_addons())'"))
+    version = get_version()
+    all_addons = get_addons()
     moves = load_moves(DATA_ROOT+"/pkg/source/moves.yaml")
     src_vm.start()
     try:
         log()
 
 
-class DEB_Packager(Packager):
-
-    def __init__(self):
-        Packager.__init__(self, deb_vm)
-        # create debian_version variable
-        if self.suffix:
-            version = self.version + "~" + self.suffix
-        else:
-            version = self.version
-        changelog = open(DATA_ROOT+"/pkg/debian/changelog").read()
-        if ('htsql (%s-1)' % version) not in changelog:
-            raise fatal("update debian/changelog for %s release" % version)
-        self.debian_version = version
-        self.build_file = "htsql_%s-1_all.deb" % version
-        
-    def package(self):
-        self.vm.run("mv %s htsql_%s.orig.tar.gz" % (self.archive, self.debian_version))
-        self.vm.run("tar xvfz htsql_%s.orig.tar.gz" % self.debian_version)
-        self.vm.put(DATA_ROOT+"/pkg/debian", "HTSQL-%s" % self.upstream_version)
-        self.vm.run("cd HTSQL-%s && dpkg-buildpackage -k%s" % \
-                     (self.upstream_version, KEYSIG))
-        self.vm.run("dpkg -i %s" % self.build_file)
-
-               
 @job
 def pkg_deb():
-    """create a debian package
+    """create Debian packages
 
-    This job creates combined source & binary package.
+    This job creates Debian packages from source packages.
+    """
+    if deb_vm.missing():
+        raise fatal("VM is not built: %s" % deb_vm.name)
+    if deb_vm.running():
+        deb_vm.stop()
+    if os.path.exists("./build/pkg/deb"):
+        rmtree("./build/pkg/deb")
+    if os.path.exists("./build/tmp"):
+        rmtree("./build/tmp")
+    version = get_version()
+    debian_version = version
+    if len(version.split(".")) > 3:
+        debian_version = (".".join(version.split(".")[:3]) + "~" +
+                          ".".join(version.split(".")[3:]))
+    moves = load_moves(DATA_ROOT+"/pkg/debian/moves.yaml")
+    deb_vm.start()
+    pubkey = pipe("gpg --armour --export %s" % KEYSIG)
+    seckey = pipe("gpg --armour --export-secret-key %s" % KEYSIG)
+    deb_vm.write("/root/sign.key", pubkey + seckey)
+    deb_vm.run("gpg --import /root/sign.key")
+    try:
+        for move in moves:
+            package = "%s-%s" % (move.code.upper(), version)
+            debian_package = "%s_%s" % (move.code, debian_version)
+            archive = "./build/pkg/src/%s.tar.gz" % package
+            if not os.path.exists(archive):
+                raise fatal("cannot find a source package;"
+                            " run `job pkg-src` first")
+            changelog = open(DATA_ROOT+"/pkg/debian/changelog").read()
+            if ('htsql (%s-1)' % debian_version) not in changelog:
+                raise fatal("run `job pkg-deb-changelog`"
+                            " to update the changelog file")
+            changelog = changelog.replace('htsql (', '%s (' % move.code)
+            mktree("./build/tmp")
+            cp(archive, "./build/tmp/%s.orig.tar.gz" % debian_package)
+            run("tar -xzf %s -C ./build/tmp" % archive)
+            move(DATA_ROOT+"/pkg/debian", "./build/tmp/%s" % package)
+            open("./build/tmp/%s/debian/changelog" % package, 'w') \
+                    .write(changelog)
+            deb_vm.put("./build/tmp", "./build")
+            deb_vm.run("cd ./build/%s && dpkg-buildpackage -k%s"
+                       % (package, KEYSIG))
+            if not os.path.exists("./build/pkg/deb"):
+                mktree("./build/pkg/deb")
+            deb_vm.get("./build/*.deb", "./build/pkg/deb")
+            deb_vm.run("rm -rf build")
+            rmtree("./build/tmp")
+    finally:
+        deb_vm.stop()
+    log()
+    log("The generated Debian packages are placed in:")
+    for filename in ls("./build/pkg/deb/*"):
+        log("  `%s`" % filename)
+    log()
 
-    You must also append a release note to tool/data/pkg/debian/changelog
-    that matches the current release version.  Debian's pre-release naming
-    convention is different than Python's since it requires a tilde 
-    before the b1, rc1, etc.
+
+@job
+def pkg_deb_changelog(message=None):
+    """update the Debian changelog
+
+    This job updates the Debian changelog to the current HTSQL version.
     """
-    packager = DEB_Packager()
-    packager()
+    if message is None:
+        message = "new upstream release"
+    version = get_version()
+    debian_version = version
+    if len(version.split(".")) > 3:
+        debian_version = (".".join(version.split(".")[:3]) + "~" +
+                          ".".join(version.split(".")[3:]))
+    debian_version += "-1"
+    changelog = open(DATA_ROOT+"/pkg/debian/changelog").read()
+    if ('htsql (%s)' % debian_version) in changelog:
+        raise fatal("changelog is already up-to-date")
+    run("dch --check-dirname-level 0 -D unstable -v %s %s"
+        % (debian_version, message),
+        cd=DATA_ROOT+"/pkg/debian")
+    log("The Debian changelog is updated to version:")
+    log("  `%s`" % debian_version)
+    log()
 
 
 class RPM_Packager(Packager):