Commit Graph

1144 Commits

Author SHA1 Message Date
Nagy Gabor 0bf340f73c Remove unused error codes and handle PM_ERR_RETRIEVE by alpm_strerror()
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-05-18 23:11:43 -05:00
Nagy Gabor 882bff36ac Remove find_replacements()
"Foo replaces bar" simply means that "foo is a new version of bar".
So this patch refactors the code to use this "rule".

_alpm_sync_sysupgrade now does the following for each local package [bar]
(pseudo-code):
for db in syncdbs {
   if(db contains bar) {check if db/bar is an upgrade; break;}
   replacers = find(bar replacers in db);
   if(replacers!=NULL) {ask_user; break;}
}

Note:
1. Replacers are grouped per repo. If more than one package replace bar in
a repo, all of them are considered ("package set of bar replacers").
2. If repo1/foo1 and repo2/foo2 both replaces bar, only repo1/foo1 is
considered (if repo1 stands before repo2 in pacman.conf). FS#11737 is fixed.
3. It can happen that pacman doesn't consider any replacer, if it found a
literal "earlier", so sync132.py modified accordingly (btw, that situation
should not appear irl).

The new sysupgrade code doesn't use sync_newversion(), so I removed the
"local is newer than repo" message, which was annoying with -Qu and
SyncFirst.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-05-18 23:11:05 -05:00
Gerardo Exequiel Pozzi ed848b1c54 Fix non-C style comments in libalpm
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-05-11 20:26:49 -05:00
Bryan Ischo db3e166503 Look in target-list first to resolve dependencies
This fixes a bug introduced by my previous changes which changes the
behavior of IgnorePkg/IgnoreGroup to allow the user to remove unresolvable
packages from the transaction.  The bug is that the target-list was no
longer being consulted first to resolve dependencies, which means that if
two packages in the sync database satisfied a dependency, and the user
explicitly requested one of those two packages in the sync, the other
package was still being pulled in.

A new test was added, sync993.py, to verify the desired behavior.

Signed-off-by: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 14:39:24 -05:00
Bryan Ischo d70465decc Remove duplicates from the unresolvable list before prompting user
Signed-off-by: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 14:24:52 -05:00
Dan McGee 4b78852f7e const-ify endswith()
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 14:13:03 -05:00
Nagy Gabor aefb4e0fa5 Remove pmsyncpkg_t
pmsyncpkg_t data sructure was removed:
1. pmpkg_t.reason is used instead of pmsyncpkg_t.newreason. (The target
packages come from sync repos, so we can use this field without any
problems. Upgrade transaction also uses this field to store this info.)
2. pmsyncpkg_t.removes was moved to pmpkg_t.removes.
This step requires careful programming, because we don't duplicate packages
when we add them to trans->packages. So we modify sync pkgcache when we
add this transaction-only info to our package. Hence it is important to
free this list when we remove any package from the target list
(remove_unresolvable, remove_conflicts, trans_free), otherwise this could
confuse the new sync transactions (with non-pacman GUI).

