This is a helper script for extracting the used pkg-bindings calls from y2log file and building a markdown document with links to the source code at GitHub.
-
-
Save lslezak/4d59c037afdf7dec3031ee1cff90b3a4 to your computer and use it in GitHub Desktop.
| # /bin/bash | |
| # A helper script hich extracts used pkg-bindings calls from y2log files and | |
| # build a markdown list with links to the GitHub sources. | |
| # Usage: | |
| # 1. Copy the y2log files (/var/log/YaST2/y2log*) from an installation | |
| # 2. Run this script in the pkg-bindings Git checkout | |
| # (https://github.com/yast/yast-pkg-bindings/), pass the path to y2log | |
| # files as arguments: | |
| # | |
| # ./pkg-calls.sh <y2log> ... | |
| # | |
| # You can use a shell glob: | |
| # | |
| # ./pkg-calls.sh y2log* | |
| # | |
| # grep the y2log files for the pkg-bindings calls, read the calls into an array, | |
| # use zgrep so it can read also the compressed files (y2log-*.gz) | |
| mapfile -t CALLS < <( zgrep "Pkg Builtin called" "$@" | sed -e "s/^.* Pkg Builtin called: //" | sort -u ) | |
| for C in "${CALLS[@]}"; do | |
| # use the first found occurence | |
| URL=$(grep -r -n "PkgFunctions::$C\\b" . | sed -e "s/\\.cc:\\([0-9]\\+\\):.*/.cc#L\\1/" -e "s@^./@https://github.com/yast/yast-pkg-bindings/blob/master/@" | head -n 1) | |
| echo "[$C]($URL)" | |
| done |
Minimal functionality for installing a system
These are the minimal functions needed to be able to install a system:
Initialize libzypp
Connect - get the libzypp lock
SetTextLocale - set the UI locale for libzypp errors, pattern descriptions, etc...
TargetInitialize, TargetLoad - initialize a temporary target in /tmp/... (for downloading repository metadata, package cache...)
ImportGPGKey - import the base GPG keys so the repository metadata and the installed packages can be verified
Add repositories
RepositoryAdd - add the installation repositories
Select packages to install
SetPackageLocale - install packages for the specified locale (translation packages, spellcheck dictionaries,...)
ResolvableInstall - install the selected package/pattern
Resolvables - query the selected/available packages/patterns
Run the solver
SetSolverFlags - might not be needed, we need to check which flags are set by YaST, maybe using the defaults is fine...
PkgSolve - run the solver
PkgSolveErrors - get details of the solver errors
Start installation
TargetInitialize, TargetLoad - move the installation target to the just created /mnt partition
Commit - start the package installation
Finish the installation
SourceCacheCopyTo - copy the repository caches to the installed system so they do not need to be downloaded again
SourceReleaseAll - free the resources, unmount the disks...
SourceSaveAll - save the *.repo files to the target system
Close libzypp
TargetFinish - free the target resources (the lock as well?)
Optional
- For displaying installation progress we need to register some download and package installation callbacks.
- We might need some revert/remove functionality, when the selected product is changed we need to drop the configured repositories and use the new ones. Alternatively we could just drop whole libzypp and start from scratch.
Resolvables - query the selected/available packages/patterns
This call supports a lot of filtering options. Let's see which ones are actually used during the installation
I have run a testing Agama installation and collected all Pkg bindings calls used by the YaST backend from the
y2log:Commit
Connect
DoProvide
ExpandedUrl
GetAdditionalLocales
GetPackageLocale
GetPackages
GetTextLocale
ImportGPGKey
IsAvailable
IsSelected
PkgApplReset
PkgAvailable
PkgMediaCount
PkgMediaNames
PkgMediaPackageSizes
PkgMediaSizes
PkgQueryProvides
PkgReset
PkgSolve
PkgSolveErrors
RepositoryAdd
RepositoryProbe
ResolvableInstall
Resolvables
SetAdditionalLocales
SetPackageLocale
SetSolverFlags
SetTextLocale
SourceGeneralData
SourceGetCurrent
SourceLoad
SourceProvideOptionalFile
SourceReleaseAll
SourceSaveAll
SourceSetEnabled
SourceURL
TargetFinish
TargetInitialize
TargetLoad
UrlSchemeIsLocal
UrlSchemeIsVolatile
There are also lots of callback registration functions, but most of them are actually not used by Agama and they are not relevant. They were found just because we use the same YaST files in backend as in normal YaST installation:
CallbackAcceptFileWithoutChecksum
CallbackAcceptUnknownDigest
CallbackAcceptUnknownGpgKey
CallbackAcceptUnsignedFile
CallbackAcceptVerificationFailed
CallbackAcceptWrongDigest
CallbackAuthentication
CallbackDestDownload
CallbackDoneDownload
CallbackDonePackage
CallbackDoneProvide
CallbackDoneRefresh
CallbackDoneScanDb
CallbackErrorScanDb
CallbackFileConflictFinish
CallbackFileConflictProgress
CallbackFileConflictReport
CallbackFileConflictStart
CallbackFinishDeltaApply
CallbackFinishDeltaDownload
CallbackImportGpgKey
CallbackInitDownload
CallbackMediaChange
CallbackMessage
CallbackPkgGpgCheck
CallbackProblemDeltaApply
CallbackProblemDeltaDownload
CallbackProcessDone
CallbackProcessNextStage
CallbackProcessProgress
CallbackProcessStart
CallbackProgressDeltaApply
CallbackProgressDeltaDownload
CallbackProgressDownload
CallbackProgressPackage
CallbackProgressProvide
CallbackProgressReportEnd
CallbackProgressReportProgress
CallbackProgressReportStart
CallbackProgressScanDb
CallbackScriptFinish
CallbackScriptProblem
CallbackScriptProgress
CallbackScriptStart
CallbackSourceChange
CallbackSourceCreateDestroy
CallbackSourceCreateEnd
CallbackSourceCreateError
CallbackSourceCreateInit
CallbackSourceCreateProgress
CallbackSourceCreateStart
CallbackSourceProbeEnd
CallbackSourceProbeError
CallbackSourceProbeFailed
CallbackSourceProbeProgress
CallbackSourceProbeStart
CallbackSourceProbeSucceeded
CallbackSourceReportDestroy
CallbackSourceReportEnd
CallbackSourceReportError
CallbackSourceReportInit
CallbackSourceReportProgress
CallbackSourceReportStart
CallbackStartDeltaApply
CallbackStartDeltaDownload
CallbackStartDownload
CallbackStartPackage
CallbackStartProvide
CallbackStartRefresh
CallbackStartScanDb
CallbackTrustedKeyAdded
CallbackTrustedKeyRemoved
Notes