Make scripts POSIX compatible
Rewrote repo-info.sh, tag-release.sh and build-presets.sh to remove the need for bash when compiling.
This commit is contained in:
parent
3973157911
commit
e489823ecb
26
configure
vendored
26
configure
vendored
@ -13,23 +13,19 @@ inpath()
|
||||
return 1
|
||||
}
|
||||
|
||||
if ( inpath bash ); then
|
||||
pp=""
|
||||
for p in python3 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python2 python2.7 python
|
||||
do
|
||||
if ( inpath $p ); then
|
||||
pp="$p"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$pp" != "" ]; then
|
||||
exec $pp `dirname $0`/make/configure.py "$@"
|
||||
exit 0
|
||||
else
|
||||
echo "ERROR: no suitable version of python found."
|
||||
pp=""
|
||||
for p in python3 python3.8 python3.7 python3.6 python3.5 python3.4 python3.3 python3.2 python3.1 python2 python2.7 python
|
||||
do
|
||||
if ( inpath $p ); then
|
||||
pp="$p"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$pp" != "" ]; then
|
||||
exec $pp `dirname $0`/make/configure.py "$@"
|
||||
exit 0
|
||||
else
|
||||
echo "ERROR: bash shell not found."
|
||||
echo "ERROR: no suitable version of python found."
|
||||
fi
|
||||
|
||||
exit 1
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
# usage: build-presets
|
||||
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
SELF="$0"
|
||||
SELF_DIR=$(cd $(dirname "${SELF}") && pwd -P)
|
||||
SELF_DIR="${SELF_DIR:-$(pwd)}"
|
||||
LIBHB_DIR="${SELF_DIR}/../libhb"
|
||||
@ -14,7 +14,7 @@ fi
|
||||
|
||||
JSON_TEMP=$(mktemp preset_builtin.json.XXX)
|
||||
C_TEMP=$(mktemp preset_builtin.h.XXX)
|
||||
if [[ "${JSON_TEMP:-}" == "" ]] || [[ "${C_TEMP:-}" == "" ]]; then
|
||||
if [ "${JSON_TEMP:-}" = "" ] || [ "${C_TEMP:-}" = "" ]; then
|
||||
echo "unable to create temporary files" >2
|
||||
exit 1
|
||||
fi
|
||||
|
@ -1,18 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# Retrieves git repository info for directory ${1} using command ${2}
|
||||
|
||||
function repo_info()
|
||||
repo_info()
|
||||
{
|
||||
local repo_dir git_exe commit upstream err
|
||||
|
||||
# Process args
|
||||
repo_dir='.'
|
||||
if [[ ${1} ]]; then
|
||||
if [ -n "${1}" ]; then
|
||||
repo_dir=${1}
|
||||
fi
|
||||
git_exe='git'
|
||||
if [[ ${2} ]]; then
|
||||
git_exe="git"
|
||||
if [ -n "${2}" ]; then
|
||||
git_exe=${2}
|
||||
fi
|
||||
|
||||
@ -23,19 +21,19 @@ function repo_info()
|
||||
fi
|
||||
|
||||
# Check whether we have git
|
||||
if ! hash ${git_exe} 2>/dev/null; then
|
||||
if [ -z "$(command -v ${git_exe})" ]; then
|
||||
echo "Command '${git_exe}' not found." 1>&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if there is a valid git repo here
|
||||
HASH=$(${git_exe} rev-parse HEAD)
|
||||
SHORTHASH=$(${git_exe} rev-parse --short HEAD)
|
||||
HASH=$(${git_exe} rev-parse HEAD 2> /dev/null)
|
||||
SHORTHASH=$(${git_exe} rev-parse --short HEAD 2> /dev/null)
|
||||
err=$?
|
||||
if [[ ${err} -ne 0 ]]; then
|
||||
if [ $err -ne 0 ]; then
|
||||
echo "Not a valid repository." 1>&2
|
||||
return ${err}
|
||||
elif [[ -z ${HASH} ]]; then
|
||||
elif [ -z "${HASH}" ]; then
|
||||
echo "Not a valid repository." 1>&2
|
||||
return 1
|
||||
fi
|
||||
@ -45,8 +43,8 @@ function repo_info()
|
||||
|
||||
# check if an annotated tag is reachable from HEAD
|
||||
TAG=$(${git_exe} describe --tags --abbrev=0 --exact-match --match \[0-9\]\*.\[0-9\]\*.\[0-9\]\* HEAD 2> /dev/null)
|
||||
if [[ ${TAG} ]]; then
|
||||
# if TAG is a release tag and HASH == TAG_HASH, this is release code
|
||||
if [ -n "${TAG}" ]; then
|
||||
# if TAG is a release tag and HASH == TAG_HASH, this is release code
|
||||
TAG_HASH=$(${git_exe} rev-list ${TAG} --max-count=1)
|
||||
REV=$(${git_exe} rev-list $(${git_exe} merge-base ${TAG} HEAD).. --count)
|
||||
else
|
||||
@ -56,7 +54,7 @@ function repo_info()
|
||||
BRANCH=$(${git_exe} symbolic-ref -q --short HEAD)
|
||||
REMOTE="${URL}"
|
||||
upstream=$(${git_exe} config branch.${BRANCH}.remote)
|
||||
if [[ ${upstream} ]]; then
|
||||
if [ -n "${upstream}" ]; then
|
||||
REMOTE="${upstream}"
|
||||
fi
|
||||
DATE=$(${git_exe} log -1 --format="format:%ci")
|
||||
@ -66,9 +64,9 @@ function repo_info()
|
||||
echo "URL=${URL}"
|
||||
echo "HASH=${HASH}"
|
||||
echo "SHORTHASH=${SHORTHASH}"
|
||||
if [[ ${TAG} ]]; then echo "TAG=${TAG}"; fi
|
||||
if [[ ${TAG_HASH} ]]; then echo "TAG_HASH=${TAG_HASH}"; fi
|
||||
if [[ ${REV} ]]; then echo "REV=${REV}"; fi
|
||||
if [ -n "${TAG}" ]; then echo "TAG=${TAG}"; fi
|
||||
if [ -n "${TAG_HASH}" ]; then echo "TAG_HASH=${TAG_HASH}"; fi
|
||||
if [ -n "${REV}" ]; then echo "REV=${REV}"; fi
|
||||
echo "BRANCH=${BRANCH}"
|
||||
echo "REMOTE=${REMOTE}"
|
||||
echo "DATE=${DATE}"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
#
|
||||
# Usage: tag-release.sh <release-ver> [<ref>]
|
||||
#
|
||||
@ -22,17 +22,14 @@
|
||||
# git push origin refs/tags/X.Y.Z
|
||||
#
|
||||
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
SELF_NAME=$(basename "${SELF}")
|
||||
|
||||
GIT_EXE='git'
|
||||
|
||||
function validate_repo()
|
||||
validate_repo()
|
||||
{
|
||||
local HASH err AHEAD BEHIND proceed
|
||||
|
||||
# Check whether we have git
|
||||
if ! hash ${GIT_EXE} 2>/dev/null; then
|
||||
if [ -z "$(command -v ${GIT_EXE})" ]; then
|
||||
echo "Command '${GIT_EXE}' not found." 1>&2
|
||||
return 1
|
||||
fi
|
||||
@ -40,15 +37,15 @@ function validate_repo()
|
||||
# Check if there is a valid git repo here
|
||||
HASH=$(${GIT_EXE} rev-parse HEAD)
|
||||
err=$?
|
||||
if [[ ${err} -ne 0 ]]; then
|
||||
if [ ${err} -ne 0 ]; then
|
||||
echo "Not a valid repository." 1>&2
|
||||
return ${err}
|
||||
elif [[ -z ${HASH} ]]; then
|
||||
elif [ -z "${HASH}" ]; then
|
||||
echo "Not a valid repository." 1>&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -n "$(${GIT_EXE} status --porcelain)" ]]; then
|
||||
if [ -n "$(${GIT_EXE} status --porcelain)" ]; then
|
||||
echo "There are uncommitted changes. Aborting." 1>&2
|
||||
return 1
|
||||
fi
|
||||
@ -56,47 +53,47 @@ function validate_repo()
|
||||
echo "Fetching repo data..."
|
||||
${GIT_EXE} fetch
|
||||
err=$?
|
||||
if [[ ${err} -ne 0 ]]; then
|
||||
if [ ${err} -ne 0 ]; then
|
||||
echo "Failed to fetch repo data." 1>&2
|
||||
return ${err}
|
||||
fi
|
||||
AHEAD=$(${GIT_EXE} rev-list @{u}..HEAD --count)
|
||||
BEHIND=$(${GIT_EXE} rev-list HEAD..@{u} --count)
|
||||
if [[ ${AHEAD} -ne 0 ]]; then
|
||||
if [ ${AHEAD} -ne 0 ]; then
|
||||
echo "There are unpushed changes. Continue anyway? (y/N)"
|
||||
read proceed
|
||||
if [[ ( "x${proceed}" != "xy" ) && ( "x${proceed}" != "xY" ) ]] ; then
|
||||
if [ "x${proceed}" != "xy" ] && [ "x${proceed}" != "xY" ] ; then
|
||||
echo "Aborting..."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
if [[ ${BEHIND} -ne 0 ]]; then
|
||||
if [ ${BEHIND} -ne 0 ]; then
|
||||
echo "There are unmerged upstream changes. Continue anyway? (y/N)"
|
||||
read proceed
|
||||
if [[ ( "x${proceed}" != "xy" ) && ( "x${proceed}" != "xY" ) ]] ; then
|
||||
if [ "x${proceed}" != "xy" ] && [ "x${proceed}" != "xY" ] ; then
|
||||
echo "Aborting..."
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function tag_release()
|
||||
tag_release()
|
||||
{
|
||||
local TAG REF COMMIT BRANCH proceed new_branch ERR HASH
|
||||
|
||||
TAG=${1}
|
||||
REF=${2}
|
||||
|
||||
if [ "x${TAG}" == "x" ]; then
|
||||
if [ "x${TAG}" = "x" ]; then
|
||||
echo "Missing release tag (e.g. 1.0.0)"
|
||||
echo "Usage: ${SELF_NAME} tag [commit]"
|
||||
echo "Usage: tag-release.sh tag [commit]"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# bugfix branch name
|
||||
BRANCH=${TAG%.[0-9]*}.x
|
||||
|
||||
if [ "x${REF}" == "x" ]; then
|
||||
if [ "x${REF}" = "x" ]; then
|
||||
echo "Creating release tag ${TAG} and branch ${BRANCH} from HEAD, proceed? (y/N)"
|
||||
# retrieve full hash of HEAD
|
||||
COMMIT=$(${GIT_EXE} rev-list HEAD --max-count=1)
|
||||
@ -106,7 +103,7 @@ function tag_release()
|
||||
COMMIT=$(${GIT_EXE} rev-list ${REF} --max-count=1)
|
||||
fi
|
||||
read proceed
|
||||
if [[ ( "x${proceed}" != "xy" ) && ( "x${proceed}" != "xY" ) ]] ; then
|
||||
if [ "x${proceed}" != "xy" ] && [ "x${proceed}" != "xY" ] ; then
|
||||
echo "Aborting..."
|
||||
return 0
|
||||
fi
|
||||
@ -183,7 +180,7 @@ function tag_release()
|
||||
echo " git push -u origin ${BRANCH}"
|
||||
echo " git push origin refs/tags/${TAG}"
|
||||
read proceed
|
||||
if [[ ( "x${proceed}" == "xy" ) || ( "x${proceed}" == "xY" ) ]] ; then
|
||||
if [ "x${proceed}" = "xy" ] || [ "x${proceed}" = "xY" ] ; then
|
||||
if [ $new_branch .eq 1 ]; then
|
||||
${GIT_EXE} push -u origin "${BRANCH}"
|
||||
ERR=$?
|
||||
@ -204,7 +201,7 @@ function tag_release()
|
||||
|
||||
}
|
||||
|
||||
function main()
|
||||
main()
|
||||
{
|
||||
if validate_repo; then
|
||||
tag_release "$@"
|
||||
|
Loading…
x
Reference in New Issue
Block a user