blob: 817b6f11a73cacf18a433c6a76808b865cf0fd35 [file] [log] [blame]
Patrick Venturebf58cd62018-12-11 09:05:46 -08001/*
2 * Copyright 2018 Google Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "updater.hpp"
18
Patrick Venture00887592018-12-11 10:57:06 -080019#include <algorithm>
Patrick Ventureaf696252018-12-11 10:22:14 -080020#include <memory>
21
Patrick Venturea6586362018-12-11 18:47:13 -080022int updaterMain(BlobInterface* blob, DataInterface* handler,
Patrick Venture00887592018-12-11 10:57:06 -080023 const std::string& imagePath, const std::string& signaturePath)
Patrick Venturebf58cd62018-12-11 09:05:46 -080024{
Patrick Ventureaf696252018-12-11 10:22:14 -080025 /* TODO(venture): Add optional parameter to specify the flash type, default
26 * to legacy for now.
27 */
Patrick Venture00887592018-12-11 10:57:06 -080028 std::string goalFirmware = "/flash/image";
29
30 std::vector<std::string> blobs = blob->getBlobList();
31
32 auto blobInst = std::find(blobs.begin(), blobs.end(), goalFirmware);
33 if (blobInst == blobs.end())
34 {
35 std::fprintf(stderr, "firmware goal not found!\n");
36 return -1; /* throw custom exception. */
37 }
Patrick Ventureaf696252018-12-11 10:22:14 -080038
39 /* Get list of blob_ids, check for /flash/image, or /flash/tarball.
40 * TODO(venture) the mechanism doesn't care, but the caller of burn_my_bmc
41 * will have in mind which they're sending and we need to verify it's
42 * available and use it.
43 */
44
45 /* Call stat on /flash/image (or /flash/tarball) and check if data interface
Patrick Venture00887592018-12-11 10:57:06 -080046 * is supported.
47 */
Patrick Ventureaf696252018-12-11 10:22:14 -080048
Patrick Venturebf58cd62018-12-11 09:05:46 -080049 return 0;
50}