diff --git a/Cargo.toml b/Cargo.toml index 8f4d7c4..aadade0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ feat_common_core = [ ] [workspace.dependencies] -uucore = "0.0.24" +uucore = "0.0.25" clap = { version = "4.4", features = ["wrap_help", "cargo"] } clap_complete = "4.4" clap_mangen = "0.2" diff --git a/README.md b/README.md index e9f36ea..b0c3346 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,14 @@ # bsdutils +[![Crates.io](https://img.shields.io/crates/v/bsdutils.svg)](https://crates.io/crates/bsdutils) +[![Discord](https://img.shields.io/badge/discord-join-7289DA.svg?logo=discord&longCache=true&style=flat)](https://discord.gg/wQVJbvJ) +[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/uutils/bsdutils/blob/main/LICENSE) +[![dependency status](https://deps.rs/repo/github/uutils/bsdutils/status.svg)](https://deps.rs/repo/github/uutils/bsdutils) + +[![CodeCov](https://codecov.io/gh/uutils/bsdutils/branch/master/graph/badge.svg)](https://codecov.io/gh/uutils/bsdutils) + +# bsdutils + Rust reimplementation of the bsdutils project Provides command line tools: @@ -17,3 +26,21 @@ TODO: - `/usr/bin/scriptreplay`: This command is used to replay a terminal session that was recorded using the `script` command. - `/usr/bin/wall`: This command is used to broadcast a message to all users logged into a system. The message can be typed directly into the terminal or read from a file. + +## Installation + +Ensure you have Rust installed on your system. You can install Rust through [rustup](https://rustup.rs/). + +Clone the repository and build the project using Cargo: + +```bash +git clone https://github.com/uutils/bsdutils.git +cd bsdutils +cargo build --release +cargo run --release +``` + + +## License + +bsdutils is licensed under the MIT License - see the `LICENSE` file for details diff --git a/src/uu/renice/Cargo.toml b/src/uu/renice/Cargo.toml index 2f5fce5..d3a514a 100644 --- a/src/uu/renice/Cargo.toml +++ b/src/uu/renice/Cargo.toml @@ -2,8 +2,14 @@ name = "uu_renice" version = "0.0.1" edition = "2021" +authors = ["uutils developers"] +license = "MIT" +description = "renice ~ (uutils) Alter priority of running processes" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +homepage = "https://github.com/uutils/procps" +repository = "https://github.com/uutils/procps/tree/main/src/uu/renice" +keywords = ["bsdutils", "uutils", "cross-platform", "cli", "utility"] +categories = ["command-line-utilities"] [dependencies] libc = { workspace = true } diff --git a/util/publish.sh b/util/publish.sh new file mode 100755 index 0000000..b422630 --- /dev/null +++ b/util/publish.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# spell-checker:ignore uuhelp +ARG="" +if test "$1" != "--do-it"; then + ARG="--dry-run --allow-dirty" +fi + +# Function to check if the crate is already published +is_already_published() { + local crate_name=$1 + local crate_version=$2 + + # Use the crates.io API to get the latest version of the crate + local latest_published_version + latest_published_version=$(curl -s https://crates.io/api/v1/crates/$crate_name | jq -r '.crate.max_version') + + if [ "$latest_published_version" = "$crate_version" ]; then + return 0 + else + return 1 + fi +} + +# Figure out any dependencies between the util via Cargo.toml +# We store this as edges in a graph with each line: +# [dependent] [dependency] +# We use ROOT as a the node that should come before all other nodes. +PROGS=$(ls -1d src/uu/*/) +PARTIAL_ORDER="" +for p in $PROGS; do + DEPENDENCIES=$(grep -oE "^uu_[a-z0-9]+" ${p}Cargo.toml) + + # Turn "src/uu/util/" into "util" + p=${p#src/uu/} + p=${p%/} + + PARTIAL_ORDER+="$p ROOT\n" + while read d; do + if [ $d ]; then + # Remove "uu_" prefix + d=${d#uu_} + + PARTIAL_ORDER+="$p $d\n" + fi + done <<<"$DEPENDENCIES" +done + +# Apply tsort to get the order in which to publish the crates +TOTAL_ORDER=$(echo -e $PARTIAL_ORDER | tsort | tac) + +# Remove the ROOT node from the start +TOTAL_ORDER=${TOTAL_ORDER#ROOT} + +CRATE_VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2) + +set -e + +for p in $TOTAL_ORDER; do + ( + cd "src/uu/$p" + CRATE_NAME=$(grep '^name =' "Cargo.toml" | head -n1 | cut -d '"' -f2) + #shellcheck disable=SC2086 + if ! is_already_published "$CRATE_NAME" "$CRATE_VERSION"; then + cargo publish $ARG + else + echo "Skip: $CRATE_NAME $CRATE_VERSION already published" + fi + ) +done + +#shellcheck disable=SC2086 +cargo publish $ARG