YaST2 Developers Documentation: Package Repository Management

Package Repository Management

modules/SourceManager.ycp
SourceManager settings, input and output functions

This module has an unstable interface.

Representation of the configuration of source-manager. Input and output routines.

Imports

  • Arch
  • FileUtils
  • HTML
  • InstURL
  • Installation
  • Label
  • Linuxrc
  • Message
  • Mode
  • Popup
  • Progress
  • Report
  • Stage
  • String
  • String
  • SuSEFirewall
  • Summary
  • URL

Structures

Global Variables

Global Functions

Local Functions

global Modified () -> boolean

Prototypes

global modified -> boolean

Data was modified?

global proposal_valid -> boolean

global AbortFunction () -> boolean

Abort function return boolean return true if abort

global Abort () -> boolean

Abort function

Return value:
return true if abort
global Modified () -> boolean

Data was modified?

Return value:
true if modified
global GetSyncFlag () -> boolean

Return ZMD synchronization flag.

Return value:
true/false = ZMD sync is enabled/disabled, nil = unknown (not configured/read)
global ReadSyncFlag () -> boolean

Read ZMD sync flag from the persistent store (/var/lib/YaST2/inst_source_config.ycp)

Return value:
true = success, false = read/parse error or the file doesn't exist
global SetSyncFlag (boolean sync_enabled) -> void

Set ZMD synchronization flag.

Parameters:
sync_enabled true/false = enable/disable ZMD sync, nil = unknown (not configured/read)
global WriteSyncFlag () -> boolean

Write ZMD sync flag to the persistent store

Return value:
true = success
global Read () -> boolean

Read all source-manager settings

Return value:
true on success
global CommitSources () -> boolean

Commit changed repositories

global Write () -> boolean

Write all repository-manager settings

Return value:
true on success
global Import (map settings) -> boolean

Get all repository-manager settings from the first parameter (For use by autoinstallation.)

Parameters:
settings The YCP structure to be imported.
Return value:
True on success
global Export () -> map

Dump the repository-manager settings to a single map (For use by autoinstallation.)

Return value:
Dumped settings (later acceptable by Import ())
global GetSrcIdByIndex (integer idx) -> integer

Get Repository ID by index

Parameters:
idx
global SetUrlByIndex (integer idx) -> void

Set current used repository URL by index

Parameters:
idx
global getSourceId (string url) -> integer

Get Repository ID when only URL is known

Parameters:
url
global SourceData (integer source) -> map

Gather Repository Metadata

Parameters:
source
global createSource (string url) -> symbol

Create a repository from an URL

Parameters:
url
global deleteSourceBySrcId (integer SrcId) -> void

Delete repository by Repository ID

Parameters:
SrcId
global deleteSourceByIndex (integer idx) -> void

Delete Repository by the repository index

Parameters:
idx
global deleteSourceByUrl (string url) -> void

Delete Repository by repository URL

Parameters:
url
local createItem (integer index, map source) -> string

Create Summary Item

Parameters:
index
source
local createOverviewItem (integer index, map source) -> term

Create Repository Item for Overview

Parameters:
index
source
local HandleMultipleSources (string url) -> boolean

Handle Multiple repositories URLs (order/instorder)

Parameters:
url
global Summary () -> list

Create a textual summary and a list of unconfigured cards

Return value:
summary of the current configuration
global Overview () -> list

Create an overview table with all configured cards

Return value:
table items
global RunCommandWithTimeout (string run_command, string log_command, integer script_time_out) -> map

Runs a bash command with timeout.

Structure Returns map $[

     "exit" : int_return_code,
     "stdout"  : [ "script", "stdout", "lines" ],
     "stderr"  : [ "script", "stderr", "lines" ],
 ]
Parameters:
run_command what to run
log_command what to log (passwords masked)
script_time_out in sec.
Return value:
with out, err and ret_code
global RunDumbTimeout (string command, string log_command, integer seconds) -> map

Run - with a timeout - on dumb terminal to disable colors etc - using 'exit $?' because of buggy behavior '.background vs. ZMD' (FIXME still needed???)

Parameters:
command a command
log_command a command to log
seconds timeout
Return value:
with out, err and ret_code
local RunLongLog (string command, string log_command) -> map

