blob: f970080a10b95db27f7346b8afefd91050a8b944 [file] [log] [blame]
michajlo3d8925d2019-05-20 16:10:41 -07001// Copyright 2014 The Bazel Authors. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_
16#define BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_
17
18#include <string>
19#include <vector>
20
michajlo3d8925d2019-05-20 16:10:41 -070021namespace blaze {
22
michajlo6f38f342019-05-22 11:53:22 -070023// Determines the contents of the archive, storing the names of the contained
24// files into `files` and the install md5 key into `install_md5`.
25void DetermineArchiveContents(const std::string &archive_path,
michajlo6f38f342019-05-22 11:53:22 -070026 std::vector<std::string> *files,
27 std::string *install_md5);
michajlo3d8925d2019-05-20 16:10:41 -070028
michajlo6f38f342019-05-22 11:53:22 -070029// Extracts the embedded data files in `archive_path` into `output_dir`.
michajloaeae59a2020-03-27 12:21:25 -070030// It's expected that `output_dir` already exists and that it's a directory.
michajlo6f38f342019-05-22 11:53:22 -070031// Fails if `expected_install_md5` doesn't match that contained in the archive,
32// as this could indicate that the contents has unexpectedly changed.
33void ExtractArchiveOrDie(const std::string &archive_path,
34 const std::string &product_name,
35 const std::string &expected_install_md5,
36 const std::string &output_dir);
michajlo3d8925d2019-05-20 16:10:41 -070037
michajlo371a2e32019-05-23 13:14:39 -070038// Retrieves the build label (version string) from `archive_path` into
39// `build_label`.
40void ExtractBuildLabel(const std::string &archive_path,
michajlo371a2e32019-05-23 13:14:39 -070041 std::string *build_label);
michajlo97559ba2019-06-03 14:14:22 -070042
43// Returns the server jar path from the archive contents.
44std::string GetServerJarPath(const std::vector<std::string> &archive_contents);
45
michajlo3d8925d2019-05-20 16:10:41 -070046} // namespace blaze
47
48#endif // BAZEL_SRC_MAIN_CPP_ARCHIVE_UTILS_H_