Commit Graph

838 Commits

Author SHA1 Message Date
Dan McGee 0303b26b1e Style change: return(x) --> return x
This was discussed and more or less agreed upon on the mailing list. A
huge checkin, but if we just do it and let people adjust the pain will
end soon enough. Rebasing should be relatively straighforward for anyone
that sees conflicts; just be sure you use the new return style if
possible.

The following semantic patch was used to do the change, along with some
hand-massaging in order to preserve parenthesis where appropriate:

The semantic match that finds this problem is as follows, although some
hand-massaging was done in order to keep parenthesis where appropriate:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression a;
@@
- return(a);
+ return a;

// </smpl>

A macros_file was also provided with the following content:

Additional steps taken, mainly for ASSERT() macros:
$ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c
$ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 19:49:45 -05:00
Pang Yan Han 58df372be6 Fix handling of ignored packages
Noted in FS#23342. When the user attempts to install an ignored package
and answers no when asked whether to install it, pacman bails out with:

"error: target not found: packagename"

This is because satisfiers are not found for the package and execution
continues to process_group(), where the package is treated as a group
(which does not exist).

In addition, test ignore006.py is updated with PACMAN_RETCODE=0 since
saying no to installing an ignored package should not be considered an
error.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20 11:17:41 -05:00
Dan McGee 3707d5bc46 Warn but don't error for unknown pacman.conf directives
This makes all the pacman developers' jobs harder as we have to switch
files whenever running multiple pacman versions and are using newly
introduced options. Instead of erroring out, print warnings and continue
on.

This patch also fixes a const-correctness issue. We immediately cast a
'const char *' to a 'char *' in setrepeatingoption(), which is just
plain wrong as we manipulate the underlying string. Fix the types and
remove the now unnecessary variable.

Finally, a few messages change here for consistency and clarity and
because we continue parsing rather than bailing out on a problem.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 19:52:54 -05:00
Dave Reisner 40a6c5c5ec Only read from stdin if '-' is provided as a target
This prevents a regression for people who enjoy piping yes to pacman to
avoid prompts.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-16 19:52:54 -05:00
Dan McGee 36c570712a Fix value of ngettext() count parameter in callback
I was awesome and ran alpm_list_count() on an empty list. Fail.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-07 15:34:30 -06:00
Dan McGee 09ce8b446c Fix some easy to find double translations
A lot of these were places that should have used the same message but
didn't, or were very easy to convert to using the same message and
letting some of the burden off of the translators.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 17:50:23 -06:00
Jakob Gruber dcd234ea27 --print-format displays size in bytes
Printing the exact size seems to make more sense for scripting contexts.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
[Dan: adjust for master before VerbosePkgLists patches, fix type]
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:54:33 -06:00
Dan McGee f45369800a Check local DB version before continuing transaction
Ensure we have a local DB version that is up to par with what we expect
before we go down any road that might modify it. This should prevent
stupid mistakes with the 3.5.X upgrade and people not running
pacman-db-upgrade after the transaction as they will need to.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:46:00 -06:00
Dan McGee 3149a45bfb Add directory name to ownership error message
If you were doing a -Qo via xargs, it is at least nice to see what input
caused the error message to occur rather than having a bunch of plain
messages. This matches the style when we can't find the owner of a file.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 09:48:20 -06:00
Dave Reisner 1fcc496756 alpm: alpm_db_get_pkgcache_list => alpm_db_get_pkgcache
This avoids needless breakage of the public API.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 09:46:36 -06:00
Dan McGee 7c14e48776 Mark log callback format string const
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-24 09:38:59 -06:00
Dan McGee e34fc4eddf Merge remote-tracking branch 'allan/hash' 2011-02-04 09:10:25 -06:00
Dan McGee c12ccbfb2c Add more error checking and logging
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04 09:00:47 -06:00
Allan McRae f8fdce6cb0 Read pkgcache into hash
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>
2011-02-04 09:55:45 +10:00
Florian Pritz 111e07d0be make -d less strict; add -dd option
-d skips checking the version of a dependency.

-dd skips the whole dependency check.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 10:49:53 -06:00
Dan McGee 09f9f24331 Allow both cleanmethod values to be specified at the same time
No reason to disallow this- it allows keeping even more packages around in
the cache. Test cases included for this case and to ensure the default
behavior is preserved.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 09:38:14 -06:00
Dan McGee 986edb8bd4 Style cleanups in clean cache code
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 09:37:20 -06:00
Dan McGee 2e1b5c96a6 Call count() once in callback
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-29 13:34:51 -06:00
Xavier Chantry 05f2abfba9 select_display: per-database output
This function is used both for provision and group selection. Now the
database name will be displayed.

$ pacman  -S base-devel
:: There are 11 members in group base-devel:
:: Repository testing
   1) make
:: Repository core
   2) autoconf  3) automake  4) bison  5) fakeroot  6) flex  7) gcc  8) libtool  9) m4  10) patch  11) pkg-config
