summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/remove.c
AgeCommit message (Collapse)AuthorFilesLines
2020-02-10build-aux/update-copyright 2019 2020Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2020-01-28Docs docs docsmorganamilo1-8/+0
libalpm: move docs from .c files into alpm.h And fix/expand some along the way. Signed-off-by: Allan McRae <allan@archlinux.org>
2019-10-23Update copyright yearsAllan McRae1-1/+1
make update-copyright OLD=2018 NEW=2019 Signed-off-by: Allan McRae <allan@archlinux.org>
2019-01-04Move skipping of duplicate sync/remove targets into libalpmMichael Straube1-1/+2
sync: As pointed out by Andrew Gregory there could be an error when adding duplicates if they are two separate packages with the same name. Add a check in alpm_add_pkg() to test whether the duplicate is actually the same package, and if so, log a debug message and return success to skip the package. If the duplicate is a different package return ALPM_ERR_TRANS_DUP_TARGET and treat that error just like any other error in pacman. remove: Change alpm_remove_pkg() to just log a debug message and return success to skip duplicates. Remove the handling of ALPM_ERR_TRANS_DUP_TARGET in pacman. Also fixes FS#49377. Suggested-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Michael Straube <michael.straube@posteo.de> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-14Remove all modelines from the projectEli Schwartz1-2/+0
Many of these are pointless (e.g. there is no need to explicitly turn on spellchecking and language dictionaries for the manpages by default). The only useful modelines are the ones enforcing the project coding standards for indentation style (and "maybe" filetype/syntax, but everything except the asciidoc manpages and makepkg.conf is already autodetected), and indent style can be applied more easily with .editorconfig Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-05-12Fix gcc8 warnings.Eli Schwartz1-4/+12
Attempting to compile pacman with gcc8 results in several warnings like: remove.c: In function ‘unlink_file.isra.4’: remove.c:407:34: warning: ‘.pacsave.’ directive output may be truncated writing 9 bytes into a region of size between 1 and 4096 [-Wformat-truncation=] Fix by adding checks to error out if snprintf tries to reserve a truncated filename. Because the return values are checked, gcc delegates the truncation response to our code instead of throwing warnings. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2018-03-14Update coyrights for 2018Allan McRae1-1/+1
make update-copyright OLD=2017 NEW=201 Signed-off-by: Allan McRae <allan@archlinux.org>
2017-04-17unlink_file: strip trailing slashesAndrew Gregory1-1/+12
If the user replaces a directory with a symlink, libalpm would get confused because the trailing slash causes system calls to resolve the symlink. This leads to errors and a misleading message during upgrades. Even though libalpm does not support this, it should not be giving misleading errors. Also adds an overflow check. Fixes FS#51377 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2017-01-04Update copyright yearsAllan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-09-03Fix memory leak in remove_notify_needed_optdependsAllan McRae1-0/+1
Also add pactest which captures this leak when run under valgrind. Reported-by: Sergey Petrenko Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26Use versions specified in optdependsAllan McRae1-1/+2
Checking install status and if a package is optionally required on removal now considers the version of the optdepend. Fixes FS#44957. Signed-off-by: Allan McRae <allan@archlinux.org>
2016-02-26Consider provides when warning about optdepnd removalAllan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2016-01-04Update copyright years for 2016Allan McRae1-1/+1
make update-copyright OLD=2015 NEW=2016 Signed-off-by: Allan McRae <allan@archlinux.org>
2015-11-11Use correct format specifiersRikard Falkeborn1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2015-07-14Do not warn about packages that optionally require a removal when ignoring depsAllan McRae1-1/+3
If a transaction is removing a package while ignoring all dependencies, there should not be any warning about other packages optionally requiring it. Signed-off-by: Allan McRae <allan@archlinux.org>
2015-03-03remove: use strcmp for files in skip_removeAndrew Gregory1-49/+33
Paths from noupgrade, the transaction skip_remove, and package backup lists were combined into a single list matched using fnmatch causing paths with glob characters to match unrelated files. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2015-02-01Update copyright notices for 2015Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2014-12-18remove.c: honor inverted patterns in noupgradeAndrew Gregory1-2/+2
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-08-03move _alpm_lstat into util-commonAndrew Gregory1-1/+1
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
2014-03-03Add events on pacnew/pacsave/pacorig file creationOlivier Brunel1-1/+6
ALPM still adds a warning to the log, but doesn't emit an event about said warning, instead using a specific event to let the frontend what happened/how to inform the user. Note that there are 2 cases for installing a .pacnew file, to not overwrite user changes and because file is in NoUpgrade. In the later case the warning was a bit different: it happened before and said "extracting" instead of "installed." Now both happen after and are phrased the same. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03restrict transaction package originsAndrew Gregory1-0/+2
This moves the "wrong args" error up from trans_commit to add_pkg when used with a local pkg and adds the error for remove_pkg when used with a sync pkg, which currently just removes the db entry. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-03-03Update the event callbackOlivier Brunel1-5/+20
Instead of using two void* arguments for all events, we now send one pointer to an alpm_event_t struct. This contains the type of event that was triggered. With this information, the pointer can then be typecasted to the event-specific struct in order to get additional arguments. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-02-04alpm: export *_free functionsAndrew Gregory1-3/+4
Front-ends should be able to free memory that alpm hands them. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28Remove ts and sw from vim modeline when noet is setFlorian Pritz1-1/+1
Forcing vim users to view files with a tabstop of 2 seems really unnecessary when noet is set. I find it much easier to read code with ts=4 and I dislike having to override the modeline by hand. Command run: find . -type f -exec sed -i '/vim.* noet/s# ts=2 sw=2##' {} + Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-28Rename ALPM_EVENT_OPTDEP_REQUIRED to _OPTDEP_REMOVALOlivier Brunel1-1/+1
Because this event is triggered when an optdepend for another package is being removed. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2014-01-06Update copyright years for 2014Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-12-19trans_prepare: always sort trans->remove by depsAndrew Gregory1-7/+0
Packages can be removed during a sync transaction either directly or due to conflicts and need to be sorted. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-11-15Fix whitespace and other formatting issuesJason St. John1-2/+2
This commit: -- replaces space-based indents with tabs per the coding standards -- removes extraneous whitespace (e.g. extra spaces between function args) -- adds missing braces for a one-line if statement Signed-off-by: Jason St. John <jstjohn@purdue.edu>
2013-11-15log important events from the backendAndrew Gregory1-0/+5
This ensures that important events will be logged and consistent regardless of the frontend. The need for global context in the event callback is also removed. The event is logged before any post_* scripts run, so this also moves the post_* script output underneath the event in the log. Fixes FS#36504 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31deps.c: pass alpm_list** to _alpm_recursedepsAndrew Gregory1-2/+2
Improves consistency and makes it clear that targs will be modified by _alpm_recursedeps. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-10-31sortbydeps: include local pkgs in dep graphAndrew Gregory1-1/+1
Detecting indirect dependencies by traversing a package's entire dependency tree is prohibitively slow for larger transactions. Instead add local packages to the dependency graph. This additionally requires delaying dependency ordering for sync operations so that removed packages may be excluded from dependency detection. tests/sync012.py was also updated to ensure that the dependency cycle was actually detected. Fixes FS#37380 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-07-05use full path when checking for mountpointsAndrew Gregory1-2/+13
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03unlink_file: treat symlinks like normal filesAndrew Gregory1-5/+1
We always want to work with the package file itself, not its target if it's a symlink. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03alpm_filelist: remove resolved_pathAndrew Gregory1-5/+0
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-14alpm/remove.c: add newlines to debug outputAndrew Gregory1-2/+2
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-03-07Do not resolve every local package filelist on removeAllan McRae1-1/+3
Although technically correct, this results in my system taking ~30 seconds to resolve all filelists when removing a package that has a directory not owned by any package. The check for if any package own the empty directory is a rare enough occurance, and it will be even rarer when that directory has a directory symlink in its path, so just revert this at this stage. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24use resolved_path for filelist_containsAndrew Gregory1-0/+3
alpm_filelist_contains was being used to search for resolved paths, but searching in the unresolved paths, causing it to miss matches. We always search unresolved paths and search the resolved paths if available because _alpm_filelist_resolve is not public and requires a context handle, so it can't be called from alpm_filelist_contains. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16libalpm: never attempt to remove a mountpointDave Reisner1-0/+40
Arch Linux typically runs into this with /sys when upgrading the filesystem package in build chroots, but LXC users might also run into this, since their /sys is shared from the host and must, for security reasons, be mounted RO. I've neglected to add any tests for this because they would require root in order to run. Current tests all pass with this patch and I've confirmed the desired behavior in a VM. Incidentally, the first hunk of this patch (skipping can_remove_file checks for directories) resolves the case of API mountpoints being removed since they eventually fall into unlink_file and fail with "contains files". However, this patch should still be the Right Thing To Do™, as we can't possibly remove a directory that is also a mountpoint. Signed-off-by: Dave Reisner <dreisner@archlinux.org> [Allan] Do not skip checking if directories can be removed. Instead test if directories are mountpoints in can_remove_file. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28add caller prefix to alpm_logactionAndrew Gregory1-4/+6
prefix defaults to "UNKOWN" if null or an empty string is provided. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Save backup files with extension .pacsave.nPang Yan Han1-0/+76
Teach pacman to save backup files with extension .pacsave.n, where n is a positive integer. The current backup file shall be saved as <name>.pacsave, while existing .pacsave.n files will be renamed to <name>.pacsave.n+1 Example: 1. You have subversion installed in your local repo. /etc/conf.d/svnserve is a file to be backed up. It contains local modifications 2. You remove subversion from your repo. /etc/conf.d/svnserve is backed up as /etc/conf.d/svnserve.pacsave 2. You install subversion again 3. You edit /etc/conf.d/svnserve 4. You remove subversion. The existing /etc/conf.d/svnserve.pacsave is renamed to /etc/conf.d/svnserve.pacsave.1 and /etc/conf.d/svnserve is backed up as /etc/conf.d/svnserve.pacsave Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Rebased from original email and adjusted for util-common usage. Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03Update copyright year for 2013Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Make alpm_pkg_find publicAllan McRae1-5/+5
This function is particularly useful, so make it public. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Notify of removed package required as optdependAllan McRae1-0/+29
When a package is being removed, provide a notification (via a callback) if any local package requires it as an optdepend. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-09-18Remove incorrect documentation for unlink_fileAllan McRae1-4/+0
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-08-02Move filelist functions into separate source fileDan McGee1-4/+4
We have a few of these and might as well gather them together. This also cleans up the code a bit by using an enum instead of integer values, as well as makes a "search for file in filelist" function public so frontends can do better than straight linear search of the filelists. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-21libalpm/remove.c - add doxygenAndrew Gregory1-3/+86
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23Merge branch 'maint'Dan McGee1-1/+1
Conflicts: lib/libalpm/diskspace.c src/pacman/util.h
2012-01-19Update copyright on changed files since beginning of yearDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-08Merge branch 'maint'Dan McGee1-1/+0
Conflicts: lib/libalpm/signing.c Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-05Remove useless logger messageDan McGee1-1/+0
We don't need two log messages back-to-back about the same thing here. Signed-off-by: Dan McGee <dan@archlinux.org>