Remove libcurl support from update_engine_sideload.
While sideloading an update from recovery we don't need nor want to
download payload from HTTP(S) URLs, only local file:// are supported.
This patch moves libcurl_http_fetcher and certificate_checker files out
of libpayload_consumer dropping the libcurl and libssl dependencies from
it and the update_engine_sideload.
Bug: 27178350
TEST=build UE for Brillo and Android. Unittests still pass and
update_engine_sideload doesn't link to libcurl.
Change-Id: Iffefdb094654f7277dc825c041fe55aac9ee8756
diff --git a/Android.mk b/Android.mk
index bf84547..10335e4 100644
--- a/Android.mk
+++ b/Android.mk
@@ -146,14 +146,11 @@
$(ue_update_metadata_protos_exported_static_libraries)
ue_libpayload_consumer_exported_shared_libraries := \
libcrypto \
- libcurl-host \
- libssl \
$(ue_update_metadata_protos_exported_shared_libraries)
ue_libpayload_consumer_src_files := \
common/action_processor.cc \
common/boot_control_stub.cc \
- common/certificate_checker.cc \
common/clock.cc \
common/constants.cc \
common/cpu_limiter.cc \
@@ -163,7 +160,6 @@
common/http_common.cc \
common/http_fetcher.cc \
common/hwid_override.cc \
- common/libcurl_http_fetcher.cc \
common/multi_range_http_fetcher.cc \
common/platform_constants_android.cc \
common/prefs.cc \
@@ -250,7 +246,9 @@
libexpat \
libbrillo-policy \
libhardware \
+ libcurl \
libcutils \
+ libssl \
$(ue_libpayload_consumer_exported_shared_libraries) \
$(ue_update_metadata_protos_exported_shared_libraries)
ifeq ($(local_use_dbus),1)
@@ -304,11 +302,13 @@
$(ue_update_metadata_protos_exported_shared_libraries)
LOCAL_SRC_FILES := \
boot_control_android.cc \
+ certificate_checker.cc \
common_service.cc \
connection_utils.cc \
daemon.cc \
hardware_android.cc \
image_properties_android.cc \
+ libcurl_http_fetcher.cc \
metrics.cc \
metrics_utils.cc \
omaha_request_action.cc \
@@ -388,7 +388,9 @@
libbinderwrapper \
libbrillo-binder \
libcutils \
+ libcurl \
libhardware \
+ libssl \
libutils
include $(CLEAR_VARS)
@@ -417,9 +419,11 @@
binder_bindings/android/os/IUpdateEngineCallback.aidl \
binder_service_android.cc \
boot_control_android.cc \
+ certificate_checker.cc \
daemon.cc \
daemon_state_android.cc \
hardware_android.cc \
+ libcurl_http_fetcher.cc \
network_selector_android.cc \
proxy_resolver.cc \
update_attempter_android.cc \
@@ -486,7 +490,9 @@
bspatch
LOCAL_CPP_EXTENSION := .cc
LOCAL_CLANG := true
-LOCAL_CFLAGS := $(ue_common_cflags)
+LOCAL_CFLAGS := \
+ $(ue_common_cflags) \
+ -D_UE_SIDELOAD
LOCAL_CPPFLAGS := $(ue_common_cppflags)
LOCAL_LDFLAGS := $(ue_common_ldflags)
LOCAL_C_INCLUDES := \
@@ -938,10 +944,10 @@
$(ue_common_shared_libraries) \
$(ue_libpayload_generator_exported_shared_libraries:-host=)
LOCAL_SRC_FILES := \
+ certificate_checker_unittest.cc \
common/action_pipe_unittest.cc \
common/action_processor_unittest.cc \
common/action_unittest.cc \
- common/certificate_checker_unittest.cc \
common/cpu_limiter_unittest.cc \
common/fake_prefs.cc \
common/file_fetcher_unittest.cc \
diff --git a/common/certificate_checker.cc b/certificate_checker.cc
similarity index 98%
rename from common/certificate_checker.cc
rename to certificate_checker.cc
index 86df950..6e886e7 100644
--- a/common/certificate_checker.cc
+++ b/certificate_checker.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
#include <string>
diff --git a/common/certificate_checker.h b/certificate_checker.h
similarity index 97%
rename from common/certificate_checker.h
rename to certificate_checker.h
index c785192..5d0b5ba 100644
--- a/common/certificate_checker.h
+++ b/certificate_checker.h
@@ -14,8 +14,8 @@
// limitations under the License.
//
-#ifndef UPDATE_ENGINE_COMMON_CERTIFICATE_CHECKER_H_
-#define UPDATE_ENGINE_COMMON_CERTIFICATE_CHECKER_H_
+#ifndef UPDATE_ENGINE_CERTIFICATE_CHECKER_H_
+#define UPDATE_ENGINE_CERTIFICATE_CHECKER_H_
#include <curl/curl.h>
#include <openssl/ssl.h>
@@ -172,4 +172,4 @@
} // namespace chromeos_update_engine
-#endif // UPDATE_ENGINE_COMMON_CERTIFICATE_CHECKER_H_
+#endif // UPDATE_ENGINE_CERTIFICATE_CHECKER_H_
diff --git a/common/certificate_checker_unittest.cc b/certificate_checker_unittest.cc
similarity index 97%
rename from common/certificate_checker_unittest.cc
rename to certificate_checker_unittest.cc
index c30acc5..20efce9 100644
--- a/common/certificate_checker_unittest.cc
+++ b/certificate_checker_unittest.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
#include <string>
@@ -24,8 +24,8 @@
#include <gtest/gtest.h>
#include "update_engine/common/constants.h"
-#include "update_engine/common/mock_certificate_checker.h"
#include "update_engine/common/mock_prefs.h"
+#include "update_engine/mock_certificate_checker.h"
using ::testing::DoAll;
using ::testing::Return;
diff --git a/common/file_fetcher.cc b/common/file_fetcher.cc
index 77dadd1..d0a109b 100644
--- a/common/file_fetcher.cc
+++ b/common/file_fetcher.cc
@@ -27,7 +27,6 @@
#include <base/strings/stringprintf.h>
#include <brillo/streams/file_stream.h>
-#include "update_engine/common/certificate_checker.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/platform_constants.h"
diff --git a/common/hash_calculator_unittest.cc b/common/hash_calculator_unittest.cc
index 27dbc56..436e6a7 100644
--- a/common/hash_calculator_unittest.cc
+++ b/common/hash_calculator_unittest.cc
@@ -25,7 +25,6 @@
#include <brillo/secure_blob.h>
#include <gtest/gtest.h>
-#include "update_engine/common/libcurl_http_fetcher.h"
#include "update_engine/common/utils.h"
using std::string;
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index 6f3e480..0f34475 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -44,11 +44,11 @@
#include "update_engine/common/fake_hardware.h"
#include "update_engine/common/file_fetcher.h"
#include "update_engine/common/http_common.h"
-#include "update_engine/common/libcurl_http_fetcher.h"
#include "update_engine/common/mock_http_fetcher.h"
#include "update_engine/common/multi_range_http_fetcher.h"
#include "update_engine/common/test_utils.h"
#include "update_engine/common/utils.h"
+#include "update_engine/libcurl_http_fetcher.h"
#include "update_engine/mock_proxy_resolver.h"
#include "update_engine/proxy_resolver.h"
diff --git a/daemon_state_android.h b/daemon_state_android.h
index fc8be19..928a14e 100644
--- a/daemon_state_android.h
+++ b/daemon_state_android.h
@@ -20,8 +20,8 @@
#include <memory>
#include <set>
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/boot_control_interface.h"
-#include "update_engine/common/certificate_checker.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/prefs_interface.h"
#include "update_engine/daemon_state_interface.h"
diff --git a/common/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
similarity index 99%
rename from common/libcurl_http_fetcher.cc
rename to libcurl_http_fetcher.cc
index a222139..30ee1f3 100644
--- a/common/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -14,7 +14,7 @@
// limitations under the License.
//
-#include "update_engine/common/libcurl_http_fetcher.h"
+#include "update_engine/libcurl_http_fetcher.h"
#include <algorithm>
#include <string>
@@ -26,7 +26,7 @@
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/platform_constants.h"
diff --git a/common/libcurl_http_fetcher.h b/libcurl_http_fetcher.h
similarity index 97%
rename from common/libcurl_http_fetcher.h
rename to libcurl_http_fetcher.h
index 7101aaa..1541ea4 100644
--- a/common/libcurl_http_fetcher.h
+++ b/libcurl_http_fetcher.h
@@ -14,8 +14,8 @@
// limitations under the License.
//
-#ifndef UPDATE_ENGINE_COMMON_LIBCURL_HTTP_FETCHER_H_
-#define UPDATE_ENGINE_COMMON_LIBCURL_HTTP_FETCHER_H_
+#ifndef UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H_
+#define UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H_
#include <map>
#include <memory>
@@ -28,7 +28,7 @@
#include <base/macros.h>
#include <brillo/message_loops/message_loop.h>
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/http_fetcher.h"
@@ -265,4 +265,4 @@
} // namespace chromeos_update_engine
-#endif // UPDATE_ENGINE_COMMON_LIBCURL_HTTP_FETCHER_H_
+#endif // UPDATE_ENGINE_LIBCURL_HTTP_FETCHER_H_
diff --git a/metrics.h b/metrics.h
index bb9fa5e..7c369ee 100644
--- a/metrics.h
+++ b/metrics.h
@@ -19,7 +19,7 @@
#include <base/time/time.h>
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/constants.h"
#include "update_engine/common/error_code.h"
diff --git a/common/mock_certificate_checker.h b/mock_certificate_checker.h
similarity index 81%
rename from common/mock_certificate_checker.h
rename to mock_certificate_checker.h
index 1f55ca1..c86f502 100644
--- a/common/mock_certificate_checker.h
+++ b/mock_certificate_checker.h
@@ -14,13 +14,13 @@
// limitations under the License.
//
-#ifndef UPDATE_ENGINE_COMMON_MOCK_CERTIFICATE_CHECKER_H_
-#define UPDATE_ENGINE_COMMON_MOCK_CERTIFICATE_CHECKER_H_
+#ifndef UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
+#define UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
#include <gmock/gmock.h>
#include <openssl/ssl.h>
-#include "update_engine/common/certificate_checker.h"
+#include "update_engine/certificate_checker.h"
namespace chromeos_update_engine {
@@ -35,4 +35,4 @@
} // namespace chromeos_update_engine
-#endif // UPDATE_ENGINE_COMMON_MOCK_CERTIFICATE_CHECKER_H_
+#endif // UPDATE_ENGINE_MOCK_CERTIFICATE_CHECKER_H_
diff --git a/payload_consumer/download_action.h b/payload_consumer/download_action.h
index fc32068..285930a 100644
--- a/payload_consumer/download_action.h
+++ b/payload_consumer/download_action.h
@@ -24,8 +24,6 @@
#include <memory>
#include <string>
-#include <curl/curl.h>
-
#include "update_engine/common/action.h"
#include "update_engine/common/boot_control_interface.h"
#include "update_engine/common/http_fetcher.h"
diff --git a/real_system_state.h b/real_system_state.h
index ec17117..0964f10 100644
--- a/real_system_state.h
+++ b/real_system_state.h
@@ -25,8 +25,8 @@
#include <metrics/metrics_library.h>
#include <policy/device_policy.h>
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/boot_control_interface.h"
-#include "update_engine/common/certificate_checker.h"
#include "update_engine/common/clock.h"
#include "update_engine/common/hardware_interface.h"
#include "update_engine/common/prefs.h"
diff --git a/update_attempter.cc b/update_attempter.cc
index 5e63ef6..8afc395 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -39,17 +39,17 @@
#include <policy/libpolicy.h>
#include <update_engine/dbus-constants.h>
+#include "update_engine/certificate_checker.h"
#include "update_engine/common/boot_control_interface.h"
-#include "update_engine/common/certificate_checker.h"
#include "update_engine/common/clock_interface.h"
#include "update_engine/common/constants.h"
#include "update_engine/common/hardware_interface.h"
-#include "update_engine/common/libcurl_http_fetcher.h"
#include "update_engine/common/multi_range_http_fetcher.h"
#include "update_engine/common/platform_constants.h"
#include "update_engine/common/prefs_interface.h"
#include "update_engine/common/subprocess.h"
#include "update_engine/common/utils.h"
+#include "update_engine/libcurl_http_fetcher.h"
#include "update_engine/metrics.h"
#include "update_engine/omaha_request_action.h"
#include "update_engine/omaha_request_params.h"
diff --git a/update_attempter.h b/update_attempter.h
index af56f55..104975c 100644
--- a/update_attempter.h
+++ b/update_attempter.h
@@ -32,9 +32,9 @@
#if USE_LIBCROS
#include "update_engine/chrome_browser_proxy_resolver.h"
#endif // USE_LIBCROS
+#include "update_engine/certificate_checker.h"
#include "update_engine/client_library/include/update_engine/update_status.h"
#include "update_engine/common/action_processor.h"
-#include "update_engine/common/certificate_checker.h"
#include "update_engine/common/cpu_limiter.h"
#include "update_engine/omaha_request_params.h"
#include "update_engine/omaha_response_handler_action.h"
diff --git a/update_attempter_android.cc b/update_attempter_android.cc
index 61d2828..2de2667 100644
--- a/update_attempter_android.cc
+++ b/update_attempter_android.cc
@@ -29,7 +29,6 @@
#include "update_engine/common/constants.h"
#include "update_engine/common/file_fetcher.h"
-#include "update_engine/common/libcurl_http_fetcher.h"
#include "update_engine/common/multi_range_http_fetcher.h"
#include "update_engine/common/utils.h"
#include "update_engine/daemon_state_interface.h"
@@ -39,6 +38,12 @@
#include "update_engine/payload_consumer/postinstall_runner_action.h"
#include "update_engine/update_status_utils.h"
+#ifndef _UE_SIDELOAD
+// Do not include support for external HTTP(s) urls when building
+// update_engine_sideload.
+#include "update_engine/libcurl_http_fetcher.h"
+#endif
+
using base::Bind;
using base::TimeDelta;
using base::TimeTicks;
@@ -435,10 +440,14 @@
DLOG(INFO) << "Using FileFetcher for file URL.";
download_fetcher = new FileFetcher();
} else {
+#ifdef _UE_SIDELOAD
+ LOG(FATAL) << "Unsupported sideload URI: " << url;
+#else
LibcurlHttpFetcher* libcurl_fetcher =
new LibcurlHttpFetcher(&proxy_resolver_, hardware_);
libcurl_fetcher->set_server_to_check(ServerToCheck::kDownload);
download_fetcher = libcurl_fetcher;
+#endif // _UE_SIDELOAD
}
shared_ptr<DownloadAction> download_action(new DownloadAction(
prefs_,