Commit fd825c2e authored by Vitaly Lipatov's avatar Vitaly Lipatov

use mktemp for temp files

parent 3c1efe94
...@@ -178,10 +178,11 @@ do ...@@ -178,10 +178,11 @@ do
test -s $SPEC || fatal "Cannot find spec file '$SPEC'" test -s $SPEC || fatal "Cannot find spec file '$SPEC'"
SPECTMP=$(mktemp)
# Add group # Add group
if ! grep "^Group" $SPEC ; then if ! grep "^Group" $SPEC ; then
PACKAGT="Group: Unknown" PACKAGT="Group: Unknown"
cat $SPEC | awk 'BEGIN{desk=0}{if(/^U[rR][lL]/&&desk==0){printf("%s\n", text);desk++};print}' text="$PACKAGT" >$SPEC.tmp && mv -f $SPEC.tmp $SPEC cat $SPEC | awk 'BEGIN{desk=0}{if(/^U[rR][lL]/&&desk==0){printf("%s\n", text);desk++};print}' text="$PACKAGT" >$SPECTMP && mv -f $SPECTMP $SPEC
fi fi
# Prepare for fix only before changelog part # Prepare for fix only before changelog part
......
...@@ -102,9 +102,9 @@ remove_file_from_remove() ...@@ -102,9 +102,9 @@ remove_file_from_remove()
store_output() store_output()
{ {
# use make_temp_file from etersoft-build-utils # use make_temp_file from etersoft-build-utils
RC_STDOUT=$(mktemp) RC_STDOUT=$(make_temp_file)
mark_file_to_remove $RC_STDOUT mark_file_to_remove $RC_STDOUT
#RC_STDERR=$(mktemp) #RC_STDERR=$(make_temp_file)
"$@" 2>&1 | tee $RC_STDOUT "$@" 2>&1 | tee $RC_STDOUT
# http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF # http://tldp.org/LDP/abs/html/bashver3.html#PIPEFAILREF
return $PIPESTATUS return $PIPESTATUS
......
...@@ -35,7 +35,7 @@ build_rpms_name() ...@@ -35,7 +35,7 @@ build_rpms_name()
shift shift
test -f "$NAMESPEC" || fatal "Spec $NAMESPEC does not exist" test -f "$NAMESPEC" || fatal "Spec $NAMESPEC does not exist"
tmprpm=`make_temp_file $NAME` tmprpm=$(make_temp_file $NAME)
# Optimization # Optimization
eval_spec $NAMESPEC $@ | grep ":" >$tmprpm eval_spec $NAMESPEC $@ | grep ":" >$tmprpm
BASENAME=$(cat $tmprpm | get_var "Name") BASENAME=$(cat $tmprpm | get_var "Name")
......
...@@ -21,9 +21,11 @@ eval_spec() ...@@ -21,9 +21,11 @@ eval_spec()
# Drop changelog and make spec copy # Drop changelog and make spec copy
# see http://bugs.etersoft.ru/show_bug.cgi?id=6588 # see http://bugs.etersoft.ru/show_bug.cgi?id=6588
mark_file_to_remove $SPECNAME.tmp $SPECNAME.changelog SPECNAMETMP=$(make_temp_file)
separate_changelog $SPECNAME $SPECNAME.tmp $SPECNAME.changelog SPECNAMECHANGELOG=$(make_temp_file)
SPEC=$SPECNAME.tmp mark_file_to_remove $SPECNAMETMP $SPECNAMECHANGELOG
separate_changelog $SPECNAME $SPECNAMETMP $SPECNAMECHANGELOG
SPEC=$SPECNAMETMP
USEARCH= USEARCH=
# FIXME: rpm on 64bit ALT has no macros for ix86 arch # FIXME: rpm on 64bit ALT has no macros for ix86 arch
...@@ -39,11 +41,11 @@ eval_spec() ...@@ -39,11 +41,11 @@ eval_spec()
# on ALT we have to done without errors # on ALT we have to done without errors
$USEARCH $RPMBUILD -bE --target $SYSARCH $RPMBUILDARG $SPEC | iconv -f utf8 -r || fatal "Check spec's fields" $USEARCH $RPMBUILD -bE --target $SYSARCH $RPMBUILDARG $SPEC | iconv -f utf8 -r || fatal "Check spec's fields"
else else
( $USEARCH $RPMBUILD -bE --target $SYSARCH $RPMBUILDARG $SPEC 2>/dev/null || cat $SPEC ) | iconv -f utf8 ( $USEARCH $RPMBUILD -bE --target $SYSARCH $RPMBUILDARG $SPEC 2>/dev/null || cat $SPEC ) | iconv -f utf8
fi fi
# FIXME: hack for koi8-r in spec (grep will not work with it) # FIXME: hack for koi8-r in spec (grep will not work with it)
[ -n "$DEBUG" ] || rm -f $SPECNAME.tmp $SPECNAME.changelog [ -n "$DEBUG" ] || rm -f $SPECNAMETMP $SPECNAMECHANGELOG
remove_file_from_remove $SPECNAME.tmp $SPECNAME.changelog remove_file_from_remove $SPECNAMETMP $SPECNAMECHANGELOG
} }
get_release() get_release()
...@@ -351,11 +353,14 @@ remove_bashism() ...@@ -351,11 +353,14 @@ remove_bashism()
local SPECNAME="$1" local SPECNAME="$1"
test -w "$SPECNAME" || fatal "File '$SPECNAME' is missed or read only" test -w "$SPECNAME" || fatal "File '$SPECNAME' is missed or read only"
separate_changelog $SPECNAME $SPECNAME.main $SPECNAME.changelog local SPECNAMETMP=$(make_temp_file)
local SPECNAMEMAIN=$(make_temp_file)
local SPECNAMECHANGELOG=$(make_temp_file)
separate_changelog $SPECNAME $SPECNAMEMAIN $SPECNAMECHANGELOG
subst "s|^pushd \(.*\)|cd \1 >/dev/null|g" $SPECNAME.main subst "s|^pushd \(.*\)|cd \1 >/dev/null|g" $SPECNAMEMAIN
subst "s|^popd|cd - >/dev/null|g" $SPECNAME.main subst "s|^popd|cd - >/dev/null|g" $SPECNAMEMAIN
subst "s|^echo -e '\\\n'|echo ''|g" $SPECNAME.main subst "s|^echo -e '\\\n'|echo ''|g" $SPECNAMEMAIN
# {1,2} translation # {1,2} translation
# FIXME: miss first spaces # FIXME: miss first spaces
...@@ -364,12 +369,12 @@ remove_bashism() ...@@ -364,12 +369,12 @@ remove_bashism()
rs="$(echo "$n" | perl -pe "s|.*\s(.*?{.*?}.*?)\s.*|\1|g" )" rs="$(echo "$n" | perl -pe "s|.*\s(.*?{.*?}.*?)\s.*|\1|g" )"
res=$(eval echo "$rs") res=$(eval echo "$rs")
echo "$n" | perl -pe "s|$rs|$res|g" echo "$n" | perl -pe "s|$rs|$res|g"
done < $SPECNAME.main >$SPECNAME.tmp done < $SPECNAMEMAIN >$SPECNAMETMP
[ -s "$SPECNAME.tmp" ] && mv -f $SPECNAME.tmp $SPECNAME [ -s "$SPECNAMETMP" ] && mv -f $SPECNAMETMP $SPECNAME
$EPMCMD assure checkbashisms $EPMCMD assure checkbashisms
docmd checkbashisms $SPECNAME docmd checkbashisms $SPECNAME
cat $SPECNAME.changelog >>$SPECNAME cat $SPECNAMECHANGELOG >>$SPECNAME
rm -f $SPECNAME.main $SPECNAME.changelog rm -f $SPECNAMEMAIN $SPECNAMECHANGELOG
} }
get_last_changelog() get_last_changelog()
......
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