#!/usr/bin/bash
# Checkout all spec files into subdirectories under the current directory.
#
# Copyright © 2014–2022 Daniel Fandrich.
# This program is free software; you can redistribute it and/or modify
# Licensed under GNU General Public License 2.0 or later.
# Some rights reserved. See COPYING.
#
# This is needed to bootstrap a spec directory. To update them later, run
# update-all-specs and checkout-new-specs, which should be slightly more
# efficient. This creates a "spec only" style tree.
#
# There is an unofficial daily snapshot available at
# https://pkgsubmit.mageia.org/specs/cauldron-sparse-svn-snapshot.tar.xz that
# extracts into a "massive checkout" style tree of .spec files as an
# alternative.

set -e
#export BASE_SVN='svn+ssh://svn.mageia.org/svn/packages/cauldron/'
export BASE_SVN='svn://svn.mageia.org/svn/packages/cauldron/'
readonly SPECSLIST="$(mktemp)"
trap 'rm -f "${SPECSLIST}"' EXIT

svn ls "$BASE_SVN" >"${SPECSLIST}"
echo $(wc -l "${SPECSLIST}" | awk '{print $1}') packages to check/download
xargs -n1 -i{} -P4 sh -c "svn co '$BASE_SVN'{}current/SPECS {}" <"${SPECSLIST}"
