Commit Graph

283 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 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 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
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 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
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
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
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 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
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 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 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
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
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 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 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 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 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
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 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
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 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
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
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
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 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 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 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 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
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 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 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 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
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
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
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 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 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 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 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 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 9d73b261cf Merge branch 'maint'
Conflicts:
	src/pacman/callback.c
2011-06-02 17:34:12 -05:00
Dan McGee 8f30e1b110 Show net upgrade size on -U/-S operations
If it is different than the raw installed size metric we already show,
compute the net upgrade size. For some sync operations, this can even be
negative if newer packages are smaller than the ones they replace
locally. Implements FS#12566.

Example:

    Targets (1): telepathy-glib-0.14.7-1

    Total Download Size:    1.07 MiB
    Total Installed Size:   15.72 MiB
    Net Upgrade Size:       -0.29 MiB

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-02 17:21:38 -05:00
Dan McGee c1f742d775 Ensure list_display works on outputs of unknown width
If getcols() returns 0, we were getting stuck before in a loop of no
return. Teach getcols() to take a default value to return if the width
is unknown, and use this everywhere as appropriate.

Also make a few other cleanups while diagnosing this issue, such as
const-ifying some variables.

Noticed-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-01 14:58:10 -05:00
Dan McGee e8a40526cb Fix warnings reported by -Wwrite-strings
These are places where we stuck a string constant in a variable not
marked as const.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-04 15:48:47 -05:00
Dan McGee 791928dc48 Header inclusion cleanup
This does touch a lot of things, and hopefully doesn't break things on
other platforms, but allows us to also clean up a bunch of crud that no
longer needs to be there.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 20:09:13 -05:00
Dan McGee 4af6c72d79 syntax: if/while statements should have no trailing space
This is the standard, and we have had a few of these introduced lately
that should not be here.

Done with:
  find -name '*.c' | xargs sed -i -e 's#if (#if(#g'
  find -name '*.c' | xargs sed -i -e 's#while (#while(#g'

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 19:47:39 -05:00
Jakob Gruber e95be3379a New VerbosePkgLists option
If enabled, displays package lists for upgrade, sync and remove
operations formatted as a table. Falls back to default list display if
insufficient terminal columns are available.

Example output:

:: Starting full system upgrade...
:: Replace libjpeg with testing/libjpeg-turbo? [Y/n]
resolving dependencies...
looking for inter-conflicts...

Remove (1):

Name     Old Version       Size

libjpeg  8.3.0-1        0.83 MB

Total Removed Size:   0.83 MB

Targets (5):

Name            Old Version  New Version       Size

libjpeg-turbo                1.1.0-1        0.20 MB
linux-firmware  20110201-1   20110227-1     8.23 MB
ncurses         5.7-4        5.8-1          0.92 MB
ppl             0.11.1-1     0.11.2-1       2.74 MB
v4l-utils       0.8.1-1      0.8.3-1        0.23 MB

Total Download Size:    12.32 MB
Total Installed Size:   58.82 MB

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 18:13:02 -05:00
Jakob Gruber 0152266dd3 Table formatted output functions
table_display takes a list of lists of strings (representing the table
cells) and displays them formatted as a table.
The exact format depends on the longest string in each column.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 17:41:13 -05:00
Jakob Gruber c3f3d0b81a Refactor display_targets for readability
Row handling is moved to its own function in preparation for verbose
package lists.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 17:33:13 -05:00
Jakob Gruber 84cfc13589 Use IEC unit prefixes
Display {KiB, MiB, ...} instead of {KB, MB, ...} since that's what's
actually being displayed.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 17:31:56 -05:00
Jakob Gruber 3c8a448a2f Add a utility function to humanize sizes
Converts the given size in bytes in two possible ways:
1) target_unit is specified (!= 0): size is converted to target unit.
2) target_unit is not specified (== '\0'): size is converted to the first
   unit which will bring size to below 2048.

If specified, label will point to the long label ('MB') if long_labels is
set or the short label ('M') if it is not.

Dan: use '\0' rather than 0 for the special value as a matter of coding
style for char variables.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 17:29:32 -05:00
Jakob Gruber dcb6fb224d Remove ShowSize option
Dan: The commit message originally referenced "VerbosePkgLists", but I'm
going to change the name of the option. In addition, this patch serves
a purpose being standalone- we should really do things like this with
-S --print and hopefully -Q --print in the future.

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20 17:13:20 -05:00
Dan McGee c5addd94e3 Merge branch 'maint'
Conflicts:
	lib/libalpm/be_sync.c
	lib/libalpm/db.c
	src/pacman/util.c
2011-04-05 00:49:30 -05:00
Dan McGee 6a8b1c4f84 Coding style cleanups
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-04 19:03:27 -05:00
Dan McGee d8d89d8d27 Ensure stdout/stderr are flushed when asking questions
Addresses FS#23492, where the question was shown without knowing what
one was answering to. Ensure we flush our output streams before printing
the question, and flush the stream on which we ask the question before
waiting for an answer.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-01 15:18:52 -05:00
Dave Reisner 9477abc359 pacman/util: flush terminal input before reading response
Addresses FS#20538

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-28 09:04:15 -05:00
Dan McGee 0303b26b1e Style change: return(x) --> return x
This was discussed and more or less agreed upon on the mailing list. A
huge checkin, but if we just do it and let people adjust the pain will
end soon enough. Rebasing should be relatively straighforward for anyone
that sees conflicts; just be sure you use the new return style if
possible.

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

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

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

// </smpl>

A macros_file was also provided with the following content:

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

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

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

Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com>
[Dan: adjust for master before VerbosePkgLists patches, fix type]
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-28 10:54:33 -06:00