software-center-aptdaemon-plugins-0.1.6/0000755000000000000000000000000012030264523015136 5ustar software-center-aptdaemon-plugins-0.1.6/helper/0000755000000000000000000000000012030264523016415 5ustar software-center-aptdaemon-plugins-0.1.6/helper/ubuntu-license-key-helper0000755000000000000000000000554311663466463023401 0ustar #!/usr/bin/python import logging import json from optparse import OptionParser import os import sys sys.path.insert(0, "/usr/share/software-center") from softwarecenter.backend.piston.scaclient import SoftwareCenterAgentAPI import piston_mini_client.auth import gettext gettext.install("aptdaemon") if __name__ == "__main__": parser = OptionParser() parser.add_option("-s", "--server", default="ubuntu-production") parser.add_option("-p", "--pkgname") (options, args) = parser.parse_args() # server to use if options.server == "ubuntu-production": server = "https://software-center.ubuntu.com" elif options.server == "ubuntu-staging": server = "https://sc.staging.ubuntu.com" else: raise Exception("Unknown license key server") # allow override via environment, note that in order for this to # work aptdaemon needs to be started with that environment if os.environ.get("SOFTWARE_CENTER_BUY_HOST"): server = os.environ.get("SOFTWARE_CENTER_BUY_HOST") logging.warn("overriding server from environment: '%s'" % server) # setup server root server += "/api/2.0" SoftwareCenterAgentAPI.default_service_root = server # pkgname pkgname = options.pkgname # wait for oauth token on stdin json_token = sys.stdin.readline() token = json.loads(json_token) # get the data auth = piston_mini_client.auth.OAuthAuthorizer(token["token"], token["token_secret"], token["consumer_key"], token["consumer_secret"]) api = SoftwareCenterAgentAPI(auth=auth) try: subscriptions = api.subscriptions_for_me(complete_only=True) except piston_mini_client.APIError as e: sys.stderr.write(_("Failed to get the license key from " "the server.")) sys.exit(1) # find the right pkg license_key = None license_key_path = None for subscription in subscriptions: # paranoia, check if we actually have a license key attr too if (subscription.application["package_name"] == pkgname and hasattr(subscription, "license_key")): license_key = subscription.license_key license_key_path = subscription.license_key_path break if license_key and license_key_path: # aptdaemon expects a absolute path, fix that up if not license_key_path.startswith("/"): license_key_path = os.path.join("/opt", pkgname, license_key_path) sys.stdout.write(license_key_path + "\n") sys.stdout.write(license_key) sys.exit(0) # generic error sys.stderr.write(_("Failed to get the license key from " "the server.")) sys.exit(1) software-center-aptdaemon-plugins-0.1.6/debian/0000755000000000000000000000000012302376575016375 5ustar software-center-aptdaemon-plugins-0.1.6/debian/copyright0000644000000000000000000000111411662427623020324 0ustar Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=59 Source: https://edge.launchpad.net/software-center-aptdaemon-plugins Files: * Copyright: © 2011 Canonical © 2011 Sebastian Heinlein License: GPL-3 License: GPL-3 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; version 3. . On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL-3'. software-center-aptdaemon-plugins-0.1.6/debian/changelog0000644000000000000000000000446212302376575020255 0ustar software-center-aptdaemon-plugins (0.1.6build1) trusty; urgency=medium * Rebuild to drop files installed into /usr/share/pyshared. -- Matthias Klose Sun, 23 Feb 2014 13:54:05 +0000 software-center-aptdaemon-plugins (0.1.6) saucy; urgency=low * debian/control: fix typo in description (LP: #1175101) -- Paolo Rotolo Sun, 05 May 2013 11:24:31 +0200 software-center-aptdaemon-plugins (0.1.5) quantal; urgency=low * build a utils/ubuntu-license-key-helper as a python2 binary as there is no python3-piston-mini-client yet (LP: #1052703) -- Michael Vogt Tue, 25 Sep 2012 10:18:54 +0200 software-center-aptdaemon-plugins (0.1.4) quantal; urgency=low * fix helper location * add dependency for piston-mini-client -- Michael Vogt Mon, 24 Sep 2012 15:02:11 +0200 software-center-aptdaemon-plugins (0.1.3) quantal; urgency=low * Open subprocesses with universal_newlines=True when expecting to read text from them. On Python 2, this only enables \r\n conversion and the like, but on Python 3 this also causes subprocess-related file objects to read str rather than bytes. * build for python3 -- Michael Vogt Fri, 24 Aug 2012 10:43:32 +0200 software-center-aptdaemon-plugins (0.1.2) precise; urgency=low [ Michael Vogt ] * helper/ubuntu-license-key-helper: - extra paranoia when iterating the license-key data [ Martin Pitt ] * debian/control: Fix Vcs-Bzr: location. * softwarecenter_aptd_plugins/add_license_key_plugin.py: Port to gobject-introspection, to work with aptdaemon versions that use GI. * debian/control: Add python-gi/gir dependency and Breaks: aptdaemon (<< 0.43+bzr760), the upstream GI port commit. -- Michael Vogt Fri, 03 Feb 2012 10:12:54 +0100 software-center-aptdaemon-plugins (0.1.1) precise; urgency=low * helper/ubuntu-license-key-helper: - honor SOFTWARE_CENTER_BUY_HOST * bug fixes -- Michael Vogt Thu, 24 Nov 2011 15:13:38 +0100 software-center-aptdaemon-plugins (0.1) precise; urgency=low * Initial release, this is a helper for software-center to allow system-wide license-key installs -- Michael Vogt Mon, 21 Nov 2011 12:13:55 +0100 software-center-aptdaemon-plugins-0.1.6/debian/compat0000644000000000000000000000000211662427407017572 0ustar 8 software-center-aptdaemon-plugins-0.1.6/debian/control0000644000000000000000000000162612142135572017775 0ustar Source: software-center-aptdaemon-plugins Section: gnome Priority: optional Maintainer: Michael Vogt Build-Depends: debhelper (>= 8.0), python3-setuptools, python3-all, python-all, python-setuptools, Standards-Version: 3.8.4 X-Python3-Version: >= 3.2 X-Python-Version: >= 2.7 Vcs-Bzr: https://code.launchpad.net/~software-store-developers/software-center/software-center-aptdaemon-plugins Package: software-center-aptdaemon-plugins Architecture: all Depends: ${python:Depends}, ${misc:Depends}, python3-gi, gir1.2-glib-2.0, python-piston-mini-client Breaks: aptdaemon (<< 0.43+bzr760) Description: The aptdaemon plugins for software-center This package contains the plugins of software-center that enhance the functionality of aptdaemon. This includes the ability to install systemwide license keys. software-center-aptdaemon-plugins-0.1.6/debian/dirs0000644000000000000000000000003112026142565017244 0ustar usr/share/software-centersoftware-center-aptdaemon-plugins-0.1.6/debian/rules0000755000000000000000000000176712030263451017452 0ustar #!/usr/bin/make -f share:=usr/share/software-center #export DH_VERBOSE=1 PY3REQUESTED := $(shell py3versions -r) PY3DEFAULT := $(shell py3versions -d) # Run setup.py with the default python3 last so that the scripts use # #!/usr/bin/python3 and not #!/usr/bin/python3.X. PY3 := $(filter-out $(PY3DEFAULT),$(PY3REQUESTED)) python3 %: dh $@ --with=python2,python3 override_dh_auto_build: # this will build py2 dh_auto_build # ... and this py3 set -ex; for python in $(PY3); do \ $$python setup.py build; \ done override_dh_auto_install: # do the py3 dance set -ex; for python in $(PY3); do \ $$python setup.py install --root=$(CURDIR)/debian/software-center-aptdaemon-plugins --install-layout=deb; \ done # run the normal dh_auto_install which will copy the binary # ubuntu-license-key-helper into /usr/bin and not mangle it to py3 dh_auto_install # Move the scripts to $(SHARE) mv $(CURDIR)/debian/software-center-aptdaemon-plugins/usr/*bin/* debian/software-center-aptdaemon-plugins/$(share) software-center-aptdaemon-plugins-0.1.6/setup.py0000644000000000000000000000060511663441041016654 0ustar #!/usr/bin/env python from setuptools import setup setup(name="software-center-aptd-plugins", packages=['softwarecenter_aptd_plugins', ], scripts=["helper/ubuntu-license-key-helper", ], entry_points="""[aptdaemon.plugins] get_license_key=softwarecenter_aptd_plugins.add_license_key_plugin:get_license_key """, ) software-center-aptdaemon-plugins-0.1.6/softwarecenter_aptd_plugins/0000755000000000000000000000000012030264523022742 5ustar software-center-aptdaemon-plugins-0.1.6/softwarecenter_aptd_plugins/__init__.py0000644000000000000000000000000011662424367025057 0ustar software-center-aptdaemon-plugins-0.1.6/softwarecenter_aptd_plugins/add_license_key_plugin.py0000644000000000000000000000461012015632204027773 0ustar #!/usr/bin/env python # -*- coding: utf-8 -*- """Provides plugins for AptDaemon""" # Copyright (C) 2011 Canonical Ltd. # # 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 # 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. __author__ = "Sebastian Heinlein " import apt_pkg import os import subprocess import time from gi.repository import GLib from aptdaemon.errors import TransactionFailed from aptdaemon.enums import ERROR_LICENSE_KEY_DOWNLOAD_FAILED def get_license_key(uid, pkg_name, json_token, server_name): """Return the license key and the path for the given package.""" rootdir = apt_pkg.config["Dir"] license_key_helper = os.path.join(rootdir, "usr/share/software-center/ubuntu-license-key-helper") cmd = [license_key_helper, "--server", server_name, "--pkgname", pkg_name] proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE, preexec_fn=lambda: os.setuid(uid), close_fds=True, # this will give us str in py3 instead of bytes universal_newlines=True) # send json token to the process proc.stdin.write(json_token + "\n") # wait until it finishes while proc.poll() is None: while GLib.main_context_default().pending(): GLib.main_context_default().iteration() time.sleep(0.05) if proc.returncode != 0: stderr = proc.stderr.read() raise TransactionFailed(ERROR_LICENSE_KEY_DOWNLOAD_FAILED, stderr) # get data from stdout license_key_path = proc.stdout.readline().strip() license_key = proc.stdout.read() return license_key, license_key_path