Commit Graph

182 Commits

Author SHA1 Message Date
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
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
Dan McGee c748eadc80 Allow invalid sync DBs to be returned by the library
They are placeholders, but important for things like trying to re-sync a
database missing a signature. By using the alpm_db_validity() method at
the right time, a client can take the appropriate action with these
invalid databases as necessary.

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

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
Dan McGee 7af0ab1cde signing: move to new signing verification and return scheme
This gives us more granularity than the former Never/Optional/Always
trifecta. The frontend still uses these values temporarily but that will
be changed in a future patch.

* Use 'siglevel' consistenly in method names, 'level' as variable name
* The level becomes an enum bitmask value for flexibility
* Signature check methods now return a array of status codes rather than
  a simple integer success/failure value. This allows callers to
  determine whether things such as an unknown signature are valid.
* Specific signature error codes mostly disappear in favor of the above
  returned status code; pm_errno is now set only to PKG_INVALID_SIG or
  DB_INVALID_SIG as appropriate.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-05 10:13:20 -05:00
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 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 eb39a9482b Prefix alpm_pkgreason_t members with ALPM
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02 02:01:38 +10:00
Allan McRae f1bb56cebf Rename public functions with grp in their name
Using grp instead of group is a small saving at the cost of clarity.
Rename the following functions:

  alpm_option_get_ignoregrps -> alpm_option_get_ignoregroups
  alpm_option_add_ignoregrp -> alpm_option_add_ignoregroup
  alpm_option_set_ignoregrps -> alpm_option_set_ignoregroups
  alpm_option_remove_ignoregrp -> alpm_option_remove_ignoregroup
  alpm_db_readgrp -> alpm_db_readgroup
  alpm_db_get_grpcache -> alpm_db_get_groupcache
  alpm_find_grp_pkgs -> alpm_find_group_pkgs

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-29 15:46:49 +10:00
Allan McRae 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 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 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 25b7df4dab Make pmgrp_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:58:04 -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 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 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 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
Dan McGee 11fb9c7674 Merge branch 'maint'
Conflicts:
	lib/libalpm/trans.c
	src/pacman/query.c
2011-05-19 17:17:32 -05:00
Dan McGee f2c4e7e552 Coding style cleanups; add a null check
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-19 16:59:53 -05:00
Dan McGee 4d63ebe2fb Perform package verification at package load time
Both md5sum verification and PGP verification can and should be done at
package load time. This allows verification to happen as early as
possible for packages provided by filename and loaded in the frontend,
and moves more stuff out of sync_commit that doesn't really belong
there. This should also set the stage for simplified parallel loading of
packages later down the road.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-24 10:48:34 -05:00
Dan McGee 8b34aa50b9 Make dump_pkg_full a little less insane
The various "level" values were a bit crazy to decipher, and we were
doing some very interesting comparisons in certain places. Break it out
into two parameters instead so we can seperate the type from the extra
information display, and do things accordingly.

Nothing changes with the display of any of the five types we currently
show: -Si, -Sii, -Qi, -Qii, -Qip.

Something to note- we should expose the PKG_FROM enum type somehow, this
patch leaves the door open to do that quite easily.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-22 17:08:33 -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 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 efd8ae483f Merge branch 'maint'
Conflicts:
	lib/libalpm/alpm.h
	lib/libalpm/trans.c

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15 18:41:49 -05:00
Xavier Chantry 21a881ec68 pacman/query: correctly handle root files with -Qo
spotted by clang-analyzer (strcmp with NULL rpath is bad)

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15 15:30:09 -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
Dan McGee 3149a45bfb Add directory name to ownership error message
If you were doing a -Qo via xargs, it is at least nice to see what input
caused the error message to occur rather than having a bunch of plain
messages. This matches the style when we can't find the owner of a file.

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

Signed-off-by: Dave Reisner <d@falconindy.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25 09:46:36 -06:00
Allan McRae f8fdce6cb0 Read pkgcache into hash
Read the package information for sync/local databases into a pmpkghash_t
structure.

