YaST2 Developers Documentation: Pkg:: built-in functions



Pkg:: built-in functions

Pkg::ActivateSelections () -> bool

Activate all selected selections

To be called when user is done with selections and wants to continue on the package level (or finish)

This will transfer the selection status to package status

Pkg::AnyToInstall () -> bool

return true if any packages are to be installed

Pkg::ClearSaveState () -> bool

clear a saved state (to reduce memory consumption)

Pkg::ClearSelection (string selection) -> bool

Clear a selected selection

Pkg::CreateBackups (boolean flag) -> void

whether to create package backups during install or removal

Pkg::DoProvide (list tags) -> $["failed1":"reason", ...]

Provides (read: installs) a list of tags to the system

tag can be a package name, a string from requires/provides or a file name (since a package implictly provides all its files)

returns a map of tag,reason pairs if tags could not be provided. Usually this map should be empty (all required packages are installed) If tags could not be provided (due to package install failures or conflicts), the tag is listed as a key and the value describes the reason for the failure (as an already translated string).

Pkg::DoRemove (list tags) -> ["failed1", ...]

Removes a list of tags from the system

tag can be a package name, a string from requires/provides or a file name (since a package implictly provides all its files)

returns a map of tag,reason pairs if tags could not be removed. Usually this map should be empty (all required packages are removed) If a tag could not be removed (because other packages still require it), the tag is listed as a key and the value describes the reason for the failure (as an already translated string).

Pkg::GetAdditionalLocales -> list

return list of additional locales

Pkg::GetBackupPath () -> string

get current path for update backup of rpm config files

Pkg::GetLocale () -> string locale

get the currently preferred locale

Pkg::GetPackages (symbol which, bool names_only) -> list of strings