Which ones do you want to install?
Enter a number (default=all):

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:40:08 +01:00
Xavier Chantry 2dd53e50de pacman: improve select-question
Make use of parseindex like in multiselect, and loop until we get a
valid answer like in multiselect.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:40:07 +01:00
Xavier Chantry 00fec5e250 pacman/sync: implement interactive group selection
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:40:07 +01:00
Xavier Chantry eed7ba92e8 pacman/remove: switch to new alpm_remove_pkg interface
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:39:05 +01:00
Xavier Chantry 4a72c0964a pacman/upgrade: switch to new interface
Note that there is a behavior change here : if the same package name
appeared several times in the target list, the alpm_add_target interface
chooses the new package, while alpm_add_pkg returns PKG_DUP.

I don't see why we cannot unify the behavior of -S and -U, and just
choose one behavior that applies to both.

Otherwise, it's always possible to handle these different behaviors in
the frontend, it just requires more work.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:16 +01:00
Xavier Chantry f2fcf7eeb1 pacman/sync: rewrite target handling
This uses the new public functions to handle targets from the frontend,
like it used to be :
1) alpm_find_dbs_satisfier to find (optionally versioned) package or
provision
2) alpm_find_grp_pkgs to find members for a groups
3) alpm_add_pkg to finally add the pmpkg_t from 1 or 2

Of course, this adds more code to the frontend, but it completely
deprecates sync_target and sync_dbtarget interfaces.

This all-in-one interfaces felt wrong and left no control to the
frontend. A good frontend should just use alpm_add_pkg, with pkg coming
from alpm_db_get_pkg (for normal targets), alpm_find_dbs_satisfier (for
versioned provisions) or alpm_find_grp_pkgs (for groups).

This also opens the way to provide a better group handling in pacman
without constraint from libalpm and callbacks.

In ignore006, only the retcode changes, because no package was found to
satisfy the target (the only possible package is ignored).

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
2011-01-29 19:33:16 +01:00
Xavier Chantry 4097c98c1e Add interactive provider selection
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>
2011-01-29 19:33:15 +01:00
Dan McGee ef86da97f5 Remove need to explicitly register the local DB
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>
2011-01-29 12:13:56 -06:00
Dan McGee 27e8f06e03 Query fileowner performance improvements
Clean up some of the code by doing less string copying and printing. This is
accomplished by either doing it after we know we need it, or taking
advantage of the fact that some strings never change such as the root
directory prefix. Also, fix an issue where a file at the root level (e.g.
/foobar) could not be queried.

End result is a much faster user experience when combined with the
mbasename() changes. These timings are for looking up 113 files in /etc/,
some of which are owned and some which are not.

	$ find /etc -maxdepth 1 -type f | xargs time pacman -Qo >/dev/null
	6.10user 0.05system 0:06.17elapsed 99%CPU (0avgtext+0avgdata 131040maxresident)k
	0inputs+0outputs (0major+9436minor)pagefaults 0swaps

	$ find /etc -maxdepth 1 -type f | xargs time ./src/pacman/.libs/lt-pacman -Qo >/dev/null
	0.86user 0.04system 0:00.92elapsed 99%CPU (0avgtext+0avgdata 131120maxresident)k
	0inputs+0outputs (0major+9436minor)pagefaults 0swaps

I'll take a 600% increase in speed.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 16:34:42 -06:00
Dan McGee 4d291508c2 Improve mbasename performance
Rather than roll our own, use strrchr() instead, which glibc may have a
better implementation than the simple iteration method we were using.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 16:34:42 -06:00
Dan McGee cda7d7847f Be smarter about failure to read backup file contents
Instead of always printing MISSING, we can switch on the errno value set by
access() and print a more useful string. In this case, handle files we can't
read by printing UNREADABLE, print MISSING on ENOENT, and print UNKNOWN for
anything else. Fixes FS#22546.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 11:38:34 -06:00
Dan McGee c91bd3dda9 Mark backup status strings as untranslated
And also change "Not Modified" -> "UNMODIFIED" for consistency. This makes
it a lot easier to machine-parse this and not worry about locale
differences.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 11:25:45 -06:00
Dan McGee 61864e1f6f Refactor backup file status check into separate function
This will make it a lot easier to use this stuff elsewhere.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 11:25:21 -06:00
Xavier Chantry e277e838d7 Makefile: Use git describe --dirty for GIT VERSION
dirty indicates if the repo has uncommited changes or not when building,
so dont hardcode this info.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-22 10:02:57 -06:00
Dan McGee 5615b71688 Merge branch 'maint'
Conflicts:
	lib/libalpm/be_files.c
