Commit Graph

324 Commits

Author SHA1 Message Date
Dan McGee 6a8e50a69e Remove SyncFirst option
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-12 08:55:49 -05:00
Dan McGee a8a1b093eb Various tweaks to support building with excessive GCC warning flags
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-04-08 22:28:45 -04:00
Pierre 0145604728 pacman: show groups once with -Sg
Only displays groups that haven't appeared yet..
Previously 'pacman -Sg' iterated over syncs, printed every group.

This change does not affect '-Sgg' which still orders by sync first.

To reproduce, on a current Arch Linux with [extra] and [community]:
$ pacman -Sg|sort|uniq -c|sort -n
[...]
      1 xorg-fonts
      2 vim-plugins
      2 xfce4-goodies

Signed-off-by: Pierre <pierre@spotify.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07 11:16:58 -05:00
Dan McGee 8da489eac5 Reduce calls to getcols
This dramatically improves upon a much older attempt in 2008 in commit
ce3d70aa99. We don't need to call it once per line we print unless
there is a reasonable expectation of being able to resize the terminal
mid-operation; this is really only the case during our callback progress
bars.

Some before and after numbers of ioctl() calls, gleaned from strace of
the following operations (no targets to any of them to maximize the
amount of output):

    pacman -Qii :  37768 ->  2616  (93.1% decrease)
    pacman -Qs  :   2616 ->     4  (99.8%)
    pacman -Sii : 133036 -> 10926  (91.8%)
    pacman -Ss  :  10926 ->    14  (99.9%)

Obviously the search results are astounding; we only call getcols()
once in the case of -Qs, and once per repo in the case of -Ss. For
-Qii and -Sii we are still calling it once per package, but this is
much better than once per line of info output.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-16 17:57:04 -05:00
Dan McGee e6f72c61a0 Merge branch 'maint'
Conflicts:
	lib/libalpm/sync.c
2012-03-16 12:08:10 -05:00
Allan McRae 47d0df6c10 Skip special files when cleaning package cache
Ignore *.sig, *.db*, and *.src.tar* when cleaning the package cache.

Fixes FS#25166.

Signed-off-by: Allan McRae <allan@archlinux.org>
2012-03-13 08:24:11 -05:00
Dan McGee 8de0631edb Merge branch 'maint'
Conflicts:
	lib/libalpm/be_package.c
2012-03-08 18:08:15 -06:00
Dan McGee d1151b5ab9 Database cleanup enhancements
Ensure we give database signatures special treatment like we already did
for package signatures. Attempt to parse the database name out of them
before taking the proper steps to handle their existence. This fixes
FS#28714.

We also add an unlink_verbose() helper method that displays any errors
that occur when unlinking, optionally opting to skip any ENOENT errors
from being fatal.

Finally, the one prompt per unknown database has been removed, this has
no real sound purpose and we don't do this for packages. Simply kill
databases we don't know about; other programs shouldn't have random data
in this directory anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-03-05 11:44:33 -06:00
Dan McGee 3849c3aec1 Merge branch 'maint'
Conflicts:
	contrib/pacsysclean.in
	src/pacman/conf.h
2012-02-20 17:00:26 -06:00
Dan McGee 9a1ff474f1 Revert "Enable recursive/needed sync on SyncFirst"
This reverts commit 0903452032.

Tests affected by this revert have been adjusted; additionally a few
EXIST tests have been removed where there is already a VERSION test
doing the job for us.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-15 15:56:16 -06:00
Dan McGee b488f229d2 ALPM API adjustments for sanity and consistency
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-02-06 05:49:52 -06:00
Dan McGee e50c4a8837 Merge branch 'maint'
Conflicts:
	lib/libalpm/diskspace.c
	src/pacman/util.h
2012-01-23 12:20:52 -06:00
Dan McGee 562109c0e8 Update copyright on changed files since beginning of year
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 22:25:27 -06:00
Dan McGee be229d129e Don't remove unknown files in cache cleaning code
This removes the hack I added to skip '*.sig' files earlier since there
are other files that also fall into the same bucket- source packages
from `makepkg --source`, delta files, etc. Rather than prompting for
each and every one, simply skip them. Doing '-Scc' rather than '-Sc'
will delete these files if that is really what you want to do.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 12:15:11 -06:00
Dave Reisner d6ccd44390 include config.h via Makefiles
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-21 18:13:17 -06:00
Dan McGee 1a1f5540a4 pacman: process all sync targets before exiting on error
If someone specifies a bogus line such as

    pacman -S baz adsf/boo base-devel

