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::FilterPackages (bool byAuto, bool byApp, bool byUser, bool names_only) -> list of strings

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

if one of the first 3 parameters is set to true, it returns: byAuto: packages you get by dependencies, byApp: packages you get by selections, byUser: packages the user explicitly requested.

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::PkgGetFilelist (string name, symbol which) -> list

Return, if available, the filelist of package 'name'. Symbol 'which' specifies the package instance to query:

`installed query the installed package `candidate query the candidate package `any query the candidate or the installed package (dependent on what's available)

Pkg::PkgGetLicenseToConfirm (string package) -> string

Return the candidate packages license text. Returns an empty string if package is unknown or has no license.

Pkg::PkgGetLicensesToConfirm (list packages) -> map

Return a map for all candidate packages in list, which do have a license. Unknown packages and those without license text are not returned.

Pkg::PkgGroup (string package) -> string

Get rpm group of a package

Pkg::PkgInstall (string package) -> boolean

Select package for installation

Pkg::PkgLocation (string package) -> string

Get file location of a package in the source

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

return names of sources in installation order list

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 !! list >

Pkg::PkgNeutral (string package) -> boolean

Set package to neutral (drop install/delete flags)

Pkg::PkgProperties (string package) -> map

@param package name

@return Data about package location, source and which media contains the package

$["srcid" : YCPInteger
,"location" : YCPString
,"medianr" : YCPInteger
,"arch" : YCPString
];

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::PkgSolveCheckTargetOnly () -> boolean

Solve packages currently installed on target system. Packages status remains unchanged, i.e. does not select/deselect any packages to resolve failed dependencies.

Pkg::PkgSolveErrors () -> integer

only valid after a call of PkgSolve/PkgSolveCheckTargetOnly that returned false return number of fails

Pkg::PkgSrcInstall (string package) -> boolean

Select source of package for installation

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::Reset () -> boolean

Reset most internal stuff on the package manager.

Pkg::RestoreState (bool check_only = false) -> 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)

If called with argument (true), it only checks the saved against the current status and returns true if they differ.

Pkg::SaveState () -> bool

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

Pkg::SelectionContent (string selection, boolean to_delete, string language) -> list

-> ["aaa_base", "k_deflt", ... ]

Get list of packages listed in a selection

selection = name of selection to_delete = if false, return packages to be installed if true, return packages to be deleted language = if "" (empty), return only non-language specific packages else return only packages machting the language

Returns an empty list if no matching selection found Returns nil if called with wrong arguments

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", "requires" : ["a", "b"], "conflicts" : ["c"], "provides" : ["d"], "obsoletes" : ["e", "f"], ]

Get summary (aka label), category, visible, recommends, suggests, archivesize, order attributes of a selection, requires, conflicts, provides and obsoletes. 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) -> true

Copy cache data of all installation sources to the target located below 'dir'. To be called at end of initial installation.

@param dir Root directory of target.

@return true

Pkg::SourceChangeUrl (integer SrcId, string url ) -> true

Change url of an InstSrc. Used primarely when re-starting during installation and a cd-device changed from hdX to srX since ide-scsi was activated.

@param SrcId Specifies the InstSrc.

@param url The new url to use.

@return true

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

Load and enable all InstSrces found at media_url, i.e. all sources mentioned in /media.1/products. If no /media.1/products is available, InstSrc is expected to be located directly below media_url (product_dir: /).

If a product_dir is provided, only the InstSrc located at media_url/product_dir is loaded and enabled.

@param url The media to scan.

@param product_dir Restrict scan to a certain InstSrc located in media_url/product_dir.

@return The source_id of the first InstSrc found on the media.

Pkg::SourceDelete (integer SrcId) -> bool

Delete an InsrSrc. The InsrSrc together with all metadata cached on disk is removed. The SrcId passed becomes invalid (other SrcIds stay valid).

@param SrcId Specifies the InstSrc.

@return bool

Pkg::SourceEditGet () -> list of source states (map)

Return a list of states for all known InstSources sorted according to the source priority (highest first). A source state is a map:
$["SrcId" : YCPInteger
,"enabled" : YCPBoolean
];

@return list of source states (map)

Pkg::SourceEditSet ( list source_states ) -> true

Rearange known InstSrces rank and default state according to source_states (highest priority first). Known InstSrces not mentioned in source_states are deleted.

@param source_states List of source states. Same format as returned by @ref SourceEditGet.

@return true

Pkg::SourceFinish (integer SrcId) -> bool

Disable an InsrSrc.

@param SrcId Specifies the InstSrc.

@return bool

Pkg::SourceFinishAll () -> true

Disable all InstSrces.

@return true

Pkg::SourceGeneralData (integer SrcId) -> map

@param SrcId Specifies the InstSrc to query.

@return General data about the source as a map:
$["enabled" : YCPBoolean
,"product_dir" : YCPString
,"type" : YCPString
,"url" : YCPString
];

Pkg::SourceGetCurrent (boolean enabled_only = true) -> list of SrcIds (integer)

Return the list of all enabled InstSrc Ids.

@param enabled_only If true, or omitted, return the Ids of all enabled InstSrces. If false, return the Ids of all known InstSrces.

@return list of SrcIds (integer)

Pkg::SourceInstallOrder (map order_map) -> true

Explicitly set an install order.

@param order_map A map of 'int order : int source_id'. source_ids are expected to denote known and enabled sources.

@return true

Pkg::SourceLowerPriority (integer SrcId) -> void

Lower priority of source.

@param SrcId Specifies the InstSrc.

@return bool

Pkg::SourceMediaData (integer SrcId) -> map

@param SrcId Specifies the InstSrc to query.

@return Media data about the source as a map:
$["media_count" : YCPInteger
,"media_id" : YCPString
,"media_vendor" : YCPString
,"url" : YCPString
];

Pkg::SourceProduct (integer SrcId) -> map

@param SrcId Specifies the InstSrc to query.

@return Product info as a map. See @ref Descr2Map

Pkg::SourceProductData (integer SrcId) -> map

@param SrcId Specifies the InstSrc to query.

@return Product data about the source as a map:
$["productname" : YCPString
,"productversion" : YCPString
,"baseproductname" : YCPString
,"baseproductversion" : YCPString
,"vendor" : YCPString
,"defaultbase" : YCPString
,"architectures" : YCPList(YCPString)
,"requires" : YCPString
,"linguas" : YCPList(YCPString)
,"label" : YCPString
,"labelmap" : YCPMap(YCPString lang,YCPString label)
,"language" : YCPString
,"timezone" : YCPString
,"descrdir" : YCPString
,"datadir" : YCPString
];

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

Let an InstSrc provide some directory (make it available at the local filesystem) and all the files within it (non recursive).

@param SrcId Specifies the InstSrc .

@param medianr Number of the media the file is located on ('1' for the 1st media).

@param dir Directoryname relative to the media root.

@return local path as string

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

Let an InstSrc provide some file (make it available at the local filesystem).

@param SrcId Specifies the InstSrc .

@param medianr Number of the media the file is located on ('1' for the 1st media).

@param file Filename relative to the media root.

@return local path as string

Pkg::SourceRaisePriority (integer SrcId) -> bool

Raise priority of source.

@param SrcId Specifies the InstSrc.

@return bool

Pkg::SourceSaveRanks () -> boolean

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

Pkg::SourceScan (string media_url [, string product_dir]) -> list of SrcIds (integer)

Load all InstSrces found at media_url, i.e. all sources mentioned in /media.1/products. If no /media.1/products is available, InstSrc is expected to be located directly below media_url (product_dir: /).

If a product_dir is provided, only the InstSrc located at media_url/product_dir is loaded.

In contrary to @ref SourceCreate, InstSrces are loaded into the InstSrcManager, but not enabled (packages and selections are not provided to the PackageManager), and the SrcIds of all InstSrces found are returned.

@param url The media to scan.

@param product_dir Restrict scan to a certain InstSrc located in media_url/product_dir.

@return list of SrcIds (integer).

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

Set the default activation state of an InsrSrc.

@param SrcId Specifies the InstSrc.

@param enabled Default activation state of source.

@return bool

Pkg::SourceSetRamCache (boolean allow) -> true

In InstSys: Allow/prevent InstSrces from caching package metadata on ramdisk. If no cache is used the media cannot be unmounted, i.e. no CD change possible.

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

Make sure the InstSrcManager is up, and return the list of SrcIds. In fact nothing more than:

SourceStartManager( enabled_only );
return SourceGetCurrent( enabled_only );

@param enabled_only If true, make sure all InstSrces are enabled according to their default, and return the Ids of enabled InstSrces only. If false, return the Ids of all known InstSrces.

@return list of SrcIds (integer)

Pkg::SourceStartManager (boolean autoEnable = true) -> true

Make sure the InstSrcManager is up and knows all available InstSrces. Depending on the value of autoEnable, InstSources may be enabled on the fly. It's safe to call this multiple times, and once the InstSources are actually enabled, it's even cheap (enabling an InstSrc is expensive).

@param autoEnable If true, all InstSrces are enabled according to their default. If false, InstSrces will be created in disabled state, and remain unchanged if the InstSrcManager is already up.

@return true

Pkg::TargetBlockSize (string dir) -> integer

return block size of partition at directory

Pkg::TargetCapacity (string dir) -> integer

return capacity of partition at directory

Pkg::TargetFileHasOwner (string filepath) -> bool

returns the (first) package

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::TargetInitDU (list(map)) -> void

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

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::YouGetDirectory () -> error string

retrieve directory file listing all available patches

@return "" success "url" url not valid "login" login failed "error" other error

Pkg::YouGetServers () -> error string

get urls of patch servers

@param list(map) list of maps where results are stored. The maps have the following fields set:

"url" URL of server. "name" Descriptive name of server. "directory" Directory file used to get list of patches.

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

Pkg::YouProcessPatches () -> bool

Download and install patches.

Pkg::YouRemovePackages () -> bool

remove downloaded packages.

Pkg::YouRetrievePatchInfo ( boolean download_again, boolean check_signatures ) -> error string

retrieve patches

@param bool true if patches should be downloaded again @param bool true if signatures should be checked.

@return "" success "args" bad args "media" media error "sig" signature check failed "abort" user aborted operation "url" url not valid "login" login failed

Pkg::YouSecurityUpdatesAvailable () -> bool

check for security updates

Pkg::YouSelectPatches () -> void

select patches based on types.

Pkg::YouStatus () -> map

get map with status information

Pkg::YouUpdatesAvailable () -> bool

check for updates

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 !!


YaST2 Developers Documentation: Pkg:: built-in functions