blob: 8c3156a3c7106c93d5f0adc82653debf5d11799b [file] [log] [blame]
# -*- coding: utf-8 -*-
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Library for handling Chrome OS partition."""
from __future__ import print_function
import os
from chromite.lib import constants
from chromite.lib import cros_build_lib
from chromite.lib import cros_logging as logging
from chromite.lib import osutils
_STATEFUL_FILE = 'stateful.tgz'
def GenerateStatefulPayload(image_path, output_directory):
"""Generates a stateful update payload given a full path to an image.
image_path: Full path to the image.
output_directory: Path to the directory to leave the resulting output.
str: The full path to the generated file.
"""'Generating stateful update file.')
output_gz = os.path.join(output_directory, _STATEFUL_FILE)
# Mount the image to pull out the important directories.
with osutils.TempDir() as stateful_mnt, \
osutils.MountImageContext(image_path, stateful_mnt,
(constants.PART_STATE,)) as _:
stateful_dir = os.path.join(stateful_mnt, 'dir-%s' % constants.PART_STATE)
try:'Tarring up /usr/local and /var!')
'--directory=%s' % stateful_dir,
logging.error('Failed to create stateful update file')
raise'Successfully generated %s', output_gz)
return output_gz