we are better off trying to process all targets and showing all relevant
errors before exiting. This is easier in -U and -R operations where we
aren't dealing with groups, but here we attempt to skip group selection
once we know a target has errored to avoid cluttering the output and
hiding the real problem.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:45:40 -06:00
Jonathan Conder a3f9399295 create a typedef for enum _alpm_errno_t
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-14 08:54:03 -06:00
Dan McGee 90ddcbe71d Merge branch 'maint'
Conflicts:
	src/pacman/package.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 19:29:47 -05:00
Dan McGee 9e9ecf2183 Remove pm_fprintf() in favor of pm_printf()
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-21 10:45:18 -05:00
Dan McGee 8605284e0d Use puts() instead of no-op printf() where applicable
This replaces several printf calls of the following styles:
   printf("%s", ...);
   printf("some fixed string");
   printf("x");

We can use either fputs() or putchar() here to do the same thing
without incurring the overhead of the printf format parser.

The biggest gain here comes when we are calling the print function in a
loop repeatedly; notably when printing local package files.

    $ /usr/bin/time ./pacman-before -Ql | md5sum
      0.25user 0.04system 0:00.30elapsed 98%CPU
    $ /usr/bin/time ./pacman-after -Ql | md5sum
      0.17user 0.06system 0:00.25elapsed 94%CPU

    $ /usr/bin/time ./pacman-before -Qlq | md5sum
      0.20user 0.05system 0:00.26elapsed 98%CPU
    $ /usr/bin/time ./pacman-after -Qlq | md5sum
      0.15user 0.05system 0:00.23elapsed 93%CPU

So '-Ql' shows a 17% improvement while '-Qlq' shows a 13% improvement on
382456 total files.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13 20:59:16 -05:00
Dan McGee 6be492d2f7 Remove alpm_list_getdata wrapper function
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-10-12 14:22:49 -05:00
Dan McGee 6f3a657f66 Always show download size if -w/--downloadonly was provided
The prompt can be rather confusing otherwise when all files have already
been downloaded, but there is not a single total size listed.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 10:18:42 -05:00
Dan McGee 7edeb276b6 Keep track of explicitly added and removed packages
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-28 04:52:37 -05:00
Dan McGee bd83c8e756 Combine add and removal package list display
There was no real reason for these to be done separately.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 04:52:37 -05:00
Dan McGee 8e3b39a9e0 pacman: use dynamic string allocation where it makes sense
None of these are hot-code paths, and at least the target reading has
little need for an arbitrary length limitation (however crazy it might
be to have longer arguments).

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dave Reisner 7054e37126 sync: add missing newline in warning message
Dan: fix the other missing one too.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-06 08:43:23 -05:00
Dan McGee d88e524e7c Be fully silent on any -Sp operation
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:44:45 -05:00
Pang Yan Han 2c5f000d5b Improve advice for sync ops when db.lck is present
When the database is locked, sync operations involving transactions, such as
pacman -Syy, show the following:

:: Synchronizing package databases...
error: failed to update core (unable to lock database)
error: failed to update extra (unable to lock database)
error: failed to update community (unable to lock database)
error: failed to update multilib (unable to lock database)
error: failed to synchronize any databases

Whereas pacman -U <pkg> shows:

error: failed to init transaction (unable to lock database)
  if you're sure a package manager is not already
  running, you can remove /var/lib/pacman/db.lck

Which is much more meaningful, since the presence of db.lck may indicate an
erroneous lockfile instead of an ongoing transaction.

Improve the error messages for sync operations by advising the user to remove
db.lck if he is sure that no package manager is running.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29 20:17:08 -05:00
Dan McGee 040083b97f Allow access to package origin data
Add new alpm_pkg_get_origin() method, use it in the front end now that
the enum constants are publicly available.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 23:41:17 -05:00
Dan McGee 87fb8f5d57 Make sync error message smarter on unfound targets
We had two issues here. One is a file with an absolute path passed to -S
results in a cryptic error message due to the database name being '\0'.
The second is not realizing you should be doing -U instead of -S. Fix
both of these to transform this:

    $ sudo pacman -S /tmp/binutils-2.21.1-2-i686.pkg.tar.xz
    error: database not found:

