From 326660ff61e2558f2d1ee7544cc6139816f1b6b7 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 9 Jan 2009 14:29:51 +0100 Subject: initial version --- debian/changelog | 6 ++ debian/compat | 1 + debian/control | 15 +++++ debian/copyright | 28 ++++++++ debian/install | 1 + debian/pycompat | 1 + debian/rules | 14 ++++ make-sgpkg.py | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 26 ++++++++ 9 files changed, 284 insertions(+) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100644 debian/pycompat create mode 100755 debian/rules create mode 100755 make-sgpkg.py create mode 100644 setup.py diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..cb39817 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +sapgui-package (0.0.1) unstable; urgency=low + + * Initial Release, inspired by java-package, installation commandline taken + from Matthias Schmitt's non public sapgui package. + + -- Guido Günther Thu, 08 Jan 2009 18:54:30 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..b4ef40e --- /dev/null +++ b/debian/control @@ -0,0 +1,15 @@ +Source: sapgui-package +Section: contrib/misc +Priority: extra +Maintainer: Guido Günther +Build-Depends: cdbs, debhelper (>= 7), python, python-support +Standards-Version: 3.8.0 +VCS-Git: http://honk.sigxcpu.org/git/sapgui-package.git + +Package: sapgui-package +Architecture: all +Depends: cdbs, fakeroot, java5-runtime, ${python:Depends} +Description: utility to build SAPGui related Debian packages + This package provides the capability to create a Debian package for the + Platinum Java SAP GUI from the provided JAR by just running + 'make-sgpkg '. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..2cfe2c3 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,28 @@ +This is sapgui-package maintained by Guido Günther . + +The original source can always be found at: +http://honk.sigxcpu.org/git/sapgui.git + +Copyright: + + Copyright (C) 2009 Guido Günther + +License: + + This package 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 package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + diff --git a/debian/install b/debian/install new file mode 100644 index 0000000..ba473f7 --- /dev/null +++ b/debian/install @@ -0,0 +1 @@ +make-sgpkg /usr/bin/ diff --git a/debian/pycompat b/debian/pycompat new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/debian/pycompat @@ -0,0 +1 @@ +2 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..23b2a90 --- /dev/null +++ b/debian/rules @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +VERSION := $(shell head -n 1 $(CURDIR)/debian/changelog | sed 's/.*(//;s/).*//') + +DEB_PYTHON_SYSTEM = pysupport +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/python-distutils.mk + +configure/sapgui-package:: + sed s/@VERSION@/$(VERSION)/ make-sgpkg.py > make-sgpkg + +clean:: + rm -f make-sgpkg + rm -rf build diff --git a/make-sgpkg.py b/make-sgpkg.py new file mode 100755 index 0000000..3e88e4e --- /dev/null +++ b/make-sgpkg.py @@ -0,0 +1,192 @@ +#!/usr/bin/python -u +# vim: set fileencoding=utf-8 : +# +# (C) 2009 Guido Guenther +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +"""build a sapgui debian package""" + +import glob +import os +import re +import subprocess +import sys +import tempfile +from email.Utils import formatdate +from optparse import OptionParser + +verbose = False + +class SapGuiPkgError(Exception): + pass + + +def extract_sapgui_jar(jar, destdir): + cmd = [ "java", "-jar", "%s" % jar, "install", "-disableui", + "-noshortcuts", "-silent", "-automatic", "-installdir", + "%s/usr/lib/sapgui" % destdir ] + if verbose: + print " ".join(cmd) + ret = subprocess.call(cmd) + if ret: + raise SapGuiPkgError, "Error extracting jar" + + +def write_file(debdir, name, contents): + f = file(os.path.join(debdir, name), 'w') + f.write(contents) + f.close() + + +def get_version(destdir): + dir = None + try: + dir = glob.glob(os.path.join(destdir,'usr/lib/sapgui/SAPGUI*rev*'))[0] + version = os.path.basename(dir)[6:] + except IndexError: + raise SapGuiPkgError, "Cannot determin version number from subdir '%s'" % dir + if not re.match("[0-9\.]+rev[0-9]+", version): + raise SapGuiPkgError, "Cannot determin version number from '%s'" % version + return version + + +def gen_changelog(debiandir, version, name, email, sg_version): + date = formatdate(localtime=True) + contents="""sapgui (%(sg_version)s) unstable; urgency=low + + * This package was created with sap-gui-package %(version)s. + + -- %(name)s <%(email)s> %(date)s +""" % dict(version=version, name=name, email=email, date=date, + sg_version=sg_version) + write_file(debiandir, "changelog", contents) + + +def gen_control(debiandir, version, name, email): + contents = """Source: sapgui +Section: non-free/devel +Priority: optional +Maintainer: %(name)s <%(email)s> +Build-Depends: debhelper (>= 4.0.0) +Standards-Version: 3.8.0 + +Package: sapgui +Architecture: i386 +Depends: ${shlibs:Depends}, java2-runtime +Description: SAP GUI for the Java Environment + This package has been automatically created with sapgui-package %(version)s +""" % dict(name=name, email=email, version=version) + write_file(debiandir, "control", contents) + + +def gen_copyright(debiandir): + contents = """For copyright information please look at +/usr/share/doc/sapgui/doc/license/ +""" + write_file(debiandir, "copyright", contents) + + +def gen_install(debiandir): + contents = "dest/usr/* usr/" + write_file(debiandir, "install", contents) + + +def gen_rules(debiandir): + contents = """#!/usr/bin/make -f +export DH_COMPAT=5 + +DEB_DH_STRIP_ARGS=nostrip +DEB_DH_SHLIBDEPS_ARGS_ALL=-- --warnings=1 +include /usr/share/cdbs/1/rules/debhelper.mk + +install/sapgui:: + rm -rf dest/usr/lib/sapgui/SAPGUI +""" + write_file(debiandir, "rules", contents) + os.chmod(os.path.join(debiandir,"rules"), 0755) + + +def gen_links(debiandir, version): + contents = """usr/lib/sapgui/SAPGUI%(version)s/doc usr/share/doc/sapgui/doc +usr/lib/sapgui/SAPGUI%(version)s/bin/guilogon usr/bin/sapguilogon +usr/lib/sapgui/SAPGUI%(version)s/bin/guistart usr/bin/sapguistart +""" % dict(version=version) + write_file(debiandir, "links", contents) + + +def build_sapgui_deb(tmpdir): + curdir = os.path.abspath(os.path.curdir) + os.chdir(tmpdir) + subprocess.call(["fakeroot", "dpkg-buildpackage", "-b" ,"-uc", "-us"]) + os.chdir(curdir) + + +def main(argv): + tmpdir = None + ret = 1 + version = "@VERSION@" + global verbose + + prog = os.path.basename(argv[0]) + parser = OptionParser(prog=prog, usage='%prog [options] /path/to/sapgui.jar', version="%prog " + version) + parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, + help="verbose command execution") + parser.add_option("--maintainer", default="Guido Günther", + help="full name used in the maintainer field of the package") + parser.add_option("--email", default="agx@sigxpcu.org", + help="email address used in the maintainer field of the package") + (options, args) = parser.parse_args(argv[1:]) + + verbose = options.verbose + + try: + if len(args) != 1: + raise SapGuiPkgError, "No jar given try '%s--help'" % prog + else: + jar = args[0] + + tmpdir = tempfile.mkdtemp(prefix=prog) + destdir = os.path.join(tmpdir, 'dest') + print "Extracting '%s' to '%s'" % (jar, destdir) + extract_sapgui_jar(jar, destdir) + debiandir = os.path.join(tmpdir, 'debian') + os.mkdir(debiandir) + sg_version = get_version(destdir) + gen_changelog(debiandir, version, options.maintainer, options.email, sg_version) + gen_control(debiandir, version, options.maintainer, options.email) + gen_rules(debiandir) + gen_install(debiandir) + gen_copyright(debiandir) + gen_links(debiandir, sg_version) + print "Building Debain package at '%s'" % tmpdir + build_sapgui_deb(tmpdir) + except SapGuiPkgError, msg: + print >>sys.stderr, msg + else: + result = os.path.abspath(os.path.join(tmpdir,"..","sapgui_%s_i386.deb" % sg_version)) + print "Created sapgui package at %s" % result + ret = 0 + + if tmpdir: + if verbose: + print "Cleaning up Tempdir at %s" % tmpdir + subprocess.call(["/bin/rm", "-rf", "%s" % tmpdir]) + + return ret + +if __name__ == "__main__": + sys.exit(main(sys.argv)) + +# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..569956f --- /dev/null +++ b/setup.py @@ -0,0 +1,26 @@ +#!/usr/bin/python +# Copyright (C) 2006,2007 Guido Guenther +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# END OF COPYRIGHT # + +from distutils.core import setup + +setup(name = "make_sapgui", + author = 'Guido Guenther', + author_email = 'agx@sigxcpu.org', + scripts = [ 'make-sgpkg' ], +) + -- cgit v1.2.3