get android builds to compile and pass tests

This commit is contained in:
Justin Tracey
2022-02-09 13:08:28 -05:00
committed by Sylvestre Ledru
parent 5e7d58650d
commit 2a0d58d060
47 changed files with 244 additions and 165 deletions
Generated
+2 -2
View File
@@ -791,9 +791,9 @@ checksum = "31a7a908b8f32538a2143e59a6e4e2508988832d5d4d6f7c156b3cbc762643a5"
[[package]]
name = "filetime"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "975ccf83d8d9d0d84682850a38c8169027be83368805971cc4f238c2b245bc98"
checksum = "c0408e2626025178a6a7f7ffc05a25bc47103229f19c113755de7bf63816290c"
dependencies = [
"cfg-if 1.0.0",
"libc",
+14 -3
View File
@@ -1,7 +1,7 @@
# coreutils (uutils)
# * see the repository LICENSE, README, and CONTRIBUTING files for more information
# spell-checker:ignore (libs) libselinux
# spell-checker:ignore (libs) libselinux gethostid
[package]
name = "coreutils"
@@ -120,6 +120,7 @@ feat_Tier1 = [
# "feat_os_macos" == set of utilities which can be built/run on the MacOS platform
feat_os_macos = [
"feat_os_unix", ## == a modern/usual *nix platform
"feat_require_hostid",
]
# "feat_os_unix" == set of utilities which can be built/run on modern/usual *nix platforms
feat_os_unix = [
@@ -140,12 +141,19 @@ feat_os_unix_gnueabihf = [
#
"feat_require_unix",
"feat_require_unix_utmpx",
"feat_require_hostid",
]
# "feat_os_unix_musl" == set of utilities which can be built/run on targets binding to the "musl" library (ref: <https://musl.libc.org/about.html>)
feat_os_unix_musl = [
"feat_Tier1",
#
"feat_require_unix",
"feat_require_hostid",
]
feat_os_unix_android = [
"feat_Tier1",
#
"feat_require_unix",
]
# "feat_selinux" == set of utilities providing support for SELinux Security Context if enabled with `--features feat_selinux`.
# NOTE:
@@ -172,7 +180,6 @@ feat_require_unix = [
"chown",
"chroot",
"groups",
"hostid",
"id",
"install",
"kill",
@@ -195,6 +202,10 @@ feat_require_unix_utmpx = [
"users",
"who",
]
# "feat_require_hostid" == set of utilities requiring gethostid in libc (only some unixes provide)
feat_require_hostid = [
"hostid",
]
# "feat_require_selinux" == set of utilities depending on SELinux.
feat_require_selinux = [
"chcon",
@@ -386,7 +397,7 @@ walkdir = "2.2"
atty = "0.2"
hex-literal = "0.3.1"
[target.'cfg(target_os = "linux")'.dev-dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dev-dependencies]
rlimit = "0.8.3"
[target.'cfg(unix)'.dev-dependencies]
+1 -1
View File
@@ -208,7 +208,7 @@ fn set_groups(groups: &[libc::gid_t]) -> libc::c_int {
unsafe { setgroups(groups.len() as libc::c_int, groups.as_ptr()) }
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn set_groups(groups: &[libc::gid_t]) -> libc::c_int {
unsafe { setgroups(groups.len() as libc::size_t, groups.as_ptr()) }
}
+1 -1
View File
@@ -27,7 +27,7 @@ selinux = { version="0.2", optional=true }
uucore = { version=">=0.0.11", package="uucore", path="../../uucore", features=["entries", "fs", "perms", "mode"] }
walkdir = "2.2"
[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
ioctl-sys = "0.8"
[target.'cfg(target_os = "windows")'.dependencies]
+12 -8
View File
@@ -10,7 +10,7 @@
// spell-checker:ignore (ToDO) ficlone linkgs lstat nlink nlinks pathbuf reflink strs xattrs symlinked
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[macro_use]
extern crate ioctl_sys;
#[macro_use]
@@ -49,7 +49,7 @@ use std::mem;
use std::os::unix::ffi::OsStrExt;
#[cfg(unix)]
use std::os::unix::fs::{FileTypeExt, PermissionsExt};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::io::AsRawFd;
#[cfg(windows)]
use std::os::windows::ffi::OsStrExt;
@@ -61,7 +61,7 @@ use uucore::error::{set_exit_code, ExitCode, UError, UResult};
use uucore::fs::{canonicalize, MissingHandling, ResolveMode};
use walkdir::WalkDir;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
ioctl!(write ficlone with 0x94, 9; std::os::raw::c_int);
quick_error! {
@@ -686,11 +686,15 @@ impl Options {
}
}
} else {
#[cfg(any(target_os = "linux", target_os = "macos"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "macos"))]
{
ReflinkMode::Auto
}
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(
target_os = "linux",
target_os = "android",
target_os = "macos"
)))]
{
ReflinkMode::Never
}
@@ -1467,14 +1471,14 @@ fn copy_helper(
} else if source_is_symlink {
copy_link(source, dest, symlinked_files)?;
} else if options.reflink_mode != ReflinkMode::Never {
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
#[cfg(not(any(target_os = "linux", target_os = "android", target_os = "macos")))]
return Err("--reflink is only supported on linux and macOS"
.to_string()
.into());
#[cfg(target_os = "macos")]
copy_on_write_macos(source, dest, options.reflink_mode, context)?;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
copy_on_write_linux(source, dest, options.reflink_mode, context)?;
} else {
fs::copy(source, dest).context(context)?;
@@ -1528,7 +1532,7 @@ fn copy_link(
}
/// Copies `source` to `dest` using copy-on-write if possible.
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn copy_on_write_linux(
source: &Path,
dest: &Path,
+1 -1
View File
@@ -21,7 +21,7 @@ gcd = "2.0"
libc = "0.2"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore" }
[target.'cfg(target_os = "linux")'.dependencies]
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
signal-hook = "0.3.9"
[[bin]]
+5 -5
View File
@@ -26,7 +26,7 @@ use std::cmp;
use std::env;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Seek, Write};
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::fs::OpenOptionsExt;
use std::path::Path;
use std::sync::mpsc;
@@ -88,7 +88,7 @@ impl Input<io::Stdin> {
}
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn make_linux_iflags(iflags: &IFlags) -> Option<libc::c_int> {
let mut flag = 0;
@@ -140,7 +140,7 @@ impl Input<File> {
let mut opts = OpenOptions::new();
opts.read(true);
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(libc_flags) = make_linux_iflags(&iflags) {
opts.custom_flags(libc_flags);
}
@@ -455,7 +455,7 @@ where
}
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn make_linux_oflags(oflags: &OFlags) -> Option<libc::c_int> {
let mut flag = 0;
@@ -504,7 +504,7 @@ impl OutputTrait for Output<File> {
.create_new(cflags.excl)
.append(oflags.append);
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
if let Some(libc_flags) = make_linux_oflags(oflags) {
opts.custom_flags(libc_flags);
}
+8 -8
View File
@@ -235,7 +235,7 @@ impl std::str::FromStr for Flag {
"direct" =>
// Ok(Self::Direct),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Direct)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -244,7 +244,7 @@ impl std::str::FromStr for Flag {
"directory" =>
// Ok(Self::Directory),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Directory)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -253,7 +253,7 @@ impl std::str::FromStr for Flag {
"dsync" =>
// Ok(Self::Dsync),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Dsync)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -262,7 +262,7 @@ impl std::str::FromStr for Flag {
"sync" =>
// Ok(Self::Sync),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::Sync)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -276,7 +276,7 @@ impl std::str::FromStr for Flag {
"nonblock" =>
// Ok(Self::NonBlock),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NonBlock)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -285,7 +285,7 @@ impl std::str::FromStr for Flag {
"noatime" =>
// Ok(Self::NoATime),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoATime)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -294,7 +294,7 @@ impl std::str::FromStr for Flag {
"noctty" =>
// Ok(Self::NoCtty),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoCtty)
} else {
Err(ParseError::Unimplemented(s.to_string()))
@@ -303,7 +303,7 @@ impl std::str::FromStr for Flag {
"nofollow" =>
// Ok(Self::NoFollow),
{
if cfg!(target_os = "linux") {
if cfg!(any(target_os = "linux", target_os = "android")) {
Ok(Self::NoFollow)
} else {
Err(ParseError::Unimplemented(s.to_string()))
+3 -3
View File
@@ -4,7 +4,7 @@ use super::*;
use crate::StatusLevel;
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
#[test]
fn unimplemented_flags_should_error_non_linux() {
let mut succeeded = Vec::new();
@@ -617,7 +617,7 @@ fn parse_oflag_tokens() {
}
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn parse_iflag_tokens_linux() {
let exp = vec![
@@ -645,7 +645,7 @@ fn parse_iflag_tokens_linux() {
}
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
#[test]
fn parse_oflag_tokens_linux() {
let exp = vec![
+6 -6
View File
@@ -201,7 +201,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if state.cflag {
if state.selinux_supported {
// print SElinux context and exit
#[cfg(all(target_os = "linux", feature = "selinux"))]
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
if let Ok(context) = selinux::SecurityContext::current(false) {
let bytes = context.as_bytes();
print!("{}{}", String::from_utf8_lossy(bytes), line_ending);
@@ -520,7 +520,7 @@ fn pline(possible_uid: Option<uid_t>) {
);
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn pline(possible_uid: Option<uid_t>) {
let uid = possible_uid.unwrap_or_else(getuid);
let pw = Passwd::locate(uid).unwrap();
@@ -537,10 +537,10 @@ fn pline(possible_uid: Option<uid_t>) {
);
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn auditid() {}
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
fn auditid() {
#[allow(deprecated)]
let mut auditinfo: audit::c_auditinfo_addr_t = unsafe { std::mem::uninitialized() };
@@ -620,7 +620,7 @@ fn id_print(state: &mut State, groups: &[u32]) {
.join(",")
);
#[cfg(all(target_os = "linux", feature = "selinux"))]
#[cfg(all(any(target_os = "linux", target_os = "android"), feature = "selinux"))]
if state.selinux_supported
&& !state.user_specified
&& std::env::var_os("POSIXLY_CORRECT").is_none()
@@ -633,7 +633,7 @@ fn id_print(state: &mut State, groups: &[u32]) {
}
}
#[cfg(not(target_os = "linux"))]
#[cfg(not(any(target_os = "linux", target_os = "android")))]
mod audit {
use super::libc::{c_int, c_uint, dev_t, pid_t, uid_t};
+1 -1
View File
@@ -2370,7 +2370,7 @@ fn display_len_or_rdev(metadata: &Metadata, config: &Config) -> SizeOrDeviceId {
return SizeOrDeviceId::Device(major.to_string(), minor.to_string());
}
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
{
let ft = metadata.file_type();
if ft.is_char_device() || ft.is_block_device() {
+1 -1
View File
@@ -213,7 +213,7 @@ extern "C" {
fn _vprocmgr_detach_from_console(flags: u32) -> *const libc::c_int;
}
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "freebsd"))]
unsafe fn _vprocmgr_detach_from_console(_: u32) -> *const libc::c_int {
std::ptr::null()
}
+1 -1
View File
@@ -13,7 +13,7 @@ use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError};
use uucore::format_usage;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub const _SC_NPROCESSORS_CONF: libc::c_int = 83;
#[cfg(target_vendor = "apple")]
pub const _SC_NPROCESSORS_CONF: libc::c_int = libc::_SC_NPROCESSORS_CONF;
+2
View File
@@ -78,6 +78,7 @@ struct ProgramOptionsError(String);
#[cfg(any(
target_os = "linux",
target_os = "android",
target_os = "freebsd",
target_os = "netbsd",
target_os = "dragonflybsd"
@@ -93,6 +94,7 @@ fn preload_strings() -> (&'static str, &'static str) {
#[cfg(not(any(
target_os = "linux",
target_os = "android",
target_os = "freebsd",
target_os = "netbsd",
target_os = "dragonflybsd",
+12 -8
View File
@@ -27,17 +27,21 @@ static ARG_FILES: &str = "files";
#[cfg(unix)]
mod platform {
use super::libc;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::fs::File;
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
use std::os::unix::io::AsRawFd;
pub unsafe fn do_sync() -> isize {
// see https://github.com/rust-lang/libc/pull/2161
#[cfg(target_os = "android")]
libc::syscall(libc::SYS_sync);
#[cfg(not(target_os = "android"))]
libc::sync();
0
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub unsafe fn do_syncfs(files: Vec<String>) -> isize {
for path in files {
let f = File::open(&path).unwrap();
@@ -47,7 +51,7 @@ mod platform {
0
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
pub unsafe fn do_fdatasync(files: Vec<String>) -> isize {
for path in files {
let f = File::open(&path).unwrap();
@@ -179,10 +183,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
#[allow(clippy::if_same_then_else)]
if matches.is_present(options::FILE_SYSTEM) {
#[cfg(any(target_os = "linux", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
syncfs(files);
} else if matches.is_present(options::DATA) {
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fdatasync(files);
} else {
sync();
@@ -221,12 +225,12 @@ fn sync() -> isize {
unsafe { platform::do_sync() }
}
#[cfg(any(target_os = "linux", target_os = "windows"))]
#[cfg(any(target_os = "linux", target_os = "android", target_os = "windows"))]
fn syncfs(files: Vec<String>) -> isize {
unsafe { platform::do_syncfs(files) }
}
#[cfg(target_os = "linux")]
#[cfg(any(target_os = "linux", target_os = "android"))]
fn fdatasync(files: Vec<String>) -> isize {
unsafe { platform::do_fdatasync(files) }
}
+5 -1
View File
@@ -320,10 +320,14 @@ fn parse_timestamp(s: &str) -> UResult<FileTime> {
/// On Windows, uses GetFinalPathNameByHandleW to attempt to get the path
/// from the stdout handle.
fn pathbuf_from_stdout() -> UResult<PathBuf> {
#[cfg(unix)]
#[cfg(all(unix, not(target_os = "android")))]
{
Ok(PathBuf::from("/dev/stdout"))
}
#[cfg(target_os = "android")]
{
Ok(PathBuf::from("/proc/self/fd/1"))
}
#[cfg(windows)]
{
use std::os::windows::prelude::AsRawHandle;
+2
View File
@@ -36,6 +36,8 @@ pub mod options {
const HOST_OS: &str = "GNU/Linux";
#[cfg(all(target_os = "linux", not(any(target_env = "gnu", target_env = ""))))]
const HOST_OS: &str = "Linux";
#[cfg(target_os = "android")]
const HOST_OS: &str = "Android";
#[cfg(target_os = "windows")]
const HOST_OS: &str = "Windows NT";
#[cfg(target_os = "freebsd")]
+1 -1
View File
@@ -37,7 +37,7 @@ fn count_bytes_using_splice(fd: &impl AsRawFd) -> Result<usize, usize> {
let null_rdev = stat::fstat(null_file.as_raw_fd())
.map_err(|_| 0_usize)?
.st_rdev;
if (stat::major(null_rdev), stat::minor(null_rdev)) != (1, 3) {
if unsafe { (libc::major(null_rdev), libc::minor(null_rdev)) } != (1, 3) {
// This is not a proper /dev/null, writing to it is probably bad
// Bit of an edge case, but it has been known to happen
return Err(0);
+1 -1
View File
@@ -40,7 +40,7 @@ mod options {
static ABOUT: &str = "Print information about users who are currently logged in.";
const USAGE: &str = "{} [OPTION]... [ FILE | ARG1 ARG2 ]";
#[cfg(any(target_os = "linux"))]
#[cfg(target_os = "linux")]
static RUNLEVEL_HELP: &str = "print current runlevel";
#[cfg(not(target_os = "linux"))]
static RUNLEVEL_HELP: &str = "print current runlevel (This is meaningless on non Linux)";
+1
View File
@@ -34,6 +34,7 @@ pub mod process;
pub mod signals;
#[cfg(all(
unix,
not(target_os = "android"),
not(target_os = "fuchsia"),
not(target_os = "redox"),
not(target_env = "musl"),

Some files were not shown because too many files have changed in this diff Show More