summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
Commit message (Collapse)AuthorAge
* libalpm: clean up of md5sum functions.Chantry Xavier2008-02-27
| | | | | | | | | test_delta_md5sum and test_pkg_md5sum were simple wrappers to test_md5sum, and only used once, so not very useful. I removed them. Also, test_md5sum and alpm_pkg_checkmd5sum functions were a bit duplicated, so I refactored them with a new _alpm_test_md5sum function in libalpm/util.c Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* FS#9183 : force correct permissions on tmp/.Jaroslaw Swierczynski2008-01-13
| | | | | | | [Xav: removed unneeded makepath_internal function, and fixed the permission value : 1777 -> 01777] Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Ensure correct dir permissions in the database.Chantry Xavier2008-01-13
| | | | | | | | | | | | Fix for FS#9176. A previous commit (6e8daa553bbd5) already forced all database files to 644. Now the directories are also forced to 755. Additionally, repo-add now sets the umask to 022, just like makepkg does, to fix the problem at its root. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* util.c : fix segfault when the cachedir isn't usable.Chantry Xavier2008-01-13
| | | | | | | | | | | | For example, if the cachedir is a broken symlink or a non writable directory, pacman fallbacks to /tmp/. Just before doing that, it freed the handle->cachedirs list twice ! once in _alpm_filecache_setup, and once in alpm_option_set_cachedirs. So the first one was removed. Fixes FS#9186. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Don't stat cachedir immediatelyDan McGee2008-01-05
| | | | | | | | | | | | By attempting to stat the cachedir when we load the pacman config, pacman bails out if it is a non-existant directory, even if it will never be needed. This is unfortunate as it is only used for sync transactions anyway. Instead, wait until we need it in _alpm_filecache_setup to actually do anything. Reported as FS#9096. Signed-off-by: Dan McGee <dan@archlinux.org>
* Update GNU GPL boilerplate and copyright datesDan McGee2007-12-10
| | | | | | | Update the GPL boilerplate to direct people to the GNU website for a copy of the license, as well as bump all of Judd's copyrights to 2007. Signed-off-by: Dan McGee <dan@archlinux.org>
* _alpm_unpack: return 1 when the file is not found.Chantry Xavier2007-12-08
| | | | | | | | If _alpm_unpack has a specific file to extract (not NULL), but doesn't find it, it'll now return 1, for indicating the failure. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Force mode of all database files to 644Aaron Griffin2007-11-25
| | | | | | | | | | In the case of a packaging error where install or changelog had bad permissions, pacman respected the original permissions without trying to fix it - this means that some operations (changelog) artificially required root permissions to run In addition, minor function housekeeping on _alpm_unpack Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
* War on whitespaceDan McGee2007-11-16
| | | | | | Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm: simplify sync db lastupdateDan McGee2007-11-16
| | | | | | | | | | | Legacy code is hitting the trash here. Remove unnecessary _alpm_time2string time storage abstraction in favor of just writing the time_t value to the disk. The only drawback is that everyone's sync DBs will have to be updated at least once so that the lastupdate values are stored right. :) Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm: fix lstat wrapper to actually use newpathDan McGee2007-11-11
| | | | | | | | Commit b55abdce7aebb142ce79da3aa3645afe7693a3c4 introduced an lstat wrapper function that never dereferences paths with a trailing slash, but still called lstat on path instead of newpath. Oops! Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove the newline automatically added by alpm_logaction.Chantry Xavier2007-11-04
| | | | | | This way, _alpm_logaction behaves like _alpm_log, and gives more control. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* libalpm: use an lstat wrapper so we never dereference dir symlinksDan McGee2007-11-04
| | | | | | | | Linux lstat follows POSIX standards and dereferences a symlink pointing to a directory if there is a trailing slash. For purposes of libalpm, we don't want this so make a lstat wrapper that suppresses this behavior. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix invalid static scoping of strverscmpDan McGee2007-10-22
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* alpm: removed unused strtoupper wrapper, remove installeddate on parse_descfileDan McGee2007-09-23
| | | | | | | installdate should never be present in a package descfile, so get rid of it. With the last commit, we also don't need the util strtoupper function. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm: add newlines to all strings passed to log callbackDan McGee2007-08-23
| | | | | | | | | This allows us to remove the hack in the frontend where we added a newline to everything coming out of the pm_printf functions, and instead let the developer put newlines where they want them. This should be the last hangover of that auto-newline stuff. Signed-off-by: Dan McGee <dan@archlinux.org>
* Post trial install changes, round oneDan McGee2007-08-21
| | | | | | | | | | | | | | A bunch of changes related to my first "real" install of pacman-git into /usr/local and trying to use it. * Shift some uses of free -> FREE in libalpm. * Move stat and sanity checks of config paths into libalpm from the config and argument parsing in pacman.c. * Fix issue where dbpath still was not defined early enough due to its requirement for being used in alpm_db_register. This should be rewritten so it doesn't have this dependency, but this will work for now. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix for FS 6404 and functionalize some cachedir handling stuffDan McGee2007-08-20
| | | | | | | | | In order to best resolve bug 6404, move some cachedir handling stuff out of sync.c and into util.c and create two new functions: filecache_find and filecache_setup. sync.c was rewritten to use these, and alpm_fetch_pkgurl now also uses these routines. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add const qualifier to md5_file and alpm_get_md5sumDan McGee2007-08-20
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Clean up MD5 code.Andrew Fyfe2007-08-16
| | | | | | | | | | | | | | * Move alpm md5 functions to lib/libalpm/util.c * Remove unneeded includes for md5.h * Replace md5 implementation with one from http://www.xyssl.org Dan: clean up XySSL code by removing parts we don't use, and add a note saying what changed. Dan: fix alpm_get_md5sum, off by one error on the malloc call and other small things. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> Signed-off-by: Dan McGee <dan@archlinux.org>
* package.h: implement origin_data union in pmpkg_t structDan McGee2007-08-14
| | | | | | | | | | We were using a void *data element in pmpkg_t before, which is unsafe by its nature of being untyped. Reimplement data as origin_data being a union that can hold either a path to a package file or a pointer to a cache database, and make the other necesary updates in the code to reflect this. See package.h for details. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove versioncmp.{c,h}, clean up selective #ifdefsDan McGee2007-07-12
| | | | | | | | | Remove versioncmp.c by moving all functions to locations that make sense. Move replacement functions (for building without glibc) into util.c where they belong, and do proper checks for them instead of using __sun__, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove gettext calls from all PM_LOG_DEBUG messagesDan McGee2007-07-10
| | | | | | | There is no real reason to burden our translators with these messages, as anyone helping to debug these will probably want them in English. Signed-off-by: Dan McGee <dan@archlinux.org>
* Various small fixes as suggested by some static code checkersDan McGee2007-07-06
| | | | | | | I ran flawfinder and sparse over the pacman source code and found a few things that were worth fixing (and were quick fixes). Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm/add.c,util.c : log ARCHIVE_WARN warning to debug output.Chantry Xavier2007-07-01
| | | | Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* libalpm/util.c : stat returns 0 on successChantry Xavier2007-06-28
| | | | Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Remove lockfile configuration from frontend, make it job of libalpmDan McGee2007-06-27
| | | | | | | | | | | | I previously introduced some patches to make just about every path in pacman/libalpm configurable; doing this with the lockfile seemed a bit too far and we really should just place the lockfile where it belongs- with the DB that needs locking. More details in this thread: http://archlinux.org/pipermail/pacman-dev/2007-June/008499.html Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix wrong permissions on pacnew extractionDan McGee2007-06-27
| | | | | | | | | | | First reported here: http://bbs.archlinux.org/viewtopic.php?pid=261861 Newly created files were done with the standard umask, so those that are extracted seperately and copied to a .pacnew extension will have the wrong permissions. This should hopefully fix this. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm/util.c: remove unnecessary includeDan McGee2007-06-20
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove logmask stuff from backend; switch logging callback to new pm_printfDan McGee2007-06-09
| | | | | | | | | | Remove the logmask functionality from the backend as it has been moved to the frontend, and change the logging callback function to use pm_printf. In addition, make much better use of va_list- use the args list instead of a arbitrarily chosen string to print to in the logging functions. Signed-off-by: Dan McGee <dan@archlinux.org>
* Move DB and cache dirs away from there dependence on ROOTDIRDan McGee2007-05-31
| | | | | | | | | | | | | | | | | | | This change allows us to use all autoconf specified paths, most notably $(localstatedir). It is quite a change and touches a lot of files, as all references to the DB and cache were done with the ROOTDIR as a prefix. * add --lock command-line option to pacman to specify the location of the lockfile (this can now be specified at configure time by setting the $localstatedir path). * Rip quite a few settings out of configure.ac as they are now picked by setting the paths during configure or make. * Fix bug with /tmp fallback for sync downloads not working correctly (related to root location, now the system tmp dir is used). * Simplified the parameters to some libalpm functions, and added get/set for the new lockfile option. * Renamed several of the DEFS to names without the PM_ prefix. Signed-off-by: Dan McGee <dan@archlinux.org>
* Allow $repo expansion in 'Server' config linesAaron Griffin2007-05-18
| | | | | | | | | | | | | Small change (addition of a 'strreplace' function) which replaces any $repo tokens found in a server line with the name of the repo or section being processed. While this is more simplistic than suggestions on flyspray, it works and I think it is cleaner. Merits can be discussed further. Ref: FS#6389 Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
* Remove unnecessary casts on malloc and elsewhereDan McGee2007-05-14
| | | | | | | | | We had many unnecessary casts, most of them dealing with malloc and other memory allocations. The variable type should take care of it; no need to do it explicitly. In addition, I caught a const error while removing the casts. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm util.c and util.h cleanupDan McGee2007-04-29
| | | | | | | | | | * Remove some unnecessary conditional compiling in util.h- move the functions tha required it to trans.c (along with a bunch of new header includes). * Clean up util.h a bit- remove some header includes, remove universal libarchive include and only put it in the files that need it. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove STRNCPY macro from libalpmDan McGee2007-04-29
| | | | | | | Replaced calls to the STRNCPY macro with the actual strncpy function, and pacman passes all pactests. Signed-off-by: Dan McGee <dan@archlinux.org>
* Clean up gettext on the libalpm sideDan McGee2007-04-26
| | | | | | | Remove inclusion of libintl.h from all files, because we can do it once in util.c where the _() macro is defined. Signed-off-by: Dan McGee <dan@archlinux.org>
* Report an error on setmntent failureAaron Griffin2007-03-29
| | | | Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
* * Correct install scriptlet usage (reuse of handle->root when not needed)Aaron Griffin2007-03-22
| | | | | * Skip running scriptlet when chroot fails - to prevent issues in the host filesystem
* Nagy Gabor <ngaba@petra.hos.u-szeged.hu>Aaron Griffin2007-03-19
| | | | * correct _alpm_rmrf usage with regard to symlinks and directories
* This commit looks much more monumental than it is. Almost all just #includeDan McGee2007-03-05
| | | | | | | | reordering and adding ones that were forgotten (noticed when trying to compile after reordering). * Updated the HACKING file to include information on #include usage. * print -> vprint in "making dir" function in pactest.
* * Fixed a whole mess of extra '/' pathing issues when a different root isAaron Griffin2007-03-04
| | | | | | | | | | | | | | specified * Use db->path when appropriate * Commented out the FAKEROOT checks in libalpm. This should never ever be done. TODO test this quite a bit, as this will never cause the transactions to fail if RW operations are requested... right now it is totally up to the front end to decide when to fail * Use realpath() to canonicalize the root path when specified, so _alpm_makepath() doesn't freak out * Fixed some output/indent of MDFile and SHAFile algorithms * More efficient sprintf() usage in MDFile/SHAFile * Added real error output to _alpm_makepath
* Big commit this time:Aaron Griffin2007-03-03
| | | | | | | | | | | | | | | | | | | | | | | * Moved entirely to alpm_pkg_get_* accessors, to read data on demand * Mostly removed the INFRQ_ parameters from outside the be_files backend (making the backend more extensible in the long run) * packages created from _alpm_db_scan now have the db and origin set (making accessors actually work for these packages) * removed _alpm_db_ensure_pkgcache * totally revamped the _alpm_checkconflicts function, making it cleaner and easier to read (and thus fix in the long run) - maintainable code ftw NOTE: feel free to rename the functions... I couldn't think of anything better * removed an extra loop in sync.c:find_replacements - no sense in looping over an entire DB while strcmp'ing the name, when we have get_pkgfromcache Other: * package struct "license" -> "licenses" * Created _alpm_sync_find (duplicate code in some places, find_pkginsync * Minor const correctness changes along the way * fixed a couple extra '/' pathing issues (non-issues really) * removed a duplicate pkg_cmp function
* * strlen -> mbstowcs (multibyte str to wide char str) conversion where weDan McGee2007-02-14
| | | | | want the actual number of characters, not the number of bytes. * Added a TODO to take care of later in scriptlet processing.
* * Refactored conflict checking within packages. Profiling from Dan showed anAaron Griffin2007-02-13
| | | | | | | | unbelievable amount of strcmp() calls (25 million) due to the list searching. This has been reimplemented with a set-intersection scheme, due to the fact that file lists are always ordered. - NEEDS TESTING * Minor clean up, "globalized" the str_cmp helper to match the alpm comparison signature, so we can use it elsewhere.
* Debug logging changes:Aaron Griffin2007-01-31
| | | | | | | | | | | | | | | | * The --debug params were goofy. New setup allows --debug without params, --debug=<level> where level 1=debug output, 2=debug and download output, 3=debug, download, and function tracing output. This seems more sane to me. * Removed PM_LOG_FLOW1 and PM_LOG_FLOW2. They were just confusing. When adding new functions, it is near impossible to determin if your output should be "flow1" or "flow2" without tracking all the way up the call chain. Rarely would one ever say "ok, lets just show "flow2" output. These have both been replaced with PM_LOG_DEBUG * Removed the need for the root parameter on alpm_initialize. it is now defaulted to PM_ROOT just like dbpath and cachedir. This allows alpm to be initialized BEFORE option parsing in the front end, saving us some duplicate variables in the frontend. * Cleaned up front end variables due to early alpm_initialize call.
* K. Piche <kevin.piche@cgi.com>Aaron Griffin2007-01-30
| | | | * ALPM_LOG_FUNCTION macro and all the great work to add this macro everywhere
* * Remove -fno-strict-aliasing as it is now unnecessary to compile.Dan McGee2007-01-30
| | | | | | * Fix up add.c a bit better than it was in regards to FS #3492. * Optimized the sqrt call in dependency cycle checking to a single call. * Removal of an outdated comment.
* * Fix FS #3107- Use ISO date styleAaron Griffin2007-01-26
| | | | | | * Fix FS #5409- document that pacman.conf repo ordering is important Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* This mainly deals with code clarity- removing currently unneededAaron Griffin2007-01-24
| | | | | | | | | | optimizations in order to make the code much more readable and type-checkable. Every enum in the library now has it's own type that should be used instead of the generic 'unsigned char'. In addition, several #define statements dealing with constants were converted to enums. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
* Preliminary checkin for alpm_list conversionAaron Griffin2007-01-19
| | | | | | | | | * renamed pmlist_t -> alpm_list_t * made alpm_list_t a public type (alpm_list.h header) * removed additional storage for registered DBs in pacman source * some code cleanup * removed duplicate (pm)list_display functions from pacman source * misc code cleanup