@ -1,20 +1,28 @@
#!/usr/bin/env bash
set -e
g_version = $( git tag -l v* | sort --version-sort | tail -1)
g_version = ${ g_version # "v" }
show_help( )
{
echo -e " `basename $0 ` [option] [argument] "
echo
echo -e "Options:"
echo -e " -h show this help."
echo -e " -v with argument version (3.0.2 by default). "
echo -e " -f with argument format (tar.x z by default) used by git archive."
echo -e " -v with argument version ( ${ g_version } by default). "
echo -e " -f with argument format (tar.g z by default) used by git archive."
echo
echo -e "Examples:"
echo -e " to build base on version \`2.4.1' with format \`tar.xz', run:"
echo -e " `basename $0 ` -f tar.xz -v 2.4.1 "
}
version_greater_equal( )
{
[ " $1 " = $( printf " $1 \n $2 \n " | sort --version-sort | tail -1) ]
}
while getopts "hv:f:" opt
do
case ${ opt } in
@ -38,9 +46,15 @@ do
esac
done
: ${ version : =3.0.2 }
: ${ version : = ${ g_version } }
: ${ format : =tar.gz }
supported_max_version = "2.6.2"
if ! version_greater_equal ${ supported_max_version } ${ version } ; then
echo " version( ${ version } ) greater than ${ supported_max_version } are not currently supported. "
exit 1
fi
name = "shadowsocks-libev"
spec_name = "shadowsocks-libev.spec"
@ -52,4 +66,9 @@ sed -e "s/^\(Version: \).*$/\1${version}/" \
-e " s/^\(Source0: \).* $/\1 ${ name } - ${ version } . ${ format } / " \
SPECS/" ${ spec_name } " .in > SPECS/" ${ spec_name } "
rpmbuild -bb SPECS/" ${ spec_name } " --define "%_topdir `pwd`"
completion_min_verion = "2.6.0"
version_greater_equal ${ version } ${ completion_min_verion } \
&& with_completion = "--with completion" || :
rpmbuild -bb SPECS/" ${ spec_name } " --define "%_topdir `pwd`" \
${ with_completion }