Run with a long timeout

Parameters:
command a command
log_command a command to log
Return value:
with out, err and ret_code
local RunLong (string command) -> map

Run with a long timeout

Parameters:
command a command
Return value:
with out, err and ret_code
Info:

path to ZMD CLI

local CheckZMDStatus () -> boolean

Detect whether ZMD is running

local ResetKnownServiceCache () -> void

Force calling rug on next IsUrlKnownToZMD

local UpdateKnownServiceCache (boolean adding, string url) -> void

Update the cache after a successful rug service-{add,delete} call

Parameters:
adding add url or delete it
url what
local IsUrlKnownToZMD (string url) -> boolean

Whether the URL is known to rug service-list. The known services are cached, the caller should use ResetKnownServiceCache if appropriate (each time when coming from outside this module at least)

Parameters:
url
Return value:
or nil if determining the status failed
local RugGetPref (string pref) -> string

Get a ZMD preference

Parameters:
pref see "rug get-prefs"
local RugSetPref (string pref, string value) -> void

Set a ZMD preference

Parameters:
pref
value
local AddOrDeleteZYPPServiceIntoZMD (integer src_id, boolean adding) -> boolean

Adds a ZYPP service into ZMD

Parameters:
src_id repository id
adding
Return value:
success
local ZMDStart () -> map

Start ZMD if it was not running Report::Error on failure

Return value:
an opaque handle
local ZMDWorking (map zmd_handle) -> boolean

Parameters:
zmd_handle what ZMDStart returned
Return value:
can we work with ZMD now
local ZMDRestore (map zmd_handle) -> void

Restore the status before ZMDStart Report::Error on failure

Parameters:
zmd_handle what ZMDStart returned
global Lock () -> void

Start a section where other processes (such as ZMD helpers) should not access the repository database. #170113 The calls may be nested.

global Unlock () -> void

Other processes may access the repository database again

global SyncYaSTInstSourceWithZMD () -> boolean

Checks whether ZMD is running, starts it when isn't. Checks whether a ZYPP repository is listed in the ZMD services, adds one if it is missing. Everything is done via the .process agent with timeout (number in seconds).

Return value:
whether the syncing succeeds
global SyncAddedAndDeleted (list<integer> added_src_ids, list<integer> deleted_src_ids) -> boolean

Sync the changed repositories to ZENworks

Parameters:
added_src_ids ids of repositories that were added
deleted_src_ids ids of repositories that were deleted
Return value:
success
local ParseUrlQuery (string query) -> map<string, string>

Parse a URL query (already unescaped) to a map. If no equal sign, the value will be nil.

Parameters:
query foo=bar&baz=qux
Return value:
$["foo": "bar", "baz": "qux"]
local get_attr_to_id (string attr) -> map<string,integer>

Parameters:
attr SourceGeneralData item
Return value:
For existing repositories, get a mapping from an attribute to the id
local get_alias_to_id () -> map<string,integer>

Return value:
For existing repositories, get a mapping from the alias to the id
local get_url_to_id () -> map<string,integer>

Return value:
For existing repositories, get a mapping from the URL to the id
local SourceByAliasOrUrl (string url, map<string,integer> alias_to_id, map<string,integer> url_to_id) -> integer

Extract an alias parameter from the URL and check whether we have such a repository already.

Parameters:
url a repository with an alias parameter (actually optional)
alias_to_id a premade mapping, @see get_alias_to_id
url_to_id
Return value:
the repository id or -1
global AddUpdateSources (list<string> urls) -> list<string>

Used by registration. This is really hairy because we simultaneously add them to zypp and ZENworks, but not if they are not signed. (thus being better than inst_source)

Parameters:
urls URLs to add
Return value:
a list of added URLs
global AskForCD (string message) -> boolean

Parameters:
message
global InstallationSourceOnPartition () -> string

Function returns the partiton name which is used as a repository for the installation (IF any partition is used as a repository for installation, of course). Otherwise it returns an empty string "". See bugzilla #208222 for more information.

Return value:
partition name
global InstInitSourceMoveDownloadArea () -> void

Finds the biggest temporary directory and uses it as packager download area.