class RPM::Transaction
- RPM::Transaction
- Reference
- Object
Overview
Handles RPM transaction. Any RPM Database work must be accessed via the Transaction.
Included Modules
- Enumerable(RPM::Transaction::Element)
- Iterable(RPM::Transaction::Element)
Defined in:
rpm/transaction.crConstructors
-
.new(*, root : String = "/")
Initialize a new transaction object.
Instance Method Summary
-
#check
Run transaction check
-
#clean
Free memory needed only for dependency checks and ordering
-
#close_db
Closes the opened DB handle
-
#commit(&block : Callback)
Run the pending transaction, with given callback.
-
#commit(callback : Callback? = nil)
Run the pending transaction
-
#db_iterator(tag = DbiTag::Packages, val = nil, &block : MatchIterator -> _)
Init DB iterator, yield block and cleanup.
-
#delete(pkg : Dependency)
Register given dependency to be deleted
-
#delete(pkg : Package)
Register given package to be deleted.
-
#delete(pkg : String)
Register given package to be deleted (by a name)
-
#delete_by_iterator(iter : MatchIterator)
Register all matching packages to be deleted.
-
#each(etypes : ElementTypes = ElementTypes::ANY)
Returns iterator for transaction elements
-
#each(etypes : ElementTypes = ElementTypes::ANY, &)
Iterate over each transaction element
- #finalize
-
#flags
Get transaction flags
-
#flags=(flg)
Set transaction flags
-
#init_iterator(tag : DbiTag | DbiTagValue = DbiTag::Packages, val : String | Slice(UInt8) | Nil = nil)
Create a new package iterator with given
tag
andval
-
#install(pkg : Package, key : String)
Register a package to be installed
-
#install_element(pkg : Package, key : String, *, upgrade : Bool = false)
Base method of install, upgrade and delete
-
#order
Determine package order in the transaction according to dependencies
-
#problems?
Return transaction problems
-
#read_package_file(filename : String | Path) : Package
Read RPM package file
-
#root_dir
Gets rootdir
-
#root_dir=(dir : String | Pointer(UInt8))
Sets rootdir
-
#set_notify_callback(closure : Callback?, &)
Sets the callback method (for running under running transaction), and yields the given block.
-
#to_unsafe : Pointer(Void)
Returns pointer to
rpmts
to -
#upgrade(pkg : Package, key : String)
Register a package to be upgraded
Constructor Detail
Initialize a new transaction object.
You must close the DB with #close_db
after use.
Recommended to use RPM.transaction
instead.
Instance Method Detail
Run the pending transaction, with given callback.
To handle exception, following form will be safe:
e : Exception? = nil
ts.commit do |header, type, amount, total, key|
# do something here.
rescue ex : Exception
if e.nil?
e = ex
end
Pointer(Void).null
end
if e
raise e
end
WARNING: Call order (by type) and content of arguments are very different by RPM version.
Run the pending transaction
If callback is not given, default callback will be used.
Returns true if transaction has been completed successfully, false if transaction has problem(s).
Raises TransactionError if any error(s) occured
Init DB iterator, yield block and cleanup.
Please refer RPM's rpmtsInitIterator()
function for more
details.
Some examples are:
- For package tag lookup, use
RPM::DbiTag::Packages
. - For package name lookup, use
RPM::DbiTag::Name
. - For filename (fullpath) lookup, use
RPM::DbiTag::BaseNames
. - To lookup by a specific tag, initialize iterator with
RPM::DbiTag::Packages
, and use#regexp
method.
Register all matching packages to be deleted.
Note: No package will be rejected (even RPM itself). Exception will be raised when some error occured.
Returns iterator for transaction elements
Iterate over each transaction element
Create a new package iterator with given tag
and val
Please refer RPM's rpmtsInitIterator()
function for more
details.
Some examples are:
- For package tag lookup, use
RPM::DbiTag::Packages
. - For package name lookup, use
RPM::DbiTag::Name
. - For filename (fullpath) lookup, use
RPM::DbiTag::BaseNames
. - To lookup by a specific tag, initialize iterator with
RPM::DbiTag::Packages
, and use#regexp
method.
Register a package to be installed
key
should (must?) be the path of the source package.
Base method of install, upgrade and delete
Determine package order in the transaction according to dependencies
The final order ends up as installed packages followed by removed packages, with packages removed for upgrades immediately following the new package to be installed.
Read RPM package file
For independent use, RPM::Package.open
.
Gets rootdir
Optimization NOTE: The rootdir will not be cached. Each time this method is called, this method allocates a new memory space to store the rootdir pathname, and return it.
Sets rootdir
This is possible only while no iterators are bound and no installations and/or deletions are set.
Sets the callback method (for running under running transaction), and yields the given block. Callback is set only while the block is yielded.
For user-friendly way to apply callback, use following form instead:
ts.commit do |header, type, amount, total, key|
# do something here.
end
WARNING: We notifies rpmtsRun
(#commit
) may raises an Exception
to the compiler, but raising an exception is highly discouraged.
It may break the RPM database.
WARNING: Call order (by type) and content of arguments are very different by RPM version.
Register a package to be upgraded
key
should (must?) be the path of the source package.