Add support for local settings in the Git jobs

This commit is contained in:
Pierre Pronchery 2020-11-03 14:54:53 +01:00
parent e7b4f70c44
commit 73a95e5c92
3 changed files with 81 additions and 22 deletions

View File

@ -28,13 +28,8 @@
#variables
PREFIX="/usr/local"
GIT_BRANCH="master"
GIT_REMOTE="https://git.defora.org"
DATADIR="$PREFIX/share"
MIRROR="doc:doc"
PROGNAME_GIT_DOC="deforaos-git-doc"
#executables
CONFIGURE="/usr/local/bin/configure"
CONFIGURE="configure"
GIT="git"
GIT_CLONE="$GIT clone -q"
GIT_SUBMODULE="$GIT submodule -q"
@ -42,6 +37,18 @@ MAKE="make"
MKTEMP="mktemp"
RM="/bin/rm -f"
RSYNC="rsync -a"
#settings
DATADIR="$PREFIX/share"
GIT_BRANCH="master"
GIT_REMOTE=
MIRROR="doc:doc"
PROGNAME="deforaos-git-doc"
SYSCONFDIR="$PREFIX/etc"
#load local settings
[ -f "$SYSCONFDIR/DeforaOS/$PROGNAME.conf" ] &&
. "$SYSCONFDIR/DeforaOS/$PROGNAME.conf"
[ -f "$HOME/.config/DeforaOS/$PROGNAME.conf" ] &&
. "$HOME/.config/DeforaOS/$PROGNAME.conf"
#functions
@ -58,7 +65,7 @@ _git_tests()
fi
#clone the repository
$GIT_CLONE --single-branch -b "$GIT_BRANCH" \
"$GIT_REMOTE/${repository}.git" "$tmpdir/repository"
"$GIT_REMOTE${repository}.git" "$tmpdir/repository"
if [ $? -ne 0 ]; then
echo "$repository: Could not clone" 1>&2
elif [ -d "$tmpdir/repository/doc" ]; then
@ -87,12 +94,24 @@ _git_tests()
#usage
_usage()
{
echo "Usage: $PROGNAME_GIT_DOC repository" 1>&2
echo "Usage: $PROGNAME repository" 1>&2
return 1
}
#main
while getopts "O:" name; do
case "$name" in
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
*)
_usage
exit $?
;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 1 ]; then
_usage
exit $?

View File

@ -27,14 +27,22 @@
#variables
GIT_MIRROR="/home/defora/git"
GIT_REMOTE="origin"
PROGNAME_GIT_MIRROR="deforaos-git-mirror.sh"
#executables
GIT="git"
GIT_CLONE="$GIT clone -q"
GIT_FETCH="$GIT fetch -q"
GIT_RESET="$GIT reset -q"
GIT_MIRROR=
GIT_REMOTE="origin"
#settings
PREFIX="/usr/local"
PROGNAME="deforaos-git-mirror"
SYSCONFDIR="$PREFIX/etc"
#load local settings
[ -f "$SYSCONFDIR/DeforaOS/$PROGNAME.conf" ] &&
. "$SYSCONFDIR/DeforaOS/$PROGNAME.conf"
[ -f "$HOME/.config/DeforaOS/$PROGNAME.conf" ] &&
. "$HOME/.config/DeforaOS/$PROGNAME.conf"
#functions
@ -42,7 +50,7 @@ GIT_RESET="$GIT reset -q"
_git_mirror()
{
repository="$1"
mirror="$GIT_MIRROR/${repository}.git"
mirror="$GIT_MIRROR${repository}.git"
if [ ! -d "$mirror" ]; then
#clone the repository
@ -62,12 +70,24 @@ _git_mirror()
#usage
_usage()
{
echo "Usage: $PROGNAME_GIT_MIRROR repository" 1>&2
echo "Usage: $PROGNAME repository" 1>&2
return 1
}
#main
while getopts "O:" name; do
case "$name" in
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
*)
_usage
exit $?
;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 1 ]; then
_usage
exit $?

View File

@ -27,17 +27,25 @@
#variables
GIT_BRANCH="master"
GIT_REMOTE="https://git.defora.org"
PROGNAME_GIT_TESTS="deforaos-git-tests.sh"
#executables
CONFIGURE="/usr/local/bin/configure"
CONFIGURE="configure"
GIT="git"
GIT_CLONE="$GIT clone -q"
GIT_SUBMODULE="$GIT submodule -q"
MAKE="make"
MKTEMP="mktemp"
RM="/bin/rm -f"
RM="rm -f"
#settings
GIT_BRANCH="master"
GIT_REMOTE=
PREFIX="/usr/local"
PROGNAME="deforaos-git-tests"
SYSCONFDIR="$PREFIX/etc"
#load local settings
[ -f "$SYSCONFDIR/DeforaOS/$PROGNAME.conf" ] &&
. "$SYSCONFDIR/DeforaOS/$PROGNAME.conf"
[ -f "$HOME/.config/DeforaOS/$PROGNAME.conf" ] &&
. "$HOME/.config/DeforaOS/$PROGNAME.conf"
#functions
@ -54,15 +62,15 @@ _git_tests()
fi
#clone the repository
$GIT_CLONE --single-branch -b "$GIT_BRANCH" \
"$GIT_REMOTE/${repository}.git" "$tmpdir"
"$GIT_REMOTE${repository}.git" "$tmpdir"
if [ $? -ne 0 ]; then
echo "$repository: Could not clone" 1>&2
elif [ -d "$tmpdir/tests" ]; then
#update submodules if any
[ -f "$tmpdir/repository/.gitmodules" ] &&
(cd "$tmpdir/repository" &&
$GIT submodule init &&
$GIT submodule update)
$GIT_SUBMODULE init &&
$GIT_SUBMODULE update)
#run tests if available
(cd "$tmpdir" && $CONFIGURE && $MAKE tests) || ret=2
fi
@ -75,12 +83,24 @@ _git_tests()
#usage
_usage()
{
echo "Usage: $PROGNAME_GIT_TESTS repository" 1>&2
echo "Usage: $PROGNAME repository" 1>&2
return 1
}
#main
while getopts "O:" name; do
case "$name" in
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
*)
_usage
exit $?
;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 1 ]; then
_usage
exit $?