Commit graph

87 commits

Author SHA1 Message Date
Andreas Hartmann
ce0d9bce28 install: Adapt to modified backup_control interface 2021-08-25 16:33:50 +02:00
Michael Debertol
7153a595c6 chgrp: forward to chown
chgrp does mostly the same as chown.
By making chown a bit more configurable we can reuse its code for chgrp.
2021-08-24 15:22:05 +02:00
Michael Debertol
252220e9eb refactor/uucore ~ make util_name and execution_phrase functions
Since util_name and execution_phrase no longer rely on features that are
only available to macros, they may as well be plain functions.
2021-08-14 17:55:18 +02:00
Roy Ivy III
c0854000d1 refactor ~ use execution_phrase!() for usage messaging 2021-08-14 14:01:33 +02:00
Roy Ivy III
23b68d80ba refactor ~ usage() instead of get_usage() 2021-08-14 13:58:43 +02:00
Roy Ivy III
c5792c2a0f refactor ~ use util_name!() as clap::app::App name argument for all utils 2021-08-14 13:53:13 +02:00
Sylvestre Ledru
ea5097e4a0
Merge pull request #2562 from tertsdiepraam/uucore/simpler-uerror
`uucore`: simpler `UResult` and `UError`
2021-08-13 01:33:23 +02:00
Michael Debertol
1c30fb42d2 chgrp: handle empty group 2021-08-11 19:03:41 +02:00
Terts Diepraam
1649217116 uucore: remove distinction between common and custom errors
As custom errors are prefered over wrapping around common errors, the
distinction between UCommonError and UCustomError is removed. This
reduces the number of types and makes the error handling easier to
understand.
2021-08-10 17:55:28 +02:00
Andreas Hartmann
ce037bdf55 install: remove obsolete function call
The `copy_file_to_file` function was only a wrapper to a `copy` function with
the exact same interface. It has now beed removed for clarity.
2021-07-31 13:06:37 +02:00
Andreas Hartmann
4f235e9e95 install: Use uio_error to construct errors from std::io::Error
Use new macro to construct UIoError types from `std::io::Error` before
printing. This gives consistent error messages across all utilities as it
prepends custom errors to the error description for the respective application
and error type. This saves the developers from manually appending the
`std::io::Error`-specific error messages.
2021-07-31 13:06:37 +02:00
Andreas Hartmann
0461a45c9a install: Use show! macro for noncritical errors during execution
Drop the previous flags that would tell whether a noncritical error occured
during execution in favor of the `show!` macro from the error submodule.

This allows us to generate regular error types during execution to signify
failures inside the program, but without prematurely aborting program execution
if not needed or specified.

Also make verbose outputs use `print!` and friends instead of `show_error!` to
ensure verbose output is redirected to stdout, not stderr.
2021-07-31 13:06:37 +02:00
Andreas Hartmann
2b18e45ece install: Use UResult
Related to uutils#2464
2021-07-31 13:06:37 +02:00
Terts Diepraam
eae8c72793
Merge pull request #2467 from Funky185540/backup_mode_determination
backup_control: Fix backup mode determination
2021-07-20 13:27:04 +02:00
Andreas Hartmann
e07b4e9f59 install: Adapt to modified backup mode determination 2021-07-19 17:01:49 +02:00
Sylvestre Ledru
26a882551b update the dep to uucore_procs 0.0.6 2021-07-11 21:04:11 +02:00
Sylvestre Ledru
1d8a66b7d3 Update to version 0.0.7 2021-07-11 18:04:56 +02:00
Sylvestre Ledru
d3652cc3c0
Merge pull request #2457 from Funky185540/install-implement-backup
install: implement --backup, -b and -S
2021-07-04 09:57:45 +02:00
Andreas Hartmann
1a43a94e31 install: Apply rustfmt 2021-06-27 17:59:04 +02:00
Michael Debertol
2ebca384c6 all utils: enable wrap_help
This makes clap wrap the help text according to the terminal width,
which improves readability for terminal widths < 120 chars,
because clap defaults to a width of 120 chars without this feature.
2021-06-27 16:17:10 +02:00
Andreas Hartmann
df41fed640 install: Mark '-S', '-b' and '--backup' as implemented
Removes the "unimplemented" notice from the respective help texts. Stop
printing errors if the options are supplied via CLI.
2021-06-27 09:54:55 +02:00
Andreas Hartmann
5437985705 install: Implement '--backup' and '-b'
Adds the ability to perform file backups before installing newer files on top
of existing ones. Adds a status message about backups to stdout if running in
verbose mode.
2021-06-27 09:54:17 +02:00
Andreas Hartmann
49a9f359bb install: Make use of 'backup_controls' for '--backup' opts
Use the methods and types offered by the 'backup_controls' module to implement
the logic for backing up files instead of overwriting.
2021-06-27 09:54:07 +02:00
Andreas Hartmann
a85adf3c3f install: Internally rename short '-b' option
Rename from OPT_BACKUP_2 to a more descriptive name "OPT_BACKUP_NO_ARGS".
2021-06-26 00:27:08 +02:00
Andreas Hartmann
3155cd510f install: Fix argument parsing for '--backup'
The '--backup' option would previously accept arguments separated from the
option either by a space or an equals sign. The GNU implementation strictly
requires an "equals" for argument separation.

