- File conflicts should only be resolved to preferred color when
both files are colored. Prior to this we would happily overwrite
scripts with a clearly conflicting ELF binary.
- These are already taken care of in other places but they're littered
a little bit of here and there, eg in case of collections these
modes are only skipped deep down in the plugin code. This should
make the intended behavior more obvious upfront.
- There's no meaningful way to return error from rpmdbExtendIterator()
in rpmFindBaseNamesInDB() so dont bother collecting the result.
At least there'll be rpmlog spew on errors so it wouldn't be
silently failing.
- There are places in rpmio and build that would benefit from hashing, but
hashFunctionString() being internal to librpm has prevented that. Rename
to rstrhash() to resemble the other foo in rpmstring.h for
minimal namespacing as its now public function and update callers.
- Also mark the function as "pure" - it only looks at its arguments.
This is one of the busiest functions in entire rpm so any optimization
no matter how minor is well worth it.
- Hereby awarding hashFunctionString() with the grand prize for
the Most Moved Around Function in rpm ;)
- Bail out early and complain if current directory can't be open()'ed,
as we'll need it for reliable cwd restoration after running Lua
scripts.
- Technically we'd only need open(".") succeeding for chroot operations
and running Lua-scripts, but there's no easy way to determine whether
a transaction will run Lua-scripts. They could be in-db triggers
which will only be evaluated in the middle of transaction, better
to fail early for consistent behavior.
- For rpm itself forging global umask on init is kinda convenient, but can
be troublesome for API users. This is especially bad in python bindings
where just importing the rpm module silently changes process umask with
no good reason.
- Instead of global setting on init, only change the umask to 022 default
for the duration of rpmtsRun() where it's necessary for consistent
transaction results on implicitly created directories and files created
by scriptlets. This way we dont affect callers and provide better
"protection" for ourselves too - we don't know if API users change
umask again behind our back if we just set it on initialization.
- To make matters more fun, Lua scripts can change our umask. Save
and restore umask when running Lua scriptlets.
- These were used by the netsharedpath calculations which used
to be inline here, but that's now in a function of their own. Also
move the temporary variables to the scope where they're actually used.
- No point "documenting" with reverse ifdef's what somebody was
considering to implement eight years ago, as it is directory and
file iterations can't be mixed as they both mess with fi->j.
- Also eliminate pointless "can't happen" check - this never gets
called with NULL fi in an element (which is already a cant happen)
- There's exactly one spot within rpm which needs the former behavior
of rpmdbInitIterator() on a secondary index with keyp of NULL:
rpmFindBaseNamesInDB(): it wants an empty iterator on RPMDBI_BASENAMES,
which is then extended as it progresses. Starting with commit
c70e076e08, rpmdbInitIterator()
however returns the actual index in that case, which is not
optimal for rpmFindBaseNamesInDB(). Handle the basenames in db
as the special case it is, and have it explicitly create an
empty iterator with the new call.
This replaces the old matchpathcon interfaces with the new selabel
interfaces for relabeling files, storing an selabel handle in the
transaction set.
With this change, also comes an added distinction between --nocontexts
being specified and a failure to read the load file contexts.
Previously, there was no distinction, and both cases used the
RPMTRANS_FLAG_NOCONTEXTS flag.
However, with the new policy plugin, it is necessary to make such a
distinction. This is because matchpathcon_init (now selabel interfaces)
can fail at the beginning of the transaction, but succeed later after
new policy is installed. Because of this, we may need to enable/disable
RPMTRANS_FLAG_NOCONTEXTS multiple times. However, because this flag
could also mean --nocontexts, we cannot do that. By storing the selabel
handle in the rpmts, we can easily keep track if the handle has been
successfully created, rather than overloading RPMTRANS_FLAG_NOCONTEXTS
with two meanings.
This moves most of the plugin logic to a new rpmplugins file with a
struct and functions for managing plugins, allowing for plugins to carry
state. This also adds init and cleanup hooks for plugins to initialize
and cleanup their state, and a new 'open te' hook allowing plugins to
read and save information from transaction elements.
This also generalizes the plugin architecture a bit so it isn't so
specific to collections.
- it never was anything more than a cached value of is_selinux_enabled()
and caching this fairly expensive result is no longer needed as
scriptlet execution wrt selinux contexts is now conditionalized on
RPMTRANS_FLAG_NOCONTEXTS instead
There are three times during a transaction when Collection actions can be
performed:
1) After the last time a member of a collection is either installed or removed
2) After the last time a member of a collection is installed only
3) Before the first time a member of a collection is removed only
This patch adds three lists to the rpmte structure to mark which transaction
elements fall into each of these groups, and the collections that caused that.
A new function is added to the TSM to scan through all the transaction elements
and update these lists. When a collection is added to one of these lists, it
signifies that when that transaction element is installed, the appropriate
action should be performed for that collection.
- psm in test-mode is a no-op anyway, so dont bother at all with it
- also removes the need to check for test mode on pre/posttrans scripts,
these are now fully covered by psm too
- Besides there not being much point in having a separate source + header
for a small single function, this fixes build on case-insensitive
systems such as Mac OS X.
- Move transaction lock path handling into rpmts.c, export new low
level rpmlockAcquire() function to actually grab a lock
- Rename rpmtsFreeLock() to rpmlockFree() and return NULL in the
general rpm style
- This mechanism has never been used by anything at all, which suggests
its not a particularly useful feature
- Removing unused rpmpsTrim() from rpmps
- Marking okProbs parameter of rpmtsRun() function as unused to avoid
unnecessary breakage
- Any problem found in transaction processing is caused, or at least
triggered by, some transaction element. Having the problems in
elements lets API users easily determine which package caused which
problem instead of having to parse problem strings in vain.
- No problem set stored in transaction set itself now, rpmtsProblems() API p
reserved by making it collect problems from our transaction elements
into a new set. The problem set fiddling in rpmtsRun() wrt %pretrans
and all is a bit crazy - always was, now its just more visible...
- Make rpmtsCheck() pass the associated transaction elements into
the lower level functions. rpmdsProblem() removed from API, it's
not particularly useful outside rpmtsCheck() internals.
- rpmts struct is now opaque within depends.c except for solve callback
- This breaks --badreloc, need to figure out something saner for the
problem filtering
- add internal rpmtsMembers() function to get the member structures
- the main rpmts struct is now opaque within order.c, and much closer
to being so for depends.c and transaction.c too
- no functional changes
- The psm structures aren't stored or passed around by any users,
so there's no need for them to separately allocate and free the
struct, bury this all inside rpmpsmRun() which takes care of
initialization, actual actions and freeing.
- There's also no need for refcounting now as allocations are completely
contained within the rpmpsmRun() blackbox. Lose psm-debug foo which
was only used for refcount debugging.
- No functional changes
- rpmfiFC() returns 0 if called with NULL, which is ok in these cases
- rpmfiInit() and rpmfiNext() behave correctly when passed NULL, no need
check separately
- "dn" is already referenced before checking for NULL... it really
cannot happen ;)
- Loose rpmpsmScriptStage() hack and bury the psm details inside
the psm implementation
- Map the script-only goal enums to the corresponding script tag
to avoid having to re-re-re-map stuff unnecessarily
- pretrans and posttrans should really be handled as a part of PKG_INSTALL
process, but as these stages are disconnected from the main install
part we can't remember the state in the psm - it would need to be
stashed into transaction elements in the meanwhile
- no functional changes - supposedly
- nothing outside the PSM should need to know anything about its
internals, the general goals need to be sufficient (not the case yet)
- define goals to match rpmteType so there's no need to re-re-re-map
the operations
- loose the big unused individual stage string switch
- handle failed element in rpmteOpen() already, avoiding need to check
everywhere else
- elements cancelled due to parent failure can further cancel their
dependent elements
- all failed, including skipped, elements are now logged