Overall, our code became ~100 line shorter, and we can call our helper
functions directly on trans->packages in sync.c, we don't need to maintain
parallel package lists.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 14:05:13 -05:00
Nagy Gabor 391952600d Fix for trans001.py (FS#9088)
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-04-11 13:59:55 -05:00
Nagy Gabor 634304feae Free *data list when user removes unresolvable packages
Resolvedeps reports error when it cannot resolve some dependencies, puts
them into the *data list, and set pm_errno. If user removes the
unresolvable packages from the target list, we have no error anymore,
so from now on we free *data list (we eliminate a memleak) and unset
pm_errno.

(Additionally I removed two needless lines from the code, unresolvable list
is always freed in cleanup.)

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 13:55:46 -05:00
Nagy Gabor 56fd24ecf8 Print warning in _alpm_resolvedep() if a satisfier package is ignored without QUESTION
After commit f57f8d3386 pacman *silently*
ignores packages from IgnorePkg/IgnoreGroup during dependency resolving,
if prompt == 0. This behavior is changed to "give warning + ignore".
(Otherwise the user is not informed about the fact that the package
resolving was blocked by ignorepkg.)

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 13:54:50 -05:00
Nagy Gabor 77efd51216 New error type: PM_ERR_PKG_IGNORED
This patch fixes FS#12059.
Now sync_addtarget can return with PM_ERR_PKG_IGNORED, which indicates that
although the requested package was found it is in ignorepkg, so alpm could
not add it to the transaction. So the front-end can decide what to do.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 13:54:25 -05:00
Dan McGee 93ca155b48 Merge branch 'xav/repo-add' 2009-04-11 13:50:56 -05:00
Sebastian Nowicki 63fc93607b Add detail documentation for alpm_db_update()
This adds alpm_db_update() to the alpm_databases Doxygen group. The function
is described in more detail and a code example is given.

Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-11 12:50:37 -05:00
Samed Beyribey 3cb4eaef4f fixed typos and alignment problem in Turkish translation
Signed-off-by: Samed Beyribey <ras0ir@eventualis.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-04-05 21:40:58 -05:00
Xavier Chantry c8beffa790 Fix several issues with xdelta
1) The changes to sync.c look big but there are mostly caused by
the indentation. Fix a bug where download_size == 0 because the packages and
deltas are already in the cache, but we still need to build the deltas list
and apply the deltas to create the final package.

2) Fix the gzip / md5sum issue by switching to xdelta3, disabling external
recompression and using gzip -n in pacman, and disable bsdtar compression
and using gzip -n in makepkg.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-03-15 18:08:36 +01:00
Xavier Chantry 9519d22df7 be_files.c : use %jd instead of %ju for intmax_t
Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-03-15 11:41:37 -05:00
Xavier Chantry de97282fbd Revert "popen does NOT require /bin/sh in a subchroot"
This reverts commit 9558639d80.

This change was wrong, popen does require /bin/sh in a subchroot.

1) pacman -S lilo -r root

Notice no error

2) rm root/bin/sh ; pacman -S lilo -r root

Notice an error :
error: scriptlet failed to execute correctly

Actually, we already get an explicit error here, when popen is run, so there
is no need to check for bin/sh explicitely.

Besides this check was problematic in some cases. For example, bash itself
has a scriptlet, but only post_install and post_upgrade, no pre_install and
pre_upgrade. However, since bash has a scriptlet, runscriptlet will also be
called before bash is installed. It won't do anything since the scriptlet
has no pre_install function. But if we keep the check, we will still get
"error : no /bin/sh".

Conflicts:

	lib/libalpm/trans.c

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-03-15 11:41:37 -05:00
Xavier Chantry 36863b968f runscriptlet : Flush open fds before fork() to avoid cloning buffers
This is a bug I noticed 2 years ago :
http://www.nabble.com/Re%3A-logging-output-crazy-to11437357.html#a11479679

I thought I fixed it with 57d77eab32

But the bug was still here. Reading man fork, this part caught my attention:

*  The child inherits copies of the parent's set  of  open  file
descriptors.  Each  file descriptor  in  the  child refers to the same open
file description (see open(2)) as the corresponding file descriptor in the
parent.  This means that the two descriptors  share open  file  status
flags, current file offset, and signal-driven I/O attributes (see the
description of F_SETOWN and F_SETSIG in fcntl(2)).

Since the open file descriptors are inherited, it is probably a good idea to
flush them before forking.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-03-15 11:40:49 -05:00
Dan McGee 4458f71851 Merge branch 'maint' 2009-02-28 15:43:36 -06:00
Xavier Chantry 8c09c19139 libalpm: remove from_md5 and to_md5 from pmdelta_t
The from_md5 and to_md5 fields were a nice extra safety, which would avoid
trying to apply deltas on corrupted package files. However, they are not
strictly necessary, since xdelta should be able to detect that on its own.

