Skip to content
Snippets Groups Projects
Commit 05dd754f authored by Apertis package maintainers's avatar Apertis package maintainers
Browse files

d/patches: add fixes for Apertis


The current implementation of `rust-coreutils` isn't complete yet, and
some of the executables need improvements in order to be able to build a
base Apertis system.

This commit adds the necessary patches to ensure we can use to package
to build Apertis images.

Signed-off-by: default avatarArnaud Ferraris <arnaud.ferraris@collabora.com>
parent e1b41e53
No related branches found
No related tags found
No related merge requests found
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Mon, 7 Jun 2021 18:13:18 +0200
Subject: HACK cp, mv, ls: add dummy missing arguments
Post-installation scripts for `apparmor` and the kernel make use of
the `-Z` flag for `cp` or `mv` in order to set the SELinux context of
copied/moved files. As the current implementations don't support this
flag, the commands error out, causing those packages' installation to
fail. As those are required, building Apertis images using
`rust-coreutils` subsequently fails too.
This commit adds support for the `-Z` flag without implementing the
associated behavior as it isn't strictly needed for building basic
Apertis images.
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: not-needed
Bug: https://github.com/uutils/coreutils/issues/2404
---
src/uu/cp/src/cp.rs | 4 ++++
src/uu/ls/src/ls.rs | 10 ++++++++++
src/uu/mv/src/mv.rs | 11 +++++++++++
3 files changed, 25 insertions(+)
diff --git a/src/uu/cp/src/cp.rs b/src/uu/cp/src/cp.rs
index 569ee78..1277acc 100644
--- a/src/uu/cp/src/cp.rs
+++ b/src/uu/cp/src/cp.rs
@@ -238,6 +238,7 @@ static OPT_ATTRIBUTES_ONLY: &str = "attributes-only";
static OPT_BACKUP: &str = "backup";
static OPT_CLI_SYMBOLIC_LINKS: &str = "cli-symbolic-links";
static OPT_CONTEXT: &str = "context";
+static OPT_CONTEXT_DEFAULT: &str = "context-default";
static OPT_COPY_CONTENTS: &str = "copy-contents";
static OPT_DEREFERENCE: &str = "dereference";
static OPT_FORCE: &str = "force";
@@ -450,6 +451,9 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_CONTEXT)
.takes_value(true)
.value_name("CTX")
+ .help("NotImplemented: set the SELinux or SMACK security context to CTX"))
+ .arg(Arg::with_name(OPT_CONTEXT_DEFAULT)
+ .short("Z")
.help("NotImplemented: set SELinux security context of destination file to default type"))
.arg(Arg::with_name(OPT_CLI_SYMBOLIC_LINKS)
.short("H")
diff --git a/src/uu/ls/src/ls.rs b/src/uu/ls/src/ls.rs
index ece497b..c63a771 100644
--- a/src/uu/ls/src/ls.rs
+++ b/src/uu/ls/src/ls.rs
@@ -138,6 +138,7 @@ pub mod options {
pub static COLOR: &str = "color";
pub static PATHS: &str = "paths";
pub static INDICATOR_STYLE: &str = "indicator-style";
+ pub static CONTEXT: &str = "context";
}
#[derive(PartialEq, Eq)]
@@ -884,6 +885,15 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
options::INDICATOR_STYLE,
]))
+ // TODO: implement the following args
+ .arg(
+ Arg::with_name(options::CONTEXT)
+ .long(options::CONTEXT)
+ .short("Z")
+ .help("NotImplemented: print any security context of each file.")
+ )
+ // END TODO
+
// Positional arguments
.arg(Arg::with_name(options::PATHS).multiple(true).takes_value(true));
diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs
index b481aee..4bcf19c 100644
--- a/src/uu/mv/src/mv.rs
+++ b/src/uu/mv/src/mv.rs
@@ -62,6 +62,7 @@ static OPT_TARGET_DIRECTORY: &str = "target-directory";
static OPT_NO_TARGET_DIRECTORY: &str = "no-target-directory";
static OPT_UPDATE: &str = "update";
static OPT_VERBOSE: &str = "verbose";
+static OPT_CONTEXT: &str = "context";
static ARG_FILES: &str = "files";
@@ -164,6 +165,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.min_values(2)
.required(true)
)
+
+ // TODO: implement the following args
+ .arg(
+ Arg::with_name(OPT_CONTEXT)
+ .short("Z")
+ .long(OPT_CONTEXT)
+ .help("NotImplemented: set SELinux security context of destination file to default type")
+ )
+ // END TODO
+
.get_matches_from(args);
let files: Vec<String> = matches
--
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Mon, 7 Jun 2021 18:13:06 +0200
Subject: HACK tr: add limited support for uppercase<->lowercase conversion
`tr` doesn't support character classes for now, however we need limited
support as `pam-auth-update` uses `tr` for performing uppercase ->
lowercase conversion.
This patch adds a quick hack in order to support `[:upper:]` and
`[:lower:]` character classes by substituting those with the
corresponding character range.
This is a "good enough" solution for the purpose of building Apertis
images based on `rust-coreutils` but is not suitable for upstreaming as
it has several drawbacks:
- this approach cannot be used for other character classes
- non-ASCII characters are ignored
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: not-needed
Bug: https://github.com/uutils/coreutils/issues/556
---
src/uu/tr/src/expand.rs | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/src/uu/tr/src/expand.rs b/src/uu/tr/src/expand.rs
index e71cf26..9be9df8 100644
--- a/src/uu/tr/src/expand.rs
+++ b/src/uu/tr/src/expand.rs
@@ -61,6 +61,18 @@ struct Unescape<'a> {
string: &'a str,
}
+impl<'a> Unescape<'a> {
+ #[inline]
+ pub fn new(s: &'a str) -> Unescape<'a> {
+ Unescape {
+ string: Box::leak(
+ s.replace("[:upper:]", "A-Z").as_str()
+ .replace("[:lower:]", "a-z").into_boxed_str()
+ ),
+ }
+ }
+}
+
impl<'a> Iterator for Unescape<'a> {
type Item = char;
@@ -139,7 +151,7 @@ impl<'a> ExpandSet<'a> {
pub fn new(s: &'a str) -> ExpandSet<'a> {
ExpandSet {
range: 0..=0,
- unesc: Unescape { string: s }.peekable(),
+ unesc: Unescape::new(s).peekable(),
}
}
}
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 4 Jun 2021 16:53:33 +0200
Subject: [PATCH] chown: fix argument parsing when using `--reference`
chown can be used either with `--reference=RFILE FILE...` or with
`OWNER[:GROUP] FILE...`. In the former case, using `--reference` with a
single FILE argument raises an error as OWNER and FILE are both required
arguments.
Similarly to what has been done in chmod, setting FILE to be a required
argument only when `--reference` isn't used, and adding the contents of
OWNER to the file list solves this issue.
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: https://github.com/uutils/coreutils/pull/2344
---
src/uu/chown/src/chown.rs | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/uu/chown/src/chown.rs b/src/uu/chown/src/chown.rs
index 42010de..c58007b 100644
--- a/src/uu/chown/src/chown.rs
+++ b/src/uu/chown/src/chown.rs
@@ -126,7 +126,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(options::REFERENCE)
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
.value_name("RFILE")
- .min_values(1),
+ .takes_value(true),
)
.arg(Arg::with_name(options::verbosity::SILENT).short("f").long(options::verbosity::SILENT))
.arg(
@@ -162,7 +162,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
Arg::with_name(ARG_FILES)
.multiple(true)
.takes_value(true)
- .required(true)
+ .required_unless(options::REFERENCE)
.min_values(1),
)
.get_matches_from(args);
@@ -171,10 +171,16 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
let owner = matches.value_of(ARG_OWNER).unwrap();
/* Then the list of files */
- let files: Vec<String> = matches
+ let mut files: Vec<String> = matches
.values_of(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default();
+ if matches.is_present(options::REFERENCE) {
+ // "--reference" and OWNER are mutually exclusive
+ // if "--reference" was used OWNER needs to be interpreted as another FILE
+ // it wasn't possible to implement this behavior directly with clap
+ files.push(owner.to_string());
+ }
let preserve_root = matches.is_present(options::preserve_root::PRESERVE);
...@@ -14,3 +14,10 @@ Sort-Implement-stable-sort-ignore-non-printing-month.patch ...@@ -14,3 +14,10 @@ Sort-Implement-stable-sort-ignore-non-printing-month.patch
Ignore-a-test.patch Ignore-a-test.patch
Sort-Various-fixes-and-performance-improvements.patch Sort-Various-fixes-and-performance-improvements.patch
sort-implement-k-and-t-support.patch sort-implement-k-and-t-support.patch
# Apertis patches
sort-fix-dependencies-versions.patch
sort-fix-key-argument-handling.patch
chown-fix-argument-parsing-when-using-reference.patch
HACK-tr-add-limited-support-for-uppercase-lowercase.patch
HACK-cp-mv-ls-add-dummy-missing-arguments.patch
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 11 Jun 2021 13:45:43 +0200
Subject: sort: fix dependencies versions
Importing upstream patches for `sort` have the side-effect of setting
dependencies versions incompatible with those we have in Apertis.
As the lower versions we carry are functionally equivalent for this
use-case, this patch downgrades the required versions to the ones
available in Apertis.
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: not-needed
---
src/uu/sort/Cargo.toml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/uu/sort/Cargo.toml b/src/uu/sort/Cargo.toml
index ddea900..9a2e808 100644
--- a/src/uu/sort/Cargo.toml
+++ b/src/uu/sort/Cargo.toml
@@ -15,13 +15,13 @@ edition = "2018"
path = "src/sort.rs"
[dependencies]
-rayon = "1.5"
+rayon = "1.1"
rand = "0.7"
clap = "2.33"
-fnv = "1.0.7"
+fnv = "1.0.6"
itertools = "0.9"
semver = "0.9.0"
-smallvec = "1.6.1"
+smallvec = "1.4.2"
uucore = { version=">=0.0.8", package="uucore", path="../../uucore", features=["fs"] }
uucore_procs = { version=">=0.0.5", package="uucore_procs", path="../../uucore_procs" }
From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Date: Fri, 11 Jun 2021 13:45:58 +0200
Subject: sort: fix `--key` argument handling
When using `sort` with the `--key` option, all subsequent arguments
are considered its values, leading to failures such as:
$ sort -t ":" -k 3 /etc/passwd
sort: failed to parse key `/etc/passwd`: invalid option: `e`
This is a side-effect of having `multiple(true)` for this option,
as `multiple` supports separating values with either a comma or
whitespace. Therefore, as long as no other flag or option is
provided, all arguments following `-k` are treated like values
for this option.
Switching to `use_delimiter(true)` instead ensures only
comma-separated values are taken into account, and the following
arguments are properly interpreted.
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Forwarded: https://github.com/uutils/coreutils/pull/2403
---
src/uu/sort/src/sort.rs | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/uu/sort/src/sort.rs b/src/uu/sort/src/sort.rs
index 7b1fe07..c4d9e60 100644
--- a/src/uu/sort/src/sort.rs
+++ b/src/uu/sort/src/sort.rs
@@ -658,7 +658,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
.long(OPT_KEY)
.help("sort by a key")
.long_help(LONG_HELP_KEYS)
- .multiple(true)
+ .use_delimiter(true)
.takes_value(true),
)
.arg(
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment