Commits

Kirill Simonov committed 6961a51

Updated the build script for RPM packages.

  • Participants
  • Parent commits 30474d2

Comments (0)

Files changed (6)

tool/data/pkg/debian/docs

 README
+LICENSE
 NEWS
 AUTHORS

tool/data/pkg/debian/htsql.docs

 README
+LICENSE
 NEWS
 AUTHORS
 doc/

tool/data/pkg/debian/watch

-version=3
-opts=uversionmangle=s/(beta|rc|a|b|c)/~$1/ \
-http://pypi.python.org/packages/source/H/HTSQL/HTSQL-(.*)\.tar\.gz debian uupdate

tool/data/pkg/redhat/HTSQL.spec

 %{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
 
-Name:           HTSQL
-Version:        2.2.1
+Name:           ${NAME}
+Version:        ${VERSION}
 Release:        1%{?dist}
-Summary:        navigational query language for relational databases
+Summary:        ${SUMMARY}
 
 Group:          Application/Databases
 License:        Free To Use But Restricted
 URL:            http://htsql.org 
-Source:         %{name}-%{version}.tar.gz
+Source:         ${PACKAGE}.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 Prefix:         %{_prefix}
 
 BuildArch:      noarch
 Vendor:         Prometheus Research, LLC
 BuildRequires:  python-devel, python-setuptools
-Requires:       PyYAML, python-setuptools
+Requires:       ${REQUIRES}
 
 %description
-***********************************************************
-  HTSQL -- A Query Language for the Accidental Programmer
-***********************************************************
+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.
-
-For installation instructions, see ``INSTALL``.  For list of new
-features in this release, see ``NEWS``.  HTSQL documentation is in the
-``doc`` directory. 
-
-    http://htsql.org/
-        The HTSQL homepage
-
-    http://htsql.org/doc/introduction.html
-        Get taste of HTSQL
-
-    http://htsql.org/doc/tutorial.html
-        The HTSQL tutorial
-
-    http://bitbucket.org/prometheus/htsql
-        HTSQL source code
-
-    irc://irc.freenode.net#htsql
-        IRC chat in #htsql on freenode
-
-    http://lists.htsql.org/mailman/listinfo/htsql-users
-        The mailing list for users of HTSQL
-
-HTSQL is copyright by Prometheus Research, LLC.  HTSQL is written by
-Clark C. Evans <cce@clarkevans.com> and Kirill Simonov <xi@resolvent.net>.
-
-Generous support for HTSQL was provided by the Simons Foundation.
-This material is also based upon work supported by the National
-Science Foundation under Grant #0944460.
-
+${DESCRIPTION}
 
 %prep
-%setup -q -n %{name}-%{version}
+%setup -q -n ${PACKAGE}
 
 %build
 %{__python} setup.py build
 
 %files
 %defattr(-,root,root,-)
-%doc README NEWS LICENSE AUTHORS doc
-/usr/bin/htsql-ctl
+%doc ${DOC_FILES}
+${FILES}
 # For noarch packages: sitelib
 %{python_sitelib}/*
 

tool/data/pkg/redhat/moves.yaml

+#
+# Copyright (c) 2006-2012, Prometheus Research, LLC
+#
+
+---
+code:
+files:
+  BUILD/:
+  RPMS/:
+  SOURCES/:
+  SPECS/:
+  SRPMS/:
+variables:
+  name:
+  version: # set by the build script
+  package: # set by the build script
+  requires:
+  summary:
+  description:
+  doc-files:
+  files:
+
+---
+code: htsql
+files:
+  SPECS/HTSQL.spec: HTSQL.spec
+variables:
+  name: HTSQL
+  requires: PyYAML, python-setuptools
+  summary:
+    a database query language (core & SQLite backend)
+  description:
+    This package provides HTSQL core and SQLite backend.
+  doc-files: README LICENSE NEWS AUTHORS doc
+  files: /usr/bin/htsql-ctl
+
+---
+code: htsql-pgsql
+files:
+  SPECS/HTSQL-PGSQL.spec: HTSQL.spec
+variables:
+  name: HTSQL-PGSQL
+  requires: HTSQL, python-psycopg2
+  summary:
+    a database query language (PostgreSQL backend)
+  description:
+    This package provides HTSQL backend for PostgreSQL.
+  doc-files: README LICENSE NEWS AUTHORS
+
+---
+code: htsql-mysql
+files:
+  SPECS/HTSQL-MYSQL.spec: HTSQL.spec
+variables:
+  name: HTSQL-MYSQL
+  requires: HTSQL, MySQL-python
+  summary:
+    a database query language (MySQL backend)
+  description:
+    This package provides HTSQL backend for MySQL.
+  doc-files: README LICENSE NEWS AUTHORS
+
                 parts = [parts]
             assert isinstance(parts, list) and all(isinstance(part, str)
                                                    for part in parts)
+            filename = os.path.join(dst, filename)
+            if filename.endswith("/"):
+                assert not parts
+                os.makedirs(filename)
             if not parts:
                 continue
-            filename = os.path.join(dst, filename)
             dirname = os.path.dirname(filename)
             if not os.path.exists(dirname):
                 os.makedirs(dirname)
     log()
 
 
-class Packager(object):
-
-    def __init__(self, vm):
-        self.vm = vm
-        if self.vm.missing():
-             raise fatal("VM is not built: %s" % self.vm.name)
-        source_paths = ls("./build/pkg/src/HTSQL-*.tar.gz")
-        if not source_paths:
-            raise fatal("cannot find a source package; run `job pkg-src` first")
-        if len(source_paths) > 1:
-            raise fatal("too many source packages in `./build/pkg/src`")
-        [self.source_path] = source_paths
-        self.archive = os.path.basename(self.source_path)
-        self.upstream_version = re.match(r'^HTSQL-(?P<version>.+).tar.gz$',
-                                         self.archive).group('version')
-        (self.version, self.suffix) = re.match(r'^(\d+\.\d+.\d+)(.*)$', 
-                                               self.upstream_version).groups()
-        self.build_path = "build/pkg/%s" % self.vm.name
-
-    def __call__(self):
-        if self.vm.running():
-            self.vm.stop()
-        if os.path.exists(self.build_path):
-            rmtree(self.build_path)
-        self.vm.start()
-        try:
-            # install signing key
-            pubkey = pipe("gpg --armour --export %s" % KEYSIG)
-            seckey = pipe("gpg --armour --export-secret-key %s" % KEYSIG)
-            self.vm.write("/root/sign.key", pubkey + seckey)
-            self.vm.run("gpg --import /root/sign.key")
-            # upload package source, build and test
-            self.vm.put(self.source_path, '/root')
-            mktree(self.build_path)
-            self.package()
-            self.vm.run("htsql-ctl get sqlite:test.db /%27Hello%20World%27")
-            self.vm.get(self.build_file, self.build_path)
-        finally:
-            self.vm.stop()
-        log()
-        log("Package is built successfully:")
-        log("  %s/`%s`" % (self.build_path, self.build_file))
-        log()
-
-
 @job
 def pkg_deb():
     """create Debian packages
     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:]))
+    debian_version = ".".join(version.split(".")[:3])
     moves = load_moves(DATA_ROOT+"/pkg/debian/moves.yaml")
     deb_vm.start()
     pubkey = pipe("gpg --armour --export %s" % KEYSIG)
     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 = ".".join(version.split(".")[:3])
     debian_version += "-1"
     changelog = open(DATA_ROOT+"/pkg/debian/changelog").read()
     if ('htsql (%s)' % debian_version) in changelog:
     log()
 
 
-class RPM_Packager(Packager):
-
-    def __init__(self):
-        Packager.__init__(self, rpm_vm)
-        self.distribution = 'el6'
-        self.build_file = "HTSQL-%s-1.%s.noarch.rpm" % \
-                             (self.upstream_version, self.distribution)
-        
-    def package(self):
-        self.vm.run("mkdir -p rpmbuild/{BUILD,RPMS,S{OURCE,PEC,RPM}S}")
-        self.vm.put(DATA_ROOT+"/pkg/redhat", "redhat")
-        self.vm.run("cp redhat/.rpmmacros ~ ")
-        self.vm.run("mv redhat/HTSQL.spec rpmbuild/SPECS")
-        self.vm.run("mv %s rpmbuild/SOURCES" % self.archive)
-        self.vm.run("rpmbuild -bb rpmbuild/SPECS/HTSQL.spec")
-        self.vm.run("mv rpmbuild/RPMS/noarch/%s ~" % self.build_file)
-        #self.vm.run("rpmsign --addsign %s" % self.build_file)
-        self.vm.run("rpm -i %s" % self.build_file)
-
-               
 @job
 def pkg_rpm():
-    """create a redhat package
+    """create RedHat/CentOS packages
 
-    This job creates combined source & binary package.
+    This job creates RedHat/CentOS packages from source packages.
     """
-    packager = RPM_Packager()
-    packager()
+    if rpm_vm.missing():
+        raise fatal("VM is not built: %s" % rpm_vm.name)
+    if rpm_vm.running():
+        rpm_vm.stop()
+    if os.path.exists("./build/pkg/rpm"):
+        rmtree("./build/pkg/rpm")
+    if os.path.exists("./build/tmp"):
+        rmtree("./build/tmp")
+    version = get_version()
+    redhat_version = ".".join(version.split(".")[:3])
+    moves = load_moves(DATA_ROOT+"/pkg/redhat/moves.yaml")
+    rpm_vm.start()
+    pubkey = pipe("gpg --armour --export %s" % KEYSIG)
+    seckey = pipe("gpg --armour --export-secret-key %s" % KEYSIG)
+    rpm_vm.write("/root/sign.key", pubkey + seckey)
+    rpm_vm.run("gpg --import /root/sign.key")
+    rpm_vm.put(DATA_ROOT+"/pkg/redhat/.rpmmacros", ".")
+    try:
+        for move in moves:
+            name = move.variables['name']
+            move.variables['version'] = redhat_version
+            move.variables['package'] = "%s-%s" % (name, version)
+            package = "%s-%s" % (name, 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")
+            mktree("./build/tmp")
+            move(DATA_ROOT+"/pkg/redhat", "./build/tmp")
+            cp(archive, "./build/tmp/SOURCES")
+            rpm_vm.put("./build/tmp", "./rpmbuild")
+            rpm_vm.run("rpmbuild -bb rpmbuild/SPECS/%s.spec" % name)
+            if not os.path.exists("./build/pkg/rpm"):
+                mktree("./build/pkg/rpm")
+            #rpm_vm.run("rpmsign --addsign ./rpmbuild/RPMS/noarch/*.rpm")
+            rpm_vm.get("./rpmbuild/RPMS/noarch/*.rpm", "./build/pkg/rpm")
+            rpm_vm.run("rm -rf rpmbuild")
+            rmtree("./build/tmp")
+    finally:
+        rpm_vm.stop()
+    log()
+    log("The generated RedHat/CentOS packages are placed in:")
+    for filename in ls("./build/pkg/rpm/*"):
+        log("  `%s`" % filename)
+    log()
 
 
 @job