Commit 2600428f authored by Vitaly Lipatov's avatar Vitaly Lipatov

rpmbph: move remove_bashism to the spec module, fix it and add test

parent 61a0b678
......@@ -12,25 +12,7 @@
# load common functions, compatible with local and installed script
. `dirname $0`/../share/eterbuild/functions/common
load_mod repl rpm git buildsrpm
# for rpm + (d)ash
remove_bashism()
{
local SPECNAME=$1
subst "s|^pushd \(.*\)|cd \1 >/dev/null|g" $SPECNAME
subst "s|^popd|cd - >/dev/null|g" $SPECNAME
# {1,2} translation
# FIXME: miss first spaces
while read -r n ; do
echo "$n" | grep -v "{.*}" && continue
eval echo "$n"
done < $SPECNAME >$SPECNAME.tmp
[ -e "$SPECNAME.tmp" ] && mv -f $SPECNAME.tmp $SPECNAME
checkbashisms $SPECNAME
}
load_mod repl rpm git buildsrpm spec
altspec_to_local()
......
......@@ -233,3 +233,26 @@ separate_changelog()
cat $SPEC | awk 'BEGIN{desk=0}{if (desk==1) {print}; if(/^%changelog/&&desk==0){desk++}}' > "$3"
}
# for rpm + (d)ash
remove_bashism()
{
local SPECNAME="$1"
test -w "$SPECNAME" || fatal "File '$SPECNAME' is missed or read only"
separate_changelog $SPECNAME $SPECNAME.main $SPECNAME.changelog
subst "s|^pushd \(.*\)|cd \1 >/dev/null|g" $SPECNAME.main
subst "s|^popd|cd - >/dev/null|g" $SPECNAME.main
# {1,2} translation
# FIXME: miss first spaces
while read -r n ; do
echo "$n" | grep -v "{.*}" && continue
eval echo "$n"
done < $SPECNAME.main >$SPECNAME.tmp
[ -s "$SPECNAME.tmp" ] && mv -f $SPECNAME.tmp $SPECNAME
checkbashisms $SPECNAME
cat $SPECNAME.changelog >>$SPECNAME
rm -f $SPECNAME.main $SPECNAME.changelog
}
#!/bin/bash
. `dirname $0`/../share/eterbuild/functions/common
load_mod spec
SPEC=get_ver.spec
gen_spec()
{
cat <<EOF >$SPEC
Name: get_version_test
Release: alt1
Version: $TESTVER
Source: $SOURCEPATH%name-%version.tar.bz2
Summary: Test
Group: Other
License: Public License
%define major 1.0
%define ver 10
%define maj 1.0
%build
pushd txt
echo {1,2}text
popd
%description
Get version test
%changelog
* Date
- Hello
* dsdkljd
* Date
EOF
}
TESTVER=0
SOURCEPATH=ftp://etersoft.ru/pub/Etersoft/TEST/
gen_spec
remove_bashism $SPEC
mv $SPEC $SPEC.new
gen_spec
diff -u $SPEC $SPEC.new
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