WEBDIR=https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/
RPMNAME=cuda-cudart-devel
OUTDIR="$(pwd)"
LOCALPATH="$RPMNAME"

mkdir "$LOCALPATH"
pushd "$LOCALPATH"

mkdir .rpms
git init
git config advice.addIgnoredFile false

curl "$WEBDIR" | sed -ne "s/.*'\($RPMNAME[^']*\)'.*/\1/p" | while read rpm
do
    wget "$WEBDIR"/"$rpm" -O .rpms/"$rpm"
done

for rpm in .rpms/*
do
    git rm -rf * || true
    rm -rf * || true
    rpm2cpio "$rpm" | cpio -idv &&
      git add * &&
      git commit -m "$rpm" ||
        exit
done

git log --patch --raw > "$OUTDIR"/"$RPMNAME".gitpatchraw
popd

echo Created "$LOCALPATH" and "$RPMNAME".gitpatchraw .
