summaryrefslogtreecommitdiff
path: root/lib/libalpm/remove.c
Commit message (Collapse)AuthorAge
* Revamp scriptlet path formation for scriptlets in local databaseDan McGee2011-09-30
| | | | | | | | | Expose the current static get_pkgpath() function internally to the rest of the library as _alpm_local_db_pkgpath(). This allows use of this convenience function in add.c and remove.c when forming the path to the scriptlet location. Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor _alpm_runscriptlet()Dan McGee2011-09-30
| | | | | | | | | | Add an is_archive parameter to reduce the amount of black magic going on. Rework to use fewer PATH_MAX sized local variables, and simplify some of the logic where appropriate in both this function and in the callers where duplicate calls can be replaced by some conditional parameter code. Signed-off-by: Dan McGee <dan@archlinux.org>
* Move pacsave path construction code off the stackDan McGee2011-09-28
| | | | | | | This is definitely not in the normal hot path, so we can afford to do some temporary heap allocation here. Signed-off-by: Dan McGee <dan@archlinux.org>
* Be smarter about running ldconfig during removal transactionsDan McGee2011-09-19
| | | | | | | | | | 1. Don't run it if something failed in package removal- this mirrors what we already do in sync transactions. 2. Don't run it if we are invoking it for the replaces removal bit of a sync transaction- it doesn't make sense to run ldconfig halfway through a sync install; we should only run it once at the end. Signed-off-by: Dan McGee <dan@archlinux.org>
* Search for non-prefixed paths in skip_remove listDan McGee2011-09-19
| | | | | | | We add them to this list with the root path not appended; we should be searching for them this way as well. Signed-off-by: Dan McGee <dan@archlinux.org>
* Former transaction callback rename refactorDan McGee2011-09-02
| | | | | | | | | | | | | Put all the callback stuff in alpm.h in one spot, and make the following renames for clarity with the new structure: ALPM_TRANS_EVT_* --> ALPM_EVENT_* ALPM_TRANS_CONV_* --> ALPM_QUESTION_* ALPM_TRANS_PROGRESS_* --> ALPM_PROGRESS_* alpm_option_get_convcb() --> alpm_option_get_questioncb() alpm_option_set_convcb() --> alpm_option_set_questioncb() Signed-off-by: Dan McGee <dan@archlinux.org>
* Move all callbacks up to the handle levelDan McGee2011-09-02
| | | | | | | | | This was just disgusting before, unnecessary to limit these to only usage in a transaction. Still a lot of more room for cleanup but we'll start by attaching them to the handle rather than the transaction we may or may not even want to use these callbacks. Signed-off-by: Dan McGee <dan@archlinux.org>
* Be more robust when copying package dataDan McGee2011-08-19
| | | | | | | | | | | | | | | | This changes the signature of _alpm_pkg_dup() to return an integer error code and provide the new package in a passed pointer argument. All callers are now more robust with checking the return value of this function to ensure a fatal error did not occur. We allow load failures to proceed as otherwise we have a chicken and egg problem- if a 'desc' local database entry is missing, the best way of restoring said file is `pacman -Sf --dbonly packagename`. This patch fixes a segfault that was occurring in this case. Fixes the segfault reported in FS#25667. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove use of no-op accessor functions in libraryDan McGee2011-08-18
| | | | | | | | | The functions alpm_db_get_name(), alpm_pkg_get_name(), and alpm_pkg_get_version() are not necessary at all, so remove the calling and indirection when used in the backend, which makes things slightly more efficient and reduces code size. Signed-off-by: Dan McGee <dan@archlinux.org>
* Dependency code style cleanupsDan McGee2011-08-11
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Check return value of rename() callsDan McGee2011-08-08
| | | | | | | | | We did a good job checking this in add.c, but not necessarily anywhere else. Fix this up by adding checks into dload.c, remove.c, and conf.c in the frontend. Also add loggers where appropriate and make the message syntax more consistent. Signed-off-by: Dan McGee <dan@archlinux.org>
* Convert package filelists to an array instead of linked listDan McGee2011-07-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This accomplishes quite a few things with one rather invasive change. 1. Iteration is much more performant, due to a reduction in pointer chasing and linear item access. 2. Data structures are smaller- we no longer have the overhead of the linked list as the file struts are now laid out consecutively in memory. 3. Memory allocation has been massively reworked. Before, we would allocate three different pieces of memory per file item- the list struct, the file struct, and the copied filename. What this resulted in was massive fragmentation of memory when loading filelists since the memory allocator had to leave holes all over the place. The new situation here now removes the need for any list item allocation; allocates the file structs in contiguous memory (and reallocs as necessary), leaving only the strings as individually allocated. Tests using valgrind (massif) show some pretty significant memory reductions on the worst case `pacman -Ql > /dev/null` (366387 files on my machine): Before: Peak heap: 54,416,024 B Useful heap: 36,840,692 B Extra heap: 17,575,332 B After: Peak heap: 38,004,352 B Useful heap: 28,101,347 B Extra heap: 9,903,005 B Several small helper methods have been introduced, including a list to array conversion helper as well as a filelist merge sort that works directly on arrays. Signed-off-by: Dan McGee <dan@archlinux.org>
* replace access() calls for debug info where applicableFlorian Pritz2011-07-18
| | | | | Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Dan McGee <dan@archlinux.org>
* Handle removal of empty directories properlyDan McGee2011-07-18
| | | | | | | | | | | | | | | | | | | | This addresses FS#25141. We shouldn't remove every empty directory we come across during the removal process unless it is truly not known to any other package. This will prevent removal of essential directories such as '/var/lock/'. This is accomplished by first checking the empty/non-empty status of a directory, which was previously done implicitly by calling rmdir() and ignoring errors. We do this to avoid the next (new) check in most cases, which is to look at all local packages to see if the to-be-removed directory is present in another packages' filelist. If we do not find it anywhere, then we remove it, else we keep the file around. The pactest has been updated to test more cases, as well as finding a flaw in the original expected to fail case- we need separate DIR and FILE based EXIST rules. Signed-off-by: Dan McGee <dan@archlinux.org>
* Allow fileconflict if unowned file moving into backup arrayDan McGee2011-07-14
| | | | | | | | | | | The bulk of this commit is adding new tests to ensure the new behavior works without disrupting old behavior. This is a relatively sane maneuver when a package adds a conf file (e.g. '/etc/mercurial/hgrc') that was not previously in the package, but it is placed in the backup array. In essence, we can treat the existing file as having always been a part of the package and do our normal compare/install as pacnew logic checks. Signed-off-by: Dan McGee <dan@archlinux.org>
* Unify package removal codeDan McGee2011-07-06
| | | | | | | | | | | | | | This code duplication has always been a rather clumsy casuality of fixing some past upgrade issues. Unify the removal code across upgrade and remove operations into a new _alpm_remove_single_package() method wihch makes it very clear how we handle upgrade and remove differently, via several conditionals on newpkg. This commit highlights interesting behavior such as the fact that the implicit removal in every package upgrade never gets transaction events or progress callbacks. Signed-off-by: Dan McGee <dan@archlinux.org>
* Simplify alpm_list_previousAllan McRae2011-07-05
| | | | | | | | | | We can readily detect the first node in a list by checking if node->prev->next is NULL. So there is no need to pass the head of the list to this function and its prototype now looks like all the other item accessors. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge remote-tracking branch 'allan/ALPM'Dan McGee2011-07-03
|\ | | | | | | | | | | | | | | | | | | Conflicts: lib/libalpm/be_local.c lib/libalpm/be_package.c lib/libalpm/conflict.c lib/libalpm/diskspace.c lib/libalpm/dload.c lib/libalpm/remove.c
| * Prefix _alpm_errno_t members with ALPMAllan McRae2011-07-02
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
| * Prefix alpm_transprog_t members with ALPMAllan McRae2011-07-02
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
| * Prefix alpm_transevt_t members with ALPMAllan McRae2011-07-02
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
| * Prefix alpm_transflag_t members with ALPMAllan McRae2011-07-02
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
| * Prefix alpm_loglevel_t members with ALPMAllan McRae2011-07-02
| | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* | Move alpm filelists to a struct objectDan McGee2011-07-03
| | | | | | | | | | | | | | | | This allows us to capture size and mode data when building filelists from package files. Future patches will take advantage of this newly available information, and frontends can use it as well. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Do not replicate files list when removing packagesAllan McRae2011-07-03
|/ | | | | | | | This saves replicating the potentially large list of files in a package that is being removed. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Rename pmbackup_t to alpm_backup_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Rename pmdepmissing_t to alpm_depmissing_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Rename pmtrans_t to alpm_trans_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Rename pmpkg_t to alpm_pkg_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Rename pmdb_t to alpm_db_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Rename pmhandle_t to alpm_handle_tAllan McRae2011-06-28
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Remove two alpm_list_count usagesAllan McRae2011-06-27
| | | | | | | | We have just looped through the list of files, so might as well get the count as we go. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Convert backup list to new pmbackup_t typeDan McGee2011-06-22
| | | | | | | | This allows us to separate the name and hash elements in one place and not scatter different parsing code all over the place, including both the frontend and backend. Signed-off-by: Dan McGee <dan@archlinux.org>
* Ensure handle is valid and pm_errno is reset when calling into APIDan McGee2011-06-14
| | | | | | | | | | | | | | | | | We didn't do due diligence before and ensure prior pm_errno values weren't influencing what happened in further ALPM calls. I observed one case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that flag persisting the entire time we were calling library code. Add a new CHECK_HANDLE() macro that does two things: 1) ensures the handle variable passed to it is non-NULL and 2) clears any existing pm_errno flag set on the handle. This macro can replace many places we used the ASSERT(handle != NULL, ...) pattern before. Several other other places only need a simple 'set to zero' of the pm_errno field. Signed-off-by: Dan McGee <dan@archlinux.org>
* Conflict check and skip_remove code cleanupsDan McGee2011-06-14
| | | | | | | | | | * Move several variables into better scope * const-ify a few variables * Avoid duplicating filelists if it is unnecessary * Better handling out out of memory condition when adding file conflicts to our list Signed-off-by: Dan McGee <dan@archlinux.org>
* Switch all logging to use handle directlyDan McGee2011-06-13
| | | | | | | This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
* Move pm_errno onto the handleDan McGee2011-06-13
| | | | | | This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add handle argument to two more alpm methodsDan McGee2011-06-13
| | | | | | This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier(). Signed-off-by: Dan McGee <dan@archlinux.org>
* Add handle argument to alpm_(add|remove)_pkg()Dan McGee2011-06-13
| | | | | | | | This makes these functions consistent with the rest of the transaction related API calls. We do an additional assert to ensure the handle attached to the package is the same as the handle passed in. Signed-off-by: Dan McGee <dan@archlinux.org>
* Require handle argument to alpm_logaction()Dan McGee2011-06-09
| | | | | | | This is the first in a series of patches to update the API to remove the implicit global handle variable. Signed-off-by: Dan McGee <dan@archlinux.org>
* Kill all remaining 'PATH_MAX + 1' usagesDan McGee2011-06-09
| | | | | | | | | The few remaining instances were utilized for buffers in calls to snprintf() and realpath(). Both of these functions will always ensure the returned value is padded with '\0', so there is no need for the extra byte. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove global handle from remove.cDan McGee2011-06-03
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove global handle from util.cDan McGee2011-06-03
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Push down extern handle variable to files that need itDan McGee2011-06-03
| | | | | | | This will make the patching process less invasive as we start to remove this variable from all source files. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove ALPM_LOG_FUNC macroDan McGee2011-06-03
| | | | | | | | | The usefulness of this is rather limited due to it not being compiled into production builds. When you do choose to see the output, it is often overwhelming and not helpful. The best bet is to use a debugger and/or well-placed fprintf() statements. Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2011-05-19
|\ | | | | | | | | | | Conflicts: lib/libalpm/trans.c src/pacman/query.c
| * Fix segfault when uninstalling broken backed-up symlinkDan McGee2011-05-16
| | | | | | | | | | | | | | | | | | Issue FS#24230. If a symlink is broken and included in the removal process of a package, we blew up and segfaulted due to alpm_compute_md5sum() returning NULL and then performing a strcmp() operation. Signed-off-by: Dan McGee <dan@archlinux.org>
* | cleanup: add_pkg() and remove_pkg()Dan McGee2011-04-22
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Header inclusion cleanupDan McGee2011-04-20
| | | | | | | | | | | | | | | | This does touch a lot of things, and hopefully doesn't break things on other platforms, but allows us to also clean up a bunch of crud that no longer needs to be there. Signed-off-by: Dan McGee <dan@archlinux.org>
* | syntax: if/while statements should have no trailing spaceDan McGee2011-04-20
| | | | | | | | | | | | | | | | | | | | | | This is the standard, and we have had a few of these introduced lately that should not be here. Done with: find -name '*.c' | xargs sed -i -e 's#if (#if(#g' find -name '*.c' | xargs sed -i -e 's#while (#while(#g' Signed-off-by: Dan McGee <dan@archlinux.org>