blob: 1014beb62b0fc57ce118b03c5d7e46258976d7a4 [file] [log] [blame]
// Copyright 2020 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package pave
import (
"context"
"fmt"
"time"
"go.fuchsia.dev/fuchsia/src/sys/pkg/testing/host-target-testing/artifacts"
"go.fuchsia.dev/fuchsia/src/sys/pkg/testing/host-target-testing/device"
"go.fuchsia.dev/fuchsia/tools/lib/logger"
)
func PaveDevice(
ctx context.Context,
d *device.Client,
build artifacts.Build,
otaToRecovery bool,
) error {
logger.Infof(ctx, "Starting to pave device")
startTime := time.Now()
mode := device.RebootToRecovery
if otaToRecovery {
mode = device.OTAToRecovery
}
if err := d.Pave(ctx, build, mode); err != nil {
return fmt.Errorf("device failed to pave: %w", err)
}
logger.Infof(ctx, "Paving successful in %s", time.Now().Sub(startTime))
return nil
}