options.py revision 3158
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#!/usr/bin/python
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# CDDL HEADER START
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# The contents of this file are subject to the terms of the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Common Development and Distribution License (the "License").
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# You may not use this file except in compliance with the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# or http://www.opensolaris.org/os/licensing.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# See the License for the specific language governing permissions
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# and limitations under the License.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen#
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# CDDL HEADER END
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen#
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenimport os
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenimport pkg.client.pkgdefs as pkgdefs
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenimport pkg.client.linkedimage as li
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenimport pkg.misc as misc
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainenfrom pkg.client.api_errors import InvalidOptionError, LinkedImageException
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfrom pkg.client import global_settings
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen_orig_cwd = None
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# List of available options for common option processing.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenACCEPT = "accept"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenALLOW_RELINK = "allow_relink"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenATTACH_CHILD = "attach_child"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenATTACH_PARENT = "attach_parent"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenBACKUP_BE = "backup_be"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenBACKUP_BE_NAME = "backup_be_name"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenBE_ACTIVATE = "be_activate"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenBE_NAME = "be_name"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenCONCURRENCY = "concurrency"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenDENY_NEW_BE = "deny_new_be"
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo SirainenFORCE = "force"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenIGNORE_MISSING = "ignore_missing"
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo SirainenLI_IGNORE = "li_ignore"
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo SirainenLI_IGNORE_ALL = "li_ignore_all"
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo SirainenLI_IGNORE_LIST = "li_ignore_list"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_MD_ONLY = "li_md_only"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_NAME = "li_name"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_PARENT_SYNC = "li_parent_sync"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_PKG_UPDATES = "li_pkg_updates"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_PROPS = "li_props"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_TARGET_ALL = "li_target_all"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_TARGET_LIST = "li_target_list"
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen# options for explicit recursion; see description in client.py
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_ERECURSE_ALL = "li_erecurse_all"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_ERECURSE_INCL = "li_erecurse_list"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_ERECURSE_EXCL = "li_erecurse_excl"
02b79f9c2636da1829eee5b92753602bba8b67edTimo SirainenLI_ERECURSE = "li_erecurse"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenLIST_ALL = "list_all"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenLIST_INSTALLED_NEWEST = "list_installed_newest"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenLIST_NEWEST = "list_newest"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenLIST_UPGRADABLE = "list_upgradable"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenMED_IMPLEMENTATION = "med_implementation"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenMED_VERSION = "med_version"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenNEW_BE = "new_be"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenNO_BACKUP_BE = "no_backup_be"
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo SirainenNOEXECUTE = "noexecute"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenOMIT_HEADERS = "omit_headers"
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo SirainenORIGINS = "origins"
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo SirainenPARSABLE_VERSION = "parsable_version"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenQUIET = "quiet"
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo SirainenREFRESH_CATALOGS = "refresh_catalogs"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenREJECT_PATS = "reject_pats"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenREQUIRE_BACKUP_BE = "require_backup_be"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenREQUIRE_NEW_BE = "require_new_be"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenSHOW_LICENSES = "show_licenses"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenSTAGE = "stage"
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo SirainenSUMMARY = "summary"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenTAGGED = "tagged"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenUPDATE_INDEX = "update_index"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenVERBOSE = "verbose"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenSYNC_ACT = "sync_act"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenACT_TIMEOUT = "act_timeout"
659fe5d24825b160cae512538088020d97a60239Timo SirainenPUBLISHERS = "publishers"
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainendef opts_table_cb_beopts(api_inst, opts, opts_new):
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen # synthesize require_new_be and deny_new_be into new_be
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen del opts_new[REQUIRE_NEW_BE]
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen del opts_new[DENY_NEW_BE]
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen opts_new[NEW_BE] = None
659fe5d24825b160cae512538088020d97a60239Timo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if (opts[BE_NAME] or opts[REQUIRE_NEW_BE]) and opts[DENY_NEW_BE]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen [REQUIRE_NEW_BE, DENY_NEW_BE])
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen # create a new key called BACKUP_BE in the options array
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if opts[REQUIRE_NEW_BE] or opts[BE_NAME]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen opts_new[NEW_BE] = True
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if opts[DENY_NEW_BE]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen opts_new[NEW_BE] = False
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # synthesize require_backup_be and no_backup_be into backup_be
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen del opts_new[REQUIRE_BACKUP_BE]
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen del opts_new[NO_BACKUP_BE]
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen opts_new[BACKUP_BE] = None
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainen if (opts[REQUIRE_BACKUP_BE] or opts[BACKUP_BE_NAME]) and \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts[NO_BACKUP_BE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen [REQUIRE_BACKUP_BE, NO_BACKUP_BE])
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if (opts[REQUIRE_BACKUP_BE] or opts[BACKUP_BE_NAME]) and \
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen (opts[REQUIRE_NEW_BE] or opts[BE_NAME]):
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen [REQUIRE_BACKUP_BE, REQUIRE_NEW_BE])
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # create a new key called BACKUP_BE in the options array
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if opts[REQUIRE_BACKUP_BE] or opts[BACKUP_BE_NAME]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen opts_new[BACKUP_BE] = True
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if opts[NO_BACKUP_BE]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen opts_new[BACKUP_BE] = False
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainendef opts_table_cb_li_ignore(api_inst, opts, opts_new):
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen # synthesize li_ignore_all and li_ignore_list into li_ignore
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen del opts_new[LI_IGNORE_ALL]
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen del opts_new[LI_IGNORE_LIST]
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen opts_new[LI_IGNORE] = None
96c253a039f102fa78a313ee05200ab3970112dcTimo Sirainen
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen # check if there's nothing to ignore
c3412ddeb9abc13f99d3caf50faf76cd99f7e9d2Timo Sirainen if not opts[LI_IGNORE_ALL] and not opts[LI_IGNORE_LIST]:
c3412ddeb9abc13f99d3caf50faf76cd99f7e9d2Timo Sirainen return
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen if opts[LI_IGNORE_ALL]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen # can't ignore all and specific images
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen if opts[LI_IGNORE_LIST]:
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen [LI_IGNORE_ALL, LI_IGNORE_LIST])
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainen # can't ignore all and target anything.
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen if LI_TARGET_ALL in opts and opts[LI_TARGET_ALL]:
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen [LI_IGNORE_ALL, LI_TARGET_ALL])
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen if LI_TARGET_LIST in opts and opts[LI_TARGET_LIST]:
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainen [LI_IGNORE_ALL, LI_TARGET_LIST])
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainen if LI_NAME in opts and opts[LI_NAME]:
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [LI_IGNORE_ALL, LI_NAME])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[LI_IGNORE] = []
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen assert opts[LI_IGNORE_LIST]
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen # it doesn't make sense to specify images to ignore if the
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen # user is already specifying images to operate on.
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if LI_TARGET_ALL in opts and opts[LI_TARGET_ALL]:
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen [LI_IGNORE_LIST, LI_TARGET_ALL])
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if LI_TARGET_LIST in opts and opts[LI_TARGET_LIST]:
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen [LI_IGNORE_LIST, LI_TARGET_LIST])
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if LI_NAME in opts and opts[LI_NAME]:
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen [LI_IGNORE_LIST, LI_NAME])
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen li_ignore = []
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen for li_name in opts[LI_IGNORE_LIST]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # check for repeats
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if li_name in li_ignore:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen InvalidOptionError.ARG_REPEAT, [li_name,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen LI_IGNORE_LIST])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # add to ignore list
3f190f4cbb9233a3a6830956cb5c7ae56a577b79Timo Sirainen li_ignore.append(li_name)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[LI_IGNORE] = api_inst.parse_linked_name_list(li_ignore)
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainendef opts_table_cb_li_no_psync(api_inst, opts, opts_new):
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen # if a target child linked image was specified, the no-parent-sync
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen # option doesn't make sense since we know that both the parent and
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen # child image are accessible
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if LI_TARGET_ALL not in opts:
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen # we don't accept linked image target options
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen assert LI_TARGET_LIST not in opts
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[LI_TARGET_ALL] and not opts[LI_PARENT_SYNC]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [LI_TARGET_ALL, LI_PARENT_SYNC])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[LI_TARGET_LIST] and not opts[LI_PARENT_SYNC]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen [LI_TARGET_LIST, LI_PARENT_SYNC])
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainendef __parse_linked_props(args):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen """"Parse linked image property options that were specified on the
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen command line into a dictionary. Make sure duplicate properties were
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen not specified."""
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen linked_props = dict()
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen for pv in args:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen try:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen p, v = pv.split("=", 1)
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen except ValueError:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen raise InvalidOptionError(msg=_("linked image "
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen "property arguments must be of the form "
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen "'<name>=<value>'."))
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if p not in li.prop_values:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=_("invalid linked "
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen "image property: '{0}'.").format(p))
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if p in linked_props:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=_("linked image "
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen "property specified multiple times: "
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen "'{0}'.").format(p))
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen linked_props[p] = v
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen return linked_props
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainendef opts_table_cb_li_props(api_inst, opts, opts_new):
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen """convert linked image prop list into a dictionary"""
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen opts_new[LI_PROPS] = __parse_linked_props(opts[LI_PROPS])
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainen
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainendef opts_table_cb_li_target(api_inst, opts, opts_new):
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainen # figure out which option the user specified
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen if opts[LI_TARGET_ALL] and opts[LI_TARGET_LIST]:
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen [LI_TARGET_ALL, LI_TARGET_LIST])
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen elif opts[LI_TARGET_ALL]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen arg1 = LI_TARGET_ALL
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen elif opts[LI_TARGET_LIST]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen arg1 = LI_TARGET_LIST
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen if BE_ACTIVATE in opts and not opts[BE_ACTIVATE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [arg1, BE_ACTIVATE])
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen if BE_NAME in opts and opts[BE_NAME]:
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen [arg1, BE_NAME])
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen if DENY_NEW_BE in opts and opts[DENY_NEW_BE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [arg1, DENY_NEW_BE])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if REQUIRE_NEW_BE in opts and opts[REQUIRE_NEW_BE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [arg1, REQUIRE_NEW_BE])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if REJECT_PATS in opts and opts[REJECT_PATS]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [arg1, REJECT_PATS])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if ORIGINS in opts and opts[ORIGINS]:
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [arg1, ORIGINS])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # validate linked image name
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen li_target_list = []
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen for li_name in opts[LI_TARGET_LIST]:
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen # check for repeats
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen if li_name in li_target_list:
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen raise InvalidOptionError(
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen InvalidOptionError.ARG_REPEAT, [li_name,
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen LI_TARGET_LIST])
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen # add to ignore list
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen li_target_list.append(li_name)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen opts_new[LI_TARGET_LIST] = \
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen api_inst.parse_linked_name_list(li_target_list)
484efa22e65c509f787dbbc892351146c726c257Timo Sirainen
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainendef opts_table_cb_li_target1(api_inst, opts, opts_new):
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen # figure out which option the user specified
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[LI_NAME]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen arg1 = LI_NAME
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen return
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if BE_ACTIVATE in opts and not opts[BE_ACTIVATE]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, BE_ACTIVATE])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if BE_NAME in opts and opts[BE_NAME]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, BE_NAME])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if DENY_NEW_BE in opts and opts[DENY_NEW_BE]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, DENY_NEW_BE])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if REQUIRE_NEW_BE in opts and opts[REQUIRE_NEW_BE]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, REQUIRE_NEW_BE])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if REJECT_PATS in opts and opts[REJECT_PATS]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, REJECT_PATS])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if ORIGINS in opts and opts[ORIGINS]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [arg1, ORIGINS])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainendef opts_table_cb_li_recurse(api_inst, opts, opts_new):
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen del opts_new[LI_ERECURSE_INCL]
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen del opts_new[LI_ERECURSE_EXCL]
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen del opts_new[LI_ERECURSE_ALL]
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if opts[LI_ERECURSE_EXCL] and not opts[LI_ERECURSE_ALL]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [LI_ERECURSE_EXCL, LI_ERECURSE_ALL])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if opts[LI_ERECURSE_INCL] and not opts[LI_ERECURSE_ALL]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [LI_ERECURSE_INCL, LI_ERECURSE_ALL])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if opts[LI_ERECURSE_INCL] and opts[LI_ERECURSE_EXCL]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen [LI_ERECURSE_INCL, LI_ERECURSE_EXCL])
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if not opts[LI_ERECURSE_ALL]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_new[LI_ERECURSE] = None
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen return
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen # Go through all children and check if they are in the recurse list.
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen li_child_targets = []
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen li_child_list = set([
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen lin
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen for lin, rel, path in api_inst.list_linked()
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if rel == "child"
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen ])
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen def parse_lin(ulin):
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen lin = None
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen try:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen lin = api_inst.parse_linked_name(ulin,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen allow_unknown=True)
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen except LinkedImageException, e:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen try:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen lin = api_inst.parse_linked_name(
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen "zone:{0}".format(ulin), allow_unknown=True)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen except LinkedImageException, e:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pass
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if lin is None or lin not in li_child_list:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen _("invalid linked image or zone name "
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen "'{0}'.").format(ulin))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen return lin
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[LI_ERECURSE_INCL]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # include list specified
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen for ulin in opts[LI_ERECURSE_INCL]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen li_child_targets.append(parse_lin(ulin))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[LI_ERECURSE] = li_child_targets
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
8af07808ba203f8709e2ff9eaf2291e1c4a4d53dTimo Sirainen # exclude list specified
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen for ulin in opts[LI_ERECURSE_EXCL]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen li_child_list.remove(parse_lin(ulin))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[LI_ERECURSE] = li_child_list
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # If we use image recursion we need to make sure uninstall and update
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # ignore non-existing packages in the parent image.
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen if opts_new[LI_ERECURSE] and IGNORE_MISSING in opts:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[IGNORE_MISSING] = True
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainendef opts_table_cb_no_headers_vs_quiet(api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # check if we accept the -q option
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if QUIET not in opts:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # -q implies -H
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[QUIET]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[OMIT_HEADERS] = True
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainen
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainendef opts_table_cb_q(api_inst, opts, opts_new):
b9ac6179d3aee0d1641a4ee1d78da28628929c61Timo Sirainen # Be careful not to overwrite global_settings.client_output_quiet
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # because it might be set "True" from elsewhere, e.g. in
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # opts_table_cb_parsable.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[QUIET] is True:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen global_settings.client_output_quiet = True
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainendef opts_table_cb_v(api_inst, opts, opts_new):
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen global_settings.client_output_verbose = opts[VERBOSE]
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainendef opts_table_cb_nqv(api_inst, opts, opts_new):
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen if opts[VERBOSE] and opts[QUIET]:
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen [VERBOSE, QUIET])
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainendef opts_table_cb_publishers(api_inst, opts, opts_new):
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen publishers = set()
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen for p in opts[PUBLISHERS]:
33d63688ed8b26dc333e3c2edbfb2fe6e412604dTimo Sirainen publishers.add(p)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[PUBLISHERS] = publishers
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_table_cb_parsable(api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[PARSABLE_VERSION] and opts.get(VERBOSE, False):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [VERBOSE, PARSABLE_VERSION])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[PARSABLE_VERSION]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen try:
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen opts_new[PARSABLE_VERSION] = int(
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen opts[PARSABLE_VERSION])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen except ValueError:
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen raise InvalidOptionError(
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen options=[PARSABLE_VERSION],
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen msg=_("integer argument expected"))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen global_settings.client_output_parsable_version = \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[PARSABLE_VERSION]
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen opts_new[QUIET] = True
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen global_settings.client_output_quiet = True
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainendef opts_table_cb_origins(api_inst, opts, opts_new):
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen origins = set()
88553367d677170a4b703b9d52aac9eabf91c656Timo Sirainen for o in opts[ORIGINS]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen origins.add(misc.parse_uri(o, cwd=_orig_cwd))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[ORIGINS] = origins
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_table_cb_stage(api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[STAGE] == None:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[STAGE] = pkgdefs.API_STAGE_DEFAULT
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts_new[STAGE] not in pkgdefs.api_stage_values:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=_("invalid operation stage: "
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen "'{0}'").format(opts[STAGE]))
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_cb_li_attach(api_inst, opts, opts_new):
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if opts[ATTACH_PARENT] and opts[ATTACH_CHILD]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [ATTACH_PARENT, ATTACH_CHILD])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if not opts[ATTACH_PARENT] and not opts[ATTACH_CHILD]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(InvalidOptionError.XOR,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [ATTACH_PARENT, ATTACH_CHILD])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if opts[ATTACH_CHILD]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # if we're attaching a new child then that doesn't affect
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # any other children, so ignoring them doesn't make sense.
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if opts[LI_IGNORE_ALL]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen InvalidOptionError.INCOMPAT,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [ATTACH_CHILD, LI_IGNORE_ALL])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if opts[LI_IGNORE_LIST]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen InvalidOptionError.INCOMPAT,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [ATTACH_CHILD, LI_IGNORE_LIST])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainendef opts_table_cb_md_only(api_inst, opts, opts_new):
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # if the user didn't specify linked-md-only we're done
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if not opts[LI_MD_ONLY]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen return
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # li_md_only implies no li_pkg_updates
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if LI_PKG_UPDATES in opts:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen opts_new[LI_PKG_UPDATES] = False
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen #
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # if li_md_only is false that means we're not updating any packages
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # within the current image so there are a ton of options that no
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # longer apply to the current operation, and hence are incompatible
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen # with li_md_only.
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen #
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen arg1 = LI_MD_ONLY
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if BE_NAME in opts and opts[BE_NAME]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [arg1, BE_NAME])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if DENY_NEW_BE in opts and opts[DENY_NEW_BE]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen [arg1, DENY_NEW_BE])
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen if REQUIRE_NEW_BE in opts and opts[REQUIRE_NEW_BE]:
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen [arg1, REQUIRE_NEW_BE])
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen if LI_PARENT_SYNC in opts and not opts[LI_PARENT_SYNC]:
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen [arg1, LI_PARENT_SYNC])
ab3c1eab9ca13916358a9e8b12df8212fefb7dbfTimo Sirainen if REJECT_PATS in opts and opts[REJECT_PATS]:
99be58a447b69d62cbd9e764000a06226b9c9c89Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen [arg1, REJECT_PATS])
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainendef opts_cb_list(api_inst, opts, opts_new):
bbc92cfb17eb71d2ee9463c9cfd70dfea9a36bb6Timo Sirainen if opts_new[ORIGINS] and opts_new[LIST_UPGRADABLE]:
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen [ORIGINS, LIST_UPGRADABLE])
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen if opts_new[ORIGINS] and not opts_new[LIST_NEWEST]:
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen # Use of -g implies -a unless -n is provided.
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen opts_new[LIST_INSTALLED_NEWEST] = True
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen if opts_new[LIST_ALL] and not opts_new[LIST_INSTALLED_NEWEST]:
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen raise InvalidOptionError(InvalidOptionError.REQUIRED,
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen [LIST_ALL, LIST_INSTALLED_NEWEST])
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen if opts_new[LIST_INSTALLED_NEWEST] and opts_new[LIST_NEWEST]:
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen [LIST_INSTALLED_NEWEST, LIST_NEWEST])
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen if opts_new[LIST_INSTALLED_NEWEST] and opts_new[LIST_UPGRADABLE]:
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen [LIST_INSTALLED_NEWEST, LIST_UPGRADABLE])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen if opts_new[SUMMARY] and opts_new[VERBOSE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [SUMMARY, VERBOSE])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts_new[QUIET] and opts_new[VERBOSE]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(InvalidOptionError.INCOMPAT,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [QUIET, VERBOSE])
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_cb_int(k, api_inst, opts, opts_new, minimum=None):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if k not in opts or opts[k] == None:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen err = _("missing required parameter")
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen raise InvalidOptionError(msg=err, options=[k])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # get the original argument value
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen v = opts[k]
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # make sure it is an integer
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen try:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen v = int(v)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen except (ValueError, TypeError):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # not a valid integer
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen err = _("value '{0}' invalid").format(v)
3f190f4cbb9233a3a6830956cb5c7ae56a577b79Timo Sirainen raise InvalidOptionError(msg=err, options=[k])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen # check the minimum bounds
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if minimum is not None and v < minimum:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen err = _("value must be >= {0:d}").format(minimum)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=err, options=[k])
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # update the new options array to make the value an integer
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[k] = v
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainendef opts_cb_fd(k, api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_cb_int(k, api_inst, opts, opts_new, minimum=0)
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen err = _("value '{0}' invalid").format(opts_new[k])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen try:
659fe5d24825b160cae512538088020d97a60239Timo Sirainen os.fstat(opts_new[k])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen except OSError:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # not a valid file descriptor
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise InvalidOptionError(msg=err, options=[k])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_table_cb_concurrency(api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[CONCURRENCY] is None:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # remove concurrency from parameters dict
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen del opts_new[CONCURRENCY]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen # make sure we have an integer
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen opts_cb_int(CONCURRENCY, api_inst, opts, opts_new)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen # update global concurrency setting
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen global_settings.client_concurrency = opts_new[CONCURRENCY]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen global_settings.client_concurrency_set = True
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # remove concurrency from parameters dict
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen del opts_new[CONCURRENCY]
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_table_cb_actuators(api_inst, opts, opts_new):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen del opts_new[ACT_TIMEOUT]
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen del opts_new[SYNC_ACT]
ff640b54224881abbc21141f217c881d6ba5cd28Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if opts[ACT_TIMEOUT]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # make sure we have an integer
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_cb_int(ACT_TIMEOUT, api_inst, opts, opts_new)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen elif opts[SYNC_ACT]:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen # -1 is no timeout
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[ACT_TIMEOUT] = -1
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen # 0 is no sync actuators are used (timeout=0)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_new[ACT_TIMEOUT] = 0
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen#
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# options common to multiple pkg(1) operations. The format for specifying
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# options is a list which can contain:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen#
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen# - Tuples formatted as:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# (k, v, [val])
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# where the values are:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# k: the key value for the options dictionary
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# v: the default value. valid values are: True/False, None, [], 0
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# val: the valid argument list. It should be a list,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen# and it is optional.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen#
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainenopts_table_beopts = [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_cb_beopts,
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen (BACKUP_BE_NAME, None),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (BE_NAME, None),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (DENY_NEW_BE, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (NO_BACKUP_BE, False),
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen (BE_ACTIVATE, True),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (REQUIRE_BACKUP_BE, False),
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen (REQUIRE_NEW_BE, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_concurrency = [
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen opts_table_cb_concurrency,
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen (CONCURRENCY, None),
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen]
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_force = [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (FORCE, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen
a205d315b0978985ba77d871f44e4a98273612e6Timo Sirainenopts_table_li_ignore = [
a205d315b0978985ba77d871f44e4a98273612e6Timo Sirainen opts_table_cb_li_ignore,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (LI_IGNORE_ALL, False),
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen (LI_IGNORE_LIST, []),
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_li_md_only = [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_cb_md_only,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (LI_MD_ONLY, False),
01cbf4ac5d44137ab434791be7f838d98d0fcf3bTimo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_li_no_pkg_updates = [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (LI_PKG_UPDATES, True),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_li_no_psync = [
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_cb_li_no_psync,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen (LI_PARENT_SYNC, True),
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen]
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_li_props = [
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen opts_table_cb_li_props,
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (LI_PROPS, []),
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainen]
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
36e2fa21c22452470c1509cc63de20f7415c7b5eTimo Sirainenopts_table_li_target = [
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_cb_li_target,
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (LI_TARGET_ALL, False),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen (LI_TARGET_LIST, []),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_li_target1 = [
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_cb_li_target1,
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen (LI_NAME, None),
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen]
cece2b9cd692c06025cc0a7a0ff54d996a8c90efTimo Sirainen
cece2b9cd692c06025cc0a7a0ff54d996a8c90efTimo Sirainenopts_table_li_recurse = [
cece2b9cd692c06025cc0a7a0ff54d996a8c90efTimo Sirainen opts_table_cb_li_recurse,
cece2b9cd692c06025cc0a7a0ff54d996a8c90efTimo Sirainen (LI_ERECURSE_ALL, False),
cece2b9cd692c06025cc0a7a0ff54d996a8c90efTimo Sirainen (LI_ERECURSE_INCL, []),
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen (LI_ERECURSE_EXCL, []),
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen]
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainenopts_table_licenses = [
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen (ACCEPT, False),
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen (SHOW_LICENSES, False),
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen]
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainen
7f773564b94e6054a40d3785cb63c29f1e4d4deeTimo Sirainenopts_table_no_headers = [
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainen opts_table_cb_no_headers_vs_quiet,
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (OMIT_HEADERS, False),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_no_index = [
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen (UPDATE_INDEX, True),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_no_refresh = [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (REFRESH_CATALOGS, True),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_table_reject = [
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (REJECT_PATS, []),
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen]
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_verbose = [
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_cb_v,
f1b7a02a05fbca580934c7312aae63ea9542aa79Timo Sirainen (VERBOSE, 0),
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen]
f1b7a02a05fbca580934c7312aae63ea9542aa79Timo Sirainen
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainenopts_table_quiet = [
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen opts_table_cb_q,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen (QUIET, False),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_table_parsable = [
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen opts_table_cb_parsable,
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen (PARSABLE_VERSION, None),
f1b7a02a05fbca580934c7312aae63ea9542aa79Timo Sirainen]
f1b7a02a05fbca580934c7312aae63ea9542aa79Timo Sirainen
f1b7a02a05fbca580934c7312aae63ea9542aa79Timo Sirainenopts_table_nqv = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_quiet + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_verbose + \
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen [
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen opts_table_cb_nqv,
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen (NOEXECUTE, False),
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen]
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainenopts_table_origins = [
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen opts_table_cb_origins,
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (ORIGINS, []),
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen]
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainenopts_table_stage = [
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen opts_table_cb_stage,
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (STAGE, None),
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen]
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainenopts_table_missing = [
755fe6da51ab7f54aa1d86913cb344bffef60e79Timo Sirainen (IGNORE_MISSING, False),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainenopts_table_actuators = [
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen opts_table_cb_actuators,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (SYNC_ACT, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (ACT_TIMEOUT, None)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainenopts_table_publishers = [
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen opts_table_cb_publishers,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (PUBLISHERS, []),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen#
d7abb52419f9aaf5de040778de3ea238b2431234Timo Sirainen# Options for pkg(1) subcommands. Built by combining the option tables above,
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen# with some optional subcommand unique options defined below.
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen#
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainenopts_main = \
9a06cabdfdf4d5e2f19a07e506c3c7d08a7e7038Timo Sirainen opts_table_beopts + \
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen opts_table_concurrency + \
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen opts_table_li_ignore + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_li_no_psync + \
6fd7c571326c61949ffc0f3ea565c3df04104235Timo Sirainen opts_table_licenses + \
6fd7c571326c61949ffc0f3ea565c3df04104235Timo Sirainen opts_table_reject + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_no_index + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_no_refresh + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_nqv + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_parsable + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_origins + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen []
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainenopts_install = \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_main + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_stage + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_li_recurse + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen opts_table_actuators + \
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen []
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainen# "update" cmd inherits all main cmd options
7f3be7d885c75cdd77f536929a45bc9764595960Timo Sirainenopts_update = \
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen opts_main + \
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen opts_table_force + \
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen opts_table_li_recurse + \
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen opts_table_stage + \
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen opts_table_actuators + \
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen opts_table_missing + \
71a74e26cf070a205d31cf6c6fae003f90027b63Timo Sirainen []
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen# "attach-linked" cmd inherits all main cmd options
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainenopts_attach_linked = \
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen opts_main + \
6843896c40bee4f9b6680ca7ced598c446e9f999Timo Sirainen opts_table_force + \
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen opts_table_li_md_only + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_li_no_pkg_updates + \
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen opts_table_li_props + \
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_cb_li_attach,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (ALLOW_RELINK, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (ATTACH_CHILD, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (ATTACH_PARENT, False),
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainenopts_revert = \
b2ecd50bb98c44816cb07c17aa17fae2b425f941Timo Sirainen opts_table_beopts + \
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen opts_table_nqv + \
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen opts_table_parsable + \
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen [
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen (TAGGED, False),
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen]
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainen
907723f35f4d3dfc774ca42d00a8a7b8ef90dd5dTimo Sirainenopts_set_mediator = \
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen opts_table_beopts + \
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen opts_table_no_index + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_nqv + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_parsable + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (MED_IMPLEMENTATION, None),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (MED_VERSION, None)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen# "set-property-linked" cmd inherits all main cmd options
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainenopts_set_property_linked = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_main + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_md_only + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_no_pkg_updates + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_target1 + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen []
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen# "sync-linked" cmd inherits all main cmd options
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_sync_linked = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_main + \
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen opts_table_li_md_only + \
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen opts_table_li_no_pkg_updates + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_target + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_stage + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen []
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_uninstall = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_beopts + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_concurrency + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_ignore + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_no_psync + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_no_index + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_nqv + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_parsable + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_stage + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_recurse + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_missing + \
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen opts_table_actuators + \
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen []
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainenopts_audit_linked = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_no_psync + \
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen opts_table_li_target + \
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen opts_table_no_headers + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_quiet + \
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen []
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_detach_linked = \
3cfff0ca01961d885bdbd6ef08d761880116af07Timo Sirainen opts_table_force + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_li_md_only + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_li_no_pkg_updates + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_li_target + \
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen opts_table_nqv + \
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen []
33ae95df45c9b5ec51332a6b39eb5322038686b9Timo Sirainen
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainenopts_list_linked = \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_li_ignore + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen opts_table_no_headers + \
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen []
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenopts_list_property_linked = \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_li_target1 + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_no_headers + \
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen []
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_list_inventory = \
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen opts_table_li_no_psync + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_no_refresh + \
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen opts_table_no_headers + \
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen opts_table_origins + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_quiet + \
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen opts_table_verbose + \
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen [
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen opts_cb_list,
02b79f9c2636da1829eee5b92753602bba8b67edTimo Sirainen (LIST_INSTALLED_NEWEST, False),
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen (LIST_ALL, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (LIST_NEWEST, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen (SUMMARY, False),
e68309fcfa2eaa88217fd51e7b4900fc9c20ef5dTimo Sirainen (LIST_UPGRADABLE, False),
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_dehydrate = \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_nqv + \
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen opts_table_publishers + \
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen []
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_fix = \
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen opts_table_beopts + \
60d3fa9883237e896a8704275b6116fa46f7ffdaTimo Sirainen opts_table_nqv + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_licenses + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_no_headers + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen []
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainenopts_verify = \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_quiet + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen opts_table_verbose + \
f16c114c20bbd7d292d93415d1e56c8dd6abd3e7Timo Sirainen opts_table_no_headers + \
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [
a205d315b0978985ba77d871f44e4a98273612e6Timo Sirainen opts_table_cb_nqv
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen]
fc1696e32dd732a5bbabc3c8f64810448e327043Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainenpkg_op_opts = {
e5c08648676d1989f6e70b95e5990c26b3e8b96bTimo Sirainen
99be58a447b69d62cbd9e764000a06226b9c9c89Timo Sirainen pkgdefs.PKG_OP_ATTACH : opts_attach_linked,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen pkgdefs.PKG_OP_AUDIT_LINKED : opts_audit_linked,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen pkgdefs.PKG_OP_CHANGE_FACET : opts_install,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen pkgdefs.PKG_OP_CHANGE_VARIANT : opts_install,
313fe89df4d91cd0cd7f3558dc6d7fd21ad39eeeTimo Sirainen pkgdefs.PKG_OP_DEHYDRATE : opts_dehydrate,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_DETACH : opts_detach_linked,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_EXACT_INSTALL : opts_main,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_FIX : opts_fix,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_INSTALL : opts_install,
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen pkgdefs.PKG_OP_LIST : opts_list_inventory,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_LIST_LINKED : opts_list_linked,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_PROP_LINKED : opts_list_property_linked,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_PUBCHECK : [],
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_REHYDRATE : opts_dehydrate,
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen pkgdefs.PKG_OP_REVERT : opts_revert,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_SET_MEDIATOR : opts_set_mediator,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_SET_PROP_LINKED: opts_set_property_linked,
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen pkgdefs.PKG_OP_SYNC : opts_sync_linked,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_UNINSTALL : opts_uninstall,
db7c9201c88e3d9bee10485194ee5b0c67249916Timo Sirainen pkgdefs.PKG_OP_UPDATE : opts_update,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen pkgdefs.PKG_OP_VERIFY : opts_verify
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen}
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef get_pkg_opts(op, add_table=None):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen """Get the available options for a particular operation specified by
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen 'op'. If the client uses custom pkg_op_opts tables they can be specified
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen by 'add_table'."""
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen popts = pkg_op_opts.copy()
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if add_table is not None:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen popts.update(add_table)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
8fcff4c5b52f24d9c681805fdf06b486f1d0fcbeTimo Sirainen try:
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen opts = popts[op]
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen except KeyError:
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen opts = None
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen return opts
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainendef get_pkg_opts_defaults(op, opt, add_table=None):
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen """ Get the default value for a certain option 'opt' of a certain
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen operation 'op'. This is useful for clients which toggle boolean options.
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen """
292a66475ffe1037c2535063614f8beb71d266bfTimo Sirainen popts = get_pkg_opts(op, add_table)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
fcfd317f7eb1f0216764c75c5fab3555020552d4Timo Sirainen for o in popts:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if type(o) != tuple:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen continue
fcfd317f7eb1f0216764c75c5fab3555020552d4Timo Sirainen if len(o) == 2:
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen opt_name, default = o
178511b57faa7c3f8203dd8b7e4059d00cbfc23aTimo Sirainen elif len(o) == 3:
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen opt_name, default, valid_args = o
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen if opt_name == opt:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return default
fcfd317f7eb1f0216764c75c5fab3555020552d4Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainendef opts_assemble(op, api_inst, opts, add_table=None, cwd=None):
fcfd317f7eb1f0216764c75c5fab3555020552d4Timo Sirainen """Assembly of the options for a specific operation. Options are read in
fcfd317f7eb1f0216764c75c5fab3555020552d4Timo Sirainen from a dict (see explanation below) and sanity tested.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen This is the common interface to supply options to the functions of the
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen API.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen 'op' is the operation for which the options need to be assembled and
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen verified. The currently supported operations are listed in
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen pkgdefs.pkg_op_values.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen 'api_inst' is a reference to the API instance, required for some of the
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen verification steps.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen 'opts' is the raw options table to be processed. It needs to be a dict
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen in the format: { option_name: argument, ... }
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen """
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen global _orig_cwd
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
e06c0b65c16ccce69bbee009ead14d7d3d17a256Timo Sirainen if cwd is not None:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen _orig_cwd = cwd
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen _orig_cwd = None
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen popts = get_pkg_opts(op, add_table)
26687b22a471df9c28ce7bf233e7128e9d85f64cTimo Sirainen
f0569d9fbb25c8437760be69f194595a841ad711Timo Sirainen rv = {}
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen callbacks = []
a393d9d6dabdc46cf724f8cb004a652b4036d53dTimo Sirainen
325f4573edfa5b751832ac01023f3e81be992bf0Timo Sirainen for o in popts:
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen if type(o) != tuple:
9e59a1f3f095b3099478562cf3f3970a24736970Timo Sirainen callbacks.append(o)
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen continue
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen valid_args = []
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen # If no valid argument list specified.
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if len(o) == 2:
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen avail_opt, default = o
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen elif len(o) == 3:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen avail_opt, default, valid_args = o
63a61b7a739ae0f3f520215137d9c50f94d0f34fTimo Sirainen # for options not given we substitue the default value
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen if avail_opt not in opts:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen rv[avail_opt] = default
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen continue
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen if type(default) == int:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen assert type(opts[avail_opt]) == int, opts[avail_opt]
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen elif type(default) == list:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen assert type(opts[avail_opt]) == list, opts[avail_opt]
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen elif type(default) == bool:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen assert type(opts[avail_opt]) == bool, opts[avail_opt]
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen if valid_args:
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen assert type(default) == list or default is None, \
345212e8f61ebf14ff4f80df26df9e655eb5121eTimo Sirainen default
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen raise_error = False
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if type(opts[avail_opt]) == list:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if not set(opts[avail_opt]).issubset(
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen set(valid_args)):
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen raise_error = True
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen else:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if opts[avail_opt] not in valid_args:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen raise_error = True
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen if raise_error:
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen raise InvalidOptionError(
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen InvalidOptionError.ARG_INVALID,
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen [opts[avail_opt], avail_opt])
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen rv[avail_opt] = opts[avail_opt]
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen
b3febb0933fdce10394d25093e23ce0a5aadddd3Timo Sirainen rv_updated = rv.copy()
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
abe8230dd1dd37d7ccf0163100e934bb5e658c20Timo Sirainen # run the option verification callbacks
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen for cb in callbacks:
9aa52288a4b53186d81b0ec9afa7d9e0a8ee8753Timo Sirainen cb(api_inst, rv, rv_updated)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen return rv_updated
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen
dda2c506c8fc8ac2f88272de4523ded42baa0aa0Timo Sirainen