2011-01-12 09:23:24 -06:00
Dan McGee 8e30a46adb Make debug config messages consistent in capitalization
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-11 23:16:52 -06:00
Dan McGee fe6e90c21f Add a progressbar for package integrity checking
This can take a while too, and it is really easy to add the necessary
callback stuff for adding a progressbar.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-11 21:15:10 -06:00
Dan McGee 9a82cb92a4 Small fix to download size lookup and a logger
These were just two small things I came across today and found could be
fixed or helpful, so I've added them and I'm not sure what else to bundle
them with. commit_count++

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-11 21:15:04 -06:00
Dan McGee 3e1bdfa93c Use double rather than float everywhere
No real need to use the smaller floating point types here.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-10 10:50:03 -06:00
Dan McGee 5f140a62de Progress callback cleanups and fixes
* Remove a stale comment
* Fix a logic error- the conditional disagreed with the comments
* Remove some unnecessary floating point casts

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-10 10:50:03 -06:00
Dan McGee 62f5da3779 Fix some more simple conversion "errors"
None of these warn at the normal "-Wall -Werror" level, but casts do occur
that we are fine with. Make them explicit to silence some warnings when
using "-Wconversion".

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 21:15:47 -06:00
Allan McRae f966f3a834 Use size_t for alpm_list sizes
There is a lot of swtiching between size_t and int for alpm_list sizes
in the codebase.   Start converting these to all be size_t by adjusting
the return type of alpm_list_count and fixing all additional warnings
given by -Wconversion that are generated by this change.

Dan: a few more small changes to ensure things compile, adjusting some
printf format string characters to accommodate the larger size on x86_64.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 21:15:46 -06:00
Allan McRae d288240426 Update copyright years for 2011
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 18:47:37 -06:00
Allan McRae 351250adb4 Declare all local functions static
All functions that are limited to the local translation unit are
declared static.  This exposed that the _pkg_get_deltas declaration
in be_local.c was being satified by the function in packages.c which
when declared static caused linker failures.

Fixes all warnings with -Wmissing-{declarations,prototypes}.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-30 09:39:23 -06:00
Allan McRae a611879318 Always specify arguement type in function delcarations
Always declare a function with (void) rather than () when we expect
no arguements.  Fixes all warnings with -Wstrict-prototypes.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-20 18:03:21 -06:00
Allan McRae 9f96c5433a Explicitly test time difference is greater than zero
We are comparing a floating point number so should use an inequality
rather than implicitly testing != 0.

Prevents warning given by -Wfloat-equal.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:32:32 -06:00
Allan McRae 24684a616e Display progress bar for disk space checking
Checking disk space needed for a transaction can take a while so add
an informative progress bar.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:30:11 -06:00
Allan McRae e22aa23c8f Add configuration option to control disk space checking
Disk space checking is likely to be an unnecessary bottleneck to
people with reasonable partition sizes so add a configuration option
to allow it to be disabled/enabled as wanted.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:30:05 -06:00
Dan McGee f0051a7678 Remove AC_TYPE_SIGNAL usage
This macro is deemed unnecessary by even the autoconf guys, so we really
don't need to use it.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:29:30 -06:00
Dan McGee fc74ef93b6 dirent usage cleanup
We were including the header in a lot of places it is no longer used.
Additionally, use the correct autoconf macro for determining whether
d_type is available as a member: HAVE_STRUCT_DIRENT_D_TYPE.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:29:20 -06:00
Xavier Chantry abefa23341 alpm/remove.c : respect --dbonly during remove-upgrade
When a -Sk or -Uk operation induced a removal of an existing local
package, --dbonly was not in effect and the files were all removed.

Fixing this behavior was already marked as TODO in database012 pactest
------------
TODO: I honestly think the above should NOT delete the original les, it
hould upgrade the DB entry without touching anything on the file stem.
E.g. this test should be the same as:
   pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz
------------

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
[Dan: small coding style touchup]
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:19:24 -06:00
Xavier Chantry 3a9dec1048 pacman: sort --help output
Example with pacman -Uh :
$ pacman -Uh
options:
  -b, --dbpath <path>  set an alternate database location
  -d, --nodeps         skip dependency checks
  -f, --force          force install, overwrite conflicting files
  -k, --dbonly         only modify database entries, not package files
  -r, --root <path>    set an alternate installation root
  -v, --verbose        be verbose
      --arch <arch>    set an alternate architecture
      --asdeps         install packages as non-explicitly installed
      --asexplicit     install packages as explicitly installed
      --cachedir <dir> set an alternate package cache location
      --config <path>  set an alternate configuration file
      --debug          display debug messages
      --ignore <pkg>   ignore a package upgrade (can be used more than once)
      --ignoregroup <grp>
                       ignore a group upgrade (can be used more than once)
      --logfile <path> set an alternate log file
      --noconfirm      do not ask for any confirmation
      --noprogressbar  do not show a progress bar when downloading files
      --noscriptlet    do not execute the install scriptlet if one exists
      --print          only print the targets instead of performing the operation
      --print-format <string>
                       specify how the targets should be printed

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
[Dan: small coding style touchups]
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:17:38 -06:00