parse_options: initialize unused_options as array

Since we treat this as an array, we need to initialize it as one. This
avoids addition of an empty element to the option string when we set the
option array from the calling program, e.g.

  +/usr/bin/makepkg[2033]: set -- -i --pkg vim -- ''

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
sync: fix crash on failed downloads

Dan was right. This should have been FREE(), not free().

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
pkgdelta: use bsdtar -q option

This matches the optimization made to repo-add in commit 8bbaf045b9ce
way back in 2009. We don't need to read the whole package file to ensure
multiple .PKGINFO entries don't exist, as well-formed packages should
have this file first in the archive.

Signed-off-by: Dan McGee <dan@archlinux.org>
pacman-key: Actually verify signatures and exit with correct codes

We cannot rely on gpg's exit code. Instead we have to check the status-fd to
figure out whether a signature is valid or not.

In addition to this pacman-key --verify can now be used in scripts as it will
return an exit code of 1 if the signature is invalid.

Signed-off-by: Pierre Schmitz <pierre@archlinux.de>
Signed-off-by: Dan McGee <dan@archlinux.org>
pkgdelta: exit 1 upon error

This has been 0 since 9fa18d9a4b4ce5217842c71d8a45676e3fb9d3f4, but it
doesn't makes sense because we are raising an error.

Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
Revert "parseopts: normalize options into an array"

This was really only half a fix for FS#28445, as it still doesn't
correctly handle the case of filenames with spaces. In the short term,
there is no obvious fix for this. In the long term, I believe the
correct decision is to rewrite the options parser to be more in line
with GNU getopt_long.

This reverts commits:
  ca4142714137b16feabac09c4cda86b0a75036f8.
  969dcddbdf9d5dbd91aa414cdd193f3fb26b644b.
4.0.3 release NEWS, version bumps, etc.

Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg.conf: enable curl's cookie engine for http

Implements FS#28098.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
pacman: show groups once with -Sg

Only displays groups that haven't appeared yet..
Previously 'pacman -Sg' iterated over syncs, printed every group.

This change does not affect '-Sgg' which still orders by sync first.

To reproduce, on a current Arch Linux with [extra] and [community]:
$ pacman -Sg|sort|uniq -c|sort -n
[...]
      1 xorg-fonts
      2 vim-plugins
      2 xfce4-goodies

Signed-off-by: Pierre <pierre@spotify.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Revert "makepkg: calculate exact total file size"

This reverts commit b264fb9e9ddcc31dc8782390309421965e507383.
With our "fix" of sleeping for BTRFS, we can go back to using `du` to
calculate total installed size.
Merge branch 'maint'

Conflicts:
	lib/libalpm/signing.c
	lib/libalpm/sync.c
makepkg: remove unused variable

Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg: devel_check(): determine vcs

Rather than prioritizing an arbitrary VCS, collect all development
directives. If there is more than one, give a warning and abort.
makepkg: devel_check(): consolidate common code
makepkg: devel_check(): set newpkgver (cleanup)

The case structure allows the syntax to focus on what's actually being
done here.
makepkg: devel_check(): cleanup for hg version

Use pushd/popd, quote args, handle some more errors
makepkg: the rhs in string comparisons should be quoted

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg: use printf rather than echo to output variable

Also make sure the strings passed to %s in printf are always quoted.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
makepkg: safely change directories

In preparation for the removal of the global error trap we need a
way to ensure changing directories succeeds.  Add a "cd_safe"
wrapper that performs the necessary check.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
Make selecting scriptlet shell work

The initial patch to implement this achieved nothing apart from
adding a configure option.  This patch makes that configure option
do what it advertises.

Note that specifing any shell apart from /bin/sh causes testsuite
failures as /bin/sh is the only shell in the testing environment.

Bug-found-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>