Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,166 changes: 1,597 additions & 569 deletions Cargo.lock

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,36 @@ build = "build.rs"
default=["testpacman", "rustls-tls"]
testpacman = [] # whether to perform pacman checks on tests
native-tls = ["raur/native-tls"] # build with support for OS native TLS
rustls-tls = ["raur/rustls-tls"] # build with rustls TLS
rustls-tls = ["raur/rusttls-tls"] # build with rustls TLS

[build-dependencies]
structopt = "0.3.26"
libscmp = "0.2.0"

[dependencies]
alpm = { version = "2.2.3", default-features = false, features = [], optional = true }
anyhow = { version = "1.0.79", default-features = false, features = ["std", "backtrace"] }
chrono = { version = "0.4.31", default-features = false, features = ["std", "clock"] }
colored = "2.0.2"
directories = "5.0.1"
env_logger = "0.10.1"
alpm = { version = "5.0.2", default-features = false, features = [], optional = true }
anyhow = { version = "1.0.100", default-features = false, features = ["std", "backtrace"] }
chrono = { version = "0.4.43", default-features = false, features = ["std", "clock"] }
colored = "3.1.1"
directories = "6.0.0"
env_logger = "0.11.9"
fs2 = "0.4.3"
fs_extra = "1.3.0"
indexmap = { version = "1.9.3", default-features = false }
itertools = { version = "0.11.0", default-features = false, features = ["use_std"] }
lazy_static = "1.4.0"
libc = { version = "0.2.151", default-features = false }
libflate = "2.0.0"
log = { version = "0.4.20", default-features = false }
indexmap = { version = "2.13.0", default-features = false }
itertools = { version = "0.14.0", default-features = false, features = ["use_std"] }
lazy_static = "1.5.0"
libc = { version = "0.2.163", default-features = false }
libflate = "2.2.1"
log = { version = "0.4.28", default-features = false }
prettytable-rs = "0.10.0"
raur = { version = "7.0.0", default-features = false, features = ["blocking", "rustls-tls"] }
raur = { version = "8.0.0", default-features = false, features = ["blocking", "rusttls-tls"] }
regex = { version = "1.9.6", default-features = false, features = ["perf"] }
rm_rf = "0.6.2"
ruzstd = "0.4.0"
srcinfo = "1.1.0"
ruzstd = "0.8.2"
srcinfo = "2.1"
structopt = "0.3.26"
tar = { version = "0.4.40", default-features = false }
termize = "0.1.1"
tar = { version = "0.4.44", default-features = false }
termize = "0.2.1"
uname = "0.1.1"
xz2 = "0.1.7"

Expand Down
64 changes: 64 additions & 0 deletions docs/local_development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Local development
When creating new features for rua, this document describes how to set up your computer, build and test the changes

# Prerequisites

You'll need rust installed on your system to begin development. The [Arch wiki](https://wiki.archlinux.org/title/Rust) describes the various ways to accomplish this (but installing the rustup package is suggested). Use the stable toolchain `rustup default stable`

