#!/bin/sh
osc mkpac rust-$1
(
cd rust-$1
url="https://src.fedoraproject.org/rpms/rust-$1"
sprg='/%cargo_generate_buildrequires/d; /%cargo_test/d; s~%{crates_source}~https://crates.io/api/v1/crates/%crate/%version/download#/%crate-%version.crate~;'

if [[ "$LITE" ]]; then
  sprg="$sprg"'; /BuildRequires:.*crate(.*/d; /%cargo_build/d; s~%cargo_install~dir=%{buildroot}/%{crate_instdir}; mkdir -pv "$dir"; cp -R ./* $dir/; echo \"{\\\"files\\\":{},\\\"package\\\":\\\"\\\"}\" > "$dir/.cargo-checksum.json" ~;'
fi

cat << EOF > _service
<services>
 <service name="download_files"/>
</services>
EOF
echo "setBadness('summary-too-long', 0)" > "rust-$1.rpmlintrc"

git clone --depth 1 "$url" "../.dir_$1"; cp "../.dir_$1/"* ./; sed -i "$sprg" "rust-$1.spec"
osc add *
osc update
osc ci -m update
osc service rr
)