The main problem is that it is impossible to compute these informations from
the delta only. So repo-add would not be able to compute the delta entry
based on just the delta file.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-02-28 15:33:46 -06:00
Baurzhan Muftakhidinov b3c67a195f Add new Kazakh translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-02-24 08:24:47 -06:00
Bryan Ischo f57f8d3386 Don't prompt the user for unignore of IgnorePkg/IgnoreGroup packages
Don't prompt the user for unignore of IgnorePkg/IgnoreGroup packages,
except for packages explicitly listed for sync by the user.  This
eliminates many unnecessary prompts when IgnorePkg/IgnoreGroup is
used.

Signed-off-by: Bryan Ischo <bryan@ischo.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-02-23 20:37:14 -06:00
Bryan Ischo 0268550401 Enabled new interactive prompt and updated some tests
Enabled a new prompt to ask the user if they'd like to remove
unresolvable packages from the transaction rather than failing it.

Many pactest tests that used to fail now return success codes, because
pacman now issues a prompt allowing the user to cancel rather than
failing many transactions, and the pactest scripts always choose to
cancel with no error rather than failing.  The only net effect is that
the return status of pacman is now 0 in cases where it used to be
nonzero.

Signed-off-by: Bryan Ischo <bryan@ischo.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-02-23 20:33:56 -06:00
Bryan Ischo 6c4d702cb1 Reorganize code for one-at-a-time resolving
This change reorganizes the internal code so that packages are
resolved one at a time instead of all at once from a list.  This will
allow a future checkin to prompt the user to see if they'd rather
remove unresolvable packages from the transaction and continue, or
fail the transaction.  This change does not affect the actual behavior
of libalpm and all tests pass without changes.

Signed-off-by: Bryan Ischo <bryan@ischo.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-02-18 20:52:22 -06:00
Xavier Chantry 34e1413d75 Delay the creation of local and sync db dir.
We don't need to create the directories when local or sync dbs are
registered. For example, if a sync db does not exist, we cannot even do
"pacman -Q" as an user.

Instead, we can create the local db if needed during the db_prepare
operation, and sync dbs on db_update.

Also remove some more useless abstractions in db_update and switch to a much
more efficient way to remove a sync db : rm -rf.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-01-20 14:07:15 +01:00
Xavier Chantry 14230869e6 Remove some db abstraction crap.
These db_open and db_close looked quite useless. And they caused the db
directory to be opened on a simple registering of a database. This is
totally unneeded, this opening can be delayed to when we actually need it.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-01-20 14:04:54 +01:00
Xavier Chantry eab9684837 alpm_unpack : change prefix handling to workaround FS#12148.
Instead of appending the prefix to each entry name, we can chdir to the
prefix before extracting, and restoring when it is done.
This seems to work better with the strange and special case of FS#12148
where an archive contained the "./" entry.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
2009-01-20 14:03:46 +01:00
Dan McGee c794661f1e Merge branch 'maint' 2009-01-18 13:48:48 -06:00
Nagy Gabor 472e51b975 Use archive_entry_set_perm instead of archive_entry_set_mode
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-18 13:35:17 -06:00
Nagy Gabor cb7337eb64 db->pkgcache_loaded and db->grpcache_loaded
Clearly the old code was more elegant (NULL cache indicated "not loaded"),
but it had some drawbacks, so from now on we indicate the state of caches
explicitly.

