* osutil: Refactoring the code exporting mocking APIs to other packages
File 'mockable.go' is used to mock certain data obtained by 'osutil'
from the system (e.g. 'mountinfo'). The file also contained some
variables that belong to production code itself. A cleanup
refactoring was applied to this file and 'mountinfo_linux.go':
- Package variables moved from 'mockable.go' to logic that owns it
- Test-related logic moved from 'mountinfo_linux.go' to 'mockable.go'
- United and refactored logic designed to mock 'mountinfo'
Signed-off-by: Arseniy Aharonov <arseniy.aharonov@canonical.com>
* osutil: Fixes and cleanups after the code review
Signed-off-by: Arseniy Aharonov <arseniy.aharonov@canonical.com>
* osutil: make mustNotBeTestBinary function non-exportable
To avoid unwonted usage of this method in different places in
the code it was requested to make this function local to package
osutil only.
Signed-off-by: Arseniy Aharonov <arseniy.aharonov@canonical.com>
* osutil: refactoring mountinfo code following PR review
My original refactoring of the mountinfo logic introduced
an inconsistency into the code, so that os-agnostic code
contain Linux-related logic. This inconsistencey was
eliminated.
Signed-off-by: Arseniy Aharonov <arseniy.aharonov@canonical.com>
The CommandFromCore helper is currently always looking at the
core snap. With the snapd snap we need to refactor it so that
it uses the snapd snap if available and just falls back to the
core snap.
The osutil.CommandFromCore is not in the rightplace and it also does
not take the snapd snap into account. This PR moves it to the
cmd/cmdutil package (cannot be in cmd because of an import cycle
with cmd/snapinfo.go).
It also tweaks the arguments slightly (no need to pass the
snapMountDir anymore).
Importing `dirs` package in `osutil` leads to import cycles if one attempts to
use `osutils` from packages that are directly or indirectly imported by `dirs`,
such as `release`. It doesn't make any sense for `osutil` to depend on
other non `*util` packages.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This will help in upcoming improvements to mocking. As more things are
added to osutil it is sometimes unclear what is being mocked and how.
This patch should help to improve the situation.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
This avoids us having to add a dependency to snapd for xdelta3 (and fixes the issues that snapd 2.0.10 from Ubuntu 16.04.1 won't apt-get upgrade with any new dependencies).
It is slightly complicated because we want to ensure that the correct ld-linux.so is used and also that the correct libraries from core (instead of from the host) are used.