rpcaptcache: Purge configs of deleted packages

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
rpcaptcache: Add update functions

Add mark_keep, update, get_marked_install, get_upgradeable and a way to
get all packages available from get_pkglist.

Signed-off-by: Markus Kreidl <mkreidl@linutronix.de>
Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Add read_current_project_log

Can be used to read the current build log into memory.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: CurrentlyBuilt -> InvalidState

Rename the exception class, as a similar condition also exists when
accessing the APT Cache directly.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Extend AsyncBuilder to support APT cache commit

An APT cache commit can take some time (depending on the number of
packages to be changed), so add functionality to AsyncBuilder to do this
in the background. Also add a buildtype parameter to
ProjectManager.build_current_project, specifing whether we want to do a
full build or just an APT cache commit.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Add package management methods

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Increase connection timeout

This is necessary to avoid the occassional "Database is locked" messages
after doing heavy I/O. In particular we had the problem that
set_build_done takes quite long after a build. If we get another query
during the transaction, this can fail as the default timeout is too short.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
RPCAptCache: Add get_changes method

Lists all package changes not yet commited.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Add apt_get_changes method

This lists all changes to the package list of the current project that
are not yet commited.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
AsyncBuilder: Add with statement for APT commit

We need the interpreter, otherwise we get following error:

Failed to exec method /usr/lib/apt/methods/http
E:Method http has died unexpectedly!, E:Sub-process http returned an error code (100), E:Method /usr/lib/apt/methods/http did not start correctly

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Rename AsyncBuilder -> AsyncWorker

This module does not only build projects, it also performs APT commits
and will handle APT cache updates.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db, ProjectManager: Rework project states

We now have following project states:

empty_project:  Fresh project, without XML file
needs_build:    Has an XML file, but has not been built before
busy:           Project is currently built or updated
build_done:     Project has been built successfully, no open changes to
                the project (e.g. package upgrades, new XML file)
build_failed:   Build has failed
has_changes:    Project has been built successfully before, but there
                are open changes that make a rebuild recommended.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Move APT update to AsyncBuilder

This might take some time because it downloads the package lists, so
move it to the AsyncBuilder. While we're at it, add the missing
with job.project.buildenv, as we need the interpreter, otherwise we fail
in the same way as we did during the commit operation.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add version management

Add methods to save, list, get and delete the source.xml file of
projects, so we can later use them to create update packages against
earlier versions of the project.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add a method to set the version of a project

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
AsyncWorker: Update fullpkg list after APT commit

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Add methods for version management

Add methods to set the version number, list versions of the current
project, create and delete version snapshots of the current project.
Next step will be to use these to generate update packages from the
current project against a previously stored version.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Fix version XML node name

In set_current_project_version, it has to be "/project/version", not
"/target/version".

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

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Method to change version descr.

Add a method to change version descriptions of the project the user is
currently working with.

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