1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
# Copyright (C) 2013 Canonical Ltd.
# Author: Colin Watson <cjwatson@ubuntu.com>
# 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; version 3 of the License.
#
# 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, see <http://www.gnu.org/licenses/>.
"""Install a Click package (low-level; consider pkcon instead)."""
from __future__ import print_function
from optparse import OptionParser
import sys
from textwrap import dedent
import gi
gi.require_version('Click', '0.4')
from gi.repository import Click
from click_package.install import ClickInstaller, ClickInstallerError
def run(argv):
parser = OptionParser(dedent("""\
%prog install [options] PACKAGE-FILE
This is a low-level tool; to install a package as an ordinary user
you should generally use "pkcon install-local PACKAGE-FILE"
instead."""))
parser.add_option(
"--root", metavar="PATH", help="install packages underneath PATH")
parser.add_option(
"--force-missing-framework", action="store_true", default=False,
help="install despite missing system framework")
parser.add_option(
"--user", metavar="USER", help="register package for USER")
parser.add_option(
"--all-users", default=False, action="store_true",
help="register package for all users")
parser.add_option(
"--allow-unauthenticated", default=False, action="store_true",
help="allow installing packages with no signatures")
parser.add_option(
"--verbose", default=False, action="store_true",
help="be more verbose on install")
options, args = parser.parse_args(argv)
if len(args) < 1:
parser.error("need package file name")
db = Click.DB()
db.read(db_dir=None)
if options.root is not None:
db.add(options.root)
package_path = args[0]
installer = ClickInstaller(
db=db, force_missing_framework=options.force_missing_framework,
allow_unauthenticated=options.allow_unauthenticated)
try:
installer.install(
package_path, user=options.user, all_users=options.all_users,
quiet=not options.verbose)
except ClickInstallerError as e:
print("Cannot install %s: %s" % (package_path, e), file=sys.stderr)
return 1
return 0
|