getopt added for much beauty
This commit is contained in:
parent
3b563a5ffc
commit
02592be363
59
build.sh
59
build.sh
|
|
@ -27,6 +27,8 @@ usage: $0 [options] [repo[:tag] ...]
|
||||||
options:
|
options:
|
||||||
--help, -h, -? Print this help message
|
--help, -h, -? Print this help message
|
||||||
--all Builds all docker repos specified in LIBRARY
|
--all Builds all docker repos specified in LIBRARY
|
||||||
|
--no-clone Don't pull the git repos
|
||||||
|
--no-build Don't build, just echo what would have built
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
# where to find repository manifest files
|
# where to find repository manifest files
|
||||||
|
|
@ -45,17 +47,46 @@ variables:
|
||||||
EOUSAGE
|
EOUSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO impove arg hanlding for complex args; ex: --exclude=repo:tag
|
opts="$(getopt -o 'h?' --long 'all,help,no-build,no-clone' -- "$@" || { usage >&2 && false; })"
|
||||||
if [ "$1" = '--help' -o "$1" = '-h' -o "$1" = '-?' ]; then
|
eval set -- "$opts"
|
||||||
usage
|
|
||||||
|
doClone=1
|
||||||
|
doBuild=1
|
||||||
|
buildAll=
|
||||||
|
while true; do
|
||||||
|
flag=$1
|
||||||
|
shift
|
||||||
|
case "$flag" in
|
||||||
|
--help|-h|'-?')
|
||||||
|
uasge
|
||||||
exit 0
|
exit 0
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
buildAll=1
|
||||||
|
;;
|
||||||
|
--no-clone)
|
||||||
|
doClone=
|
||||||
|
;;
|
||||||
|
--no-build)
|
||||||
|
doBuild=
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "error: unknown flag: $flag"
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
repos=()
|
||||||
|
if [ "$buildAll" ]; then
|
||||||
|
repos=( $(cd "$LIBRARY" && echo *) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = '--all' ]; then
|
repos+=( "$@" )
|
||||||
repos=( $(cd "$LIBRARY" && echo *) )
|
|
||||||
else
|
|
||||||
repos=( "$@" )
|
|
||||||
fi
|
|
||||||
repos=( "${repos[@]%/}" )
|
repos=( "${repos[@]%/}" )
|
||||||
|
|
||||||
if [ "${#repos[@]}" -eq 0 ]; then
|
if [ "${#repos[@]}" -eq 0 ]; then
|
||||||
|
|
@ -112,6 +143,12 @@ for repoTag in "${repos[@]}"; do
|
||||||
gitRepo="${gitRepo%/}"
|
gitRepo="${gitRepo%/}"
|
||||||
gitRepo="$SRC/$gitRepo"
|
gitRepo="$SRC/$gitRepo"
|
||||||
|
|
||||||
|
if [ -z "$doClone" ]; then
|
||||||
|
if [ "$doBuild" -a ! -d "$gitRepo" ]; then
|
||||||
|
echo >&2 "error: directory not found: $gitRepo"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
if [ ! -d "$gitRepo" ]; then
|
if [ ! -d "$gitRepo" ]; then
|
||||||
mkdir -p "$(dirname "$gitRepo")"
|
mkdir -p "$(dirname "$gitRepo")"
|
||||||
echo "Cloning '$gitUrl' into '$gitRepo' ..."
|
echo "Cloning '$gitUrl' into '$gitRepo' ..."
|
||||||
|
|
@ -120,6 +157,7 @@ for repoTag in "${repos[@]}"; do
|
||||||
else
|
else
|
||||||
( cd "$gitRepo" && git fetch -q && git fetch -q --tags )
|
( cd "$gitRepo" && git fetch -q && git fetch -q --tags )
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
repoGitRepo[$repo:$tag]="$gitRepo"
|
repoGitRepo[$repo:$tag]="$gitRepo"
|
||||||
repoGitRef[$repo:$tag]="$gitRef"
|
repoGitRef[$repo:$tag]="$gitRef"
|
||||||
|
|
@ -148,6 +186,8 @@ while [ "$#" -gt 0 ]; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Processing $repoTag ..."
|
echo "Processing $repoTag ..."
|
||||||
|
|
||||||
|
if [ "$doClone" ]; then
|
||||||
( cd "$gitRepo" && git clean -dfxq && git checkout -q "$gitRef" && "$dir/git-set-dir-times" )
|
( cd "$gitRepo" && git clean -dfxq && git checkout -q "$gitRef" && "$dir/git-set-dir-times" )
|
||||||
# TODO git tag
|
# TODO git tag
|
||||||
|
|
||||||
|
|
@ -165,7 +205,9 @@ while [ "$#" -gt 0 ]; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$doBuild" ]; then
|
||||||
thisLog="$logDir/build-$repoTag.log"
|
thisLog="$logDir/build-$repoTag.log"
|
||||||
touch "$thisLog"
|
touch "$thisLog"
|
||||||
ln -sf "$thisLog" "$latestLogDir/$(basename "$thisLog")"
|
ln -sf "$thisLog" "$latestLogDir/$(basename "$thisLog")"
|
||||||
|
|
@ -174,4 +216,5 @@ while [ "$#" -gt 0 ]; do
|
||||||
for namespace in $NAMESPACES; do
|
for namespace in $NAMESPACES; do
|
||||||
docker tag "$repoTag" "$namespace/$repoTag"
|
docker tag "$repoTag" "$namespace/$repoTag"
|
||||||
done
|
done
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
38
push.sh
38
push.sh
|
|
@ -37,17 +37,39 @@ variables:
|
||||||
EOUSAGE
|
EOUSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO impove arg hanlding for complex args; ex: --exclude=repo:tag
|
opts="$(getopt -o 'h?' --long 'all,help' -- "$@" || { usage >&2 && false; })"
|
||||||
if [ "$1" = '--help' -o "$1" = '-h' -o "$1" = '-?' ]; then
|
eval set -- "$opts"
|
||||||
usage
|
|
||||||
|
buildAll=
|
||||||
|
while true; do
|
||||||
|
flag=$1
|
||||||
|
shift
|
||||||
|
case "$flag" in
|
||||||
|
--help|-h|'-?')
|
||||||
|
uasge
|
||||||
exit 0
|
exit 0
|
||||||
|
;;
|
||||||
|
--all)
|
||||||
|
buildAll=1
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo >&2 "error: unknown flag: $flag"
|
||||||
|
usage >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
repos=()
|
||||||
|
if [ "$buildAll" ]; then
|
||||||
|
repos=( $(cd "$LIBRARY" && echo *) )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$1" = '--all' ]; then
|
repos+=( "$@" )
|
||||||
repos=( $(cd "$LIBRARY" && echo *) )
|
|
||||||
else
|
|
||||||
repos=( "$@" )
|
|
||||||
fi
|
|
||||||
repos=( "${repos[@]%/}" )
|
repos=( "${repos[@]%/}" )
|
||||||
|
|
||||||
if [ "${#repos[@]}" -eq 0 ]; then
|
if [ "${#repos[@]}" -eq 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue