Commit Graph

1385 Commits

Author SHA1 Message Date
Dan McGee f55be48977 Merge branch 'maint'
Conflicts:
	lib/libalpm/alpm_list.c
2012-02-06 05:50:48 -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 52afce0a10 Update translations from Transifex
The pacman-scripts catalog is omitted here due to various newline errors
I don't have the time to fix right now.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06 05:44:35 -06:00
Andrew Gregory 216db87f99 remove.c: make "target not found" error consistent with sync.c
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06 05:36:22 -06:00
Dan McGee e01fdc3dba Add simple integer-only pow() implementation
We hardly need the complexity (or slowness) provided by the libm power
function; add a super-cheap one that suits our needs and is specialized
for the values we plan on passing in.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-03 08:56:17 -06:00
Thomas Dziedzic e8db984ce5 Fix FS#27924: don't display negative zeroes
Dan: don't compute lower bound unless needed, flip argument order so
out values are last, add param Doxygen documentation.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-03 08:56:16 -06:00
Dan McGee 4f54bde439 Merge branch 'maint'
Conflicts:
	scripts/makepkg.sh.in
2012-01-30 22:00:26 -06:00
Dan McGee 9d1e8084df Update translations
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-30 21:56:53 -06:00
Dan McGee 7b2f600d71 Update pot translation catalogs
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-30 21:49:34 -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 b3612e9cc1 Allow UseDelta option to specify a delta ratio
Rework the frontend and backend to allow passing a ratio value in for
UseDelta rather than having a hardcoded #define-d 0.7 value always used.
This is useful for those with fast connections, who would likely benefit
from tuning this ratio to lower values; it is also useful for general
testing purposes.

The libalpm API changes for this, but we do support the old config file
format with a no-value 'UseDelta' option; in this case we simply use the
old default of 0.7.

We clamp the ratio values to a sane range between 0.0 and 2.0, allowing
ratios above 1.0 for testing purposes.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 22:10:06 -06:00
Olivier Brunel 1b50223f82 util.c, rmrf(): only create string when needed
The entry's name is only used when not "." or ".." so only print the
string then.

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 22:08:03 -06:00
Allan McRae c77cec2ffc Fix missing [removal] output
Currently, a transaction is considered to be purely package removal
until the first package install is found.  This resulted in the
removed packages at the start of a combined upgrade/removal transaction
not getting the "[removal]" output.

