makepkg: allow empty source arrays

Necessary for metapackages.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
libalpm/db.c: default to ALPM_DB_USAGE_ALL

This allows existing front-ends other than pacman to continue working
normally.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
callback.c: check for negative xfered size

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
upgrade.c: use iterator variable

remote was being used to loop over itself, making the FREELIST
ineffective.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
check for -1 return value from getopt_long

getopt_long returns -1 when it has finished parsing all args.  A return
value of 0 indicates that a flag was set directly by getopt_long and
parsing should continue.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
alpm_handle: store lock file descriptor

There was a brief window between opening the file descriptor and
creating a stream to it.  If the process was interrupted during that
window the lock file would not be removed correctly.

The pid is no longer printed to the lock file as this was virtually
meaningless for lock files on NFS.

Fixes FS#35603

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
trans_prepare: always prepare removed packages

* allows proper combined add/remove transaction support with removal
  transaction flags honored
* adds the ability to use ALPM_TRANS_FLAG_RECURSE with sync transactions
  to remove unneeded dependencies of conflicts (but not the upgraded
  package itself)
* enforces proper ordering for removed conflicts on sync transactions

Fixes FS#9694

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>