mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-29 12:36:53 +00:00
Make genrpm.sh a little safer. (#895)
1. Remove function `get_att_val`: That function uses `eval` to set default values for bash variables. Because it is very dangerous to use `eval` (someone call it the plague of shell scripting), I'd like to use the bash builtin to do that. 2. Double quote all variables to avoid unexpected expansion when using it.
This commit is contained in:
+5
-15
@@ -38,28 +38,18 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
get_att_val()
|
||||
{
|
||||
att=$1
|
||||
val=$2
|
||||
|
||||
if [ -z $(eval echo \$$att) ]; then
|
||||
eval $att=$val
|
||||
fi
|
||||
}
|
||||
|
||||
get_att_val version "2.5.5"
|
||||
get_att_val format "tar.gz"
|
||||
: ${version:=2.5.5}
|
||||
: ${format:=tar.gz}
|
||||
|
||||
name="shadowsocks-libev"
|
||||
spec_name="shadowsocks-libev.spec"
|
||||
|
||||
pushd `git rev-parse --show-toplevel`
|
||||
git archive v${version} --format=${format} --prefix=${name}-${version}/ -o rpm/SOURCES/${name}-${version}.${format}
|
||||
git archive "v${version}" --format="${format}" --prefix="${name}-${version}/" -o rpm/SOURCES/"${name}-${version}.${format}"
|
||||
pushd rpm
|
||||
|
||||
sed -e "s/^\(Version: \).*$/\1${version}/" \
|
||||
-e "s/^\(Source0: \).*$/\1${name}-${version}.${format}/" \
|
||||
SPECS/${spec_name}.in > SPECS/${spec_name}
|
||||
SPECS/"${spec_name}".in > SPECS/"${spec_name}"
|
||||
|
||||
rpmbuild -bb SPECS/${spec_name} --define "%_topdir `pwd`"
|
||||
rpmbuild -bb SPECS/"${spec_name}" --define "%_topdir `pwd`"
|
||||
|
||||
Reference in New Issue
Block a user