Browse Source

pack submodules for genrpm (#1293)

* add option to run autogen before configure

* pack submodules for genrpm
pull/1379/head
was4444 7 years ago
committed by Max Lv
parent
commit
c809cc0246
2 changed files with 71 additions and 27 deletions
  1. 5
      rpm/SPECS/shadowsocks-libev.spec.in
  2. 93
      rpm/genrpm.sh

5
rpm/SPECS/shadowsocks-libev.spec.in

@ -1,4 +1,5 @@
%bcond_with completion
%bcond_with autogen
Name: shadowsocks-libev
@ -54,6 +55,10 @@ shadowsocks-libev is a lightweight secured scoks5 proxy for embedded devices and
%build
%if %{with autogen}
./autogen.sh
%endif
%if 0%{?use_system_lib}
%configure --enable-shared --enable-system-shared-lib
%else

93
rpm/genrpm.sh

@ -1,8 +1,18 @@
#!/usr/bin/env bash
set -e
set -ex
g_script_path=$(dirname $(readlink -e $0))
g_toplevel_path=$(pushd $g_script_path > /dev/null 2>&1; \
git rev-parse --show-toplevel; \
popd > /dev/null 2>&1)
g_version=$(git tag -l v* | sort --version-sort | tail -1)
g_version=${g_version#"v"}
g_format="tar.gz"
g_name="shadowsocks-libev"
g_rpmbuild_topdir="${g_toplevel_path}/rpm"
g_rpmbuild_conditions=
show_help()
{
@ -23,6 +33,49 @@ version_greater_equal()
[ "$1" = $(printf "$1\n$2\n" | sort --version-sort | tail -1) ]
}
verify_options()
{
local completion_min_verion="2.6.0"
local archive_format_supported_max_version="2.6.2"
version_greater_equal ${g_version} ${completion_min_verion} \
&& g_rpmbuild_conditions="${g_rpmbuild_conditions} --with completion" || :
if ! version_greater_equal ${archive_format_supported_max_version} ${g_version}; then
g_rpmbuild_conditions="${g_rpmbuild_conditions} --with autogen"
if [ "${g_format}" != "tar" ]; then
echo -e "version(${g_version}) greater than ${archive_format_supported_max_version} can only use archive format \`tar'."
echo -e "change format from \`${g_format}' to \`tar'"
g_format="tar"
fi
fi
}
generate_tarball()
{
local tarball_name="${g_name}-${g_version}"
local tarball_dir="${g_rpmbuild_topdir}/SOURCES"
pushd ${g_toplevel_path}
git archive "v${g_version}" \
--format="${g_format}" \
--prefix="${tarball_name}/" \
-o "${tarball_dir}/${tarball_name}.${g_format}"
git ls-tree -dr "v${g_version}" | grep commit \
| while read eat_mod eat_type mod_sha mod_path; do \
[ "${mod_path}" = "" ] && continue || :; \
(pushd ${mod_path=} \
&& git archive ${mod_sha} \
--prefix="${tarball_name}/${mod_path}/" \
-o "${tarball_dir}/sub_mod.tar" \
&& tar --concatenate "${tarball_dir}/sub_mod.tar" \
--file="${tarball_dir}/${tarball_name}.tar" \
&& rm "${tarball_dir}/sub_mod.tar" \
&& popd) \
done
}
while getopts "hv:f:" opt
do
case ${opt} in
@ -32,13 +85,13 @@ do
;;
v)
if [ "${OPTARG}" = v* ]; then
version=${OPTARG#"v"}
g_version=${OPTARG#"v"}
else
version=${OPTARG}
g_version=${OPTARG}
fi
;;
f)
format=${OPTARG}
g_format=${OPTARG}
;;
*)
exit 1
@ -46,29 +99,15 @@ do
esac
done
: ${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"
pushd `git rev-parse --show-toplevel`
git archive "v${version}" --format="${format}" --prefix="${name}-${version}/" -o rpm/SOURCES/"${name}-${version}.${format}"
pushd rpm
verify_options
sed -e "s/^\(Version: \).*$/\1${version}/" \
-e "s/^\(Source0: \).*$/\1${name}-${version}.${format}/" \
SPECS/"${spec_name}".in > SPECS/"${spec_name}"
generate_tarball
completion_min_verion="2.6.0"
version_greater_equal ${version} ${completion_min_verion} \
&& with_completion="--with completion" || :
spec_path="${g_rpmbuild_topdir}/SPECS/shadowsocks-libev.spec"
sed -e "s/^\(Version: \).*$/\1${g_version}/" \
-e "s/^\(Source0: \).*$/\1${g_name}-${g_version}.${g_format}/" \
"${spec_path}".in > "${spec_path}"
rpmbuild -bb SPECS/"${spec_name}" --define "%_topdir `pwd`" \
${with_completion}
rpmbuild -bb ${spec_path} \
--define "%_topdir ${g_rpmbuild_topdir}" \
${g_rpmbuild_conditions} \
Loading…
Cancel
Save