class RPM::Transaction

Overview

Handles RPM transaction. Any RPM Database work must be accessed via the Transaction.

Included Modules

Defined in:

rpm/transaction.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(*, root : String = "/") #

Initialize a new transaction object.

You must close the DB with #close_db after use. Recommended to use RPM.transaction instead.


[View source]

Instance Method Detail

def check #

Run transaction check

Raises exception if check errored.


[View source]
def clean #

Free memory needed only for dependency checks and ordering


[View source]
def close_db #

Closes the opened DB handle


[View source]
def commit(&block : Callback) #

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.


[View source]
def commit(callback : Callback? = nil) #

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


[View source]
def db_iterator(tag = DbiTag::Packages, val = nil, &block : MatchIterator -> _) #

Init DB iterator, yield block and cleanup.

Please refer RPM's rpmtsInitIterator() function for more details.

Some examples are:


[View source]
def delete(pkg : Dependency) #

Register given dependency to be deleted


[View source]
def delete(pkg : Package) #

Register given package to be deleted.


[View source]
def delete(pkg : String) #

Register given package to be deleted (by a name)


[View source]
def delete_by_iterator(iter : MatchIterator) #

Register all matching packages to be deleted.

Note: No package will be rejected (even RPM itself). Exception will be raised when some error occured.


[View source]
def each(etypes : ElementTypes = ElementTypes::ANY) #

Returns iterator for transaction elements


[View source]
def each(etypes : ElementTypes = ElementTypes::ANY, &) #

Iterate over each transaction element


[View source]
def finalize #

[View source]
def flags #

Get transaction flags


[View source]
def flags=(flg) #

Set transaction flags


[View source]
def init_iterator(tag : DbiTag | DbiTagValue = DbiTag::Packages, val : String | Slice(UInt8) | Nil = nil) #

Create a new package iterator with given tag and val

Please refer RPM's rpmtsInitIterator() function for more details.

Some examples are:


[View source]
def install(pkg : Package, key : String) #

Register a package to be installed

key should (must?) be the path of the source package.


[View source]
def install_element(pkg : Package, key : String, *, upgrade : Bool = false) #

Base method of install, upgrade and delete


[View source]
def order #

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.


[View source]
def problems? #

Return transaction problems

If there are no problems, returns nil.


[View source]
def read_package_file(filename : String | Path) : Package #

Read RPM package file

For independent use, RPM::Package.open.


[View source]
def root_dir #

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.


[View source]
def root_dir=(dir : String | Pointer(UInt8)) #

Sets rootdir

This is possible only while no iterators are bound and no installations and/or deletions are set.


[View source]
def set_notify_callback(closure : Callback?, &) #

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.


[View source]
def to_unsafe : Pointer(Void) #

Returns pointer to rpmts to


[View source]
def upgrade(pkg : Package, key : String) #

Register a package to be upgraded

key should (must?) be the path of the source package.


[View source]