Provide a alpm_db_get_pkgcache_list() method that returns the list from
the hash object.  Most usages of alpm_db_get_pkgcache are converted to
this at this stage for ease of implementation.  Review whether these are
better accessing the hash table directly at a later stage.

Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04 09:55:45 +10:00
Dan McGee ef86da97f5 Remove need to explicitly register the local DB
Perform the cheap struct and string setup of the local DB at handle
initialization time to match the teardown we do when releasing the handle.
If the local DB is not needed, all real initialization is done lazily after
DB paths and other things have been configured anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-29 12:13:56 -06:00
Dan McGee 27e8f06e03 Query fileowner performance improvements
Clean up some of the code by doing less string copying and printing. This is
accomplished by either doing it after we know we need it, or taking
advantage of the fact that some strings never change such as the root
directory prefix. Also, fix an issue where a file at the root level (e.g.
/foobar) could not be queried.

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

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

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

I'll take a 600% increase in speed.

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

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

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 21:15:47 -06:00
Allan McRae d288240426 Update copyright years for 2011
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 18:47:37 -06:00
Dan McGee e7d5803f07 Use the plural features of gettext
Gettext has this whole 'Plural-Form' thing that until now we haven't taken
advantage of. Given that not all languages have the same plural form rules
as English, take advantage of it by defining a new _n() macro which will
normally define to ngettext(), and adjust a few messages as an example of
how to use.

There are surely other places where we do singular/plural logic without me
having noticed, so further patches are welcome to fix those up too.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-07-27 15:50:43 -05:00
Allan McRae 7f02f7cb9f Allow -Qo to perform a functional 'which'
When pacman queries the ownership of an object that is not a path, it will
check in the users PATH for a match. Implements FS#8798.

Dan: did some small refactoring and error message changes when PATH is
searched and nothing is found.

Original-patch-by: Shankar <jatheendra@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-11 12:09:43 -05:00
Dan McGee a36ff9404b Bump copyright dates to 2010
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14 19:46:59 -05:00
Xavier Chantry 1df3b91931 String improvements
Add more untranslated strings, improve consistency, etc.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-16 19:36:49 -05:00
Xavier Chantry bba234a92e query.c : return 1 when no package match
For example, if no package is outdated, -Qu will return 1.

This implements FS#15938

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-08-18 20:37:54 -05:00
Xavier Chantry 600782853a Quiet ShowSize with -Ss and -Qs
This fixes FS#15923

PS : duplicated code ftw

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-08-18 20:37:38 -05:00
Xavier Chantry 6fa5f2075a Use lstat instead of stat for -Qo
This fixes: FS#15675 - pacman can not determine ownership of dangling
symlinks

Using lstat seems more correct than stat for the -Qo operation anyway.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-25 17:25:50 -05:00
Dan McGee ca6ef852f9 New feature: files verification
This implements FS#13877. Add a new option "-Qk" which checks if all of the
files for a given package (or packages) are really on the system (i.e. not
accidentally deleted). This can be combined with filters and other display
options. It also respects both the --quiet and --verbose flags to give
varying levels of output.

Based on the original patch by Charly Coste <changaco@laposte.net>, thanks
for your work!

Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-22 20:13:53 -05:00
Dan McGee c72b4543b6 Update copyright headers and messages
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-01 02:08:33 -05:00
Dan McGee 20017354f7 Remove version information from -Qqo output
This was the only --quiet operation that showed version information; make it
consistent with the rest.

Signed-off-by: Dan McGee <dan@archlinux.org>
2009-05-11 21:43:36 -05:00
Nagy Gabor a783f3fbf1 Introduce -Qlq
With --quiet flag, -Ql doesn't print the package name, just lists the files.
I made --quiet documentation up-to-date (I also added -Sgq/-Qgq).

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-05-11 21:36:43 -05:00
Nagy Gabor 314b4462d2 -Qu rework
From now on -Qu is an "outdated package" filter on local database.
(This is a behaviour change.)

This patch fixes some memleaks and makes the code cleaner, for details see
my comment on FS#7884.