Next, install the system dependencies listed in project's [README.md](/README.md). You'll also need to add clippy `rustup component add clippy` in order to run the linters.
With that, assuming you have rust, a rust toolchain, cargo, you should be ready to build. You can verify your system is setup correctly by following the [Compiling](#compiling) section

# Compiling

Debug build (faster compile, slower binary):

```sh
cargo build
```

Release build (optimized binary):

```sh
cargo build --release
```

Binaries are written to `target/debug/rua` and `target/release/rua` respectively.

### Running the locally built binary

Using cargo:

```sh
cargo run -- <args> # debug build
cargo run --release -- <args> # release build
```

Or run the binary directly:

```sh
./target/debug/rua --help
./target/release/rua install pinta
```

# Testing
Unit tests can be run with cargo

```sh
cargo test
```

To run a single test, pass a substring of the test name (all matching tests run):

```sh
cargo test test_name_substring
```

After a failure, re-run only that test by using its name (or a unique substring) from the failure output.

## Linters
The following linters are applied during CI build, and can be run locally to format and fix the code before committing
```sh
cargo fmt --all
cargo ci-clippy
shellcheck -e SC1090 res/wrapper/*.sh
```
49 changes: 49 additions & 0 deletions docs/updating_dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Updating dependencies

This document describes how to update the project's Rust dependencies (crates) in `Cargo.toml` and `Cargo.lock`.

# Prerequisites
You'll need the `cargo-edit` package to add the cargo upgrade/update commands, and `cargo-audit` to add the audit commands
```sh
pacman -S cargo-edit cargo-audit
```

# Updating all dependencies

Upgrade version requirements in `Cargo.toml` to the latest compatible (semver) versions, then refresh the lockfile:

```sh
cargo upgrade
cargo update
```

`cargo upgrade` rewrites dependency version bounds in `Cargo.toml`. `cargo update` resolves them and updates `Cargo.lock`.

To preview changes without modifying files:

```sh
cargo upgrade --dry-run
```

The output may show some crates as `incompatible`: the latest version bumps the major (or minor, for 0.x) version and may break the API. By default `cargo upgrade` only bumps to the latest *compatible* version for those; `new req` stays within semver.

## Finding missing upgrades
`cargo upgrade` still misses some dependencies. You can see which ones were not updated by running

```sh
cargo update --verbose
```
and then manually updating the cargo.toml with those versions


# After updating

Build, test, and run linters (see [local_development.md](local_development.md)). CI runs `cargo audit` on dependency changes; run it locally to check for known vulnerabilities:

```sh
cargo audit
```

Commit both `Cargo.toml` and `Cargo.lock` when updating dependencies.


1 change: 1 addition & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[toolchain]
channel = "stable"
profile = "minimal"
components = ["rust-analyzer"]
4 changes: 2 additions & 2 deletions src/action_builddir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ pub fn action_builddir(dir: &Option<PathBuf>, rua_paths: &RuaPaths, offline: boo

let srcinfo = wrapped::generate_srcinfo(dir_str, rua_paths).expect("Failed to obtain SRCINFO");
let ver = srcinfo.version();
let packages = srcinfo.pkgs.iter().map(|package| {
let arch = if package.arch.contains(&*pacman::PACMAN_ARCH) {
let packages = srcinfo.pkgs().iter().map(|package| {
let arch = if package.arch().contains(&*pacman::PACMAN_ARCH) {
pacman::PACMAN_ARCH.to_string()
} else {
"any".to_string()
Expand Down
2 changes: 1 addition & 1 deletion src/action_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ fn install_all(
.unique_by(|(pkgbase, _depth, _split)| pkgbase.to_string())
.collect::<Vec<_>>();
// once we have a collection of pkgname-s and their depth, proceed straightforwardly.
for (depth, packages) in &packages.iter().group_by(|(_pkgbase, depth, _split)| *depth) {
for (depth, packages) in &packages.iter().chunk_by(|(_pkgbase, depth, _split)| *depth) {
let packages = packages.collect::<Vec<&(String, i32, String)>>();
for (pkgbase, _depth, _split) in &packages {
let review_dir = rua_paths.review_dir(pkgbase);
Expand Down
4 changes: 2 additions & 2 deletions src/print_format.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::anyhow;
use anyhow::Result;
use chrono::NaiveDateTime;
use chrono::DateTime;
use colored::*;

const DATE_FORMAT: &str = "%Y-%m-%d %H:%M:%S UTC";
Expand All @@ -10,7 +10,7 @@ pub fn opt(opt: &Option<String>) -> &str {
}

pub fn date(timestamp: i64) -> Result<String> {
match NaiveDateTime::from_timestamp_opt(timestamp, 0) {
match DateTime::from_timestamp(timestamp, 0) {
Some(dt) => Ok(dt.format(DATE_FORMAT).to_string()),
None => Err(anyhow!(
"Cannot convert timestamp {} to date/time",
Expand Down
15 changes: 7 additions & 8 deletions src/srcinfo_to_pkgbuild.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::terminal_util::escape_bash_arg;
use srcinfo::ArchVec;
use srcinfo::Srcinfo;
use srcinfo::{ArchVecs, Srcinfo};
use std::path::Path;

fn push_field(pkgbuild: &mut String, key: &str, value: &str) {
Expand All @@ -17,26 +16,26 @@ fn push_array(pkgbuild: &mut String, key: &str, values: &[String]) {
pkgbuild.push_str(")\n");
}

fn push_arrays(pkgbuild: &mut String, key: &str, arch_values: &[ArchVec]) {
fn push_arrays(pkgbuild: &mut String, key: &str, arch_values: &ArchVecs) {
for values in arch_values {
if let Some(ref arch) = values.arch {
if let Some(arch) = values.arch() {
let key = &format!("{}_{}", key, arch);
push_array(pkgbuild, key, &values.vec);
push_array(pkgbuild, key, values.values());
} else {
push_array(pkgbuild, key, &values.vec);
push_array(pkgbuild, key, values.values());
};
}
}

pub fn static_pkgbuild(path: &Path) -> String {
let srcinfo = Srcinfo::parse_file(path)
let srcinfo = Srcinfo::from_path(path)
.unwrap_or_else(|e| panic!("{}:{} Failed to parse {:?}, {}", file!(), line!(), path, e));
let mut pkgbuild = String::new();

push_field(&mut pkgbuild, "pkgname", "tmp");
push_field(&mut pkgbuild, "pkgver", "1");
push_field(&mut pkgbuild, "pkgrel", "1");
push_array(&mut pkgbuild, "arch", &srcinfo.pkg.arch);
push_array(&mut pkgbuild, "arch", srcinfo.pkg.arch());
push_arrays(&mut pkgbuild, "source", &srcinfo.base.source);
push_arrays(&mut pkgbuild, "md5sums", &srcinfo.base.md5sums);
push_arrays(&mut pkgbuild, "sha1sums", &srcinfo.base.sha1sums);
Expand Down
2 changes: 1 addition & 1 deletion src/tar_check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use colored::*;
use indexmap::IndexSet;
use libflate::gzip::Decoder;
use log::debug;
use ruzstd::StreamingDecoder;
use ruzstd::decoding::StreamingDecoder;
use std::fs::File;
use std::io::Read;
use std::path::Path;
Expand Down