summaryrefslogtreecommitdiff
path: root/lib/libalpm/add.c
Commit message (Collapse)AuthorAge
* add support for back end fnmatch'd optionsDave Reisner2011-11-13
| | | | | | | | | | | | | This is work originally provided by Sascha Kruse on FS#20360 with only minor adjustments to the implementation. It's been expanded to cover: NoUpgrade, NoExtract, IgnorePkg, IgnoreGroup. Adds tests ignore008, sync139, sync502, and sync503. Also satisfies FS#18988. Original-work-by: Sascha Kruse <knopwob@googlemail.com> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
* Add OPEN() and CLOSE() util macrosDan McGee2011-11-01
| | | | | | | These wrap the normal open() and close() low-level I/O calls and ensure EINTR is handled correctly. Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2011-11-01
|\
| * Introduce ALPM_BUFFER_SIZE constantDan McGee2011-10-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This takes the place of three previously used constants: ARCHIVE_DEFAULT_BYTES_PER_BLOCK, BUFFER_SIZE, and CPBUFSIZE. In libarchive 3.0, the first constant will be no more, so we can ensure we are forward-compatible by removing our usage of it now. The rest are unified for consistency. By default, we will use the value of BUFSIZ provided by <stdio.h>, which is 8192 on Linux. If that is undefined, a default value is provided. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Move infrequently used path variables off the stackDan McGee2011-10-12
| | | | | | | | | | | | | | | | | | These backup-related paths in package extraction are used on relatively few files during the install process, so bump them off the stack and into the heap. This removes the artificial PATH_MAX limitation on their length as well. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Extract a try_rename helper from extract_single_file()Dan McGee2011-10-12
| | | | | | | | | | | | | | This moves the repetitive (and highly unlikely) logging work to a single location. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Introduce alpm_time_t typeDan McGee2011-10-12
|/ | | | | | | | | | This will always be a 64-bit signed integer rather than the variable length time_t type. Dates beyond 2038 should be fully supported in the library; the frontend still lags behind because 32-bit platforms provide no localtime64() or equivalent function to convert from an epoch value to a broken down time structure. Signed-off-by: Dan McGee <dan@archlinux.org>
* 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>
* Remove noisy debug loggerDan McGee2011-09-21
| | | | | | | | This one can be overwhelming when reading debug output from a very large package. We already have the output of each extracted file so we probably can do without this in 99.9% of cases. Signed-off-by: Dan McGee <dan@archlinux.org>
* Use more efficient way of restoring working directoryDan McGee2011-09-19
| | | | | | | | | | | | Rather than using a string-based path, we can restore the working directory via a file descriptor and use of fchdir(). From the getcwd manpage: Opening the current directory (".") and calling fchdir(2) to return is usually a faster and more reliable alternative when sufficiently many file descriptors are available. 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>
* 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>
* 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>
* Prefix alpm_pkgreason_t members with ALPMAllan McRae2011-07-02
| | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* Make local_db_read() private to the local backendDan McGee2011-06-30
| | | | | | | | | | | | | | | | | | | There is little need to expose the guts of this function even within the library. Make it static in be_local.c, and clean up a few other things since we know exactly where it is being called from: * Remove unnecessary origin checks in _cache_get_*() methods- if you are calling a cache method your package type will be correct. * Remove sanity checks within local_db_read() itself- packages will always have a name and version if they get this far, and the package object will never be NULL either. The one case calling this from outside the backend was in add.c, where we forced a full load of a package before we duplicated it. Move this concern elsewhere and have pkg_dup() always force a full package load via a new force_load() function on the operations callback struct. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix a few warnings pointed out via clang scan-buildDan McGee2011-06-30
| | | | | | | | | Some of these are legit (the backup hash NULL checks), while others are either extemely unlikely or just impossible for the static code analysis to prove, but are worth adding anyway because they have little overhead. 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 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>
* 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>
* 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 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>
* commit_single_pkg(): Use handle object directlyDan McGee2011-06-09
| | | | | | | | Commit e68f5d9a3067141 did something a bit silly and changed the scriptlet calls to use 'newpkg->handle' rather than the 'handle' argument passed in. Use the handle directly. 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>
* Merge branch 'maint'Dan McGee2011-06-07
|\ | | | | | | | | Conflicts: lib/libalpm/add.c
| * Remove incorrect output when downloading onlyAllan McRae2011-06-07
| | | | | | | | | | | | | | | | | | | | | | | | | | When only downloading a package, pacman can produce some incorrect output. > pacman -Sddw nvidia-utils warning: nvidia-utils-270.41.19-1 is up to date -- reinstalling This line is now now silenced when using -Sw. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove global handle dependencies from sync/upgrade pathsDan McGee2011-06-03
| | | | | | | | | | | | | | | | | | This kills a lot more global handle business off. sync.c still requires the handle declaration for one reference that can't be changed yet; it will be removed in a future patch which isolates all of the necesary API changes. 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>
* | cleanup: add_pkg() and remove_pkg()Dan McGee2011-04-22
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | alpm.h: add/improve function documentationRémy Oudompheng2011-04-21
| | | | | | | | Signed-off-by: Rémy Oudompheng <remy@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>
* | Style change: return(x) --> return xDan McGee2011-03-20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>