FS#11868 is implemented.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-10-31 19:46:13 -05:00
Xavier Chantry d05882db9e Rename alpm_db_get{pkg,grp}cache to alpm_db_get_{pkg,grp}cache
This is more consistent with the private functions :
_alpm_db_get_{pkg,grp}cache

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-08-25 18:10:03 -05:00
Xavier Chantry dfae7bdd52 src/pacman : rework the display_targets function.
We had a lot of duplicated code here. The code handling the showsize option
needed to be there three times :
1) for install part of -S
2) for remove part of -S (conflict removal)
3) for -R

This patch introduce a new display_targets(pkglist, install) function which
can handle the 3 cases above. We pass install == 1 for case 1), and install
== 0 for case 2) and 3).

Now we can finally get the benefit of an old patch which handled the
ShowSize option consistently in the 3 cases above, without an awful lot of
duplicated code :
http://www.archlinux.org/pipermail/pacman-dev/2008-January/011029.html

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-24 22:16:29 -05:00
Nagy Gabor 075b244be2 -Sqg and -Qqg
With --quiet, "pacman -Sg grp" and "pacman -Qg grp" don't list group names.

Note that "pacman -Qgq" and "pacman -Sggq" (without targets) still list
group names becuase their output would not be very useful without them.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-22 19:50:35 -05:00
Allan McRae 3c3cb001a4 Make all error messages use pm_fprintf
Tested using many easily generated error conditions.  Also added "malloc
failure" (conf.c) and "segmentation fault" (pacman.c) error messages for
translation.

Signed-off-by: Allan McRae <mcrae_allan@hotmail.com>
[Dan: fix trailing whitespace errors, other compilation issues]
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-11 20:05:28 -05:00
Dan McGee a13bf74979 pacman-side code cleanups
When taking a look at PATH_MAX usage, I found a few small things we can
clean up or fix.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-08 20:58:33 -05:00
Dan McGee 404e0a0e10 Add quiet printout to --owns functionality
If we specify -q/--quiet on an --owns operation, only print a matching
package name rather than the verbose human-readable message.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-06 19:49:41 -05:00
Dan McGee 5f17ac8150 Enable display of multiple groups in -Ss and -Qs output
Not too complicated of a fix, but just adds some code to loop over the
entire group list and space it out.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-30 16:41:13 -05:00
Dan McGee 4b8ada818e Fix segfault on -Qs usage
This segfault creeped in as a result of commit bf867003. We were incorrectly
assuming the group member of our package was a pmgrp_t list when in fact it
is just a string list, which caused a segfault on any -Qs operation.

Also slightly cleanup the -Ss code (which was originally correct unlike the
-Qs code).

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-30 16:36:55 -05:00
Dan McGee bf86700369 Switch pmgrp_t to dynamic allocation, general group cleanup
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-23 14:51:51 -05:00
Chantry Xavier b29838c825 Don't follow symlinks with -Qo.
Fixes FS#9473 and the issue reported there :
http://www.archlinux.org/pipermail/pacman-dev/2008-February/011061.html

Only the dirname should be resolved, not the basename.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-05 19:19:17 -06:00
Chantry Xavier aec7c13648 Rename -t --orphans to -t --unrequired (FS#9144).
It turns out the orphan name was misleading. Real orphans are packages
installed as dependency no longer required by any others (-Qtd).
The -t option only shows package not required by any others, so --unrequired
describes it better.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-10 22:58:19 -06:00
Dan McGee 9781d0d637 Update GNU GPL boilerplate and copyright dates
Update the GPL boilerplate to direct people to the GNU website for a copy of
the license, as well as bump all of Judd's copyrights to 2007.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-10 22:55:39 -06:00
Dan McGee 7249c08bdf Improve changelog handling through addition of open/read/close functions
Thanks to Allan for inspiring all this work on what was one little TODO item
in the codebase. :)

