SUMMARY="A minimal, fast alternative to 'du -sh'"
DESCRIPTION="diskus is a very simple program that computes the total size of \
the current directory. It is a parallelized version of 'du -sh'. On the \
author's 8-core laptop, it is about ten times faster than 'du' for a cold disk \
cache and more than three times faster on a warm disk cache."
HOMEPAGE="https://github.com/sharkdp/diskus"
COPYRIGHT="diskus developers 2018-2019"
LICENSE="Apache v2
	MIT"
REVISION="1"
SOURCE_URI="$HOMEPAGE/archive/v$portVersion.tar.gz"
CHECKSUM_SHA256="661687edefa3218833677660a38ccd4e2a3c45c4a66055c5bfa4667358b97500"
SOURCE_FILENAME="diskus-$portVersion.tar.gz"

SOURCE_URI_2="https://static.crates.io/crates/ansi_term/ansi_term-0.11.0.crate"
CHECKSUM_SHA256_2="ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"

SOURCE_URI_3="https://static.crates.io/crates/arrayvec/arrayvec-0.4.11.crate"
CHECKSUM_SHA256_3="b8d73f9beda665eaa98ab9e4f7442bd4e7de6652587de55b2525e52e29c1b0ba"

SOURCE_URI_4="https://static.crates.io/crates/atty/atty-0.2.13.crate"
CHECKSUM_SHA256_4="1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90"

SOURCE_URI_5="https://static.crates.io/crates/bitflags/bitflags-1.1.0.crate"
CHECKSUM_SHA256_5="3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd"

SOURCE_URI_6="https://static.crates.io/crates/cfg-if/cfg-if-0.1.9.crate"
CHECKSUM_SHA256_6="b486ce3ccf7ffd79fdeb678eac06a9e6c09fc88d33836340becb8fffe87c5e33"

SOURCE_URI_7="https://static.crates.io/crates/clap/clap-2.33.0.crate"
CHECKSUM_SHA256_7="5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9"

SOURCE_URI_8="https://static.crates.io/crates/crossbeam-channel/crossbeam-channel-0.3.9.crate"
CHECKSUM_SHA256_8="c8ec7fcd21571dc78f96cc96243cab8d8f035247c3efd16c687be154c3fa9efa"

SOURCE_URI_9="https://static.crates.io/crates/crossbeam-deque/crossbeam-deque-0.7.1.crate"
CHECKSUM_SHA256_9="b18cd2e169ad86297e6bc0ad9aa679aee9daa4f19e8163860faf7c164e4f5a71"

SOURCE_URI_10="https://static.crates.io/crates/crossbeam-epoch/crossbeam-epoch-0.7.2.crate"
CHECKSUM_SHA256_10="fedcd6772e37f3da2a9af9bf12ebe046c0dfe657992377b4df982a2b54cd37a9"

SOURCE_URI_11="https://static.crates.io/crates/crossbeam-queue/crossbeam-queue-0.1.2.crate"
CHECKSUM_SHA256_11="7c979cd6cfe72335896575c6b5688da489e420d36a27a0b9eb0c73db574b4a4b"

SOURCE_URI_12="https://static.crates.io/crates/crossbeam-utils/crossbeam-utils-0.6.6.crate"
CHECKSUM_SHA256_12="04973fa96e96579258a5091af6003abde64af786b860f18622b82e026cca60e6"

SOURCE_URI_13="https://static.crates.io/crates/either/either-1.5.3.crate"
CHECKSUM_SHA256_13="bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3"

SOURCE_URI_14="https://static.crates.io/crates/fuchsia-cprng/fuchsia-cprng-0.1.1.crate"
CHECKSUM_SHA256_14="a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"

SOURCE_URI_15="https://static.crates.io/crates/humansize/humansize-1.1.0.crate"
CHECKSUM_SHA256_15="b6cab2627acfc432780848602f3f558f7e9dd427352224b0d9324025796d2a5e"

SOURCE_URI_16="https://static.crates.io/crates/itoa/itoa-0.4.4.crate"
CHECKSUM_SHA256_16="501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f"

SOURCE_URI_17="https://static.crates.io/crates/kernel32-sys/kernel32-sys-0.2.2.crate"
CHECKSUM_SHA256_17="7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"

SOURCE_URI_18="https://static.crates.io/crates/lazy_static/lazy_static-1.4.0.crate"
CHECKSUM_SHA256_18="e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"

SOURCE_URI_19="https://static.crates.io/crates/libc/libc-0.2.62.crate"
CHECKSUM_SHA256_19="34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"

SOURCE_URI_20="https://static.crates.io/crates/memoffset/memoffset-0.5.1.crate"
CHECKSUM_SHA256_20="ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f"

SOURCE_URI_21="https://static.crates.io/crates/nodrop/nodrop-0.1.13.crate"
CHECKSUM_SHA256_21="2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945"

SOURCE_URI_22="https://static.crates.io/crates/num-format/num-format-0.4.0.crate"
CHECKSUM_SHA256_22="bafe4179722c2894288ee77a9f044f02811c86af699344c498b0840c698a2465"

SOURCE_URI_23="https://static.crates.io/crates/num_cpus/num_cpus-1.10.1.crate"
CHECKSUM_SHA256_23="bcef43580c035376c0705c42792c294b66974abbfd2789b511784023f71f3273"

SOURCE_URI_24="https://static.crates.io/crates/rand/rand-0.4.6.crate"
CHECKSUM_SHA256_24="552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"

SOURCE_URI_25="https://static.crates.io/crates/rand_core/rand_core-0.3.1.crate"
CHECKSUM_SHA256_25="7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"

SOURCE_URI_26="https://static.crates.io/crates/rand_core/rand_core-0.4.2.crate"
CHECKSUM_SHA256_26="9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"

SOURCE_URI_27="https://static.crates.io/crates/rayon/rayon-1.2.0.crate"
CHECKSUM_SHA256_27="83a27732a533a1be0a0035a111fe76db89ad312f6f0347004c220c57f209a123"

SOURCE_URI_28="https://static.crates.io/crates/rayon-core/rayon-core-1.6.0.crate"
CHECKSUM_SHA256_28="98dcf634205083b17d0861252431eb2acbfb698ab7478a2d20de07954f47ec7b"

SOURCE_URI_29="https://static.crates.io/crates/rdrand/rdrand-0.4.0.crate"
CHECKSUM_SHA256_29="678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"

SOURCE_URI_30="https://static.crates.io/crates/remove_dir_all/remove_dir_all-0.5.2.crate"
CHECKSUM_SHA256_30="4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e"

SOURCE_URI_31="https://static.crates.io/crates/rustc_version/rustc_version-0.2.3.crate"
CHECKSUM_SHA256_31="138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"

SOURCE_URI_32="https://static.crates.io/crates/scopeguard/scopeguard-1.0.0.crate"
CHECKSUM_SHA256_32="b42e15e59b18a828bbf5c58ea01debb36b9b096346de35d941dcb89009f24a0d"

SOURCE_URI_33="https://static.crates.io/crates/semver/semver-0.9.0.crate"
CHECKSUM_SHA256_33="1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"

SOURCE_URI_34="https://static.crates.io/crates/semver-parser/semver-parser-0.7.0.crate"
CHECKSUM_SHA256_34="388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"

SOURCE_URI_35="https://static.crates.io/crates/strsim/strsim-0.8.0.crate"
CHECKSUM_SHA256_35="8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"

SOURCE_URI_36="https://static.crates.io/crates/tempdir/tempdir-0.3.7.crate"
CHECKSUM_SHA256_36="15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"

SOURCE_URI_37="https://static.crates.io/crates/term_size/term_size-0.3.1.crate"
CHECKSUM_SHA256_37="9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"

SOURCE_URI_38="https://static.crates.io/crates/textwrap/textwrap-0.11.0.crate"
CHECKSUM_SHA256_38="d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"

SOURCE_URI_39="https://static.crates.io/crates/unicode-width/unicode-width-0.1.6.crate"
CHECKSUM_SHA256_39="7007dbd421b92cc6e28410fe7362e2e0a2503394908f417b68ec8d1c364c4e20"

SOURCE_URI_40="https://static.crates.io/crates/vec_map/vec_map-0.8.1.crate"
CHECKSUM_SHA256_40="05c78687fb1a80548ae3250346c3db86a80a7cdd77bda190189f2d0a0987c81a"

SOURCE_URI_41="https://static.crates.io/crates/winapi/winapi-0.2.8.crate"
CHECKSUM_SHA256_41="167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"

SOURCE_URI_42="https://static.crates.io/crates/winapi/winapi-0.3.8.crate"
CHECKSUM_SHA256_42="8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6"

SOURCE_URI_43="https://static.crates.io/crates/winapi-build/winapi-build-0.1.1.crate"
CHECKSUM_SHA256_43="2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"

SOURCE_URI_44="https://static.crates.io/crates/winapi-i686-pc-windows-gnu/winapi-i686-pc-windows-gnu-0.4.0.crate"
CHECKSUM_SHA256_44="ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"

SOURCE_URI_45="https://static.crates.io/crates/winapi-x86_64-pc-windows-gnu/winapi-x86_64-pc-windows-gnu-0.4.0.crate"
CHECKSUM_SHA256_45="712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"

ARCHITECTURES="all !x86_gcc2 ?x86"
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
SECONDARY_ARCHITECTURES="x86"
commandBinDir=$prefix/bin
fi

PROVIDES="
	diskus$secondaryArchSuffix = $portVersion
	cmd:diskus
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:cargo$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	"

defineDebugInfoPackage diskus$secondaryArchSuffix \
	"$commandBinDir"/diskus

BUILD()
{
	export CARGO_HOME=$sourceDir/../cargo
	vendor=$CARGO_HOME/haiku
	mkdir -p "$vendor"
	for i in $(seq 2 45); do
		eval "srcDir=\$sourceDir$i"
		eval "sha256sum=\$CHECKSUM_SHA256_$i"
		set -- "$srcDir"/*
		ln -sf "$1" "$vendor"
		cat <<-EOF >"$vendor/${1##*/}/.cargo-checksum.json"
		{
		  "package": "$sha256sum",
		  "files": {}
		}
		EOF
	done

	cat <<-EOF >"$CARGO_HOME"/config
	[source.haiku]
	directory = "$vendor"

	[source.crates-io]
	replace-with = "haiku"
	EOF

	cargo build --release --frozen
}

INSTALL()
{
	install -m 755 -d "$commandBinDir" "$docDir" "$manDir/man1"
	install -m 755 target/release/diskus "$commandBinDir"
	install -m 644 README.md "$docDir"
	install -m 644 doc/diskus.1 "$manDir/man1"

}

TEST()
{
	export CARGO_HOME=$sourceDir/../cargo
	cargo test --release --frozen
}
