rearrange id injection for signed apps (bug 875533)
Write to temp file when signing apps (bug 875535)
Also fix broken signed apps upon re-signing.