-
Notifications
You must be signed in to change notification settings - Fork 61
Conversation
riqkum
commented
Dec 14, 2018
- build script update required by atkualizr-android
- package manager for android
- log system integration
Codecov Report
@@ Coverage Diff @@
## master #1034 +/- ##
==========================================
- Coverage 76.19% 75.58% -0.62%
==========================================
Files 164 158 -6
Lines 9860 9355 -505
==========================================
- Hits 7513 7071 -442
+ Misses 2347 2284 -63
Continue to review full report at Codecov.
|
Please update your commit using following command: 'git commit --amend -s', then push with force flag. |
@@ -152,9 +152,19 @@ class BaseConfig { | |||
continue; | |||
} | |||
if (boost::filesystem::is_directory(config)) { | |||
#if (!defined(ANDROID) || __ANDROID_API__ >= 28) | |||
for (const auto& config_file : Utils::glob((config / "*.toml").string())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, let's just use generic version in both cases.
src/libaktualizr/utilities/utils.cc
Outdated
std::mutex Utils::storage_root_path_mutex_; | ||
std::string Utils::storage_root_path_; | ||
|
||
void Utils::setStorageRootPath(const std::string &storage_root_path) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where/how is it used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use it to point aktualizr to an allowed private storage on Android.
return {AndroidInstallationState::STATE_INSTALLED, package_file_path}; | ||
} else if (ext == ".inprogress") { | ||
return {AndroidInstallationState::STATE_IN_PROGRESS, package_file_path}; | ||
} else if (true /* check ext is actually a hash */) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still a TODO? What's the challenge there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No challenge, I'll restore the implementation soon.
data::InstallOutcome finalizeInstall(const Uptane::Target &target) const override { | ||
(void)target; | ||
throw std::runtime_error("Unimplemented"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to just return a positive result instead of throwing if there really is nothing to do here. This function exists for the case when installation requires reboot or some external action before we can really call it complete. Does that apply to the android case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did android package manager when finalizeInstall call was not yet introduced. It may leads some changes in the current implementation, I need to check.
caa76bf
to
aa4f3b4
Compare
@@ -144,9 +144,8 @@ class BaseConfig { | |||
continue; | |||
} | |||
if (boost::filesystem::is_directory(config)) { | |||
for (const auto& config_file : Utils::glob((config / "*.toml").string())) { | |||
for (const auto& config_file : Utils::getDirEntriesByExt(config, ".toml")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flagged by clang-tidy: we do not allow braceless for loops.
src/libaktualizr/utilities/utils.h
Outdated
#if defined(ANDROID) | ||
static void setStorageRootPath(const std::string &storage_root_path); | ||
static boost::filesystem::path getStorageRootPath(); | ||
static std::mutex storage_root_path_mutex_; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it really need a mutex? I would have thought that setStorageRootPath()
would be called once in early initialization.
I also think we could forego the #if defined
here and just make this api available in all cases, with a suitable comment (like "used for Android support").
The code in SafeTempRoot
could default to use this path if not empty and attempt to use a temporary directory otherwise.
So, if (!Utils::getStorageRootPath())
instead of #if defined(ANDROID)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a better idea.
}; | ||
|
||
struct AndroidInstallationState { | ||
enum State { STATE_NOP, STATE_READY, STATE_IN_PROGRESS, STATE_INSTALLED, STATE_UPDATE }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another style consideration: we now prefer using enum class
and name enum variants according to google's c++ style.
e.g.:
enum class InitRetCode { kOk, kOccupied, kServerFailure, kStorageFailure, kSecondaryFailure, kBadP12, kPkcs11Failure }; |
} | ||
|
||
Uptane::Target AndroidManager::getCurrent() const { | ||
std::vector<Uptane::Target> installed_versions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there is a lot going on behind the scene between this and the aktualizr-android code. I don't object merging soon since it's platform-specific code but it would be nice to have quick summaries:
- what are exactly the roles of the different components and how they interact with the state machine?
- do you think the need to structure the code like that came from limitations of our current package manager api (not flexible enough)? If so, do you have suggestions to change it to handle this scenario more nicely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Existing package manager interface doesn't fit well while aktualizr is in role of a slave within aktualizr-android application. Extra entity (dispatcher) that I've introduced is required in that case as a sync. point between the sides. I did so to minimize interaction complexity and decrease amount of data to be exposed. And it brings me faster to the point I could play with an update mechanism on Android side.
However I have the same doubts about clearness of the current solution. I'll look what I can do to simplify it.
While entire update approach on Android is not well-established yet, I have no precise suggestions about changing package manager api.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your summary!
If you don't manage to simplify the integration dramatically, I think it could wait. But some documentation about the complete installation process with details about each actors' interactions would be greatly appreciated (when you think it's ready). Either an external doc or helpful code comments would work.
01a70d6
to
e117009
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the demo today! Just a couple questions and small issues.
Would you mind rebasing on master once again? Unless @lbonn or @eu-smirnov have other thoughts, we can finally merge this soon.
@@ -736,6 +740,12 @@ class SafeTempRoot { | |||
boost::filesystem::path path; | |||
}; | |||
|
|||
std::string Utils::storage_root_path_; | |||
|
|||
void Utils::setStorageRootPath(const std::string &storage_root_path) { storage_root_path_ = storage_root_path; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic with storage_root_path
seems fine, but is setStorageRootPath
ever used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, just realized it's called by aktualizr-android.
target_sources(package_manager PRIVATE androidmanager.cc) | ||
endif(ANDROID) | ||
|
||
aktualizr_source_file_checks(androidmanager.cc androidmanager.h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call to aktualizr_source_file_checks can be combined with the two immediately above it.
using qi::_1; | ||
|
||
std::string getprop_output; | ||
if (0 == Utils::shell("getprop ota.last_installed_package_file", &getprop_output)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this property get set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See explanation in aktualizr-android.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
#include <boost/phoenix/stl/algorithm/transformation.hpp> | ||
#include <boost/spirit/include/phoenix_container.hpp> | ||
#include <boost/spirit/include/phoenix_core.hpp> | ||
#include <boost/spirit/include/qi.hpp> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was it that required using these boost libraries? I see the code below, but I'm curious while normal C++ string parsing was inadequate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not aware of all the approaches you're trying to follow in the project, so be specific. Standard library does not offer comparable functionality, and hand-written find/extract would be less expressive than using boost/spirit/Qi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, I think I've got a good enough handle on it.
I think this is also good to go when we'll have resolved your comments @patrickvacek. The boost spirit added dependency doesn't worry me too much if it stays in the android part of code. |
* build script update required by atkualizr-android * package manager for android * log system integration Signed-off-by: Maksim Beznos <maximbns@gmail.com>
It relies on Anroid system in-built property to match installed target. Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
Signed-off-by: Maksim Beznos <maximbns@gmail.com>
e117009
to
68c5411
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gitlab actually succeeded despite what Github says, and the LGTM check is bogus and irrelevant. So I think this is ready to go.
Thanks for your patience with keeping this going and seeing it through, @riqkum!
It was added in #1034 for the Android support, but it doesn't appear to be used anywhere. Signed-off-by: Patrick Vacek <patrickvacek@gmail.com>