Commit 918825fc authored by Vitaly Lipatov's avatar Vitaly Lipatov

rename get_gear_rules to get_gear_rules_by_spec and introduce new get_gear_rules, fix get_gear_spec

parent 6524dd52
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
# Author: Vitaly Lipatov <lav@etersoft.ru> # Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain # Public domain
# TODO: move to gear file
get_gear_rules() get_gear_rules_by_spec()
{ {
local SPECNAME="$1" local SPECNAME="$1"
# FIXME: move get rules file to separate function # FIXME: move get rules file to separate function
...@@ -59,7 +59,7 @@ uni_rpmbuild() ...@@ -59,7 +59,7 @@ uni_rpmbuild()
shift # skip spec name shift # skip spec name
# FIXME: use spec name as project name # FIXME: use spec name as project name
GEARRULES=$(get_gear_rules "$SPECNAME") GEARRULES=$(get_gear_rules_by_spec "$SPECNAME")
# build package without MENV checking # build package without MENV checking
if true || [ "$MENV" = "SS" ] ; then if true || [ "$MENV" = "SS" ] ; then
...@@ -92,7 +92,7 @@ uni_buildreq() ...@@ -92,7 +92,7 @@ uni_buildreq()
if is_gear $SPECDIR ; then if is_gear $SPECDIR ; then
# FIXME: use spec name as project name # FIXME: use spec name as project name
GEARRULES=$(get_gear_rules "$SPECNAME") GEARRULES=$(get_gear_rules_by_spec "$SPECNAME")
docmd $NICE $GEARBUILDREQ $BUILDREQPARAM $GEARRULES --commit -- "$SPECNAME" "$@" || RET=$? docmd $NICE $GEARBUILDREQ $BUILDREQPARAM $GEARRULES --commit -- "$SPECNAME" "$@" || RET=$?
else else
......
...@@ -36,7 +36,7 @@ uni_rpmbuildsrpm() ...@@ -36,7 +36,7 @@ uni_rpmbuildsrpm()
shift # skip spec name shift # skip spec name
# FIXME: use spec name as project name # FIXME: use spec name as project name
GEARRULES=$(get_gear_rules "$SPECNAME") GEARRULES=$(get_gear_rules_by_spec "$SPECNAME")
# build package without MENV checking # build package without MENV checking
if true || [ "$MENV" = "SS" ] ; then if true || [ "$MENV" = "SS" ] ; then
......
...@@ -128,8 +128,9 @@ get_root_git_dir() ...@@ -128,8 +128,9 @@ get_root_git_dir()
readlink -f "$DIR" 2>/dev/null || realpath "$DIR" readlink -f "$DIR" 2>/dev/null || realpath "$DIR"
} }
# Usage: is_gear [path_to_spec|dir_inside_git] # TODO: move to separate gear file
is_gear() # TODO: rewrite with get_gear_rules_by_spec in mind
get_gear_rules()
{ {
local DIR="$1" local DIR="$1"
[ -z "$IGNOREGEAR" ] || return 1 [ -z "$IGNOREGEAR" ] || return 1
...@@ -137,9 +138,17 @@ is_gear() ...@@ -137,9 +138,17 @@ is_gear()
[ -n "$DIR" ] && cd $DIR [ -n "$DIR" ] && cd $DIR
local GITDIR=$(get_root_git_dir) local GITDIR=$(get_root_git_dir)
[ -n "$DIR" ] && cd - >/dev/null [ -n "$DIR" ] && cd - >/dev/null
[ -d "$GITDIR/.gear" ] && return 0 local rules="$GITDIR/.gear/rules"
[ -r "$GITDIR/.gear-rules" ] && return 0 [ -r "$rules" ] || rules="$GITDIR/.gear-rules"
return 1 [ -r "$rules" ] || return
echo $rules
}
# Usage: is_gear [path_to_spec|dir_inside_git]
is_gear()
{
get_gear_rules $@ >/dev/null
} }
filter_gear_name() filter_gear_name()
......
...@@ -218,21 +218,24 @@ set_specdir() ...@@ -218,21 +218,24 @@ set_specdir()
fi fi
} }
# internal func
get_gear_rule_spec() get_gear_rule_spec()
{ {
local SPEC="$(grep "^spec:" $(get_root_git_dir)/.gear/rules 2>/dev/null | cut -d" " -f2)" local rules=$(get_gear_rules)
[ -r "$rules" ] || return
local SPEC="$(grep "^spec:" $rules 2>/dev/null | cut -d" " -f2)"
test -r "$(get_root_git_dir)/$SPEC" && echo $(get_root_git_dir)/$SPEC test -r "$(get_root_git_dir)/$SPEC" && echo $(get_root_git_dir)/$SPEC
} }
# search for gear spec # search for gear spec
get_gear_spec() get_gear_spec()
{ {
local trySpec="" local trySpec
# check locally only if in gear repo trySpec=$(get_gear_rule_spec)
is_gear && trySpec=$(echo *.spec) # check spec in git root dir (by default)
# if not in local dir, check spec in git root dir
[ -f "$trySpec" ] || trySpec=`echo $(get_root_git_dir)/*.spec` [ -f "$trySpec" ] || trySpec=`echo $(get_root_git_dir)/*.spec`
[ -f "$trySpec" ] || trySpec=$(get_gear_rule_spec) # check locally only if in gear repo
#is_gear && trySpec=$(echo *.spec)
# printout nothing if can't get spec # printout nothing if can't get spec
[ -f "$trySpec" ] || trySpec="" [ -f "$trySpec" ] || trySpec=""
echo $trySpec echo $trySpec
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment