summaryrefslogtreecommitdiff
path: root/src/pacman/conf.c
AgeCommit message (Collapse)Author
2012-07-10pacman: be more descriptive when opening an include failsDave Reisner
if fopen returns NULL, append the libc strerror-ized error message to our own error message. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-12Remove SyncFirst optionDan McGee
This has outlived its usefulness and causes more problems than it solves. It has historically only ever been used to install pacman first. That should not be needed given we provide the vercmp utility (which has no library dependencies) and so calling pacman in install scripts is a sign of poor packaging. Work-duplicated-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-08Various tweaks to support building with excessive GCC warning flagsDan McGee
This fixes a bunch of small issues in order to enable a clean successful build with a crazy number of GCC warning flags. A lot of these changes are covered by -Wshadow, -Wformat-security, and -Wstrict-overflow=5. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-20Update copyright yearsAllan McRae
Add 2012 to the copyright range for all libalpm and pacman source files. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06ALPM API adjustments for sanity and consistencyDan McGee
This makes several small adjustments to our exposed method names, and in one case, parameters. The justification here is to make methods less odd in their naming convention. If a method takes an alpm_db_t argument, the method should be named 'alpm_db_*', but perhaps more importantly, if it doesn't take a database as the first parameter, it should not. Summary of changes: alpm_db_register_sync -> alpm_register_syncdb alpm_db_unregister_all -> alpm_unregister_all_syncdbs alpm_option_get_localdb -> aplpm_get_localdb alpm_option_get_syncdbs -> aplpm_get_syncdbs alpm_db_readgroup -> alpm_db_get_group alpm_db_set_pkgreason -> alpm_pkg_set_reason All methods keep the same argument list except for alpm_pkg_set_reason; there we drop the 'handle' argument as it can be retrieved from the passed in package object. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18Allow UseDelta option to specify a delta ratioDan McGee
Rework the frontend and backend to allow passing a ratio value in for UseDelta rather than having a hardcoded #define-d 0.7 value always used. This is useful for those with fast connections, who would likely benefit from tuning this ratio to lower values; it is also useful for general testing purposes. The libalpm API changes for this, but we do support the old config file format with a no-value 'UseDelta' option; in this case we simply use the old default of 0.7. We clamp the ratio values to a sane range between 0.0 and 2.0, allowing ratios above 1.0 for testing purposes. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23Convert strtrim/strlen paired calls to only strtrimDan McGee
This utilizes the new return value so we don't have to find the length of the string again. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23Merge branch 'maint'Dan McGee
2011-12-23Allow comments after repo section header in pacman.confAllan McRae
Pacman assumes that the final character of a line specifing a repo in pacman.conf is a "]". But it did not clean whitespace from the line after removing any comments. So lines like: [allanbrokeit] # could break system caused pacman not to recognize the repo. Adjust config parsing to strip comments before trimming whitespace from the end of the string. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21include config.h via MakefilesDave Reisner
Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12code syntax cleanupDave Reisner
As per HACKING file, we use 'CTRL(' rather than 'CTRL (' Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-14create a typedef for enum _alpm_errno_tJonathan Conder
This is consistent with the other enums and structs, and should be slightly more readable. Signed-off-by: Jonathan Conder <jonno.conder@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Add OPEN() and CLOSE() util macrosDan McGee
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>
2011-10-21Merge branch 'maint'Dan McGee
Conflicts: src/pacman/package.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21Remove pm_fprintf() in favor of pm_printf()Dan McGee
Now that pm_printf() always prints to stderr, we don't need this second function that was always used with stderr as the first argument. Thus, this patch removes the function and makes the following sed replacement: sed -i -e 's#pm_fprintf(stderr, #pm_printf(#g' src/pacman/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Remove alpm_list_getdata wrapper functionDan McGee
This one is pretty darn useless. Just derefence the ->data attribute since the type is public anyway and save yourself the function call. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Keep track of explicitly added and removed packagesDan McGee
This allows us to sort the output list by showing all pulled dependencies first, followed by the explicitly specified targets. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22config parsing: add note if libcurl disabled and no XferCommandDan McGee
Just a helpful warning for those users in this unenviable position. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22config parsing: include file and line number in more errorsDan McGee
Before: $ pacman -Si pacman error: invalid value for 'SigLevel' : 'FooValue' After: $ ./src/pacman/pacman -Si pacman error: config file /etc/pacman.conf, line 88: invalid value for 'SigLevel' : 'FooValue' Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22Pull option names out of messages in config parsingDan McGee
This allows some message reuse, as well as making it clear to translators what *not* to translate. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22Check capabilities in SigLevel option parsingDan McGee
Only allow turning it on if the backend library has support for it. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22Move default siglevel value from backend to frontendDan McGee
This takes the libraries hidden default out of the equation: hidden in the sense that we can't even find out what it is until we create a handle. This is a chicken-and-egg problem where we have probably already parsed the config, so it is hard to get the bitmask value right. Move it to the frontend so the caller can do whatever the heck they want. This also exposes a shortcoming where the frontend doesn't know if the library even supports signatures, so we should probably add a alpm_capabilities() method which exposes things like HAS_DOWNLOADER, HAS_SIGNATURES, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20Flip getcwd()/chdir() for open()/fchdir() in the frontendDan McGee
Just like we did in libalpm in commit 288a81d8470b1. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02Former transaction callback rename refactorDan McGee
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>
2011-09-02Move all callbacks up to the handle levelDan McGee
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>
2011-08-23Retrieve default SigLevel value from backend after initial settingDan McGee
This ensures we grab and use the library default once we have processed the global SigLevel setting, but before processing the repo-specific settings. This means the following two configs will now evaluate the same, as the backend currently defaults to 'Optional': Config 1: [options] # nothing here [repo] SigLevel = TrustAll Config 2: [options] SigLevel = Optional [repo] SigLevel = TrustAll Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08Check return value of rename() callsDan McGee
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>
2011-08-02Implement parsing of the new SigLevel directiveDan McGee
Add code to conf.c that parses the new SigLevel directive. An overwhelming number of options are presented, but most users will still be fine with the Never/Optional/Required trio. More advanced users can combine these or any of the other options on a 'SigLevel = ' line, which is parsed in a left-to-right fashion and flags turned on and off accordingly. For example, all three of these will net the same config: SigLevel = Required PackageOptional SigLevel = Optional DatabaseRequired SigLevel = DatabaseRequired PackageOptional Additionally, database-specific lines assume you wish to start with any global default that has been set. For example, if any of the above lines were in the [options] section, something such as: SigLevel = PackageRequired PackageAllowMarginal Would continue to enforce required database signatures. Inspiration-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05fix segfault if pacman.conf can't be readFlorian Pritz
Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05signing: move to new signing verification and return schemeDan McGee
This gives us more granularity than the former Never/Optional/Always trifecta. The frontend still uses these values temporarily but that will be changed in a future patch. * Use 'siglevel' consistenly in method names, 'level' as variable name * The level becomes an enum bitmask value for flexibility * Signature check methods now return a array of status codes rather than a simple integer success/failure value. This allows callers to determine whether things such as an unknown signature are valid. * Specific signature error codes mostly disappear in favor of the above returned status code; pm_errno is now set only to PKG_INVALID_SIG or DB_INVALID_SIG as appropriate. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-02Prefix _alpm_errno_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_loglevel_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-29Rename public functions with grp in their nameAllan McRae
Using grp instead of group is a small saving at the cost of clarity. Rename the following functions: alpm_option_get_ignoregrps -> alpm_option_get_ignoregroups alpm_option_add_ignoregrp -> alpm_option_add_ignoregroup alpm_option_set_ignoregrps -> alpm_option_set_ignoregroups alpm_option_remove_ignoregrp -> alpm_option_remove_ignoregroup alpm_db_readgrp -> alpm_db_readgroup alpm_db_get_grpcache -> alpm_db_get_groupcache alpm_find_grp_pkgs -> alpm_find_group_pkgs Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmerrno_t to alpm_errno_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdb_t to alpm_db_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmhandle_t to alpm_handle_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-24Add a 'valid' flag to the database objectDan McGee
Start by converting all of our flags to a 'status' bitmask (pkgcache status, grpcache status). Add a new 'valid' flag as well. This will let us keep track if the database itself has been marked valid in whatever fashion. For local databases at the moment we ensure there are no depends files; for sync databases we ensure the PGP signature is valid if required/requested. The loading of the pkgcache is prohibited if the database is invalid. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24Move database 'version' check to registration timeDan McGee
This is another step toward doing both local database validation (ensuring we don't have depends files) and sync database validation (via signatures if present) when the database is registered. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24Do database signature checking at load timeDan McGee
This is the ideal place to do it as all clients should be checking the return value and ensuring there are no errors. This is similar to pkg_load(). We also add an additional step of validation after we download a new database; a subsequent '-y' operation can potentially invalidate the original check at registration time. Note that this implementation is still a bit naive; if a signature is invalid it is currently impossible to refresh and re-download the file without manually deleting it first. Similarly, if one downloads a database and the check fails, the database object is still there and can be used. These shortcomings will be addressed in a future commit. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15API: change 'signaturedir' to 'gpgdir'Dan McGee
This is more in line with reality and what we have our makepkg, etc. options named anyway. Original-patch-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Avoid setting sigverify option twiceDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13conf: do batch processing of repo sectionsDan McGee
We now parse an entire repo section and store all information about it. When the next section is encountered or the end of the root config file is reached, we will then process the stored information. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13conf: _parseconfig() cleanups and documentationDan McGee
* Function doxygen documentation * Reuse a single strlen() call * Prevent infinite recursion (limit to 10 levels) * Other small cleanups Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Move pm_errno onto the handleDan McGee
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle for alpm_db_register_sync()Dan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee
This requires a lot of line changes, but not many functional changes as more often than not our handle variable is already available in some fashion. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Kill all remaining 'PATH_MAX + 1' usagesDan McGee
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>
2011-06-07Revamp pacman setup code to handle new alpm initialize routineDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-05Rework config parsing to reduce variable duplicationDan McGee
This removes the need to strdup() the section name at every decent into an Include statement, as well as having duplicate DB pointers around that are never used independently. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-05Refactor VerifySig option value parsing into standalone methodDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>