portable: handle gotd/auth
[got-portable.git] / regress / gotd / prepare_test_repo.sh
blob8e364cdc52ed8662ae2562398c885d5a21c3061b
1 #!/bin/sh
3 # Copyright (c) 2022 Stefan Sperling <stsp@openbsd.org>
5 # Permission to use, copy, modify, and distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 . ../cmdline/common.sh
19 make_repo()
21 local repo_path="$1"
22 local no_tree="$2"
24 gotadmin init "${repo_path}"
26 if [ -n "$no_tree" ]; then
27 return
30 test_tree=`mktemp -d "${GOTD_TEST_ROOT}/gotd-test-tree-XXXXXXXXXX"`
31 make_test_tree "$test_tree"
32 got import -m "import the test tree" -r "${GOTD_TEST_REPO}" "$test_tree" \
33 > /dev/null
34 rm -r "$test_tree" # TODO: trap
38 if [ -e "${GOTD_TEST_REPO}" ]; then
39 rm -rf "${GOTD_TEST_REPO}"
42 make_repo "${GOTD_TEST_REPO}" "$1"