Commit Graph

2124 Commits

Author SHA1 Message Date
Allan McRae 3ba5391839 Allow specifying shell for running scriptlets
Some distributions insist on using bash specific commands in their
install scripts under the assumption that "sh" is a symlink to bash.
This can causes issues if (e.g.) their users what to change sh to
point at another shell, such as dash, that does not support these
features. Add a configure option to explicitly set the shell being
used to run install scripts.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-13 10:02:35 -06:00
Florian Pritz 20a16f55b3 use _alpm_access in a few more places for increased debugging info
pacman -U <pkg> returns a bogus "could not find or read package" if the
file is on a fuse file system that doesn't allow root access. Debug
output isn't very helpful here either so we should log why the access
check failed.

The other 2 checks already log something when failing so logging a more
specific error won't hurt either.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-13 10:02:02 -06:00
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 f12effc6ff alpm.h: enum cleanups, comment formatting cleanup
Don't use trailing commas in enums if people really want to use a strict
C89 compiler, and document why on earth one particular enum uses bitmask
values when it doesn't seem necessary.

With comments, shoot for more consistency. When something is a
one-liner, keep it that way and move the whole /** sequence */ to one
line. When it needs more than one line, ensure we format most of them in
a similar fashion.

Two minor function signature adjustments are made that don't change
anything other than matching the parameter name (name -> filename)
and fitting in with our coding style (type* var -> type *var).

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06 05:49:46 -06:00
Dan McGee d8e1c450a3 Remove last explicit include of config.h
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-06 05:49:40 -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
Allan McRae fcbae69fe8 Fix rare segfault on package removal
Very rarely a segfault would occur when removing a number of packages
due to a corrupted list for the local database (FS#27805, FS#28195).
This was caused by the alpm_list_msort function not correctly dealing
with the two new head node's prev values.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-31 11:22:30 -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 be038f9cb2 Remove rmrf implementation from backend
This moves the code for removal of local database entries right into
be_local.c, which was the last user of the rmrf() function we had in our
utility source file. We can simplify the implementation and make it
non-recursive as we know the structure of the local database entries.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:21:11 -06:00
Dan McGee ac239c54d0 libalpm/deps.c: access trans flags directly
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:21:05 -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
Dave Reisner 825b4ff35a lib/dload: give uniform naming to curl CB functions
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:16:49 -06:00
Dan McGee a03c35125e Fix sys/mnttab.h header include
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:15:53 -06:00
Dave Reisner 44f146f232 lib/dload: enforce usage of TCP keepalives
This is particularly important in the case of FTP control connections,
which may be closed by rogue NAT/firewall devices detecting idle
connections on larger transfers which may take 5-10+ minutes.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-23 12:14:58 -06:00
Dan McGee 1eb40c8328 Add diskspace checking support for Solaris/Illumos
Was able to get my hands on one of these boxes today, so add yet another
new way of doing this. I'm glad these calls are so standardized. This
was compile tested on Linux and Illumos and seems to still be working in
both places.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-19 16:28:04 -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
Dave Reisner 4e60b9646d fetch_url: look for files in cache before downloading
We lost this logic somewhere between the libfetch and libcurl
transition, as it existed in the internal downloader, but was pulled
back only into the sync workflow. Add a helper function that will let us
check for existance in the filecache prior to calling the downloader.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 21:56:50 -06:00
Dan McGee b426488e2b Use isdigit() rather than character range comparisons
This is safer and guaranteed to work with even exotic character sets.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-18 15:32:48 -06:00
Dan McGee 6e8ca48cbb Reorder some operations in sig check for efficiency
We don't need to open the data to be checked if we don't have a
signature to check against, so postpone that open until we know we have
either the base64_data or a valid signature file.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-12 09:31:09 -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 7f51ba99ae Fix segfaults on opening invalid archive files
"invalid" in this case simply means files that may or may not be
archives. Discovered via a `pacman -Sc` operation with delta files in
the package cache directory, but can be triggered if any file is passed
to `pacman -Ql` that isn't an archive, for instance, or if the sync
database file is not an archive.

Fix it up so we are more careful about calling archive_read_finish()
only on archives that are valid and have not already been closed, and
teach our archive open function to set the returned archive to NULL if
we aren't going to be returning something valid anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-08 11:53:22 -06:00
Dan McGee 2d794cc031 Update sync database size estimation values
As the comment states, this is more like a dartboard than science.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-07 11:28:37 -06:00
Dan McGee b7ecff160e Clean up <inttypes.h> header inclusions
In both cases we can go with the slightly leaner <stdint.h> header
include since we aren't using the print macros.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-07 11:28:37 -06:00
Dan McGee d59324c8ff Use 32-bit wide integer type in PolarSSL code
A look at what this does on 64 bit systems since we were using the
unnecessarily large 'unsigned long' type before even though it was 64
bits wide:

$ ~/bin/bloat-o-meter libalpm.so.old lib/libalpm/.libs/libalpm.so
add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-10412 (-10412)
function                                     old     new   delta
md5_finish                                   370     356     -14
sha2_finish                                  547     531     -16
md5_process                                 3762    2643   -1119
sha2_process                               20356   11093   -9263

The code size is nearly halved in the sha2 case (44% smaller code size),
and md5 gets a nice size reduction (27% smaller) as well.

We also move base64 code to <stdint.h> types as well; we can use
'uint32_t' rather than 'unsigned long' for at least two variables in the
decode function. This doesn't net the same size benefit as the hash code
case, but it is more proper.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-07 11:27:41 -06:00
Dan McGee a1437cbf1b Remove useless logger message
We don't need two log messages back-to-back about the same thing here.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-05 16:48:21 -06:00
Dan McGee def9e45aff Search for PGP subkeys in a keyserver-acceptable way
PGP keyservers are pieces of sh** when it comes to searching for
subkeys, and only allow it if you submit an 8-character fingerprint
rather than the recommended and less chance of collision 16-character
fingerprint.

Add a second remote lookup for the 8-character version of a key ID if we
don't find anything the first time we look up the key. This fixes
FS#27612 and the deficiency has been sent upstream to the GnuPG users
mailing list as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-05 16:34:51 -06:00
Dan McGee 6513b0ba59 Merge branch 'maint'
Conflicts:
	doc/Makefile.am
2012-01-02 19:44:00 -06:00
Dan McGee 0b9cd9448c pkghash improvements/modifications
This patch changes a variety of small things related to our pkghash
implementation with an eye toward performance, especially on native
32-bit systems.

* Use `unsigned int` rather than `size_t` for hash sizes. We already
  return ERANGE for any attempted creation of a hash greater than 1
  million elements, so unsigned int is more than large enough for our
  purposes. Switching to this type allows 32 bit systems to do native
  math without helper functions from libgcc.
* _alpm_pkghash_create() now internally adds extra padding for
  additional array elements, rather than that being the responsibility of
  the caller.
* #define values are moved into static const values in pkghash.c; a new
  `stride` value is also extracted (but remains set at 1).
* Division and modulus operators are removed from the normal find and
  add paths if possible. We store the upper limit of the number of
  elements in the hash so we no longer need to calculate this every
  element addition. When doing wraparound position calculations, we only
  apply the modulus operator if the value is greater than the number of
  buckets.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 19:41:42 -06:00
Dan McGee 177beb91c9 Minor optimization on likely sync package lookup
We have a name_hash value here, so add a cheap compare of it before
falling to the strcmp() call.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 13:17:44 -06:00
Allan McRae 29e94dc065 be_package.c: fix compiler warning
be_package.c: In function 'parse_descfile':
be_package.c:181:28: error: comparison between signed and unsigned
integer expressions [-Werror=sign-compare]

ptr - key + 2 is guaranteed to be > 0 so we can cast to size_t

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 12:58:51 -06:00
Dan McGee eb5cb8ec02 Remove unnecessary counters in file removal code
Now that filelist arrays know their own size, we don't need to do the
bookkeeping we used to do when they were linked lists. Remove some of
the counter variables and use math instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 12:58:51 -06:00
Dan McGee 496f7b4f64 alpm_list_msort: inline alpm_list_nth() call
This reduces the number of functions we call by log(n) in this function,
and the inlined version is trivial and barely increases the size of the
function.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 12:58:51 -06:00
Dan McGee 819c28bf8c Only compile delta regex once
This reduces the number of regcomp() calls when parsing delta entries in
the database from once per entry to once for the entire context handle
by storing the compiled regex data on the handle itself. Just as we do
with the cURL handle, we initialize it the first time it is needed and
free it when releasing the handle.

A few other small tweaks to the parsing function also take place,
including using the stack to store the transient and short file size
string while parsing it.

When parsing a sync database with 1378 delta entries, this reduces the
time of a `pacman -Sl deltas` operation by 50% from 0.22s to 0.12s.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-01-02 12:55:55 -06:00
Dan McGee 627cf6bca8 Fix delta parsing
In commit 4c5e7af32f, we changed this code to use the regex gathered
substrings. However, we failed to correctly store the delta file name
(leaking memory), as well as freeing the temporary string used to hold
the file size string.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-31 21:03:24 -06:00
Dan McGee 39cb865e71 Simplify hash function to a single multiplication
More than likely the compiler will do the three operation breakdown we
had here before (2 shifts + subtraction), but let the compiler do the
optimizations and make the actual operation more obvious. This actually
slightly shrinks the function binary size, likely due to instruction
reordering or something.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-31 21:03:24 -06:00
Dan McGee 7113ea4e08 Fix bogus string cast in search debug message
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-29 14:24:08 -06:00
Dan McGee aac639351f Remove strtrim function from backend
The last user of this was the code in the backend for loading packages,
but this no longer uses it.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:37:03 -06:00
Dan McGee a7cb150931 be_package: be more explicit parsing key/value pairs
This eliminates the need for strtrim() usage completely, instead relying
on the fact that the only allowed delimiter between key and value is the
" = " string.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:37:03 -06:00
Dan McGee 6b29374a60 Rework package removal code
Extract the actual unlinking of files into a new method, which
eliminates a goto used for flow control. Also fix up a few small issues
in the code:

* Unnecessary (unsigned long) cast, use '%zd' instead
* Total up errors returned from unlink_file calls and return to caller
* Be consistent with scriptlets- we run pre_remove on dbonly, so we
  should also run post_remove. Both can be disabled by way of the
  --noscriptlet argument.
* Don't pass an invalid pointer to oldpkg to the event callbacks;
  instead call the callback before we free the object.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-23 14:37:03 -06:00
Diogo Sousa 7b2f68cc21 Created hex_representation() in lib/libalpm/util.c
Used in alpm_compute_md5sum() and alpm_compute_sha256sum().

Signed-off-by: Diogo Sousa <diogogsousa@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21 18:13:17 -06:00
Dave Reisner d6ccd44390 include config.h via Makefiles
Ensures that config.h is always ordered correctly (first) in the
includes. Also means that new source files get this for free without
having to remember to add it.

We opt for -imacros over -include as its more portable, and the
added constraint by -imacros doesn't bother us for config.h.

This also touches the HACKING file to remove the explicit mention of
config.h as part of the includes.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21 18:13:17 -06:00
Dan McGee ee96900605 Don't check diskspace when using --dbonly
Mostly a waste of time. Sure, we no longer make sure your pacman
database partition has enough space, but if you are using this option
you better know what you are doing anyway.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21 16:42:47 -06:00
Dave Reisner 71164b76c4 sync: avoid checking file conflicts with --dbonly
Scratches my own itch from FS#25667

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-13 10:44:37 -06:00
Dave Reisner 4c5e7af32f delta: use regex substring matching
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-13 10:44:28 -06:00
Dan McGee 370c873be5 Calculate root length only once when checking for file conflicts
It is quite easy to hoist this potentially repeated computation out of
the loop; even if we don't end up using it, it is super cheap to do it
only once.

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 13:05:10 -06:00
Dave Reisner 8c8f043717 lib/conflict: save strlen call by reusing snprintf return
The return should probably be checked to ensure its not longer than
PATH_MAX, but I have no idea what the correct behavior is when that
happens.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12 12:56:48 -06:00