Bug 958694: Make .state gear scoped and refactor primary cart concept

Make the .state file represent the state of a gear rather than the application
as a whole. Redefine the concept of the 'primary' cartridge as the first cartridge
installed on the gear. Add state to Runtime::Manifest to flag a cartridge as
'buildable' or 'deployable' in order to make more granular decisions related
to the build process which are unrelated to the primary cartridge concept.

Move the platform closer to cartridge level state management.

Resolve bug 958694.