contrib: use a separate build rule for bash scripts

Treat bash scripts separately from the others to allow for a different
build rule, which is reused from the scripts/ subdir.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
contrib: rename bash scripts: .in -> .sh.in

For consistency with the scripts/ directory, ensure that all bash
scripts use the same pre-build suffix.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
validate bash scripts with 'bash -n' during build.

Use the no-exec mode of $(BASH_SHELL) to check for syntax errors in
shell scripts. Since we use the extglob feature in various places, this
requires that we pass -O extglob to the shell as well, to ensure that
the parser is armed to handle this syntax.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
configure: require bash >= 4.1 at compile time

We've unofficially agreed to raise our minimum supported bash version to
4.1, and since added features that require it. Additionally, an earlier
commit adds a syntax check to the builds of scripts/ and contrib/ which
could conceivably fail with an earlier shell. Therefore, make this a
hard requirement of the build process.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
paccache: adopt parseopts for options parsing

Add longopts and update usage. This removes the TODO item and
incorporates --help/--version into the standard option set.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
makepkg: deal with overriden package arch properly

This fixes a lot of checks done by makepkg (e.g. to see if a package
is already built and choosing which package to install).  Previously,
if a package had both "i686" and "any" versions, the "i686" one
always took precidence regardless of the value of "arch" in the
PKGBUILD for that package.  Fixes FS#27204.

Signed-off-by: Allan McRae <allan@archlinux.org>
makepkg: treat list of packages to be installed as an array

Signed-off-by: Allan McRae <allan@archlinux.org>
makepkg: Be more consistent with missing program message

Also prevent "sudo" and "su" from being translated.

Signed-off-by: Allan McRae <allan@archlinux.org>
rankmirrors: move to contrib/

This script is of questionable value, as it ranks mirrors by an
uninteresting attribute: ping. While the script itself is interesting,
people should be encouraged to rank mirrors by more useful measures,
such as actual speed, locality, or up to date-ness.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Split check steps in Makefile into multiple targets

This allows a `make -j4 check` invocation to actually run in parallel,
even though 95% of our test suite time is currently dominated by
pactest. It also allows running something like `make test-vercmp`.

Also, add some targets to the .PHONY list that belong in it.

Signed-off-by: Dan McGee <dan@archlinux.org>
util/testdb: don't return crazy error values

With some contrived examples, you could easily make testdb return a very
high error count, which could easily overflow the 8-bit unsigned integer
limit. Instead, simply return 1 or 0 based on whether errors were found.

Signed-off-by: Dan McGee <dan@archlinux.org>
be_local: write all single-valued attributes first

There isn't a whole lot of reason other than code clarity for this, but
it makes it a bit more obvious where multivalued attributes start.

Signed-off-by: Dan McGee <dan@archlinux.org>
Pointer coding style cleanups

'foo_type_t *variable' rather than 'foo_type_t* variable'.

Signed-off-by: Dan McGee <dan@archlinux.org>
libalpm: add pkg-config file

No one seems to do this "correctly", but for the sake of having an easy
method of detecting the presence and version of libalpm on a given
system, we provide a straightforward .pc file.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
zsh completion for makepkg

This adds zsh completion for makepkg to the _pacman file
in /usr/share/zsh/site-functions/. it completes makepkg and allows for
stacking of flags like -si, -sci, et cetera.

Signed-off-by: Daniel Wallace <daniel.wallace@gatech.edu>
Move short-lived realpath buffers to the stack

There is little reason here to grab 4K from the heap only to return it a
few lines later. Instead, just use the stack to hold the returned value
saving ourselves the malloc/free cycle.

Signed-off-by: Dan McGee <dan@archlinux.org>
pacman/package.c: show checksums with -Sii

These were removed entirely by f34864cc9e, but some people (myself
included) still find them useful. Revive these details, but "demote"
them, so that they're only displayed when extra sync data is requested.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg: null terminate filenames to strip

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
makepkg: remove subshelling from check_option and friends

Instead of creating a subshell for each of these checks (of which there
are many), pass in an expected value and make the check_* function do
the comparison for us, returning 0 (match), 1, (mismatch), or 127 (not
found).

For a measureable benefit, I tested this on a fairly simple package,
perl-term-readkey, and counted the number of clone(2) syscalls to try
and isolate those generated by makepkg itself, rather than the user
defined functions. Results as shown below:

  336 before
  180 after

So, roughly a 50% reduction, which makes sense given that a single
check_option() call could be up to 3 subprocesses in total.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Merge remote-tracking branch 'dave/buildsys'