rpcaptcache: Use given version for install/upgrade

In mark_install and mark_upgrade, set the candidate to the given
version, if not set to None.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Pass allowed statuses directly to set_busy

This gives us more flexibility and makes the code easier to read.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
AsyncWorker: Adapt to new db.set_busy interface

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Make save_version callable with busy status

Make save_version callable only when the project status is "busy". This
allows us to save versions in AsyncWorker.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Move version saving to AsyncWorker

If we also want to save the packages and the repository used to build
the version, this might take some time, so save the version in the
background.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
rpcaptcache: Return downloaded file path

In download_binary and download_source, return the path name of the
downloaded file, so that it can be used in further processing steps.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager, AsyncWorker: Add package archive

When saving a version, create an APT repository containing all the
packages currently installed. This repository can later be used to
checkout old versions.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
AsyncWorker: Create version DB entry earlier

ElbeDB.save_version contains the check for duplicates, so we should
add the database entry before we create the package archive. Note that
the latter step might fail, so in that case delete the version from the
database again. In fact, we can even create the database entry when
enqueueing the project. This has the further advantage that the user
will see an error message immediately if there already is a version with
the current number.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
debian: Add pkgarchive.py to elbe-daemon.install

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add a method to checkout version XML files

Add checkout_version_xml, which is used to overwrite the current XML
file of a project with the file belonging to a given version.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
rpcaptcache: Make mark_install more flexible

Add two new optional parameters:
* from_user: If set to False, mark the package as automatically
  installed
* nodeps: Ignore dependencies, i.e. do not mark dependencies to be
  installed as well and do not try to fix broken packages

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ElbeProject: Add drop_rpcaptcache

Add a method to throw away the current RPCAptCache. This is needed to
properly reinitialize the cache after we changed the sources.list of the
project.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
pkgarchive: Add code to checkout package archives

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Support version checkout

Add a new AsyncWorkerJob that checks out given project versions and use
it in ProjectManager. This is done by copying the source.xml file of the
version to source.xml and then applying the full package list to the
buildenv.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
pkgarchive: Add missing 'with ep.buildenv'

Add missing 'with ep.buildenv' to checkout_binpkg_archive, so updating
the APT cache for other architectures than amd64 no longer fails.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
debian/control depend on same binary version between all elbe packages

Signed-off-by: Manuel Traut <manut@linutronix.de>

Conflicts:
	debian/control
lintian-fix: out-of-date-standards-version 3.9.5 (current is 3.9.6)

Signed-off-by: Manuel Traut <manut@linutronix.de>
fix lintian: maintainer-script-lacks-debhelper-token
debian/elbe-buildenv.postinst

Signed-off-by: Manuel Traut <manut@linutronix.de>
fix lintian: elbe-buildenv: maintainer-script-ignores-errors postinst

Signed-off-by: Manuel Traut <manut@linutronix.de>
add elbepack/debpkg.py to elbe-buildenv package

Signed-off-by: Manuel Traut <manut@linutronix.de>