~danyspin97/rinstall

4962d0b231bd0a2d748c07a929c05f422a60352e — Danilo Spinella 10 months ago 18533de
Support install.yml file inside .package directory
2 files changed, 20 insertions(+), 5 deletions(-)

M README.md
M src/main.rs
M README.md => README.md +4 -2
@@ 39,8 39,10 @@ $ ./target/release/rinstall --user

## Usage

In a project with the `install.yml` file present, run the following command as root to perform a
system-wide installation:
If the project has an `install.yml` file present, either in the root directory or in the
`.package` directory, it supports installation via **rinstall**.

Run the following command as root to perform a system-wide installation:

```
# rinstall

M src/main.rs => src/main.rs +16 -3
@@ 74,10 74,23 @@ fn main() -> Result<()> {

    let dirs = Dirs::new(config).context("unable to create dirs")?;

    // Try root/install.yml and root/.packaging/install.yml files
    let install_spec = {
        let install_spec = package_dir.join("install.yml");
        if install_spec.exists() {
            install_spec
        } else {
            let install_spec = package_dir.join(".packaging").join("install.yml");
            if install_spec.exists() {
                install_spec
            } else {
                bail!("unable to find 'install.yml' file");
            }
        }
    };
    let program: Package = serde_yaml::from_str(
        &fs::read_to_string(package_dir.join("install.yml")).with_context(|| {
            format!("unable to read file {:?}", package_dir.join("install.yml"))
        })?,
        &fs::read_to_string(&install_spec)
            .with_context(|| format!("unable to read file {:?}", install_spec))?,
    )?;

    program