1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00

util/publish: update to correctly handle dependencies between utils

This commit is contained in:
Terts Diepraam 2022-10-11 22:49:04 +02:00
parent d68dd23a56
commit b869c78343

View file

@ -1,11 +1,40 @@
#!/bin/sh #!/bin/sh
set -e
ARG="" ARG=""
if test "$1" != "--do-it"; then if test "$1" != "--do-it"; then
ARG="--dry-run --allow-dirty" ARG="--dry-run --allow-dirty"
fi 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}
set -e
for dir in src/uucore/ src/uucore_procs/ src/uu/stdbuf/src/libstdbuf/; do for dir in src/uucore/ src/uucore_procs/ src/uu/stdbuf/src/libstdbuf/; do
( (
cd "$dir" cd "$dir"
@ -15,10 +44,9 @@ for dir in src/uucore/ src/uucore_procs/ src/uu/stdbuf/src/libstdbuf/; do
sleep 2s sleep 2s
done done
PROGS=$(ls -1d src/uu/*/) for p in $TOTAL_ORDER; do
for p in $PROGS; do
( (
cd "$p" cd "src/uu/$p"
#shellcheck disable=SC2086 #shellcheck disable=SC2086
cargo publish $ARG cargo publish $ARG
) )