to this:

    $ sudo pacman -S /tmp/binutils-2.21.1-2-i686.pkg.tar.xz
    error: target not found: /tmp/binutils-2.21.1-2-i686.pkg.tar.xz
    warning: '/tmp/binutils-2.21.1-2-i686.pkg.tar.xz' is a file, did you mean -U/--upgrade instead of -S/--sync?

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 19:37:04 -05:00
Dan McGee a628feee46 Parse conflicts/provides/replaces at database load time
We did this with depends way back in commit c244cfecf6 in 2007. We
can do it with these fields as well.

Of note is the inclusion of provides even though only '=' is supported-
we'll parse other things, but no guarantees are given as to behavior,
which is more or less similar to before since we only looked for the
equals sign.

Also of note is the non-inclusion of optdepends; this will likely be
resolved down the road.

The biggest benefactors of this change will be the resolving code that
formerly had to parse and reparse several of these fields; it only
happens once now at load time. This does lead to the disadvantage that
we will now always be parsing this information up front even if we never
need it in the split form, but as these are uncommon fields and our
parser is quite efficient it shouldn't be a big concern.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 12:56:41 -05:00
Dan McGee 0903452032 Enable recursive/needed sync on SyncFirst
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:36:50 -05:00
Dan McGee 9d09c9fdf7 Attempt to fix up some of the brokenness around failed package loads
This is a bit of a mess, due to the fact that we have a progress meter
running. It is also ironic that we are in the midst of a method named
"commit" when we haven't done a damn thing yet, and can still fail hard
if either a checksum or signature is invalid or unrecognized.

Adapt the former test_md5sum method to be invoked for any of the various
failure types, which at least gives the user some indication of what
packages are failing. A second patch will be needed to actually show
worthwhile error codes, but this is going to involve modifying the
actual data passed with the callback.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 19:42:52 -05:00
Dan McGee 8fa330335f Merge branch 'maint'
Conflicts:
	lib/libalpm/dload.c
	lib/libalpm/po/fi.po
	lib/libalpm/po/libalpm.pot
	po/de.po
	po/fi.po
	src/pacman/po/pacman.pot
	src/pacman/util.c
2011-08-08 17:05:25 -05:00
Dan McGee 9929a34a6d Remove duplicate code shared between sync and upgrade
Pacman did a great job of having almost (but not quite) duplicate code
paths through the sync and upgrade code. We can use the same logic in
both upgrade in sync once the targets are resolved, so extract a
function and delete a bunch of code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-27 12:46:15 -05:00
Dan McGee 88644e181d Fix group selection entry for large inputs
Hardcoding anything always ends up burning you, and the arbitrary length
of 64 here did just that. Add the ability to reallocate the readline
buffer for longer inputs if necessary, and add other error checking as
approprate. This also plugs one small memory leak of the group
processing code selection array.

Addresses FS#24253.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-25 10:07:48 -05:00
Dan McGee 043931ca45 Rework -Si display logic
We did some funny stuff here before to allow specifying fully-qualified
package names, such as 'testing/gcc' or 'core/gcc'. However, it was done
by duplicating code, not to mention an early escape if a repository
could not be found for an early target. Something like `pacman -Si
foo/bar core/gcc' would not give expected results, although `pacman -Si
bar gcc' would.

Clean up the code, remove strncpy() usage, and clarify the error
messages a bit.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 21:38:32 -05:00
Dan McGee c748eadc80 Allow invalid sync DBs to be returned by the library
They are placeholders, but important for things like trying to re-sync a
database missing a signature. By using the alpm_db_validity() method at
the right time, a client can take the appropriate action with these
invalid databases as necessary.

In pacman's case, we disallow just about anything that involves looking
at a sync database outside of an '-Sy' operation (although we do check
the validity immediately after). A few operations are still permitted-
'-Q' ops that don't touch sync databases as well as '-R'.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee 7af0ab1cde signing: move to new signing verification and return scheme
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-05 10:13:20 -05:00
Allan McRae afc96f2ab3 Prefix _alpm_errno_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae 39262acab6 Prefix alpm_transflag_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae ca43fdd92f Prefix alpm_loglevel_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae d796d1cdda Prefix alpm_fileconflicttype_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae f1bb56cebf Rename public functions with grp in their name
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-29 15:46:49 +10:00
Allan McRae ddad400900 Rename pmerrno_t to alpm_errno_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 1fdbe79022 Rename pmgrp_t to alpm_group_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 37b6cceed4 Rename pmfileconflict_t to alpm_fileconflict_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 220842b37b Rename pmconflict_t to alpm_conflict_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 6d876f9b6b Rename pmdepmissing_t to alpm_depmissing_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 8a04bc25a1 Rename pmpkg_t to alpm_pkg_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:26:39 +10:00