Change changelog handling so we can now dump a changelog from both installed
packages and package files (fixes FS#7371). We do this by moving all of the
machinery to the backend where it should have been in the first place.

The changelog reading is now done through a open/read/close interface
similar to the fopen/fread/fclose functions (can you guess how it is done?).
It is buffered by the frontend, so programs using the library can read as
much or as little as they want at a time.

Unfortunately, I could not implement a changelog_feof function due to some
shortcomings of libarchive. However, I left the stub code in there,
commented out, in case it becomes possible later or anyone wants to take a
stab at it.

Original-work-by: Allan McRae <mcrae_allan@hotmail.com>
Improved-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-09 11:33:08 -06:00
Chantry Xavier d683033d3e pacman/query.c : -Qo optimization.
I didn't understand why realpath was called on every files of every filelist
in query_fileowner :
ppath = resolve_path(path);

It turns out this is needed for the diverted files. For example, cddb_get
installs /usr/lib/perl5/site_perl/5.8.8/CDDB_get.pm which actually ends in
/usr/lib/perl5/site_perl/current/CDDB_get.pm .

And for making pacman -Qo /usr/lib/perl5/site_perl/current/CDDB_get.pm ,
realpath has to be called on both the target, and the file in the filelist.

However, realpath is costly, and calling it on every single file resulted
in a poor -Qo performance. Worst case :
pacman -Qo /lib/libz.so.1  0.35s user 1.51s system 99% cpu 1.864 total

So I did a little optimization to avoid calling realpath as much as
possible: first compare the basename of each file.

Result:
src/pacman/pacman -Qo /lib/libz.so.1  0.24s user 0.05s system 99% cpu 0.298
total

Obviously, the difference will be even bigger at the first run (no fs
cache), though it's quite scary on my system : 1.7s vs 40s previously.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25 16:13:56 -06:00
Artyom 1e9a1a0292 Add -q/--quiet option for controlling output.
Currently this only affects -Ss, -Sl, and -Q to output less information (only
package names).

In the future, we can reuse this flag for other things as well.

[Aaron: rewritten as a front-end flag]
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
[Dan: squashed commits together]
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25 14:33:32 -06:00
Dan McGee c36b0f32c6 Fix memleak when querying package file(s)
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25 14:12:00 -06:00
Chantry Xavier 83fa6aa289 Remove duplicated get_upgrades function, use sysupgrade instead.
The alpm_get_upgrades was exactly the same as find_replacements +
_alpm_sync_sysupgrade, except that it automatically made the eventual
replacements, without asking the user : Replace %s with %s/%s? [Y/n]

The replace question, asked in find_replacements. can now be skipped by
using a NULL trans argument, so that we get the same behavior as with
alpm_get_upgrades.

So alpm_db_get_upgrades() can now be replaced by
alpm_sync_sysupgrade(db_local, syncdbs).

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21 00:05:05 -06:00
Dan McGee 7219326dd4 Remove REQUIREDBY usage from libalpm
Instead of using the often-busted REQUIREDBY entries in the pacman database,
compute them each time they are required. This should help many things:

1. Simplify the codebase
2. Prevent future database corruption
3. Ensure when we do use requiredby, it is always correct
4. Shrink the pmpkg_t memory overhead

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14 18:49:50 -06:00
Dan McGee 5e12d3dec9 Fix display of -Qip output when a package file is given
Too many fields were being shown on -Qip output, and sizes were not always
correct (-Qi and -Qip output on the same package did not agree).

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-13 00:09:45 -06:00
Dan McGee 86ca39d15e Clean up usage of extern variables
Instead of declaring the extern variable in every *.c file, include it in
the header file that makes sense. This means handle.h for the handle, and
conf.h for the pacman side config object.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-04 12:05:22 -06:00
Dan McGee 6af7dbcf72 pacman/query.c: add missing free()
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29 23:11:49 -05:00
Nathan Jones f5b77eb989 Add download size to target list.
This displays the download size, taking into account delta files and
cached files.

This closes FS#4182.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-19 19:30:06 -05:00
Dan McGee 219808714f Add 'full' parameter to alpm_pkg_load
In most cases, we want to fully scan a package when we load it, which serves
as a integrity verification check. However, there are times when it is only
desired to read the metadata and nothing else, so allow the caller of pkg_load
to choose the behavior they need.

This pays big dividends in speeding up pacman cache cleaning functionality.
Old (729 packages):
real    1m43.717s
user    1m20.785s
sys     0m2.993s
New (729 packages):
real    0m25.607s
user    0m19.389s
sys     0m0.543s

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28 00:16:43 -05:00
Chantry Xavier 046c8a6819 Remove the DB consistency check from pacman and libalpm.
This reverts commit dfc85cb5f5
and b6f3fe6957.
This DB check is already in testdb (among others).

Also testdb now uses the db path set at make time by default,
so specifying the db path is optional.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-16 20:10:18 -05:00
Dan McGee 2f0de317b8 Make some small changes recommended by splint
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-11 20:41:42 -05:00
Chantry Xavier 0f539832f4 new query options : explicit (-Qe) and deps (-Qd).
The t shortcut for --test was removed,
the orphan option (previously -Qe) was renamed to -Qt,
-Qe lists all packages installed explictly,
and -Qd lists all packages installed as dependencies.

Besides, t can be combined with either e or d.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-15 20:21:43 -04:00
Chantry Xavier 064de149b7 libalpm/query.c : makes orphans and foreign options as filters.
The --foreign and --orphans functions now behave as a filter
for the other options. This cleans the code a bit, and will
make easier the adding of new filter options, like
explicit (show only explictly installed packages) or depends
(show only packages installed as dependencies).

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-15 20:21:18 -04:00
Andrew Fyfe fd3a1a92c8 Fix previous makepkg patch, and some pacman output.
makepkg: We still need the source files in $srcdir because PKGBUILDS need
         access to noextract() files and other file not handled by by
         extract_source(). (eg config files)

query.c: Fix some output formating.

Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
2007-07-12 15:22:16 -04:00
Chantry Xavier 4d9b5d4a2a pacman/query.c : return after a query on all packages.
Previously, the following error was displayed even after a valid
and successful query operation on all packages,
like -Q , -Ql, -Qi, -Qil :
no targets specified (use -h for help)

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-07-02 09:22:52 -04:00
Dan McGee 620a811f91 Clean up pacman/sync.c and organize it a bit
Re-add some checks for a valid target list. In addition, move variable
declarations to the most local scope possible, which should help in finding
errors that were previously uncaught.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-13 01:09:02 -04:00
Dan McGee caf6c326ec Functionalize query.c and pacman_query
Move a lot of the operations that pacman query performs into their own
functions for ease of following the flow and for possible later merges with
their sync counterparts. We need to think less in terms of operations and
more in term of overall concepts.

Also (re)introduced checks for the target list on a -Q operation, ensuring
that we only call certain query operations when it is sane to do so.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-12 23:56:26 -04:00
Dan McGee b6f3fe6957 Implement a -Qt operation in frontend to test the database
After adding a alpm_db_check() operation in the back end, we can call it
in the front end and present a user-friendly interface to it.

Inspired-by: VMiklos <vmiklos@frugalware.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-09 12:58:12 -04:00
Dan McGee f7912e9dc6 Const correctness!
Add some 'const' keywords all over the code to make it a bit more strict on
what you can and can't do with data. This is especially important when we
return pointers to the pacman frontend- ideally this would always be
untouchable data.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05 17:34:33 -04:00
Dan McGee 26e3db423a Merge branch 'alpm.c_cleanup' into frontend_config
Conflicts:

	lib/libalpm/alpm.c
2007-06-04 23:32:38 -04:00
Dan McGee 358cc5804a Rip alpm_parse_config out of libalpm
Switch over to the new frontend parseconfig.

* Fix a few issues in parseconfig
* Remove unused callback upon database registration
* Remove conf file related errors from error.c/alpm.h

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-04 23:10:49 -04:00
Dan McGee 64d36db5f4 Move functions out of alpm.c to where they belong
alpm.h is the only "publically viewable" file, so there is no reason to have
functions in alpm.c that belong in package.c, db.c, etc. Move the functions
where they belong and leave only the library init functions in alpm.c.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-04 22:52:04 -04:00
Chantry Xavier fe2c58fc92 Move parts of pacman_query into subfunctions (query_search, query_group, query_isfile)
Clean up pacman_query so functionality is actually in functions, similar to how
sync.c is organized. After doing this, it is easy to see similarity in the code
between sync.c and query.c, so we should be able to consolidate some of this.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-02 12:44:43 -04:00
Nathan Jones 80237630af Change -z|--showsize flag to ShowSize pacman.conf option
Also cleaned up some duplicate printf lines related to the ShowSize option.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-01 11:00:39 -04:00
Dan McGee 7bd2ff6851 Move DB and cache dirs away from there dependence on ROOTDIR
This change allows us to use all autoconf specified paths, most notably
$(localstatedir). It is quite a change and touches a lot of files, as
all references to the DB and cache were done with the ROOTDIR as a prefix.

* add --lock command-line option to pacman to specify the location of the
  lockfile (this can now be specified at configure time by setting the
  $localstatedir path).
* Rip quite a few settings out of configure.ac as they are now picked by
  setting the paths during configure or make.
* Fix bug with /tmp fallback for sync downloads not working correctly
  (related to root location, now the system tmp dir is used).
* Simplified the parameters to some libalpm functions, and added get/set
  for the new lockfile option.
* Renamed several of the DEFS to names without the PM_ prefix.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-31 02:51:28 -04:00
Dan McGee 722db4535a Set an error exit status on -Qi or -Si failure
Regression from 2.9.8 where a failed -Qi lookup did not return an error
on exit. The exit status is now incremented for each error encountered.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-31 01:12:17 -04:00
Chantry Xavier 51225b3263 Add -Qee option for the original behavior of -Qe
-Qee now lists "orphans" the way pacman used to - that
is, -Qe lists packages required by nothing that were
installed as a dependency, but -Qee lists all packages
not required by something else.

Also, I snuck in a compile fix for my real_path cleanup earlier, heh

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-05-20 01:20:07 -05:00
Aaron Griffin 1ef27e97a1 Fix broken resolve_path function
Removed some unneeded path munging so that our relative
paths resolve properly.  This closes FS#7068

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-05-18 01:20:49 -05:00
Nathan Jones 5c930c318e Display size for packages
This patch adds a -z|--showsize option to the -Q and -S commands. The
option displays the size of individual packages. This is something that
I have wanted for a while, and there is a feature request for it.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-14 01:22:15 -04:00
Dan McGee 34ee32d373 Clean up query_fileowner
* gotcha -> found
* line wrap changes

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-07 14:21:44 -04:00
Dan McGee 63588aff19 Remove output.c and output.h
One function was left in this set of files after the earlier cleansing, so
I moved yesno to util.c.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 19:20:46 -04:00
Dan McGee 8d46cf6651 Remove ERR calls from the code
All ERR() calls have been replaced with fprintf(stderr, ...).

Still to be done- fix all the newline issues that are sure to pop up. What fun!

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 16:23:59 -04:00
Dan McGee 961be77c93 Remove MSG output macro (#define and in code)
This is the first step of converting output to standard functions such as printf, and
eventually allowing compiliation with the -pedantic flag as is done on the libalpm
side.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 15:28:54 -04:00
Dan McGee f0304168ee Move log.c/h -> output.c/h to properly reflect what is contained
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 14:34:47 -04:00
Dan McGee 97313ba316 More pacman side cleanup
* Cleaned up more of the header #includes, and got rid of a lot of stuff
  that was due to trying to make it compile on BSD/Darwin/CYGWIN. We can
  add it later but lets keep it simple for now and do it in seperate files
  if possible later.
* Removed a lot of #define MACROS. Some were not even used, and others were
  only used a few times.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 14:34:41 -04:00
Dan McGee 7760f5fe60 Remove more unnecessary stuff
* Remove libintl.h from most files, as we only need to include it once in
  util.h where _() is defined.
* Remove other unnecessary header inclusions.
* Remove a macro that was only used once and replaced it with actual code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-25 11:07:48 -04:00
Dan McGee 5e1419c0b5 Merge single-function header files on pacman side
Having a seperate header file for add, remove, query, etc. seemed overkill.
Merge them all into a common pacman.h and fix the necessary #includes.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-25 11:07:47 -04:00