As the argument to '--backup' is optional, the equals sign mustn't be ommited
as otherwise there is no way to tell a file argument apart from an argument
that's meant for the '--backup' option. This ensures that if '--backup' is
present it either has no further associated arguments (i.e. fallback to the
default), or the arguments are separated by an equals sign.
2021-06-26 00:27:08 +02:00
Michael Debertol
0531153fa6 uutils: move clap::App creation to separate functions 2021-06-25 21:23:45 +02:00
Michael Debertol
4e62c9db71 install: support target-directory 2021-06-18 16:45:36 +02:00
Jeong YunWon
d329c7c864 install : clean up returning Err 2021-06-11 23:26:58 +09:00
Roy Ivy III
c66d67a0b9 refactor/install ~ fix cargo clippy complaint (clippy::needless_borrow) 2021-06-06 19:28:23 -05:00
Sylvestre Ledru
d8c06dd6bb use clap::crate_version macro instead of the env variable 2021-06-02 19:00:19 +02:00
Roy Ivy III
9c0c8eb59f change ~ remove 'main.rs' spell-checker exceptions 2021-05-31 08:11:31 -05:00
Jan Scheer
3aeccfd802 fix a lot of clippy warnings 2021-05-29 15:11:22 +02:00
Yağız can Değirmenci
c78a7937f8 chore: delete show_info macro and replace with show_error 2021-05-26 02:27:10 +03:00
Sivachandran
0ea35f3fbc
Implement install create leading components(-D) option (#2092)
* Implement install's create leading components(-D) option

* Format changes

* Add install test to check fail on long dir name
2021-04-19 22:03:13 +02:00
Reto Hablützel
d67560c37a fix clippy for unix 2021-04-11 16:34:19 +02:00
Sivachandran
ee070028e4
install: implement stripping symbol table (#2047) 2021-04-10 11:53:29 +02:00
Sylvestre Ledru
f37284129e new release 0.0.6 to address the cat issue 2021-04-03 16:06:58 +02:00
Sylvestre Ledru
ac031dffa4 new release 0.0.5 2021-04-03 10:30:07 +02:00
Juliana Rodrigueiro
97da14fcb2 install: Fix behaviour of the -d flag
The '-d' flag should create all ancestors (or components) of a
directory regardless of the presence of the "-D" flag.

From the man page:
       -d, --directory
              treat all arguments as directory names; create all components of the specified directories

With GNU:
    $ install -v -d dir1/di2
    install: creating directory 'dir1'
    install: creating directory 'dir1/di2'
With this version:
    $ ./target/release/install -v -d dir3/di4
    install: dir3/di4: No such file or directory (os error 2)
    install: dir3/di4: chmod failed with error No such file or directory (os error 2)
    install: created directory 'dir3/di4'

Also, one of the unit tests misinterprets what a "component" is,
and hence was fixed.
2021-04-02 20:04:25 +01:00
Juliana Rodrigueiro
2a02f01fc2 install: Don't display success message when the dir was not created
Also don't run chmod when we just failed to create the directory.

Behaviour before this patch:

    $ ./target/release/install -v -d dir1/dir2
    install: dir1/dir2: Permission denied (os error 13)
    install: dir1/dir2: chmod failed with error No such file or directory (os error 2)
    install: created directory 'dir1/dir2'
2021-04-02 19:59:43 +01:00
Juliana Rodrigueiro
349c4f7af6 install: Make log message identical to GNU install
$ install -v -d dir1
    install: creating directory 'dir1'
2021-04-02 19:59:43 +01:00
Sylvestre Ledru
faef7e9214 fix(install): Unbreak the CI by bringing the old behavior for install of /dev/null 2021-03-27 10:08:06 +01:00
Antonio Gurgel
35675fdfe7
install: implement -C / --compare (#1811)
* install: implement `-C` / `--compare`

GNU coreutils [1] checks the following: whether
- either file is nonexistent,
- there's a sticky bit or set[ug]id bit in play,
- either file isn't a regular file,
- the sizes of both files mismatch,
- the destination file's owner differs from intended, or
- the contents of both files mismatch.

[1] https://git.savannah.gnu.org/cgit/coreutils.git/tree/src/install.c?h=v8.32#n174

* Add test: non-regular files

* Forgot a #[test]

* Give up on non-regular file test

* `cargo fmt` install.rs
2021-03-27 09:18:47 +01:00
Neculai Balaban
f8125a1040 install: match GNU warning output 2021-03-20 16:11:29 +02:00
Neculai Balaban
0f7423dfa6 install: fix bug #1823 2021-03-20 14:49:22 +02:00
Hari
406cd865eb
install: run rustfmt
Fix formatting issues based on PR review comments
2021-03-15 11:00:30 -04:00
Hari
68ec2ed0f3
install: Implement --preserve-timestamps (-p)
Last access and last modify timestamps are extracted from the
existing file metadata and are applied to the newly created file.
2021-03-12 16:51:47 -05:00
Sylvestre Ledru
6ad8528b99 update of the uucore dep to 0.0.7 2021-03-07 11:29:38 +01:00
Sylvestre Ledru
6481c5a247 Prepare version 0.0.4 2021-03-07 11:29:38 +01:00
Sylvestre Ledru
51383e10e6
Fix: install /dev/null target (#1646)
* fix(install): workaround the /dev/null bug

Caused by a limitation of fs::copy in rust. see:
https://github.com/rust-lang/rust/issues/79390
2021-02-11 15:59:58 +01:00