return list of packages (["pkg1", "pkg2", ..."] if names_only==true, ["pkg1 version release arch", "pkg1 version release arch", ... if names_only == false]

'which' defines which packages are returned:

`installed all installed packages `selected all selected but not yet installed packages `available all available packages (from the installation source)

Pkg::GetSelections (symbol status, string category) -> ["sel1", "sel2", ...]

returns a list of selection names matching the status symbol and the category. If category == "base", base selections are returned If category == "", addon selections are returned else selections matching the given category are returned

status can be:
`all : all known selections
`available : available selections
`selected : selected but not yet installed selections
`installed : installed selection

Pkg::InstSysMode () -> void

Set packagemanager to "inst-sys" mode - dont use local caches (ramdisk!)

!!!!!!!!!! CAUTION !!!!!!!!!!! Can only be called ONCE MUST be called before any other function !!!!!!!!!! CAUTION !!!!!!!!!!!

Pkg::IsAvailable (string tag) -> boolean

returns a 'true' if the tag is available on any of the currently active installation sources. (i.e. it is installable)

tag can be a package name, a string from requires/provides or a file name (since a package implictly provides all its files)

Pkg::IsManualSelection () -> bool

return true if the original list of packages (since the last Pkg::SetSelection()) was changed.

Pkg::IsProvided (string tag) -> boolean

returns a 'true' if the tag is provided in the installed system

tag can be a package name, a string from requires/provides or a file name (since a package implictly provides all its files)

Pkg::IsSelected (string tag) -> boolean

returns a 'true' if the tag is selected for installation

tag can be a package name, a string from requires/provides or a file name (since a package implictly provides all its files)

Pkg::PkgAnyToDelete () -> bool

return true if any packages are to be deleted

Pkg::PkgCommit (integer medianr) -> [ int successful, list failed, list remaining, list srcremaining ]

Commit package changes (actually install/delete packages)

the 'successful' value will be negative, if installation was aborted !

if medianr == 0, all packages regardless of media are installed if medianr > 0, only packages from this media are installed

Pkg::PkgDelete (string package) -> boolean

Select package for deletion

Pkg::PkgGroup (string package) -> string

Get rpm group of a package

Pkg::PkgInstall (string package) -> boolean

Select package for installation

Pkg::PkgMediaNames () -> [ "source_1_name", "source_2_name", ...]

return names of sources in installation order

Pkg::PkgMediaSizes () ->

[ [src1_media_1_size, src1_media_2_size, ...], [src2_media_1_size, src2_media_2_size, ...], ...] return cumulated sizes (in bytes !) to be installed from different sources and media

Returns the install size, not the archivesize !!

Pkg::PkgNeutral (string package) -> boolean

Set package to neutral (drop install/delete flags)

Pkg::PkgSize (string package) -> 12345678

Get (installed) size of a package

Pkg::PkgSolve () -> boolean

Optional: Pkg::PkgSolve (true) to filter all conflicts with installed packages (installed packages will be preferred)

Solve current package dependencies

Pkg::PkgSolveErrors () -> integer

return number of fails

Pkg::PkgSummary (string package) -> "This is a nice package"

Get summary (aka label) of a package

Pkg::PkgVersion (string package) -> "1.42-39"

Get version (better: edition) of a package

Pkg::RestoreState () -> bool

restore the package selection status from a former call to Pkg::SaveState() Returns false if there is no saved state (no Pkg::SaveState() called before)

Pkg::SaveState () -> bool

save the current package selection status for later retrieval via Pkg::RestoreState()

Pkg::SelectionData (string selection) -> map

-> $["summary" : "This is a nice selection", "category" : "Network", "visible" : true, "recommends" : ["sel1", "sel2", ...], "suggests" : ["sel1", "sel2", ...], "archivesize" : 12345678 "order" : "042"]

Get summary (aka label), category, visible, recommends, suggests, archivesize, and order attributes of a selection Returns an empty list if no selection found Returns nil if called with wrong arguments

Pkg::SetAdditionalLocales (list of string) -> void

set list of

Pkg::SetBackupPath (string path) -> void

set current path for update backup of rpm config files

Pkg::SetLocale (string locale) -> void

set the given locale as the "preferred" locale

Pkg::SetSelection (string selection) -> bool

Set a new selection

If the selection is a base selection, this effetively resets the current package selection to the packages of the newly selected base selection Usually returns true Returns false if the given string does not match a known selection.

Pkg::SourceCacheCopyTo (string dir) -> bool

copy cache data of all installation sources to 'dir' to be called at end of initial installation with the target root dir.

Pkg::SourceChangeUrl (integer source_id , string url ) -> bool

change url of source used primarely when re-starting during installation and a cd-device changed from hdX to srX since ide-scsi was activated returns false if source_id doesn't exists or the url is malformed

Pkg::SourceCreate (string url [, string product_dir]) -> integer

creates a *NEW* package source under the given url

if product_dir is _not_ given or empty, creates sources for all products and returns the id of the first product source

This is only needed at initial installation or in the source manager. Normal code should rely on the cached sources. @see SourceStartCache

Pkg::SourceDelete (integer source_id ) -> bool

Delete source. Return true, if successful, false, if not. This function invalidates all source_ids. Use SourceGetCurrent to get the new list of source_ids.

Pkg::SourceFinish (integer id) -> bool

disables source

Pkg::SourceFinishAll () -> bool

disables all known source

Pkg::SourceGeneralData (integer id) -> map

returns general data about the source as a map: $[ "default_activate" : bool, "product_dir" : string, "url" : string, // also in SourceMediaData "type" : string ];

Pkg::SourceGetCurrent (void) -> list of source ids

return all currently known and enabled sources

Pkg::SourceInstallOrder (map order_map) -> bool

set installation order order_map = map of 'int order : int source_id', with order 1 == highest

Pkg::SourceLowerPriority (integer source_id ) -> void

Raise priority of source. Return true on success, false on error. This function invalidates all source_ids. Use SourceGetCurrent to get the new list of source_ids.

Pkg::SourceMediaData (integer id) -> map

returns media data about the source as a map: $[ "media_count" : string, "media_id" : bool, "media_vendor" : string, "url" : string // also in SourceGeneralData ];

Pkg::SourceProduct (integer source_id) -> map

return $["product" : string, "vendor" : string ]

Pkg::SourceProductData (integer id) -> map

returns product data about the source as a map: $[ "productname" : string, "productversion" : string, "baseproductname" : string, "baseproductversion" : string, "vendor" : string, "defaultbase" : string, "architectures" : list (string), "requires" : string, "linguas" : list (string), "label" : string, "labelmap" : map (string lang, string label), "language" : string, "timezone" : string, "descrdir" : string, "datadir" : string ];

Pkg::SourceProvideDir (integer source, integer medianr, string path) -> string path

provide directory from source to local path @param source source id from SourceStartCache() @param medianr should be 0 (let the packagemanager decide about the media) @param dir pathname relative to source (i.e. CD) root path

Pkg::SourceProvideFile (integer source, integer medianr, string file) -> string path

provide file from source to local path @param source source id from SourceStartCache() @param medianr should be 0 (let the packagemanager decide about the media) @param file filename relative to source (i.e. CD) root path

Pkg::SourceRaisePriority (integer source_id ) -> bool

Raise priority of source. Return true on success, false on error. This function invalidates all source_ids. Use SourceGetCurrent to get the new list of source_ids.

Pkg::SourceSaveRanks () -> boolean

Save ranks to disk. Return true on success, false on error.

Pkg::SourceSetEnabled (integer source_id, boolean enabled) -> bool

Set default activation state of source. Return true, if successful, false, if not.

Pkg::SourceSetRamCache (boolean) -> boolean

enable/disable caching data on ramdisk (source is mounted, use data directly from source instead)

Pkg::SourceStartCache (boolean enabled_only) -> list of integer

Start cached sources

return list of known (and enabled) source id's This starts the packagemanager from it's cache of known sources

Pkg::SourceStartManager (boolean autoEnable) -> boolean

Starts the InstSrcManager. @param

Pkg::TagetInitDU (list(map)) -> void

init DU calculation for given directories parameter: [ $["name":"dir-without-leading-slash", "free":int_free, "used": int_used]

Pkg::TargetBlockSize (string dir) -> integer

return block size of partition at directory

Pkg::TargetCapacity (string dir) -> integer

return capacity of partition at directory

Pkg::TargetFinish () -> bool

finish target usage

Pkg::TargetGetDU (void) -> map

return current DU calculations $[ "dir" : [ total, used, pkgusage ], .... ] total == total size for this partition used == current used size on target pkgusage == future used size on target based on current package selection

Pkg::TargetInit (string root, bool new) -> bool

initialized target system with root-directory if new == true, initialize new rpm database

Pkg::TargetInstall (string filename) -> bool

install rpm package by filename the filename must be an absolute path to a file which can be accessed by the package manager.

!! uses callbacks !! You should do an 'import "PackageCallbacks"' before !

Pkg::TargetLogfile (string name) -> bool

init logfile for target

Pkg::TargetProducts () -> list

return list of maps of all installed products in reverse installation order (product installed last comes first)

Pkg::TargetRebuildDB () -> bool

call "rpm --rebuilddb"

Pkg::TargetRemove (string name) -> bool

install package by name !! uses callbacks !! You should do an 'import "PackageCallbacks"' before !

Pkg::TargetUpdateInf (string filename) -> map

return content of update.inf (usually /var/lib/YaST/update.inf) as $[ "basesystem" : "blah", "distname" : "foo", "distversion" : "bar", "distrelease" : "baz", "ftppatch" : "ftp.suse.com:/pub/suse/i386/update/8.0.99", "ftpsources" : [ "ftp.suse.com:/pub/suse/i386/current", ... ]]

Pkg::TargetUsed (string dir) -> integer

return usage of partition at directory

Pkg::YouAttachSource () -> bool

attach source of patches

Pkg::YouCheckAuthorization () -> error string

Try to login to update server.

@param string server url @param string registration code @param string password

@return "ok" success "args" bad args "error_login" authorization failed "url_invalid" invalid url "url_not_found" url not found "error" other error

Pkg::YouFirstPatch () -> map

get information about first selected patch.

Pkg::YouGetCurrentPatch () -> error string

download current patch.

@param bool true if signatures should be checked.

@return "" success "args" bad args "media" media error "sig" signature check failed

Pkg::YouGetPackages () -> bool

retrieve package data belonging to patches

Pkg::YouGetPatches () -> error string

retrieve patches @param string url of patch server. @param bool true if signatures should be checked. @return "" success "args" bad args "media" media error "sig" signature check failed "url" url not valid

Pkg::YouGetServers () -> error string

get urls of patch servers

@param list(string) list of strings where results are stored.

@return "" success "args" bad args "get" error getting file from server "read" error reading file after download

Pkg::YouInstallCurrentPatch () -> bool

install current patch.

Pkg::YouInstallPatches () -> bool

install retrieved patches

Pkg::YouNextPatch () -> map

get information about next patch to be installed.

Pkg::YouRemovePackages () -> bool

remove downloaded packages.

Pkg::YouSelectPatches () -> void

select patches based on types.

Pkg::YouStatus () -> map

get map with status information

PkgUpdateAll (bool delete_unmaintained) -> [ integer affected, integer unknown ]

mark all packages for installation which are installed and have an available candidate.

@return [ integer affected, integer unknown ]

This will mark packages for installation *and* for deletion (if a package provides/obsoletes another package)

!!! DOES NOT SOLVE !!

PkgUpdateAll (bool only_newer) -> count

mark all packages for installation which are installed and have an available candidate. if 'only_newer' == true, only affect packages which are newer, else affect all packages

@return number of packages affected

This will mark packages for installation *and* for deletion (if a package provides/obsoletes another package)


YaST2 Developers Documentation: Pkg:: built-in functions