mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-11-05 04:06:38 +08:00
Merge branch 'uutils-up' into 'master'
Fix uutils hang from oniguruma, update to 0.11.0 See merge request redox-os/redox!2354
This commit is contained in:
commit
6693842691
@ -1,9 +1,8 @@
|
||||
# TODO Fix coreutils i18n/l10n behavior on Redox
|
||||
# TODO Fix locale init bug on aarch64 before removing patches
|
||||
# TODO https://github.com/uutils/coreutils/commit/e6f7ad06 broke locales on x86_64
|
||||
# TODO Fix locale init bug caused by OnceLock combined with thread_local
|
||||
# TODO 0.12.0 requires rustix symlink_at
|
||||
[source]
|
||||
git = "https://github.com/uutils/coreutils"
|
||||
rev = "1f7c81f5d2d3e56c518349c0392158871a1ea9ec"
|
||||
rev = "0.11.0"
|
||||
patches = [
|
||||
"redox.patch"
|
||||
]
|
||||
|
||||
@ -1,123 +1,12 @@
|
||||
diff --git a/Cargo.toml b/Cargo.toml
|
||||
index 5f417bd42..b7b895a9c 100644
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -326,6 +326,7 @@ feat_os_unix_redox = [
|
||||
"feat_common_core",
|
||||
#
|
||||
"chmod",
|
||||
+ "nproc",
|
||||
"stat",
|
||||
"uname",
|
||||
]
|
||||
diff --git a/src/uucore/src/lib/features/fs.rs b/src/uucore/src/lib/features/fs.rs
|
||||
index fd1f30303..c508f6b9b 100644
|
||||
--- a/src/uucore/src/lib/features/fs.rs
|
||||
+++ b/src/uucore/src/lib/features/fs.rs
|
||||
@@ -13,7 +13,7 @@ use libc::{
|
||||
S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR,
|
||||
mkfifo, mode_t,
|
||||
};
|
||||
-#[cfg(all(unix, not(target_os = "redox")))]
|
||||
+#[cfg(unix)]
|
||||
pub use libc::{major, makedev, minor};
|
||||
use std::collections::HashSet;
|
||||
use std::collections::VecDeque;
|
||||
@@ -849,24 +849,6 @@ pub fn make_fifo(path: &Path) -> std::io::Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
-// Redox's libc appears not to include the following utilities
|
||||
-
|
||||
-#[cfg(target_os = "redox")]
|
||||
-pub fn major(dev: libc::dev_t) -> libc::c_uint {
|
||||
- (((dev >> 8) & 0xFFF) | ((dev >> 32) & 0xFFFFF000)) as _
|
||||
-}
|
||||
-
|
||||
-#[cfg(target_os = "redox")]
|
||||
-pub fn minor(dev: libc::dev_t) -> libc::c_uint {
|
||||
- ((dev & 0xFF) | ((dev >> 12) & 0xFFFFF00)) as _
|
||||
-}
|
||||
-
|
||||
-#[cfg(target_os = "redox")]
|
||||
-pub fn makedev(maj: libc::c_uint, min: libc::c_uint) -> libc::dev_t {
|
||||
- let [maj, min] = [maj as libc::dev_t, min as libc::dev_t];
|
||||
- (min & 0xff) | ((maj & 0xfff) << 8) | ((min & !0xff) << 12) | ((maj & !0xfff) << 32)
|
||||
-}
|
||||
-
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// Note this useful idiom: importing names from outer (for mod tests) scope.
|
||||
diff --git a/src/uucore/src/lib/features/i18n/mod.rs b/src/uucore/src/lib/features/i18n/mod.rs
|
||||
index 282baf2e7..a38ccb30e 100644
|
||||
--- a/src/uucore/src/lib/features/i18n/mod.rs
|
||||
+++ b/src/uucore/src/lib/features/i18n/mod.rs
|
||||
@@ -45,8 +45,21 @@ pub fn get_locale_from_env(locale_name: &str) -> (Locale, UEncoding) {
|
||||
|
||||
if let Some(simple) = split.next() {
|
||||
// Handle explicit C and POSIX locales - these should always use byte comparison
|
||||
+ let encoding = split.next();
|
||||
+ let is_utf8 = encoding.is_some_and(|enc| {
|
||||
+ let lower = enc.to_lowercase();
|
||||
+ lower == "utf-8" || lower == "utf8"
|
||||
+ });
|
||||
+
|
||||
if simple == "C" || simple == "POSIX" {
|
||||
- return (DEFAULT_LOCALE, UEncoding::Ascii);
|
||||
+ return (
|
||||
+ DEFAULT_LOCALE,
|
||||
+ if is_utf8 {
|
||||
+ UEncoding::Utf8
|
||||
+ } else {
|
||||
+ UEncoding::Ascii
|
||||
+ },
|
||||
+ );
|
||||
}
|
||||
|
||||
// Naively convert the locale name to BCP47 tag format.
|
||||
@@ -55,14 +68,9 @@ pub fn get_locale_from_env(locale_name: &str) -> (Locale, UEncoding) {
|
||||
let bcp47 = simple.replace('_', "-");
|
||||
let locale = Locale::try_from_str(&bcp47).unwrap_or(DEFAULT_LOCALE);
|
||||
|
||||
- // If locale parsing failed, parse the encoding part of the
|
||||
- // locale. Treat the special case of the given locale being "C"
|
||||
- // which becomes the default locale.
|
||||
- let encoding = if (locale != DEFAULT_LOCALE || bcp47 == "C")
|
||||
- && split.next().is_some_and(|enc| {
|
||||
- let lower = enc.to_lowercase();
|
||||
- lower == "utf-8" || lower == "utf8"
|
||||
- }) {
|
||||
+ // If the locale name was parsed successfully, use the encoding suffix
|
||||
+ // to decide whether filenames should be treated as UTF-8.
|
||||
+ let encoding = if (locale != DEFAULT_LOCALE || bcp47 == "C") && is_utf8 {
|
||||
UEncoding::Utf8
|
||||
} else {
|
||||
UEncoding::Ascii
|
||||
@@ -70,8 +78,12 @@ pub fn get_locale_from_env(locale_name: &str) -> (Locale, UEncoding) {
|
||||
return (locale, encoding);
|
||||
}
|
||||
}
|
||||
- // Default POSIX locale representing LC_ALL=C
|
||||
- (DEFAULT_LOCALE, UEncoding::Ascii)
|
||||
+
|
||||
+ #[cfg(target_os = "redox")]
|
||||
+ return (DEFAULT_LOCALE, UEncoding::Utf8);
|
||||
+
|
||||
+ #[cfg(not(target_os = "redox"))]
|
||||
+ return (DEFAULT_LOCALE, UEncoding::Ascii);
|
||||
}
|
||||
|
||||
/// Get the collating locale from the environment
|
||||
diff --git a/src/uucore/src/lib/mods/locale.rs b/src/uucore/src/lib/mods/locale.rs
|
||||
index b670f8976..a4ff9f983 100644
|
||||
index 60ca9d42..31f3ba0b 100644
|
||||
--- a/src/uucore/src/lib/mods/locale.rs
|
||||
+++ b/src/uucore/src/lib/mods/locale.rs
|
||||
@@ -211,10 +211,11 @@ fn init_localization(
|
||||
@@ -317,10 +317,10 @@ fn init_localization(
|
||||
}
|
||||
};
|
||||
|
||||
- LOCALIZER.with(|lock| {
|
||||
+ // TODO: In aarch64 redox OS, this lock (once cell) is already initialized out of nothing
|
||||
+ let _ = LOCALIZER.with(|lock| {
|
||||
lock.set(loc)
|
||||
.map_err(|_| LocalizationError::Bundle("Localizer already initialized".into()))
|
||||
@ -126,18 +15,29 @@ index b670f8976..a4ff9f983 100644
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -422,10 +423,12 @@ pub fn setup_localization(p: &str) -> Result<(), LocalizationError> {
|
||||
let english_bundle = create_english_bundle_from_embedded(&default_locale, p)?;
|
||||
let localizer = Localizer::new(english_bundle);
|
||||
@@ -637,10 +637,10 @@ pub fn setup_localization(p: &str) -> Result<(), LocalizationError> {
|
||||
Localizer::new(english_bundle)
|
||||
};
|
||||
|
||||
- LOCALIZER.with(|lock| {
|
||||
+ // TODO: In aarch64 redox OS, this lock (once cell) is already initialized out of nothing
|
||||
+ // TODO: When this code is used? Patching for keep sake
|
||||
+ let _ = LOCALIZER.with(|lock| {
|
||||
lock.set(localizer)
|
||||
.map_err(|_| LocalizationError::Bundle("Localizer already initialized".into()))
|
||||
- })?;
|
||||
+ });
|
||||
}
|
||||
LOCALIZER_IS_SET.with(|f| f.set(true));
|
||||
Ok(())
|
||||
@@ -919,10 +919,10 @@ mod tests {
|
||||
}
|
||||
};
|
||||
|
||||
- LOCALIZER.with(|lock| {
|
||||
+ let _ = LOCALIZER.with(|lock| {
|
||||
lock.set(loc)
|
||||
.map_err(|_| LocalizationError::Bundle("Localizer already initialized".into()))
|
||||
- })?;
|
||||
+ });
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6,4 +6,10 @@ script = """
|
||||
autotools_recursive_regenerate
|
||||
"""
|
||||
[build]
|
||||
template = "configure"
|
||||
template = "custom"
|
||||
script = """
|
||||
DYNAMIC_INIT
|
||||
cookbook_configure
|
||||
# TODO: fini arrays causes hang in uutils
|
||||
${OBJCOPY} --remove-section=.fini_array --remove-section=.fini ${COOKBOOK_STAGE}/usr/lib/libonig.so.5
|
||||
"""
|
||||
|
||||
Loading…
Reference in New Issue
Block a user