2020-05-26 13:20:25 +00:00
|
|
|
#!/bin/bash
|
2020-04-01 11:49:29 +00:00
|
|
|
|
2020-05-26 14:59:51 +00:00
|
|
|
set -e -o pipefail
|
|
|
|
|
2020-04-29 16:00:24 +00:00
|
|
|
# In case no value is specified, default values will be used.
|
|
|
|
gitrepo="https://github.com/ceph/ceph-csi"
|
|
|
|
workdir="tip/"
|
2021-02-25 08:23:57 +00:00
|
|
|
ref="devel"
|
|
|
|
base="devel"
|
2020-08-18 10:58:28 +00:00
|
|
|
history="no"
|
2020-04-29 16:00:24 +00:00
|
|
|
|
|
|
|
ARGUMENT_LIST=(
|
|
|
|
"ref"
|
|
|
|
"workdir"
|
|
|
|
"gitrepo"
|
2020-05-27 07:35:07 +00:00
|
|
|
"base"
|
2020-04-29 16:00:24 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
opts=$(getopt \
|
2020-08-18 12:18:33 +00:00
|
|
|
--longoptions "$(printf "%s:," "${ARGUMENT_LIST[@]}")history,help" \
|
2020-04-29 16:00:24 +00:00
|
|
|
--name "$(basename "${0}")" \
|
|
|
|
--options "" \
|
|
|
|
-- "$@"
|
|
|
|
)
|
2020-05-26 13:22:58 +00:00
|
|
|
ret=$?
|
2020-04-29 16:00:24 +00:00
|
|
|
|
2020-05-26 13:22:58 +00:00
|
|
|
if [ ${ret} -ne 0 ]
|
2020-05-07 07:45:49 +00:00
|
|
|
then
|
2020-05-26 14:59:51 +00:00
|
|
|
echo "Try '--help' for more information."
|
|
|
|
exit 1
|
2020-05-07 07:45:49 +00:00
|
|
|
fi
|
|
|
|
|
2020-05-26 14:59:51 +00:00
|
|
|
eval set -- "${opts}"
|
2020-04-29 16:00:24 +00:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "${1}" in
|
2020-05-26 14:59:51 +00:00
|
|
|
--help)
|
2020-04-29 16:00:24 +00:00
|
|
|
shift
|
|
|
|
echo "Options:"
|
|
|
|
echo "--help|-h specify the flags"
|
|
|
|
echo "--ref specify the reference of pr"
|
|
|
|
echo "--workdir specify the working directory"
|
2020-05-26 14:59:51 +00:00
|
|
|
echo "--gitrepo specify the git repository"
|
2020-05-27 07:35:07 +00:00
|
|
|
echo "--base specify the base branch to checkout"
|
2020-08-18 10:58:28 +00:00
|
|
|
echo "--history fetch the history of the base branch"
|
2020-04-29 16:00:24 +00:00
|
|
|
echo " "
|
|
|
|
echo "Sample Usage:"
|
|
|
|
echo "./prepare.sh --gitrepo=https://github.com/example --workdir=/opt/build --ref=pull/123/head"
|
|
|
|
exit 0
|
|
|
|
;;
|
2020-05-26 14:59:51 +00:00
|
|
|
--gitrepo)
|
2020-04-29 16:00:24 +00:00
|
|
|
shift
|
|
|
|
gitrepo=${1}
|
|
|
|
;;
|
2020-05-26 14:59:51 +00:00
|
|
|
--workdir)
|
2020-04-29 16:00:24 +00:00
|
|
|
shift
|
|
|
|
workdir=${1}
|
|
|
|
;;
|
2020-05-26 14:59:51 +00:00
|
|
|
--ref)
|
2020-04-29 16:00:24 +00:00
|
|
|
shift
|
|
|
|
ref=${1}
|
2020-05-26 14:59:51 +00:00
|
|
|
echo "${ref}"
|
2020-04-29 16:00:24 +00:00
|
|
|
;;
|
2020-05-27 07:35:07 +00:00
|
|
|
--base)
|
|
|
|
shift
|
|
|
|
base=${1}
|
|
|
|
;;
|
2020-08-18 10:58:28 +00:00
|
|
|
--history)
|
|
|
|
history="yes"
|
|
|
|
;;
|
2020-04-29 16:00:24 +00:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2020-04-01 11:49:29 +00:00
|
|
|
set -x
|
|
|
|
|
2022-10-12 16:18:00 +00:00
|
|
|
dnf -y install git podman make wget
|
2020-04-01 11:49:29 +00:00
|
|
|
|
2021-07-16 09:44:55 +00:00
|
|
|
# minikube wants the user (everything runs as root) to be in the libvirt group
|
|
|
|
getent group libvirt || groupadd --system libvirt
|
|
|
|
usermod --append --groups libvirt root
|
|
|
|
|
2020-08-18 10:58:28 +00:00
|
|
|
# if --history is passed, don't pass --depth=1
|
|
|
|
depth='--depth=1'
|
|
|
|
if [[ "${history}" == 'yes' ]]
|
|
|
|
then
|
|
|
|
depth=''
|
|
|
|
fi
|
|
|
|
|
2020-10-27 11:31:36 +00:00
|
|
|
git clone "${depth}" --branch="${base}" "${gitrepo}" "${workdir}"
|
2020-05-26 14:59:51 +00:00
|
|
|
cd "${workdir}"
|
2020-05-27 07:35:07 +00:00
|
|
|
git fetch origin "${ref}:tip/${ref}"
|
2020-04-29 16:00:24 +00:00
|
|
|
git checkout "tip/${ref}"
|