summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAge
...
* diskspace: allow used flag to be toggled for both remove and installDan McGee2011-02-11
| | | | | | | | | | | | | | Turn it into an enum rather than a boolean, and use a bitmask like we do for reading DB entries. The relevant flag is turned on in our two calculate loops, and anything reading the used flag later can decided which flag (or either) is relevant. This will allow the read-only partition code to be triggered on a remove-only operation, e.g. if /boot was read-only and one tried to remove grub in a sync transaction. Of course, right now, we don't actually run the diskspace check code in the '-R' codepath. Signed-off-by: Dan McGee <dan@archlinux.org>
* Check mountpoint read-only status when checking spaceDan McGee2011-02-11
| | | | | | | | | | | This is a bit of a stopgap solution for the problem, but an easier one than revamping the file conflict checking code to support the same stuff. Using some more gross autoconf magic, figure out which struct field we need to look at to determine read-only status and store that on our mountpoint struct. If we find out we needed this partition after calculating size requirements, then toss an error. Signed-off-by: Dan McGee <dan@archlinux.org>
* diskspace: use calloc instead of mallocDan McGee2011-02-11
| | | | | | Prevents us from having to manually zero out several of our fields. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix mount dir length calculationDan McGee2011-02-11
| | | | | | | | | In the getmntinfo() section, the local variable mnt doesn't exist; this would have caused a compile error if I had tested the code on such a platform. Unify both codepaths to just run strlen() on the already copied mount path instead. Signed-off-by: Dan McGee <dan@archlinux.org>
* Avoid a memmove by advancing value pointerDan McGee2011-02-11
| | | | | | | | | | | | In packages, our description file contains: key = value is here type entries, and we passed "key " and " value is here" to our strtrim function, causing us to always memmove the value portion to remove the space. Since this is a throwaway buffer, do the advancing on our own before trimming to save the need to shift memory around; "value is here" will now be passed and strtrim will be responsible for trailing whitespace. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix fileconflict progress with only one packageDan McGee2011-02-11
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Skip diskspace checking for symlinks and directories in all casesDan McGee2011-02-08
| | | | | | | | | | | | | | | | | | We did this in some but not all cases, assuming the 0 value coming out of libarchive would not be a problem. However, this does not work for "fake" filesystems such as rpc_pipefs, which reports a free block and total block count of zero. Fix this by not ever counting symlinks or directories, and adding a note explaining that if we someday do count directories, their size needs to be attributed to the proper place. This patch also includes a few cleanups/performance tweaks- avoid calling strlen() on the mountpoint directory string as much by storing this size in our mountpoint struct, and push the snprintf() call up to the calculate functions since we were already doing it here in the remove case. Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor out common code in pkghash add functionsPang Yan Han2011-02-07
| | | | | | | | | | The overlapping code in _alpm_pkghash_add() and _alpm_pkghash_add_sorted() are now in a new static function pkghash_add_pkg(). This function has a third flag parameter which determines whether the package should be added in sorted order. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Handle null pkgcache for local/sync db_populate()Pang Yan Han2011-02-07
| | | | | | | | | | | | | | | In sync_db_populate() and local_db_populate(), a NULL db->pkgcache is not caught, allowing the functions to continue instead of exiting. A later alpm_list_msort() call which uses alpm_list_nth() will thus traverse invalid pointers in a non-existent db->pkgcache->list. pm_errno is set to PM_ERR_MEMORY as _alpm_pkghash_create() will only return NULL when we run out of memory / exceed max hash table size. The local/sync db_populate() functions are also exited. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2011-02-06
|\
| * Add new translations from TransifexDan McGee2011-02-04
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove redundant _alpm_strtrim() in be_local.cPang Yan Han2011-02-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When reading the "desc" file in _alpm_local_db_read(), some strings are trimmed and checked for length > 0 before their use/duplication subsequently. They are then trimmed again when there is no need to. The following code snippet should illustrate it clearly: while(fgets(line, sizeof(line), fp) && strlen(_alpm_strtrim(line))) { char *linedup; STRDUP(linedup, _alpm_strtrim(line), goto error); info->groups = alpm_list_add(info->groups, linedup); } This patch removes the redundant _alpm_strtrim() calls in _alpm_local_db_read() such as the one inside the STRDUP shown above. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Handle PM_ERR_WRITE in alpm_strerror()Pang Yan Han2011-02-04
| | | | | | | | | | | | | | | | PM_ERR_WRITE is defined in alpm.h but not handled in alpm_strerror(). This patch corrects that. Signed-off-by: Pang Yan Han <pangyanhan@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Update translation file indexes and MakevarsDan McGee2011-02-04
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add comment about download file resolutionDan McGee2011-02-04
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge remote-tracking branch 'allan/hash'Dan McGee2011-02-04
|\ \
| * | Improve pkghash_remove algorithmDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather than potentially move every item to the next NULL, attempt to move at most one item at a time by iterating backwards from the NULL location in the hash array. If we move an item, we repeat the process on the now shorter "chain" until no more items need moving. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Use alpm_list_remove_item in pkghash_removeDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | Removes the code that was duplicated and has now been refactored into a separate method. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Add new alpm_list_remove_item() functionDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This takes in the list and a list item, and does the pointer dance necessary to remove it from the list regardless of whether it is first, last, or somewhere in the middle. It is useful for callers that already know what item needs to be removed and have a pointer to it rather than doing a search by data that the plain alpm_list_remove() does. Refactor alpm_list_remove() to use this function as well. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Actually remove packages from pkghash on removalAllan McRae2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | Fully removes a package from the hash. Also unify prototype with removal from an alpm_list_t, fixing issues when removing a package from the pkgcache. Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Refactor finding position for new hash entryAllan McRae2011-02-04
| | | | | | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Rehash efficientlyAllan McRae2011-02-04
| | | | | | | | | | | | | | | | | | | | | Rehash without recreating the hash table list or reallocating the memory for holding the list nodes. Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Slightly more efficient rehash size selectionAllan McRae2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | While probably still not optimal in terms of everyday usage in pacman, this reduces the absolute size increase to "more reasonable" levels. For databases greater than 5000 in size, the minimum size increase is used which is still on the order of a 10% increase. Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Error handling for maximum database sizeAllan McRae2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | Check that the requested size of a pkghash is not beyond the maximum prime. Also check for successful creation of a new hash before rehashing. Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Change default sync hash table sizing to 66% fullDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | Since the sync database never changes size once we initialize it, we allow it to be filled a bit more. This reduces the overall memory footprint needed by the hash table. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Implement a quick and dirty rehash functionDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | This allows us to get through the rehash required by smoke001 and pass all pactests. It is by no means the best or most efficient implementation but it does do the job. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Read pkgcache into hashAllan McRae2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Read the package information for sync/local databases into a pmpkghash_t structure. Provide a alpm_db_get_pkgcache_list() method that returns the list from the hash object. Most usages of alpm_db_get_pkgcache are converted to this at this stage for ease of implementation. Review whether these are better accessing the hash table directly at a later stage. Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Get estimated package count when populating databasesDan McGee2011-02-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works for both local and sync databases in slightly different ways. For the local database, we can use the directory hard link count on the local/ folder. For sync databases, we use the archive size coupled with some computed average per-package sizes to determine an estimate. This is currently a dead assignment once calculated, but could be used to set the initial size of a hash table. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
| * | Add a hash table for holding packagesAllan McRae2011-02-04
| | | | | | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org>
* | | Add more error checking and loggingDan McGee2011-02-04
| | | | | | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | | Ensure found files are actually filesDan McGee2011-02-04
|/ / | | | | | | | | | | | | | | | | We located files in a few places but didn't check if they were files or directories. Ensure they are actually files using stat() and S_ISREG(); this showed itself when trying to download to the directory name itself in FS#22645. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Fix locale.h/setlocale inclusion with --disable-nlsDan McGee2011-02-01
| | | | | | | | | | | | | | | | | | Noted in FS#22697. When I factored out _alpm_parsedate() into a common function, I didn't move the <locale.h> include properly, causing a build failure when NLS is disabled and this header isn't automatically included everywhere. Signed-off-by: Dan McGee <dan@archlinux.org>
* | alpm/depcmp: new NODEPVERSION flagXavier Chantry2011-01-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This flag allows to disable version checking in dependency resolving code. depcmp_tolerant respects the NODEPVERSION flag but we still keep the original strict depcmp. The idea is to reduce the impact of the NODEPVERSION flag by using it in fewer places. I replaced almost all depcmp calls by depcmp_tolerant in deps.c (except in the public find_satisfier used by deptest / pacman -T), but I kept depcmp in sync.c and conflict.c Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | libalpm: fix db_update documentationXavier Chantry2011-01-31
| | | | | | | | | | | | return codes were mixed up Signed-off-by: Dan McGee <dan@archlinux.org>
* | alpm: drop old target interfacesXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | | | It's likely that these interfaces will break sooner or later, now that pacman no longer uses them. So better force the two people who use them to migrate their code to the new add_pkg/remove_pkg interface, which is very easy anyway. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | alpm: deprecate old interfaceXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Old interface is marked as deprecated: int alpm_sync_target(char *target); int alpm_sync_dbtarget(char *db, char *target); int alpm_add_target(char *target); int alpm_remove_target(char *target); New recommended interface: int alpm_add_pkg(pmpkg_t *pkg); int alpm_remove_pkg(pmpkg_t *pkg); Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | alpm: new alpm_remove_pkg interfaceXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | For consistency with alpm_add_pkg. The new recommended interface is alpm_add_pkg / alpm_remove_pkg, all others interfaces are deprecated. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | alpm: add alpm_find_grp_pkgsXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | This group function is meant to help group handling from frontend : it scans all dbs, handling ignored packages and duplicate members (the first repo where a member is found has the priority). Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | alpm: new alpm_add_pkg interfaceXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | | | | | | | | | This new function is meant to deprecate all existing sync/add target functions : int alpm_sync_target(char *target); int alpm_sync_dbtarget(char *db, char *target); int alpm_add_target(char *target); Rather than dropping these 3 interfaces, it might be better to rewrite them using alpm_add_pkg for now. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | alpm/dep: add alpm_find_dbs_satisfierXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | | | | | This is a public interface for resolvedep. It looks nicer to expose it this way rather than through sync_target. This function can also be helpful for external tools as it should give good results close to how pacman select a package for satisfying a given dep. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | Add interactive provider selectionXavier Chantry2011-01-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there are multiple providers in one db, pacman used to just stop at the first one (both during dependency resolution or for pacman -S 'provision' which uses the same code). This adds a new conversation callback so that the user can choose which provider to install. By default (user press enter or --noconfirm), the first provider is still chosen, so for example the behavior of sync402 and 403 is preserved. But at least the user now has the possibility to make the right choice in a manual run. If one of the provider is already installed, it is picked for reinstall/upgrade, so that provision 002/003 pactest now pass. $ pacman -S community/smtp-server :: There are 3 providers available for smtp-server: 1) courier-mta 2) esmtp 3) exim Which one do you want to install? Enter a number (default=1): Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
* | Merge branch 'maint'Dan McGee2011-01-29
|\|
| * libalpm: Fix a missing "nicht" (not) in German translation.Thomas Bächler2011-01-28
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove need to explicitly register the local DBDan McGee2011-01-29
| | | | | | | | | | | | | | | | | | Perform the cheap struct and string setup of the local DB at handle initialization time to match the teardown we do when releasing the handle. If the local DB is not needed, all real initialization is done lazily after DB paths and other things have been configured anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Ignore known but unused package descfile fieldsDan McGee2011-01-28
| | | | | | | | | | | | | | | | We explicitly place 'pkgbase' (and used to place 'force') fields inside PKGINFO files, so ignore them silently instead of printing an error for them. Also make the error message for unknown keys actually contain the key. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Fix memory leak and error code in DB readingDan McGee2011-01-24
| | | | | | | | | | | | | | We were returning a package error code rather than a DB one, and we would leak the archive memory if the database file didn't exist. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Compute download size for sync packages onlyDan McGee2011-01-22
| | | | | | | | | | | | | | Neither packages from files nor packages from the local database will ever have a download size. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2011-01-22
|\|
| * Copy new backend translation over from frontend translationDan McGee2011-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since it is the same string. Done with some bash looping and sed magic. for src in po/*.po; do echo $src newtrans=$(grep -A1 "msgid.*$1" $src | tail -n1) newtrans=${newtrans//\\/\\\\} echo "$newtrans" fname=${src##*/} dest=lib/libalpm/po/$fname sed -i -e "/msgid.*$1/{N; s/msgstr.*$/$newtrans/}" $dest done Signed-off-by: Dan McGee <dan@archlinux.org>
| * Fix double read issue in maint releasesDan McGee2011-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is essentially a backport/cherry-pick of commit 33240e87b99e from master, but has to be done by hand because the DB format has diverged. Read more in the commit message used there, which follows. Due to the way we funk around with package data loading, we had a condition where the filelist got doubled up because it was loaded twice. Packages are originally loaded with INFRQ_BASE. In an upgrade/sync, the package is checked for file conflicts next, leaving us in an "INFRQ_BASE | INFRQ_FILES" state. Later, when committing a single package, we have an explicit call to _alpm_local_db_read() with INFRQ_ALL as the level. Because the package's level did not match this, we skipped over our previous "does the incoming level match where I'm at" shortcut, and continued to load things again, because of a lack of fine-grained checking for each of DESC, FILES, and INSTALL. The end result is we loaded the filelist twice, causing our remove logic to iterate twice over the installed files, spewing a bunch of "cannot find file X" messages. Fix the problem by doing a bit more bitmasking logic throughout the load method, and also fix the sanity check at the beginning of the function- this should *only* be used for local packages as opposed to the "not a package" check that was there before. Signed-off-by: Dan McGee <dan@archlinux.org>