summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/add.c
AgeCommit message (Collapse)AuthorFilesLines
2010-10-13Move the cache stuff where it should beDan McGee1-1/+0
Cache bullshit only has relevance to be_files, so move it there. Signed-off-by: Dan McGee <dan@archlinux.org> [Allan: BIG rebase] Signed-off-by: Allan McRae <allan@archlinux.org>
2010-07-01Check return value of chdir and getcwdAllan McRae1-5/+11
Prevents compiler warnings when building with -D_FORTIFY_SOURCE=2 Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15Bump copyright dates to 2010Dan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15fix a few warnings reported by clangXavier Chantry1-0/+2
- remove unused variables - some more sanity checks - safer printf Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11typing: a few more fixes for special int typesDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-20Fully implement database lazy loadingDan McGee1-6/+7
Commit 34e1413d75 attempted to implement lazy loading of package databases. Although it took care of my main complaint (creating the database directory if it didn't exist), it didn't allow sync repos to be registered before alpm_option_set_dbpath() had been called. With this patch, we no longer compute the individual repository DB paths until necessary, allowing full lazy loading to work as intended, and allowing us to drop the extra setlibpath() calls from the frontend. This allows the changes introduced in a2cd48960 (but later reverted) to be added back in again. Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-20Merge branch 'maint'Dan McGee1-1/+1
Message updates made this one a bit messy, but nothing too bad. Conflicts: lib/libalpm/add.c lib/libalpm/remove.c
2009-09-17String improvementsXavier Chantry1-2/+2
Add more untranslated strings, improve consistency, etc. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-12Change the interface for target loadingXavier Chantry1-9/+20
-int alpm_trans_sysupgrade(int enable_downgrade); -int alpm_trans_sync(char *target); -int alpm_trans_add(char *target); -int alpm_trans_remove(char *target); +int alpm_sync_sysupgrade(int enable_downgrade); +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); * functions renaming * add new sync_dbtarget which allows to specify the db * repo/ syntax handling is moved to frontend ( should implement FS#15141) * group handling is moved to backend ( see http://www.archlinux.org/pipermail/pacman-dev/2009-June/008847.html )
2009-09-09Remove transaction typeXavier Chantry1-92/+8
This basically started with this change : /* Transaction */ struct __pmtrans_t { - pmtranstype_t type; pmtransflag_t flags; pmtransstate_t state; - alpm_list_t *packages; /* list of (pmpkg_t *) */ + alpm_list_t *add; /* list of (pmpkg_t *) */ + alpm_list_t *remove; /* list of (pmpkg_t *) */ And then I have to modify all the code accordingly.
2009-09-09Use sync.c for upgrade transaction prepare and commitNagy Gabor1-86/+1
This patch utilizes the power of sync.c to fix FS#3492 and FS#5798. Now an upgrade transaction is just a sync transaction internally (in alpm), so all sync features are available with -U as well: * conflict resolving * sync dependencies from sync repos * remove unresolvable targets See http://www.archlinux.org/pipermail/pacman-dev/2009-June/008725.html for the concept. We use "mixed" target list, where PKG_FROM_FILE origin indicates local package file, PKG_FROM_CACHE indicates sync package. The front-end can add only one type of packages (depending on transaction type) atm, but if alpm resolves dependencies for -U, we may get a real mixed trans->packages list. _alpm_pkg_free_trans() was modified so that it can handle both target types _alpm_add_prepare() was removed, we use _alpm_sync_prepare() instead _alpm_add_commit() was renamed to _alpm_upgrade_targets() sync.c (and deps.c) was modified slightly to handle mixed target lists, the modifications are straightforward. There is one notable change here: We don't create new upgrade trans in sync.c, we replace the pkgcache entries with the loaded package files in the target list (this is a bit hackish) and call _alpm_upgrade_targets(). This implies a TODO (pkg->origin_data.db is not accessible anymore), but it doesn't hurt anything with pacman front-end, so it will be fixed later (otherwise this patch would be huge). I updated the documentation of -U and I added a new pactest, upgrade090.py, to test the syncdeps feature of -U. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-20Fix one bug with .paccheck leftover fileXavier Chantry1-2/+5
This happens for example if you install a new package, and one of its backup config file is already on the file system. If the local file was different, it was saved to .pacorig which is fine. However if the local file and pkg file were the same, the pkg file (temporarily extracted as .paccheck) was left on the system. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-20Fix fileconflict004Xavier Chantry1-26/+22
When one package wants to replace a directory by a file, we check that all files in that directory were owned by that package. Additionally pacman can be more verbose when the extraction of the symlink (or file) fails. The patch to add.c looks more complex than it is, I just moved and reindented code to handle cases 10 and 11 together. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-16Run ldconfig inside chroot.Xavier Chantry1-1/+0
This fixes FS#15294. The code to run a command inside a chroot was refactored from the _alpm_runscriptlet function to _alpm_run_chroot. Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-07-01Update copyright headers and messagesDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11Fix for trans001.py (FS#9088)Nagy Gabor1-1/+1
From now on _alpm_db_find_fileconflicts() works with upgrade and remove target lists (like checkdeps), which makes it transaction independent (we still need a trans param because of the progressbar). This is a small step towards the universal transaction. So we call this function directly from sync.c before commiting the remove transaction. This is much safer, but we can get false fileconflict error alarms in some tricky cases ("symlinks puzzle" etc). The patch on find_fileconflict looks complex, but it is mainly an "indent-patch", the new code-part can be found after the /* check remove list ... */ comment, and I modified something around the "file has changed hand" case (see comment modifications in the code). Unfortunately sync.c became more ugly, because we have to create 2 parallel internal transactions: to avoid duplicated work, upgrade transaction is used to load package data (filelists). This problem will disappear, when we finally get rid of internal transactions. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-18Merge branch 'maint'Dan McGee1-2/+2
2009-01-18Use archive_entry_set_perm instead of archive_entry_set_modeNagy Gabor1-2/+2
This patch fixes FS#12148 ('unstable' regular file). I also changed the other archive_entry_set_mode usage in add.c to archive_entry_set_perm. Since I cannot find any relevant info in libarchive manual, I quote Tim Kientzle (the author of libarchive) here, and I say thank you for his help. *** Tim Kientzle wrote ************************************* This is the problem in libalpm/util.c: 323 if(S_ISREG(st->st_mode)) { 324 archive_entry_set_mode(entry, 0644); 325 } else if(S_ISDIR(st->st_mode)) { 326 archive_entry_set_mode(entry, 0755); 327 } Your example unstable.db.tar.gz is not empty. It has one entry in it, called "./". That entry is marked as a directory. But, when you call archive_entry_set_mode(), you are changing the file type! archive_read_extract() then creates the file /var/unstable as you requested. (archive_read_extract() will replace an empty directory with a file.) You should either set the mode value correctly: 323 if(S_ISREG(st->st_mode)) { 324 archive_entry_set_mode(entry, IFREG | 0644); 325 } else if(S_ISDIR(st->st_mode)) { 326 archive_entry_set_mode(entry, IFDIR | 0755); 327 } Or use archive_entry_set_perm(), which does not change the file type: 323 if(S_ISREG(st->st_mode)) { 324 archive_entry_set_perm(entry, 0644); 325 } else if(S_ISDIR(st->st_mode)) { 326 archive_entry_set_perm(entry, 0755); 327 } ************************************************************ Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-13Rename alpm_get_md5sum to alpm_compute_md5sum and alpm_dep_get_string to ↵Nagy Gabor1-3/+3
alpm_dep_compute_string This patch introduces the following function name convention: _compute_ in function name: the return value must be freed. _get_ in function name: the return value must not be freed. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03Merge branch 'maint'Dan McGee1-0/+10
2009-01-03Separate local db directory creation and db writeAllan McRae1-0/+10
Changelogs and install files were getting extracted into the local db folder before it was manually created. This created issues for uses with 0077 umasks and was highlighted with the new sudo handling of umasks (FS#12263). This moves the local db creation to its own function which is called before the start of package archive extraction. Also, added a check that the folder is actually created. Signed-off-by: Allan McRae <allan@archlinux.org> [Dan: rename to _alpm_db_prepare()] Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-26Change checkdeps and checkdbconflicts to be more flexible.Xavier Chantry1-1/+1
These two functions now take directly a package list rather than a database. checkdbconflicts was renamed to checkconflicts. Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2008-08-23Pass the old package with PM_TRANS_EVT_UPGRADE_STARTNagy Gabor1-5/+6
This is more rational and coherent with PM_TRANS_EVT_UPGRADE_DONE. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-20libalpm/add.c : ensure the old pkg was fully loaded.Xavier Chantry1-0/+3
This fixes FS#11218. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-16Fix some memleaks in alpm/add.cNagy Gabor1-7/+13
In case of error some allocated memory wasn't freed in commit_single_pkg. Note: The return value of this function is not used. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-16Fix a wrong FREELIST usage in add.cNagy Gabor1-1/+2
The dynamic pmconflict_t must be freed with _alpm_conflict_free. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-06-04Get rid of double / in database paths.Xavier Chantry1-2/+2
Errors like the following one happen regularly (for unknown reasons...) : error: could not open file /var/lib/pacman/local//glibc-2.7-9/depends: No such file or directory Anyway, every time an user reported an error like that, it always seemed like he thought the error was caused by the double /, which is obviously wrong. Since db->path always include a trailing /, there is no need to add one when concatenating paths in be_files.c or add.c. Additionally, some static strings were switched to dynamic. And the computation of the "dbpath"/"pkgname"-"pkgversion" was refactored in db_read, db_write and db_remove with a get_pkgpath static function. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-06-04Use correct C type for file sizesDan McGee1-4/+10
We have been using unsigned long as a file size type for a while, which works but isn't quite correct and could easily break. Worse was probably our use of int in the download callback functions, which could be restrictive for packages > 2GB in size. Switch all file size variables to use off_t, which is the preferred type for file sizes. Note that at least on Linux, all applications compiled against libalpm must now be sure to use large file support, where _FILE_OFFSET_BITS is defined to be 64 or there will be some weird issues that crop up. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-29Remove PM_TRANS_EVT_EXTRACT_START.Xavier Chantry1-1/+0
This event was unused, was missing the equivalent EXTRACT_DONE event, and was useless because we already have ADD / UPGRADE START and DONE events. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-14Remove wrapper call around versioncmpDan McGee1-1/+1
Actually, just rename _alpm_versioncmp to alpm_pkg_vercmp and get rid of the need for a wrapper since it did nothing anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-13Cleanup usages of alpm_list_find and alpm_list_remove.Chantry Xavier1-9/+0
* remove obsolete and unused *_cmp helper functions like deppkg_cmp and _alpm_grp_cmp * new alpm_list_remove_str function, used 6 times in handle.c * remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by a more general alpm_find_pkg_satisfiers with a cleaner implementation. before: alpm_db_whatprovides(db, targ) after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ) * remove satisfycmp and replace alpm_list_find + satisfycmp usage by _alpm_find_dep_satisfiers. before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp) after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep) * remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead. This commit actually get rids of all complicated and asymmetric _cmp functions. I first thought these functions were worth it, be caused it allowed us to reuse list_find and list_remove. But this was at the detriment of the clarity and also the ease of use of these functions, dangerous because of their asymmetricity. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-09Use strdup() instead of a static bufferDan McGee1-14/+24
We only need a copy of this string once we know we are going to extract it, and we don't need a static buffer to copy it into since it is coming from a known-length string. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-29Rework extract_single_file() temp file creationDan McGee1-29/+35
We were a bit juryrigged using one call to mkstemp() before rather than extracting the new files side-by-side and doing our comparisons there. We were also facing some permissions issues. Instead, make our life easier by extracting all temp files to a '.paccheck' extension, doing our md5 comparisons, and then taking the correct actions. Still to be done here- a cleanup of the use of PATH_MAX which should not be necessary if we use dynamic allocation on the heap. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-28Remove unnecessary archive_entry_set_pathname() callsDan McGee1-4/+0
I'm not sure why these were ever here, as by this point we have already extracted the file meaning a call to this function is basically a no-op. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-15Fix compilation errors on x86_64Dan McGee1-2/+2
Things must have gotten stricter with GCC 4.3 on the '%zd' printf string and this is the first I've tried to compile there. Fix the problem by using size_t instead of int. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-15add.c: added some tracing and improved some variable localityK. Piche1-3/+10
Signed-off-by: K. Piche <kevin@archlinux.org> [Dan: removed one logger] Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-11Memory allocation and other small cleanupsDan McGee1-11/+9
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-11Merge branch 'maint'Dan McGee1-6/+4
2008-04-09Correctly use the fd returned my mkstemp()Dan McGee1-6/+4
There were a few issues with this code: 1. We already had an open fd to a file, but never used it to our benefit. Use the libarchive convienence method to write the current file contents straight to a file descriptor. 2. The real problem cropped up on Windows where the locking semantics caused the old way of extraction to fail because we had an open file descriptor. By using the file descriptor and closing it ASAP, we prevent these failures. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-07Remove unnecessary header file, move one macro to util.cDan McGee1-1/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-07libalpm error cleanup, step 1Dan McGee1-1/+1
Remove unused error codes, begin refactoring some of the others. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-30Merge branch 'maint'Dan McGee1-2/+2
2008-03-29Duplicate the result of archive_entry_pathname.Chantry Xavier1-2/+2
After the libarchive upgrade from 2.4.12 to 2.4.14, our usage of archive_entry_pathname became dangerous. We were using the result of that function even after calls to archive_entry_set_pathname. With 2.4.14, the entryname becomes wrong after these calls, and so all the future use of entryname are bogus. entryname is used quite a lot for logging, so that's not so bad. But it's also used for the backup handling, so that's not very cool. For example, reinstalling a package with backup entries will erase all the md5 entries from the DB, because they won't be found back. entryname is now a static string so that we can easily keep the result of archive_entry_pathname. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: fixed version numbers in commit message] Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-23Merge branch 'maint'Dan McGee1-0/+1
2008-03-23memleak fix: ensure backup fname isn't lost if unusedDan McGee1-0/+1
The _alpm_backup_split function always alloced memory for the fname, and we let it disappear in a specific case (upgrade026.py). Fix the issue. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-18Kill PM_TRANS_TYPE_ADD.Chantry Xavier1-10/+2
This was totally useless. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-18Kill some obsolete references to -A option.Chantry Xavier1-1/+1
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-03-11Remove trans->targetsNagy Gabor1-1/+1
Its implementation was quite broken: * add_loadtarget() might have silently filtered out some targets when replacing an older version. * This was used in sync.c to determine whether a target is implicit or not, which is incorrect behavior. Before this patch we silently removed user confirmed replacements; now we always warn on a replacement. * remove001.py behavior was quite odd in adding same target 5 times to the target list, we can change this behavior to be a failure. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xav: changed remove001 pactest accordingly] Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: rewrote commit message] Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-08Merge branch 'maint'Dan McGee1-6/+4
2008-02-07libalpm/add.c : safety check for fixing FS#9235.Chantry Xavier1-6/+4
Fixes FS#9235. We already had the following case in extract_single_file : /* cases 1,2,3: couldn't stat an existing file, skip all backup checks */ But we actually only did a lstat here. And if lstat worked, we did a stat without checking. When lstat works and stat fails, it means we have a broken symlink, like in FS#9235. We can actually treat this case like a non-existing file. The broken symlink will then be simply overwritten. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>