Old drawbacks:
When we had an empty database (unstable), libalpm called db_populate after
every pkgcache access, because NULL pkgcache indicated "not loaded" state.
This is not a common case, but the same situation can happen with grpcache,
which is more problematic: If the user had a custom repo with no groups,
grpcache was always NULL. (grpcache is also loaded per database.) Thus
every get_grpcache call induced a load_grpcache operation, so the benefits
of grpcache was completely lost.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-12 23:59:37 -06:00
Nagy Gabor 4da70d800a Rename alpm_get_md5sum to alpm_compute_md5sum and alpm_dep_get_string to 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-12 23:59:30 -06:00
Nagy Gabor a888f377a5 HoldPkg rework
The HoldPkg feature is even more important when the packages to be held are
pulled automatically by pacman, in a -Rc and -Rs operation. Before, it only
applied when the packages were explicitly requested by the user to be
removed. This patch extends holdpkg to -Rc and -Rs by doing the HoldPkg
check just before trans_commit.

Additionally, the whole HoldPkg stuff was moved to the front-end.

I changed the default behavior to "don't remove", so I modified remove030.py
pactest as well.

See also: FS#9173.

Original-work-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-12 22:44:00 -06:00
Xavier Chantry 8017b0bb8e Remove libdownload support and fix libfetch one.
Aaron said to consider libdownload a dead project so libdownload support was
removed to more easily fix libfetch one (otherwise many ifdef needed).

There was no direct replacement for ferror to detect an error while
downloading. So instead, I added a check at the end to see if the file was
fully downloaded, which is just a small chunk of code taken from here:
http://cvsweb.netbsd.org/bsdweb.cgi/pkgsrc/net/libfetch/files/fetch.c?only_with_tag=MAIN

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-12 22:40:15 -06:00
Dan McGee 0501d340cd Merge branch 'maint' 2009-01-06 20:22:15 -06:00
Vojtěch Gondžala c6bcdf4dc7 Update Czech translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-05 19:06:39 -06:00
Dan McGee 6f9539aefb Merge branch 'maint'
Conflicts:
	po/it.po
2009-01-04 11:12:28 -06:00
Mateusz Herych 997a611fa4 Update Polish translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 19:07:44 -06:00
Samed Beyribey a2cbccb8c7 Update Turkish translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 09:25:24 -06:00
Sergey Tereschenko c850786e43 Update Russian translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 09:24:07 -06:00
Roman Kyrylych 3acc265f9d Update Unkranian translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 09:20:41 -06:00
Giovanni Scafora 03a63e01a5 Update Italian translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 09:17:50 -06:00
Matthias Gorissen 024012649f Update German translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 09:14:35 -06:00
Juan Pablo González Tognarelli 792ee97645 Update Spanish translation
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 00:30:09 -06:00
Dan McGee a30bf868ca Merge branch 'maint' 2009-01-03 00:18:22 -06:00
Allan McRae b55f478042 libalpm: add PID to db.lck
This is the first step in being able to automatically remove phantom
lock files.

Signed-off-by: Allan McRae <allan@archlinux.org>
[Dan: fix compilation warnings]
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-03 00:00:19 -06:00
Allan McRae a73ad4f0e3 Separate local db directory creation and db write
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>
2009-01-02 23:52:32 -06:00
Sterling Winter b3169a5687 Log pacsave warnings to pacman.log
Pacman currently logs .pacnew warnings to pacman.log but a similar history
of .pacsave warnings isn't kept. The user should be able to search
pacman.log to discover when and where all .pac* files were created by
pacman.

Addresses FS#12531.

Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-02 23:40:20 -06:00
Dan McGee f8b689d48e Merge branch 'maint'
Conflicts:
	lib/libalpm/dload.c
	po/it.po
	scripts/makepkg.sh.in
2009-01-02 22:48:52 -06:00
Dan McGee cc7f3b705e Print proxy information when downloading
May help debug issues we come across with proxy behavior (e.g. those pesky
segfaults) as well as be informative to the user when things aren't working
quite right. Addresses FS#12396.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-12-10 19:45:15 -06:00
Dan McGee 61c6552862 Merge branch 'maint'
Conflicts:
	lib/libalpm/dload.c
2008-12-02 22:15:02 -06:00