Fixes FS#27981.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 22:02:38 -06:00
Olivier Brunel d9af1a0cf2 Fix broken output when asking question and stdin is piped
When asking question and stdin is piped, the response does not get printed out,
resulting in a missing \n and broken output (FS#27909); printing the response
fixes it.

Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 21:59:54 -06:00
Dan McGee 7b1a86b893 Remove unused strtoupper() function
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 15:32:34 -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
Dan McGee b6209b4ba4 Use fileno() in isatty() call
This was our only use of the function that had a hardcoded file
descriptor.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-12 07:47:32 -06:00
Dan McGee 4f02b98338 Merge branch 'maint'
Conflicts:
	lib/libalpm/signing.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-08 12:14:04 -06:00
Dan McGee 6f9ab22fd8 testdb: check local database for duplicate files
This adds an additional check step to find files in the local database
that claim to be owned by more than one package at once, which is
definitely not a supported setup.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-07 11:28:37 -06:00
Dan McGee a857b9c8e0 Update translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-05 17:04:42 -06:00
Dan McGee 2ce4f85f1e Convert get_update_timediff to integer return value
We don't need absolute floating point precision at all here; we can
stick to integer land and use milliseconds which are precise enough for
our purposes. This also removes most floating point math out of the
non-update code path.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 12:55:59 -06:00
Dan McGee c34b69b5c7 Convert strtrim/strlen paired calls to only strtrim
This utilizes the new return value so we don't have to find the length
of the string again.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:47:30 -06:00
Dan McGee 38143770a9 Merge branch 'maint' 2011-12-23 14:40:59 -06:00
Dave Reisner e28f321a48 pactree: cleanup register_syncs
- take advantage of the new strtrim return value
- tighten scope on line pointer

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-23 14:37:03 -06:00
Dave Reisner bec0b0c823 pactree: update with new strtrim function
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-23 14:37:03 -06:00
Dave Reisner 92216c5864 pacman/util: return size_t from strtrim
Instead of returning the same value as the parameter to this function,
return the length of the string, which can be useful to the caller when
its non-zero (e.g. to find the end of the string).

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-12-23 14:37:03 -06:00
Allan McRae d95c04945f Allow comments after repo section header in pacman.conf
Pacman assumes that the final character of a line specifing a repo
in pacman.conf is a "]".  But it did not clean whitespace from the
line after removing any comments.  So lines like:

[allanbrokeit]  # could break system

caused pacman not to recognize the repo.  Adjust config parsing to
strip comments before trimming whitespace from the end of the string.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:36:25 -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
Dave Reisner 3d4656c020 code syntax cleanup
As per HACKING file, we use 'CTRL(' rather than 'CTRL ('

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:51:59 -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
Dan McGee 074cf4cb95 pacman: process all targets on upgrade operation
If an early target fails, we stopped processing the rest of the list. We
should continue all the way through and show relevant errors for each
target if possible, and error out only at the end.

We do process all targets to check for URLs first and will error out if
some could not be processed; we then do a second loop and try to load
each target specified on the command line.

This mirrors a patch by Allan to do the same for removal operations.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:45:40 -06:00
Allan McRae 62fa0c7d8d pacman: list all unknown targets on removal operation
On a removal operation, pacman currently reports an error for the
package that is not found in the database and then exists.  Adjust
so that all unknown packages are reported.

Before:
> pacman -R foo bar
error: 'foo': target not found

After:
> pacman -R foo bar
error: 'foo': target not found
error: 'bar': target not found

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:45:40 -06:00
Dan McGee 1d98c6347c Merge branch 'maint' 2011-11-30 22:34:25 -06:00
Dan McGee f5820c8bd6 Miscellaneous post-4.0.1 updates
Some late-arriving translation updates and add the correct dates to the
index.txt releases table.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-30 22:28:13 -06:00
Dan McGee 96b3ba3470 Merge branch 'maint' 2011-11-20 21:40:50 -06:00
Florian Pritz 2141b7112d add key algo to import msg
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-20 21:40:19 -06:00
Florian Pritz 2f96067fe7 change gpg import message to resemble gpg --list-keys
Dan: const pointers, don't worry about bitfields.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-20 21:39:33 -06:00
Dan McGee 507a2d15e6 Final changes before 4.0.1 release
* Add last-minute changes to NEWS
* Don't treat '_' or '_n' special in scripts when finding translatable
  strings; this breaks with one use of `read` and a dummy _ variable

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-20 21:29:46 -06:00
Dan McGee 919b604c29 Merge branch 'maint' 2011-11-16 14:51:17 -06:00
Dan McGee c79c068fe9 Update translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-16 14:45:25 -06:00
Dan McGee f1ec3b9b10 Remove unnecessary casts in callback code
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-15 09:11:03 -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 c0ce10397a Update translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-13 22:21:02 -06:00
Dan McGee fcf0a8b203 Updates in preparation for 4.0.1 release
Bump the version, update the translation template files, and fill in
NEWS with relevant commits and changes since 4.0.0.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-13 21:55:52 -06:00
Dave Reisner 10241a6d76 add fnmatch support for HoldPkg
Adds test remove031.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-11-13 14:19:16 -05:00
Dan McGee 1a994bf180 Merge branch 'maint' 2011-11-07 09:16:10 -06:00
Dan McGee 601c808b8d Fix download progress rounding edge case
Allan's original message: Occasionally when the download rate showed
100.0 the output got messed up. This was caused by the rounding of a
number between 99.95 and 100.  Adjust the threshold to avoid this
rounding issue.

Dan: make this fix, but also show values between 0 and 9.995 with two
decimal places since we have the room.

Original-fix-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-03 09:54:33 -05:00
Dan McGee ba7a056d58 Add OPEN() and CLOSE() util macros
These wrap the normal open() and close() low-level I/O calls and ensure
EINTR is handled correctly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01 10:27:31 -05:00
Dan McGee a4ce3edf95 Merge branch 'maint' 2011-11-01 10:26:45 -05:00
Dave Reisner d98ff04cc9 src/util: link vercmp against .lo, not the .o
This seems to fix FS#26652.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01 10:25:15 -05: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 33bb7dbd35 Hide empty columns in table package list display
On -R operations, the "New Version" column is always empty, taking up
space and not really showing the user anything valuable. The same is
true on -S or -U operations for the "Old Version" column when packages
are only being installed and not upgraded.

Remove this column so we get a few screen columns back, especially now
that we show repo/packagename style output. This also makes some
adjustment to the padding logic. We no longer include padding in column
widths but it is included in the total table width. We also ensure the
last displayed column is always right aligned, even if this is not the
actual rightmost column.

Example output, before:
    $ sudo pacman -R eclipse
    checking dependencies...

    Targets (1):

    Name     Old Version  New Version   Net Change

    eclipse  3.7-1                     -194.02 MiB

    Total Removed Size:     194.02 MiB

And after:
    $ sudo pacman -R eclipse
    checking dependencies...

    Targets (1):

    Name     Old Version   Net Change

    eclipse  3.7-1        -194.02 MiB

    Total Removed Size:     194.02 MiB

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 19:29:31 -05:00
Dave Reisner 32327dc8c9 pacman: show repo name in download prompt
This only applies to the VerbosePkgLists option. Lessens the
deficiencies created by earlier work to separate download records by
repository.

Satisfies FS#26334.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 19:29:31 -05:00
Dave Reisner 6f2faf16ba sync: dont group sync records by repository
Break out the logic of finding payloads into a separate static function
to avoid nesting mayhem. After gathering all the records, download them
all at once.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 11:12:00 -05:00
Dan McGee 20a47aba8e Remove remaining usages of fprintf() from frontend
These can either be replaced with pm_printf() if they are error related,
or in the fprintf(stdout, ...) case a bare printf() will do.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 10:51:49 -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 45f86ca1ca Use stderr as output stream for pm_printf()
This matches what we now do in our backend callback function- all
debug/info/warning/error/etc. messages should be on stderr. These are
all the messages with a "warning:" or other type prefix, so does not
affect general pacman output.

This should fix the output confusion noted in FS#26555.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21 10:38:02 -05:00
Dan McGee 842c4422ed Table display: print message with warning: prefix
Use the normal error functions here rather than a bare fprintf().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17 08:28:57 -05:00
Dan McGee a33424f879 Merge branch 'maint' 2011-10-14 08:16:18 -05:00
Dan McGee dbd54c0cb9 Use fputs and putchar in callback progress display
When we have fixed strings or output, printf overhead is unnecessary.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14 08:14:44 -05:00
Dan McGee 0d2600c575 Remove -f short option for --force
This is not something that should be used on a frequent basis, and
giving it a short option encourages use without making the drawbacks
obvious. For the 1% of situations that require it, the 5 extra
keystrokes are a fair price to pay.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14 08:13:38 -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 9934052b54 Remove mcheck.h support
When was the last time anyone used this? That's what I thought.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13 20:49:24 -05:00
Dan McGee 53e525c4f3 Fix some strict 32-bit gcc warnings
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13 16:25:21 -05:00
Dan McGee 5b5b250443 Coding style cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13 15:16:59 -05:00
Dan McGee ff87046354 Merge branch 'maint'
Conflicts:
	src/pacman/util.c
2011-10-13 11:25:50 -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 61c6ae01b3 VerbosePkgLists: format table lines in i18n-compatible way
This had the unfortunate implementation detail that depended on the
strings having 1 byte == 1 column hold true. As we know, this is not at
all the case once you move past the base ASCII character set.

Reimplement this whole thing so it doesn't depend on format strings at
all. Instead, simply calculate the max column widths, and then when
displaying each row add the correct amount of padding using UTF-8 safe
string length functions.

Before:

名字        旧版本新版本  净变化 下载大小

libgee                0.6.2.1-1  0.60 MiB    0.10 MiB
libsocialweb          0.25.19-2  1.92 MiB    0.23 MiB
folks                 0.6.3.2-1  1.38 MiB    0.25 MiB

After:

名字          旧版本  新版本     净变化    下载大小

libgee                0.6.2.1-1  0.60 MiB  0.10 MiB
libsocialweb          0.25.19-2  1.92 MiB  0.23 MiB
folks                 0.6.3.2-1  1.38 MiB  0.25 MiB

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12 14:18:38 -05:00
Dan McGee 5f3629bea0 Introduce alpm_time_t type
This will always be a 64-bit signed integer rather than the variable length
time_t type. Dates beyond 2038 should be fully supported in the library; the
frontend still lags behind because 32-bit platforms provide no localtime64()
or equivalent function to convert from an epoch value to a broken down time
structure.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12 14:01:25 -05:00
Dan McGee a0d0f3f47f Final Transifex update before 4.0
We have a few incomplete translations, but these should be addressable
before the 4.0.1 maint release that is surely not that far in the
future.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12 13:42:12 -05:00
Dan McGee 8cc4ed0d63 Update translations from Transifex
In prep for the 4.0.0 release.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-11 09:07:19 -05:00
Lukas Fleischer 8f414cd040 pactree: Make error message smarter in register_syncs()
Our error message used to be very unclear when the configuration file
could not be found:

    $ ./pactree -lsr gtk
    error: failed to register sync DBs

Instead, display an accurate message and include the file name:

    $ ./pactree -lsr gtk
    error: config file /usr/local/etc/pacman.conf could not be read

Also, move the error message inside register_syncs() to allow for
differentiating between different errors that might require a handler in
the future.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-10 19:09:18 -05:00
Lukas Fleischer fb401f569e pactree: Add "--config" option
This allows for specifying an alternate configuration file path, similar
to pacman's "--config" option.

Given that there is currently no other way to tell pactree to read from
another configuration file (except for patching or symlinking), this
seems totally sensible - even if there are plans to refactor and/or
replace the standalone configuration file parser.

We do not define a short option for the sake of consistency with
pacman's set of command line options.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-10 19:09:12 -05:00
Dan McGee a8ca9b93f8 Update translation message catalogs in prep for 4.0 release
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-05 22:39:05 -05:00
Dan McGee dc7d691b20 Update translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-05 22:30:14 -05:00
Allan McRae 6dfb9d35f8 Remove redundant transaction size output
Printing all of "Installed", "Removed" and "Net Upgrade" sizes is
redundant as the difference of the first two is the last. Instead,
only print "Installed Size" and "Net Upgrade Size" when both the
installed and removed are non-zero.

This results in the following output in the following cases:
 - package installation only: Installed Size
 - package removal only: Removed Size
 - package installation involving replacement: Installed + Net Upgrade Size
 - package upgrade: Installed + Net Upgrade Size
 - combination upgrade and installation: Installed + Net Upgrade Size

Download Size remains outputted whenever something is downloaded.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-30 10:48:01 -05:00
Allan McRae 1463a9aa36 Remove redundant "removal" output in pure remove operation
Printing "[removal]" beside all package names is redundant when all
packages are being removed (i.e. when using -R).

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-09-29 13:02:02 -05:00
Dan McGee d1af9b70c8 Refactor display_targets to not be recursive
This also fixes a memory leak and makes the dual-purpose "rows" variable
go away in favor of storing the rows and non-verbose names separately.

This also fixes some potential memory leaks and/or wrong behavior due to
the config->verbosepkglists flag being flipped, which we should never be
doing.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 13:01:03 -05:00
Dan McGee a8ed39ce05 verbose package lists: remove errant debugger
Left this in as part of the last set of commits, whoops.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 10:26:53 -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 bcc6a5d72d Table format creation code cleanup
Better scoping of variables for the most part, and ensure we are using
string_length() and not strlen() as appropriate. Also refactor the
longest cell code to call string_length() a lot less; by simply using an
array of max sizes we don't have to recompute values nearly as much.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 10:17:15 -05:00
Dan McGee 1b8bb7c1cd Use unsigned types for indent width and column count
For getcols(), the functions we call return a value of type 'unsigned
short', so it makes sense for us to do the same.

string_length() is meant to behave like strlen(), so it should return
type size_t. This exposes other functions such as indentprint() which
should also be using signed return types.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 09:48:08 -05:00
Dan McGee f682cbd433 Show download sizes when using -S/--sync
We now label the old 'Size' column as 'Net Change' to reflect the
reality of what we are looking at. Sync operations now get an additional
'Download Size' column.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28 04:52:37 -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
Allan McRae 5e13b2b6af Avoid comparison between signed and unsigned types
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-26 23:04:09 -05:00
Dan McGee d26d50e664 Revamp pacman signal handler
* All errors now go to stderr, so do the same here and simplify the
  writing of the error message.
* Add SIGHUP to the handled signal list, and don't repeat code.
* Attempt to release the transaction (e.g. remove the lock file)
  for all of HUP, INT, and TERM. Signals HUP and INT respects
  transaction state, TERM will immediately terminate the process.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-26 16:02:12 -05:00
Dan McGee 43787d0067 Regenerate message catalogs and translations
We've had a bit of churn since the last time this was done.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 11:36:09 -05:00
Dan McGee a78e3e3a23 Translation file updates from Transifex
Pick up any updates before I push new source messages out to the
service.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 11:35:31 -05:00
Dan McGee 6767de5380 Add status and check for key being disabled
Because we aren't using gpgv and a dedicated keyring that is known to be
all safe, we should honor this flag being set on a given key in the
keyring to know to not honor it. This prevents a key from being
reimported that a user does not want to be used- instead of deleting,
one should mark it as disabled.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 11:14:35 -05:00
Dan McGee 0a4a5cea97 Add new import key question enum value and stub frontend function
This is for eventual use by the PGP key import code. Breaking this into
a separate commit now makes the following patches a bit easier to
understand.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:35:52 -05:00
Dan McGee 3e4749fe3e Fix signature printing in package info
pm_asprintf() does not return a length as asprintf() does. Fail. Make
sure it is not -1 as that is the only failure condition.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:34:07 -05:00
Dan McGee 361ed6a600 config parsing: add note if libcurl disabled and no XferCommand
Just a helpful warning for those users in this unenviable position.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:33:48 -05:00
Dan McGee e4690232d6 config parsing: include file and line number in more errors
Before:
    $ pacman -Si pacman
    error: invalid value for 'SigLevel' : 'FooValue'

After:
    $ ./src/pacman/pacman -Si pacman
    error: config file /etc/pacman.conf, line 88: invalid value for 'SigLevel' : 'FooValue'

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:33:43 -05:00
Dan McGee ca58e326dc Pull option names out of messages in config parsing
This allows some message reuse, as well as making it clear to
translators what *not* to translate.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:33:39 -05:00
Dan McGee 69694edd2c Check capabilities in SigLevel option parsing
Only allow turning it on if the backend library has support for it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:32:39 -05:00
Dan McGee 33f2518531 Move default siglevel value from backend to frontend
This takes the libraries hidden default out of the equation: hidden in
the sense that we can't even find out what it is until we create a
handle. This is a chicken-and-egg problem where we have probably already
parsed the config, so it is hard to get the bitmask value right.

Move it to the frontend so the caller can do whatever the heck they
want. This also exposes a shortcoming where the frontend doesn't know if
the library even supports signatures, so we should probably add a
alpm_capabilities() method which exposes things like HAS_DOWNLOADER,
HAS_SIGNATURES, etc.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-22 10:32:30 -05:00
Dan McGee 47dd315609 Fix int/size_t type in alpm_list_count() call
alpm_list_count() returns size_t, which we should use to store the
result since it is easy enough to format for printing.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 17:15:09 -05:00
Dan McGee a27f993600 Split package validation and load loops
This adds a some new callback event and progress codes for package
loading, which was formerly bundled in with package validation before.
The main sync.c loop where loading occurred is now two loops running
sequentially. The behavior should not change with this patch outside of
progress and event display; more changes will come in following patches.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dave Reisner 7eb2f0cd15 pacman/upgrade: print 'loading packages...' only once
Do this outside the loop to prevent the message from being displayed
(and pluralized!) for each individual package.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -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
Dan McGee 0f92fc5963 utils/cleanupdelta: remove unneeded syncdbpath
This variable was totally unused.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:11 -05:00
Dan McGee 95119d46d4 Flip getcwd()/chdir() for open()/fchdir() in the frontend
Just like we did in libalpm in commit 288a81d847.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-20 10:23:10 -05:00
Dave Reisner 83ee9708b1 src/util: provide strndup definitions where needed
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:58:21 -05:00
Dave Reisner c12fa4ab19 pactree: include missing ctype.h header
needed for isspace() -- avoids warnings on OSX.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-18 16:57:09 -05:00
Dave Reisner f883efe2cb pacman: add short opt '-p' for --print to -{S,R}h
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:24:55 -05:00
Dan McGee a2356d5ae3 Don't duplicate header strings
There is no need to print them into buffers; we can use the values
returned by gettext() directly without issue.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-14 17:18:07 -05:00
Dan McGee 4737a87b84 download callback: show decimal places in rate if we have room
Display now looks like this, whereas before we would have just showed
'2M/s' for the extra repository download. The cutoff is placed at 100.0
to ensure we only use 4 character slots of width (e.g. '99.9', '100').

:: Synchronizing package databases...
 testing                   39.9 KiB   470K/s 00:00 [######################] 100%
 core                      51.4 KiB   469K/s 00:00 [######################] 100%
 extra                    768.8 KiB   2.1M/s 00:00 [######################] 100%
 community-testing       1941.0   B  54.4M/s 00:00 [######################] 100%
 multilib                  26.6 KiB   458K/s 00:00 [######################] 100%
 community                449.8 KiB  1649K/s 00:00 [######################] 100%

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 13:45:59 +10:00
Dan McGee f7653e582b Move download callback static vars into function
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-11 13:45:54 +10:00
Dan McGee a03313f3f6 Print 'loading packages' message on -U operations
This will be the first thing printed when doing an upgrade. Currently
there is no output at all until we start resolving dependencies, which
can be a while in if specifying very large targets on the command line,
in which case it is nice to let the user know we are doing something.

Addresses FS#25822 in the most KISS way possible.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-08 14:14:51 -05:00
Dan McGee b961ebe16f query check: use provided filelist count instead of keeping track
We don't need to keep track of how many files are in a package now that
said value is provided to us. It also makes more sense to use size_t
here for types rather than the (hopefully never too short) int.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 20:51:35 -05:00
Dan McGee 6317db8429 Remove unnecessary cast
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-07 20:51:35 -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 7c956d5d4b Add -p/--print tip for -Q operations on filepath
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:33 -05:00
Dan McGee 98fdfa1968 Former transaction callback rename refactor
Put all the callback stuff in alpm.h in one spot, and make the following
renames for clarity with the new structure:

ALPM_TRANS_EVT_* --> ALPM_EVENT_*
ALPM_TRANS_CONV_* --> ALPM_QUESTION_*
ALPM_TRANS_PROGRESS_* --> ALPM_PROGRESS_*
alpm_option_get_convcb() --> alpm_option_get_questioncb()
alpm_option_set_convcb() --> alpm_option_set_questioncb()

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:08 -05:00
Dan McGee 37da18aee8 Move all callbacks up to the handle level
This was just disgusting before, unnecessary to limit these to only
usage in a transaction. Still a lot of more room for cleanup but we'll
start by attaching them to the handle rather than the transaction we may
or may not even want to use these callbacks.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02 21:45:03 -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
Dave Reisner 11ab9aa9f5 pacman/callback: reuse strlen calculation
Call strlen earlier in the dl progress callback, and reuse this length
to replace some heavier str*() calls with more optimized mem*()
replacements. This also gets rid of a false assumption that the ending
string will ever be longer than the original string.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-01 11:33:28 -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 515720a6fc Ensure progress callback updates if XX/YY numerator changes
We only updated if the percentage incremented and enough time had
elapsed, even though the numerator of the current/howmany fraction may
have changed. Ensure we proceed with the progress bar update in these
cases so as to not mislead the user.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29 19:56:14 -05:00
Dave Reisner b3c0ae5205 pacsort: use boolean, not binary OR operation
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-29 19:53:58 -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
Diogo Sousa 3a458783a2 Removed multiple definitions of pkgfrom_t
libalpm now exports type alpm_pkgfrom_t in alpm.h, which may be used
by frontends.

Pacman now uses alpm_pkgfrom_t instead of replicating that type (pkg_from
as was in src/pacman/package.h)

Updated API change in README.

Signed-off-by: Diogo Sousa <diogogsousa@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 23:30:10 -05:00
Dan McGee 2cfcc874b9 Better error handling out of package load method
There are many other ways to fail a package load other than "file not
found". We should also use the correct error code in this case. Clean it
up a bit in the various callers.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 19:52:41 -05:00
Dan McGee de43d00db0 Refactor signature result return format
I was trying to take a shortcut and not introduce a wrapper struct for
the signature results, so packed it all into alpm_sigresult_t in the
first iteration. However, this is painful when one wants to add new
fields or only return information regarding a single signature.

Refactor the type into a few components which are exposed to the end
user, and will allow a lot more future flexibility. This also exposes
more information regarding the key to the frontend than was previously
available.

The "private" void *data pointer is used by the library to store the
actual key object returned by gpgme; it is typed this way so the
frontend has no expectations of what is there, and so we don't have any
hard gpgme requirement in our public API.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 19:51:54 -05:00
Lukas Fleischer a2002b8f69 pacman.c: Remove redundant strdup() in parsearg_global()
config_set_arch() already calls strdup(). Remove strdup() from the
config_set_arch() invocation to avoid a memory leak.

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28 19:37:16 -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 c5982a3eb5 strtrim: don't move empty string
There were many cases where the string coming in was a blank line, e.g.
"\n\0", length 1. The trim routine starts by trimming leading spaces,
thus trimming everything. We would then proceed to do a memmove of the
NULL byte, which is completely worthless as we can just assign it
instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 17:14:19 -05:00
Dan McGee 0ee3ce70a8 Remove short/long label distinction
We only used short labels in one place, and the short label is always
the first character of the long label anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 16:09:52 -05:00
Dan McGee 73fcf17041 Slight refresh of the download progress callback
This cleans up some of the mess we have here.

* switch to long units for the download size
* omit the .0 decimal part from the download rate
* omit the almost always zero HH: from estimated time if eta_h == 0
* Display --:-- if eta_h > 99; formatting was screwed up before

The net result of this is we usually have 1 more character to use for
filename display.

Before:
 extra                   500.9K 1242.4K/s 00:00:00 [######################] 100%
 community-testing       947.0B   28.2M/s 00:00:00 [######################] 100%
 multilib                 26.5K  405.1K/s 00:00:00 [######################] 100%
 community               450.6K 1238.3K/s 00:00:00 [######################] 100%

After:
 extra                    500.9 KiB  1118K/s 00:00 [######################] 100%
 community-testing        947.0   B    23M/s 00:00 [######################] 100%
 multilib                  26.5 KiB   255K/s 00:00 [######################] 100%
 community                450.6 KiB  1211K/s 00:00 [######################] 100%

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 16:09:52 -05:00
Dan McGee 30cad47fb9 Add a few more sizes to humanize_sizes()
Because why the hell not? Exbibyte, zebibyte, and yobibyte are going in,
even though nothing bigger than the 2^60 exbibyte can be represented
using an off_t variable anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 16:09:52 -05:00
Dan McGee f0357e415c Add new 'lt' and 'zh_TW' translations from transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 16:04:41 -05:00
Dan McGee 5c48ca3239 Update existing translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-25 16:04:41 -05:00
Dan McGee a8a4395098 Retrieve default SigLevel value from backend after initial setting
This ensures we grab and use the library default once we have processed
the global SigLevel setting, but before processing the repo-specific
settings. This means the following two configs will now evaluate the
same, as the backend currently defaults to 'Optional':

Config 1:
    [options]
    # nothing here
    [repo]
    SigLevel = TrustAll

Config 2:
    [options]
    SigLevel = Optional
    [repo]
    SigLevel = TrustAll

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-23 01:06:56 -05:00
Dave Reisner c4350d90f1 pacman/util: use string_length to calculate line length
This is measuring strings that are potentially localized, so we need a
multibyte aware function to count characters instead of bytes.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:25 -05:00
Allan McRae b6914d16cc Print callback messages to stderr
Fixes FS#25099.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:01 -05:00
Dan McGee a98babbfef Print debug timestamps to same stream as rest of output
We used fprintf() elsewhere in this function, but we didn't use it on
the debug timestamp printing. Use fprintf() instead of printf() to fix
this.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:01 -05:00
Pang Yan Han 343ea81718 pacsort: correct list freeing
Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:01 -05:00
Dan McGee ffdfc82523 pacsort: ensure list is freed if size is 0
Found using: `valgrind ./src/util/.libs/lt-pacsort /dev/null`

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:01 -05:00
Pang Yan Han e9b8a7693d pacsort: correct pointer type in list_new
Pointer sizes are the same but this makes intention clearer.

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-22 08:53:01 -05:00
Dan McGee 1175702828 Update message catalogs
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 16:09:45 -05:00
Dan McGee d4a92cacc6 Update translations from Transifex
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 16:09:11 -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 f37c501657 Show 'None' in Signatures -Qip/-Si output if none found
This is to be as consistent as possible across both types of display.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 12:12:37 -05:00
Dan McGee ebb2e36cc4 Load and allow access to sha256sum
This adds a field in the package struct for this checksum type as well
as allowing access via the API to it. The frontend is now able to
display any read value. Note that this does not implement any use or
verification of the value internally.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 12:11:55 -05:00
Dave Reisner 20b5cc96be pacman/package: show presence of signature in in -Si
adds a new API method: alpm_pkg_get_base64_sig

[Dan: don't use a new header string in frontend]

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15 07:06:23 -05:00
Dan McGee c9cc2332cf pacman/query.c: avoid variable redeclaration
We were using i as the loop variable in both the inner and outer loop.
Use j in the inner loop instead for clarity.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 20:17:21 -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
Dave Reisner 6e4f695a0f pacman: remove --dbonly shortopt
This is somewhat of a dangerous option with limited use cases. Don't
advertise it as an easily accessibly option.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:29:49 -05:00
Dan McGee 725edde73f Update trust level strings in -Qi display
It makes more sense to use the same tense and construction on all of
these.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:29:49 -05:00
Dan McGee 857357f940 Allow --needed and --recursive on -U operations
Trivial to implement as the same backend machinery is used anyway.
Document it and add it to the accepted options.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:29:46 -05:00
Dan McGee f3fa77bcf1 Add -S --recursive operation
This closely matches what we had before for -R --recursive. Basically,
when specifying a target (e.g., pacman), we can now recursively pull all
dependencies, regardless of version specifiers and whether they are
already satisfied in the local database. This could be used to update
pacman on a system with an old glibc, for example, as both pacman and
glibc would get pulled into the transaction.

This is most useful with --needed to prevent needless reinstalls as
described in the man page changes.

The end goal of this change is to wire it into SyncFirst and have it be
the default mode of operation there, but that belongs in a separate
changeset.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11 11:19:04 -05:00
Dan McGee 82d45d66ca Merge branch 'maint'
Conflicts:
	src/pacman/callback.c
2011-08-09 16:24:55 -05:00
Dan McGee 76dfea6e83 Update string catalogs after string tweaks
This also pulls in some early translations we had entered in Transifex
in the last day so those would not be lost. The diffstat is huge and not
very telling as usual, as all sorts of fuzzyness switches happened this
time around for some reason.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09 16:00:48 -05:00
Dan McGee 5f38660be1 Add reason to corrupted package callback
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 19:55:44 -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 4885a7fa3a Fix divide by zero when downloading zero length files
If someone did a 'touch bogusrepo.db', we had the potential to throw a
SIGFPE or divide by zero, given that the total file size was 0 and
getting passed up to the pacman callback. Fix this so we get weird but
sane output and don't blow up when downloading:

:: Synchronizing package databases...
 core             35.7K  306.7K/s 00:00:00 [###################] 100%
 bogusrepo         0.0K    0.0K/s 00:00:00 [###################] 100%

Exception as seen in gdb:

Program received signal SIGFPE, Arithmetic exception.
0x000000000040cc73 in cb_dl_progress (filename=0x619dfc "bogusrepo.db", file_xfered=0, file_total=0) at callback.c:584
584             file_percent = (file_xfered * 100) / file_total;

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 18:18:09 -05:00
Dan McGee 9a40927533 Update all translation files
This moves us toward staring translations for the 4.0.0 release,
although this should not be interpreted as a string freeze by any means.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 17:17:15 -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
Dave Reisner 1d37c19e04 mark option structs as const
These are never modified and even getopt_long's prototype shows this
modifier on the parameter.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:50:03 -05:00
Dave Reisner b283a1e065 src/util/Makefile.am: alphabetize targets
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:49:49 -05:00
Dave Reisner 0b57da2a43 pacsort: add new utility
pacsort is a command line sorting utility that implements libalpm's
alpm_pkg_vercmp algorithm.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 16:49:43 -05:00
Dan McGee 07a1292721 Check return value of rename() calls
We did a good job checking this in add.c, but not necessarily anywhere
else. Fix this up by adding checks into dload.c, remove.c, and conf.c in
the frontend. Also add loggers where appropriate and make the message
syntax more consistent.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-08 13:29:45 -05:00
Dan McGee b03b06cfd3 Implement parsing of the new SigLevel directive
Add code to conf.c that parses the new SigLevel directive. An
overwhelming number of options are presented, but most users will still
be fine with the Never/Optional/Required trio. More advanced users can
combine these or any of the other options on a 'SigLevel = ' line, which
is parsed in a left-to-right fashion and flags turned on and off
accordingly. For example, all three of these will net the same config:

    SigLevel = Required PackageOptional
    SigLevel = Optional DatabaseRequired
    SigLevel = DatabaseRequired PackageOptional

Additionally, database-specific lines assume you wish to start with any
global default that has been set. For example, if any of the above lines
were in the [options] section, something such as:

    SigLevel = PackageRequired PackageAllowMarginal

Would continue to enforce required database signatures.

Inspiration-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-02 08:25:09 -04:00
Dan McGee 66d9995711 Revamp signing checks
This ensures we are actually making correct use of the information gpgme
is returning to us. Marginal being allowed was obvious before, but
Unknown should deal with trust level, and not the presence or lack
thereof of a public key to validate the signature with.

Return status and validity information in two separate values so check
methods and the frontend can use them independently. For now, we treat
expired keys as valid, while expired signatures are invalid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-28 18:46:52 -05:00
Dan McGee aecd0740cf Tidy up testdb to match coding styles
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-28 15:01:39 -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 bb3dada871 Convert package filelists to an array instead of linked list
This accomplishes quite a few things with one rather invasive change.

1. Iteration is much more performant, due to a reduction in pointer
   chasing and linear item access.
2. Data structures are smaller- we no longer have the overhead of the
   linked list as the file struts are now laid out consecutively in
   memory.
3. Memory allocation has been massively reworked. Before, we would
   allocate three different pieces of memory per file item- the list
   struct, the file struct, and the copied filename. What this resulted
   in was massive fragmentation of memory when loading filelists since
   the memory allocator had to leave holes all over the place. The new
   situation here now removes the need for any list item allocation;
   allocates the file structs in contiguous memory (and reallocs as
   necessary), leaving only the strings as individually allocated. Tests
   using valgrind (massif) show some pretty significant memory
   reductions on the worst case `pacman -Ql > /dev/null` (366387 files
   on my machine):

   Before:
     Peak heap:   54,416,024 B
	 Useful heap: 36,840,692 B
	 Extra heap:  17,575,332 B

   After:
     Peak heap:   38,004,352 B
	 Useful heap: 28,101,347 B
	 Extra heap:   9,903,005 B

Several small helper methods have been introduced, including a list to
array conversion helper as well as a filelist merge sort that works
directly on arrays.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-21 15:04:30 -05:00
Dave Reisner f1d25ba2dd pacman/callback: show .sig suffix on sig download
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-18 21:01:12 -05:00
Dan McGee 8f72ffbc45 Make alpm_db_set_pkgreason() arguments more sane
This can only ever operate on the local database, and a local package at
that. Change the function signature to take a handle and package object,
add the relevant asserts, and ensure the frontend can detect the package
not found condition when finding packages to pass to this method.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-14 15:59:57 -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
Florian Pritz 36474af463 fix segfault if pacman.conf can't be read
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 21:36:46 -05:00
Dan McGee ae7139adcf Remove most usages of strncmp()
The supposed safety blanket of this function is better handled by
explicit length checking and usages of strlen() on known NULL-terminated
strings rather than hoping things fit in a buffer. We also have no need
to fully fill a PATH_MAX length variable with NULLs every time as long
as a single terminating byte is there. Remove usages of it by using
strcpy() or memcpy() as appropriate, after doing length checks via
strlen().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 21:29:02 -05:00
Allan McRae 97103f860d Remove alpm_list_first
The only thing this accessor did was remove the const qualifier
given our entire list implementation requires passing around the
head anyway.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:22:05 -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 07502f2d82 Allow frontend access to signature verification information
Show output in -Qip for each package signature, which includes the UID
string from the key ("Joe User <joe@example.com>") and the validity of
said key. Example output:

Signatures     : Valid signature from "Dan McGee <dpmcgee@gmail.com>"
                 Unknown signature from "<Key Unknown>"
                 Invalid signature from "Dan McGee <dpmcgee@gmail.com>"

Also add a backend alpm_sigresult_cleanup() function since memory
allocation took place on this object, and we need some way of freeing
it.

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
Dan McGee 1ce7f39ad7 Merge remote-tracking branch 'allan/ALPM'
Conflicts:
	lib/libalpm/be_local.c
	lib/libalpm/be_package.c
	lib/libalpm/conflict.c
	lib/libalpm/diskspace.c
	lib/libalpm/dload.c
	lib/libalpm/remove.c
2011-07-03 14:44:57 -05:00
Dan McGee 6a6fc3107f Move alpm filelists to a struct object
This allows us to capture size and mode data when building filelists
from package files. Future patches will take advantage of this newly
available information, and frontends can use it as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03 14:29:30 -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 bd88a8d551 Prefix alpm_transprog_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae 495ba26e63 Prefix alpm_transconv_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:39 +10:00
Allan McRae 3189d3bc4a Prefix alpm_transevt_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 eb39a9482b Prefix alpm_pkgreason_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Dave Reisner 98a2fc8deb pacman: return with 128+signum on signaled exit
This is a convention that is widely followed in *nix and posix-ish
environments. We should follow it, too.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 12:43:57 -05:00
Dan McGee b94e8ecd1f Fix a few warnings pointed out via clang scan-build
Some of these are legit (the backup hash NULL checks), while others are
either extemely unlikely or just impossible for the static code
analysis to prove, but are worth adding anyway because they have little
overhead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-30 11:51:36 -05: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 1059df7486 Rename pmtransprog_t to alpm_transprog_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 565e167356 Rename pmtransconv_t to alpm_transconv_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 011ef6be0e Rename pmtransevt_t to alpm_transevt_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 590a8fcb1e Rename pmtransflag_t to alpm_transflag_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae 0aef91bc4f Rename pmloglevel_t to alpm_loglevel_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:24 +10:00
Allan McRae cd1e39ba62 Rename pmbackup_t to alpm_backup_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +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 9540dfc4d9 Rename pmdepend_t to alpm_depend_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
Allan McRae 939d5a9511 Rename pmdb_t to alpm_db_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:16:12 +10:00
Allan McRae 64c1cf7921 Rename pmhandle_t to alpm_handle_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:04:00 +10:00
Allan McRae 7ce674491b Rename pmpkgreason_t to alpm_pkgreason_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 13:54:04 +10:00
Dan McGee f01c6f814a Fix several -Wshadow warnings
Only one of these looked like a real red flag, in find_requiredby(), but
it doesn't hurt to fix several of them up anyway.

Unfortunately, we can't turn this on universally due to things like the
sync(), remove(), etc. builtins which we often use as variable names.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-27 10:10:08 -05:00
Dave Reisner 3725998cbc pactree: add -s option to walk sync DBs
Add a whole lot of bloat to parse pacman.conf and only a few lines to
use the list of sync DBs instead of the local DB.

Dan: I fully plan on this being temporary and us finding a better way in
the future to parse pacman.conf from multiple binaries. Adding a
standalone config parser is probably not the right way of going about
things, but for now it is by far the easiest.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 14:18:07 -05:00
Dave Reisner e06586ceb4 pactree: carry a list of databases for dep resolution
Declare an alpm_list which, for now, only holds our local database.
walk_deps and walk_reverse_deps are refactored to account for this, and
a helper function is added to wrap alpm_db_get_pkg for traversing a
list.

This is groundwork for letting pactree walk the sync DBs.

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 13:37:09 -05:00
Dan McGee 4f8ae2bab6 Don't require a transaction for sync DB updates
Instead, just do the required locking directly in the backend in calls
to alpm_db_update().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 04:11:38 -05:00
Dan McGee 79e98316ea Add a 'valid' flag to the database object
Start by converting all of our flags to a 'status' bitmask (pkgcache
status, grpcache status). Add a new 'valid' flag as well. This will let
us keep track if the database itself has been marked valid in whatever
fashion.

For local databases at the moment we ensure there are no depends files;
for sync databases we ensure the PGP signature is valid if
required/requested. The loading of the pkgcache is prohibited if the
database is invalid.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 03:46:12 -05:00
Dan McGee 1150d9e15a Move database 'version' check to registration time
This is another step toward doing both local database validation
(ensuring we don't have depends files) and sync database validation (via
signatures if present) when the database is registered.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 03:31:32 -05:00
Dan McGee db3b86e7f3 Do database signature checking at load time
This is the ideal place to do it as all clients should be checking the
return value and ensuring there are no errors. This is similar to
pkg_load().

We also add an additional step of validation after we download a new
database; a subsequent '-y' operation can potentially invalidate the
original check at registration time.

Note that this implementation is still a bit naive; if a signature is
invalid it is currently impossible to refresh and re-download the file
without manually deleting it first. Similarly, if one downloads a
database and the check fails, the database object is still there and can
be used. These shortcomings will be addressed in a future commit.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 02:34:50 -05:00
Dan McGee f12ead2cf2 Remove three unnecessary usages of alpm_list_count()
For the files count when loading from a package, we can keep a counter.
The two in the frontend were completely useless due to the fact that if
sync_dbs is non-NULL, alpm_list_count() will always be greater than 0.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24 01:36:47 -05:00
Dan McGee ac7d17f88e Merge branch 'po-split' 2011-06-23 23:44:35 -05:00
Dan McGee c699c0b154 src/pacman/po/: prune message catalog and translations
Now that we have performed the split, prune the catalogs of all
scripts-only messages.

All old messages were pruned from the files using the following command:
    sed -i -e '/^#\~/,$d' *.po

Note: the diff on this commit looks much less insane if the --patience
option is used.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-23 22:55:56 -05:00
Dan McGee a4a7006a13 po/: split into scripts/po/ and src/pacman/po/
This is the first step at separating the pacman message catalog and the
scripts message catalog. Makefiles, configure.ac, and other such files
are adjusted accordingly, as well as renaming files. The TEXTDOMAIN of
scripts is also adjusted.

Note that no actual pot or po files get changed here; these will get
pruned in a future commit so each catalog contains only the necessary
messages.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-23 22:50:01 -05:00
Dan McGee 54ef162a1a Convert backup list to new pmbackup_t type
This allows us to separate the name and hash elements in one place and
not scatter different parsing code all over the place, including both
the frontend and backend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-22 12:31:12 -05:00
Dave Reisner 620cddfc13 pacman/util.c: support terminals with unknown width
Add detection for stdout being attached to a tty device. When this check
fails, return a default width of 0, which callers interpret to mean
"don't wrap". Conversely, when our term ioctl suceeds but returns 0, we
interpret this to mean a tty with an unknown width (e.g., a serial
console), in which case we default to a sane value of 80.

Signed-off-by: Dave Reisner <d@falconindy.com>
2011-06-20 00:11:46 -05:00
Dan McGee 25b7df4dab Make pmgrp_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:58:04 -05:00
Dan McGee 7f6c1a76c6 Make pmdepend_t and pmdepmissing_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:33 -05:00
Dan McGee 19fcc74016 Make struct pmconflict_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:30 -05:00
Dan McGee bdf00d3dbd Make pmfileconflict_t type public
This removes the need to write accessor methods for every type we have,
and simplifies the API. Any type that doesn't need magic* can be
converted in this fashion to make it easier for frontend applications to
use, as well as make it less of a pain to introduce new such structs in
the future.

* "magic" meaning something like pmpkg_t where values can be lazy loaded.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:06 -05:00
Dan McGee 1cd6515af0 API: change 'signaturedir' to 'gpgdir'
This is more in line with reality and what we have our makepkg, etc.
options named anyway.

Original-patch-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15 12:02:29 -05:00
Dan McGee 5f404f2cb7 Merge branch 'maint' 2011-06-15 09:16:08 -05:00
Jakob Gruber e92083798c Ensure humanize_size works for negative values
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15 09:14:00 -05:00
Jakob Gruber 5b33f48389 Use pm_fprintpf in table_create_format
Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15 09:13:51 -05:00
Dan McGee 6eee3f6781 list_display: fix incorrect assignment
Commit 895a888865 erroneously left this around.

Noticed-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-15 09:11:47 -05:00
Dan McGee be97276735 Avoid setting sigverify option twice
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 09:32:39 -05:00
Dan McGee fbb44a6e0d Merge branch 'maint'
Conflicts:
	doc/makepkg.conf.5.txt
2011-06-14 08:29:39 -05:00
Dan McGee 00a1b1deeb Remove alpm_db_get_url()
This method is old, it doesn't adequately check for a NULL server list,
and can easily be done using better API method we provide these days.
All former users of this method can get similar results by calling
alpm_db_get_servers() and using the data from the returned server list.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14 08:26:58 -05:00
Dan McGee a775530941 conf: do batch processing of repo sections
We now parse an entire repo section and store all information about it.
When the next section is encountered or the end of the root config file
is reached, we will then process the stored information.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:37 -05:00
Dan McGee c730ca5997 conf: _parseconfig() cleanups and documentation
* Function doxygen documentation
* Reuse a single strlen() call
* Prevent infinite recursion (limit to 10 levels)
* Other small cleanups

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:37 -05:00
Dan McGee 29ea0fa09f Always pass data to trans_commit()
Even though we currently don't use it here in the backend, we might as
well pass it in since we used it earlier.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:41:16 -05:00
Dan McGee e2aa952689 Move pm_errno onto the handle
This involves some serious changes and a very messy diff, unfortunately.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:38:38 -05:00
Dan McGee 8b62d9bc0a Add handle argument to two more alpm methods
This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee 70a86c14f4 Require handle for alpm_checkconflicts()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee d76341297a Require handle for alpm_pkg_load()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee fb3ad7f882 Add handle argument to alpm_(add|remove)_pkg()
This makes these functions consistent with the rest of the transaction
related API calls. We do an additional assert to ensure the handle
attached to the package is the same as the handle passed in.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:32:59 -05:00
Dan McGee c5761bfe41 Fix all current return(x) usages
A few of these snuck in as of late, some from the table display patches
that were using the previous format before we changed it after the 3.5.X
major release.

Noticed-by: Kerrick Staley <mail@kerrickstaley.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 17:43:11 -05:00
Dan McGee 895a888865 Fix list_display on non-ttys and other output fixes
commit c1f742d775 broke what was one of the tenants of out output-
if piping pacman output somewhere else, we shouldn't ever try to
line-wrap and indent print our output. This makes it easier for tools to
use output from pacman -Ss, -Qs, -Qi, etc. list_display() unfortunately
was given a default value of 80 rather than 0, so fix this.

Next, make some additional changes that ensure we don't insert an
unnecessary blank line if for some crazy reason the indent level (such
as on -Qi output) is greater than the number of columns. Accomplish this
by printing the first item unconditionally as we do in
list_display_linebreak().

Finally, teach indentprint to not wrap if the number of columns is less
than the indent level, this prevents some forms of ridiculous output
such as the following:

    Install Date   : Wed
                     08
                     Jun
                     2011
                     04:39:19
                     AM
                     CDT

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 17:04:35 -05:00
Dan McGee ff8e519d4b Require handle for alpm_sync_sysupgrade()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee 7d27cf8364 Require handle for alpm_db_register_sync()
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee 24000b83c9 Require handle argument to all alpm_trans_*() methods
Begin enforcing the need to pass a handle. This allows us to remove one
more extern handle declaration from the backend.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee 17a6ac5675 Require handle argument to all alpm_option_(get|set)_*() methods
This requires a lot of line changes, but not many functional changes as
more often than not our handle variable is already available in some
fashion.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee 7968d30510 Require handle argument to alpm_logaction()
This is the first in a series of patches to update the API to remove the
implicit global handle variable.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:24:45 -05:00
Dan McGee e826c143d3 Kill all remaining 'PATH_MAX + 1' usages
The few remaining instances were utilized for buffers in calls to
snprintf() and realpath(). Both of these functions will always ensure
the returned value is padded with '\0', so there is no need for the
extra byte.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09 14:16:55 -05:00
Allan McRae 45fe92bf39 Remove incorrect output with download only and IgnorePkg
When only downloading a package that is in IgnorePkg, pacman
incorrectly asks about installing.

e.g. with <pkg> in IgnorePkg in pacman.conf:

> pacman -Sddw <pkg>
:: <pkg> is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n]

This output is now silenced when downloading only.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-08 15:34:47 +10:00