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 @@
# Author: Vitaly Lipatov <lav@etersoft.ru>
# Public domain
get_gear_rules()
# TODO: move to gear file
get_gear_rules_by_spec()
{
local SPECNAME="$1"
# FIXME: move get rules file to separate function
......@@ -59,7 +59,7 @@ uni_rpmbuild()
shift # skip spec 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
if true || [ "$MENV" = "SS" ] ; then
......@@ -92,7 +92,7 @@ uni_buildreq()
if is_gear $SPECDIR ; then
# 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=$?
else
......
......@@ -36,7 +36,7 @@ uni_rpmbuildsrpm()
shift # skip spec 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
if true || [ "$MENV" = "SS" ] ; then
......
......@@ -128,8 +128,9 @@ get_root_git_dir()
readlink -f "$DIR" 2>/dev/null || realpath "$DIR"
}
# Usage: is_gear [path_to_spec|dir_inside_git]
is_gear()
# TODO: move to separate gear file
# TODO: rewrite with get_gear_rules_by_spec in mind
get_gear_rules()
{
local DIR="$1"
[ -z "$IGNOREGEAR" ] || return 1
......@@ -137,9 +138,17 @@ is_gear()
[ -n "$DIR" ] && cd $DIR
local GITDIR=$(get_root_git_dir)
[ -n "$DIR" ] && cd - >/dev/null
[ -d "$GITDIR/.gear" ] && return 0
[ -r "$GITDIR/.gear-rules" ] && return 0
return 1
local rules="$GITDIR/.gear/rules"
[ -r "$rules" ] || rules="$GITDIR/.gear-rules"
[ -r "$rules" ] || return
echo $rules
}
# Usage: is_gear [path_to_spec|dir_inside_git]
is_gear()
{
get_gear_rules $@ >/dev/null
}
filter_gear_name()
......
......@@ -218,21 +218,24 @@ set_specdir()
fi
}
# internal func
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
}
# search for gear spec
get_gear_spec()
{
local trySpec=""
# check locally only if in gear repo
is_gear && trySpec=$(echo *.spec)
# if not in local dir, check spec in git root dir
local trySpec
trySpec=$(get_gear_rule_spec)
# check spec in git root dir (by default)
[ -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
[ -f "$trySpec" ] || 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