mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
OpenNOW core: build for Android (Linux helpers cover target_os android)
This commit is contained in:
1 parent
f0f17b9b63
commit
51e911f9a8
6 files changed
+25
-19
No files matched your search
Vendored
+7
-1
@@ -1,3 +1,9 @@
|
||||
# DroidDeck changes to the vendored OpenNOW code
|
||||
|
||||
None yet (pristine import of a49b124c).
|
||||
Upstream: OpenCloudGaming/OpenNOW a49b124c. Each change keeps upstream behaviour on
|
||||
Windows, macOS and Linux.
|
||||
|
||||
- `opennow-core/src/update_apply/{process,security,mod,managed,recovery}.rs`: the
|
||||
Linux-only process, ACL and boot-id helpers also cover Android (`target_os =
|
||||
"android"`), so the core compiles for aarch64-linux-android. DroidDeck never runs
|
||||
the self-updater.
|
||||
@@ -39,7 +39,7 @@ pub(super) fn verify_identity(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn output(command: &mut Command) -> Result<String, String> {
|
||||
let result = super::command_output(command, Duration::from_secs(120))?;
|
||||
if !result.status.success() {
|
||||
@@ -53,7 +53,7 @@ fn output(command: &mut Command) -> Result<String, String> {
|
||||
.map_err(|error| error.to_string())
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn deb_identity(package: &Path, target: &Path, version: &str) -> Result<Identity, String> {
|
||||
if !Path::new("/usr/bin/pkexec").is_file() {
|
||||
return Err(
|
||||
@@ -110,7 +110,7 @@ fn deb_identity(package: &Path, target: &Path, version: &str) -> Result<Identity
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn deb_file_owners(target: &Path) -> Result<String, String> {
|
||||
let name = target.file_name().ok_or("Application has no file name")?;
|
||||
let mut pattern = std::ffi::OsString::from("*");
|
||||
@@ -122,7 +122,7 @@ fn deb_file_owners(target: &Path) -> Result<String, String> {
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn deb_owns_file(files: &str, target: &Path) -> bool {
|
||||
let Ok(target) = super::canonical_file(target) else {
|
||||
return false;
|
||||
@@ -135,7 +135,7 @@ fn deb_owns_file(files: &str, target: &Path) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||
fn deb_identity(_: &Path, _: &Path, _: &str) -> Result<Identity, String> {
|
||||
Err("DEB updates require Linux".to_owned())
|
||||
}
|
||||
@@ -608,7 +608,7 @@ pub(super) fn verify_installed(
|
||||
.to_owned(),
|
||||
);
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
{
|
||||
let files = deb_file_owners(target)?;
|
||||
if !deb_owns_file(&files, target) {
|
||||
@@ -721,7 +721,7 @@ mod tests {
|
||||
assert!(msi_install_root_argument(Path::new("C:\\evil\"quote")).is_err());
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
#[test]
|
||||
fn deb_ownership_matches_canonical_directories_but_rejects_file_symlinks() {
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -158,7 +158,7 @@ pub(super) fn windows_update_package_extension(
|
||||
}
|
||||
|
||||
pub fn external_update_message() -> Option<&'static str> {
|
||||
if cfg!(target_os = "linux")
|
||||
if cfg!(any(target_os = "linux", target_os = "android"))
|
||||
&& is_flatpak_installation(
|
||||
std::env::var_os("FLATPAK_ID").as_deref(),
|
||||
Path::new("/.flatpak-info"),
|
||||
@@ -191,8 +191,8 @@ pub fn detect_install_kind(application: &Path, package: &Path) -> Result<Install
|
||||
.unwrap_or_default()
|
||||
.to_ascii_lowercase();
|
||||
match extension.as_str() {
|
||||
"appimage" if cfg!(target_os = "linux") => Ok(InstallKind::AppImage),
|
||||
"deb" if cfg!(target_os = "linux") => Ok(InstallKind::DebianPackage),
|
||||
"appimage" if cfg!(any(target_os = "linux", target_os = "android")) => Ok(InstallKind::AppImage),
|
||||
"deb" if cfg!(any(target_os = "linux", target_os = "android")) => Ok(InstallKind::DebianPackage),
|
||||
"msi" if cfg!(windows) => Ok(InstallKind::WindowsMsi),
|
||||
"zip" if cfg!(windows) => Ok(InstallKind::WindowsPortable),
|
||||
"zip" | "dmg"
|
||||
@@ -211,7 +211,7 @@ pub fn detect_install_kind(application: &Path, package: &Path) -> Result<Install
|
||||
|
||||
pub fn compatible_package_extension() -> Result<&'static str, String> {
|
||||
require_native_updates()?;
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
{
|
||||
Ok(
|
||||
if std::env::var_os("APPIMAGE").is_some_and(|path| !path.is_empty()) {
|
||||
@@ -240,7 +240,7 @@ pub fn prepare_update(request: PrepareRequest) -> Result<PreparedUpdate, String>
|
||||
if request.kind == InstallKind::WindowsMsi {
|
||||
return Err(WINDOWS_INSTALLER_REPLACEMENT_MESSAGE.to_owned());
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
validate_linux_install_kind(request.kind, std::env::var_os("APPIMAGE").as_deref())?;
|
||||
let package = canonical_file(&request.package)?;
|
||||
let manifest = read_manifest(&package)?;
|
||||
@@ -353,7 +353,7 @@ pub fn prepare_update(request: PrepareRequest) -> Result<PreparedUpdate, String>
|
||||
result
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn validate_linux_install_kind(
|
||||
kind: InstallKind,
|
||||
appimage: Option<&std::ffi::OsStr>,
|
||||
|
||||
@@ -166,7 +166,7 @@ pub(super) fn failed_start(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn group_is_running(group: u32) -> Result<bool, String> {
|
||||
for entry in std::fs::read_dir("/proc").map_err(|error| error.to_string())? {
|
||||
let entry = entry.map_err(|error| error.to_string())?;
|
||||
@@ -356,7 +356,7 @@ pub(super) fn owned_tree_is_running(identity: &ProcessIdentity) -> Result<bool,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn capture(pid: u32) -> Result<Option<ProcessIdentity>, String> {
|
||||
let path = PathBuf::from(format!("/proc/{pid}"));
|
||||
let stat = match std::fs::read_to_string(path.join("stat")) {
|
||||
|
||||
@@ -212,7 +212,7 @@ fn current_boot_id() -> Result<String, String> {
|
||||
Ok(format!("windows-boot-sequence:{boot_id}"))
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn current_boot_id() -> Result<String, String> {
|
||||
let value = std::fs::read_to_string("/proc/sys/kernel/random/boot_id")
|
||||
.map_err(|error| error.to_string())?;
|
||||
@@ -227,7 +227,7 @@ fn current_boot_id() -> Result<String, String> {
|
||||
Ok(value.to_owned())
|
||||
}
|
||||
|
||||
#[cfg(not(any(windows, target_os = "linux")))]
|
||||
#[cfg(not(any(windows, target_os = "linux", target_os = "android")))]
|
||||
fn current_boot_id() -> Result<String, String> {
|
||||
Err("Managed reboot recovery is not supported on this platform.".to_owned())
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ pub(super) fn preserve_permissions(source: &Path, destination: &Path) -> Result<
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
fn preserve_unix_acl(source: &Path, destination: &Path) -> Result<(), String> {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
let source =
|
||||
|
||||
Reference in new issue
Block a user