AU: Remove obsolete SetBootableFlagAction.
BUG=6251
TEST=unit tests, tested on device
Change-Id: If1b28d47287abeb0a507d77aa3790fdf39d6513a
Review URL: http://codereview.chromium.org/4719002
diff --git a/SConstruct b/SConstruct
index fd98b20..f772882 100644
--- a/SConstruct
+++ b/SConstruct
@@ -261,7 +261,6 @@
payload_signer.cc
postinstall_runner_action.cc
prefs.cc
- set_bootable_flag_action.cc
simple_key_value_store.cc
split_file_writer.cc
subprocess.cc
@@ -302,7 +301,6 @@
payload_signer_unittest.cc
postinstall_runner_action_unittest.cc
prefs_unittest.cc
- set_bootable_flag_action_unittest.cc
simple_key_value_store_unittest.cc
split_file_writer_unittest.cc
subprocess_unittest.cc
diff --git a/action_processor.h b/action_processor.h
index 2618c39..8bd890b 100644
--- a/action_processor.h
+++ b/action_processor.h
@@ -29,7 +29,7 @@
kActionCodeOmahaResponseHandlerError = 3,
kActionCodeFilesystemCopierError = 4,
kActionCodePostinstallRunnerError = 5,
- kActionCodeSetBootableFlagError = 6,
+ kActionCodeSetBootableFlagError = 6, // TODO(petkov): Unused. Recycle?
kActionCodeInstallDeviceOpenError = 7,
kActionCodeKernelDeviceOpenError = 8,
kActionCodeDownloadTransferError = 9,
diff --git a/set_bootable_flag_action.cc b/set_bootable_flag_action.cc
deleted file mode 100644
index 1cec31e..0000000
--- a/set_bootable_flag_action.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "update_engine/set_bootable_flag_action.h"
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <string>
-#include <vector>
-#include "update_engine/subprocess.h"
-#include "update_engine/utils.h"
-
-using std::string;
-using std::vector;
-
-namespace chromeos_update_engine {
-
-namespace {
-const char* const kGpt = "/usr/bin/gpt";
-const ssize_t kPmbrLength = 512;
-}
-
-void SetBootableFlagAction::PerformAction() {
- ScopedActionCompleter completer(processor_, this);
-
- TEST_AND_RETURN(HasInputObject());
- const InstallPlan install_plan = GetInputObject();
- TEST_AND_RETURN(!install_plan.install_path.empty());
- const string partition = install_plan.install_path;
- string root_device = utils::RootDevice(partition);
- string partition_number = utils::PartitionNumber(partition);
-
- utils::BootLoader boot_loader;
- TEST_AND_RETURN(utils::GetBootloader(&boot_loader));
-
- // For now, only support Syslinux bootloader
- TEST_AND_RETURN(boot_loader == utils::BootLoader_SYSLINUX);
-
- string temp_file;
- TEST_AND_RETURN(utils::MakeTempFile("/tmp/pmbr_copy.XXXXXX",
- &temp_file,
- NULL));
- ScopedPathUnlinker temp_file_unlinker(temp_file);
-
- // Copy existing PMBR to temp file
- vector<char> buf(kPmbrLength);
- {
- int fd = open(root_device.c_str(), O_RDONLY);
- TEST_AND_RETURN(fd >= 0);
- ScopedFdCloser fd_closer(&fd);
- ssize_t bytes_read;
- TEST_AND_RETURN(utils::PReadAll(fd, &buf[0], buf.size(), 0, &bytes_read));
- }
- TEST_AND_RETURN(utils::WriteFile(temp_file.c_str(), &buf[0], buf.size()));
-
- // Call gpt tool to do the work
- vector<string> command;
- command.push_back(kGpt);
- command.push_back("-S");
- command.push_back("boot");
- command.push_back("-i");
- command.push_back(partition_number);
- command.push_back("-b");
- command.push_back(temp_file);
- command.push_back(root_device);
- int rc = 0;
- Subprocess::SynchronousExec(command, &rc);
- TEST_AND_RETURN(rc == 0);
-
- completer.set_code(kActionCodeSuccess);
- if (HasOutputPipe())
- SetOutputObject(GetInputObject());
-}
-
-} // namespace chromeos_update_engine
diff --git a/set_bootable_flag_action.h b/set_bootable_flag_action.h
deleted file mode 100644
index 2b45df3..0000000
--- a/set_bootable_flag_action.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__
-#define CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__
-
-#include <string>
-#include "update_engine/action.h"
-#include "update_engine/install_plan.h"
-
-// This class takes in a device via the input pipe. The device is the
-// partition (e.g. /dev/sda1), not the full device (e.g. /dev/sda).
-// It will make that device bootable by editing the partition table
-// in the root device. Currently, this class doesn't support extended
-// partitions.
-
-namespace chromeos_update_engine {
-
-class SetBootableFlagAction;
-
-template<>
-class ActionTraits<SetBootableFlagAction> {
- public:
- // Takes the device path as input.
- typedef InstallPlan InputObjectType;
- // Passes the device path as output
- typedef InstallPlan OutputObjectType;
-};
-
-class SetBootableFlagAction : public Action<SetBootableFlagAction> {
- public:
- SetBootableFlagAction() {}
- typedef ActionTraits<SetBootableFlagAction>::InputObjectType
- InputObjectType;
- typedef ActionTraits<SetBootableFlagAction>::OutputObjectType
- OutputObjectType;
- void PerformAction();
-
- // This is a synchronous action, and thus TerminateProcessing() should
- // never be called
- void TerminateProcessing() { CHECK(false); }
-
- // Debugging/logging
- static std::string StaticType() { return "SetBootableFlagAction"; }
- std::string Type() const { return StaticType(); }
-
- private:
-
- DISALLOW_COPY_AND_ASSIGN(SetBootableFlagAction);
-};
-
-} // namespace chromeos_update_engine
-
-#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__
diff --git a/set_bootable_flag_action_unittest.cc b/set_bootable_flag_action_unittest.cc
deleted file mode 100644
index d2a211b..0000000
--- a/set_bootable_flag_action_unittest.cc
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <string>
-#include <vector>
-#include <gtest/gtest.h>
-#include "update_engine/set_bootable_flag_action.h"
-#include "update_engine/test_utils.h"
-#include "update_engine/utils.h"
-
-using std::string;
-using std::vector;
-
-namespace chromeos_update_engine {
-
-class SetBootableFlagActionTest : public ::testing::Test {};
-
-// These disabled tests are a reminder this needs to change.
-TEST_F(SetBootableFlagActionTest, DISABLED_SimpleTest) {
- // TODO(adlr): find a way to test this object.
-}
-
-TEST_F(SetBootableFlagActionTest, DISABLED_BadDeviceTest) {
-}
-
-TEST_F(SetBootableFlagActionTest, DISABLED_NoInputObjectTest) {
-}
-
-} // namespace chromeos_update_engine
diff --git a/update_attempter.cc b/update_attempter.cc
index f788ac8..a108001 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -27,7 +27,6 @@
#include "update_engine/omaha_response_handler_action.h"
#include "update_engine/postinstall_runner_action.h"
#include "update_engine/prefs_interface.h"
-#include "update_engine/set_bootable_flag_action.h"
#include "update_engine/update_check_scheduler.h"
using base::TimeDelta;
@@ -85,8 +84,6 @@
return kActionCodeFilesystemCopierError;
if (type == PostinstallRunnerAction::StaticType())
return kActionCodePostinstallRunnerError;
- if (type == SetBootableFlagAction::StaticType())
- return kActionCodeSetBootableFlagError;
return code;
}
@@ -164,8 +161,6 @@
new LibcurlHttpFetcher));
shared_ptr<PostinstallRunnerAction> postinstall_runner_action_precommit(
new PostinstallRunnerAction(true));
- shared_ptr<SetBootableFlagAction> set_bootable_flag_action(
- new SetBootableFlagAction);
shared_ptr<PostinstallRunnerAction> postinstall_runner_action_postcommit(
new PostinstallRunnerAction(false));
shared_ptr<OmahaRequestAction> update_complete_action(
@@ -188,7 +183,6 @@
actions_.push_back(shared_ptr<AbstractAction>(download_finished_action));
actions_.push_back(shared_ptr<AbstractAction>(
postinstall_runner_action_precommit));
- actions_.push_back(shared_ptr<AbstractAction>(set_bootable_flag_action));
actions_.push_back(shared_ptr<AbstractAction>(
postinstall_runner_action_postcommit));
actions_.push_back(shared_ptr<AbstractAction>(update_complete_action));
@@ -212,8 +206,6 @@
BondActions(download_action.get(),
postinstall_runner_action_precommit.get());
BondActions(postinstall_runner_action_precommit.get(),
- set_bootable_flag_action.get());
- BondActions(set_bootable_flag_action.get(),
postinstall_runner_action_postcommit.get());
SetStatusAndNotify(UPDATE_STATUS_CHECKING_FOR_UPDATE);
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index bb86af7..eec342d 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -10,7 +10,6 @@
#include "update_engine/filesystem_copier_action.h"
#include "update_engine/postinstall_runner_action.h"
#include "update_engine/prefs_mock.h"
-#include "update_engine/set_bootable_flag_action.h"
#include "update_engine/update_attempter.h"
using std::string;
@@ -90,10 +89,6 @@
EXPECT_EQ(kActionCodePostinstallRunnerError,
GetErrorCodeForAction(&postinstall_runner_action,
kActionCodeError));
- SetBootableFlagAction set_bootable_flag_action;
- EXPECT_EQ(kActionCodeSetBootableFlagError,
- GetErrorCodeForAction(&set_bootable_flag_action,
- kActionCodeError));
ActionMock action_mock;
EXPECT_CALL(action_mock, Type()).Times(1).WillOnce(Return("ActionMock"));
EXPECT_EQ(kActionCodeError,
@@ -176,7 +171,6 @@
DownloadAction::StaticType(),
OmahaRequestAction::StaticType(),
PostinstallRunnerAction::StaticType(),
- SetBootableFlagAction::StaticType(),
PostinstallRunnerAction::StaticType(),
OmahaRequestAction::StaticType()
};