mirror of
https://github.com/shadowsocks/simple-obfs.git
synced 2026-02-09 01:59:16 +08:00
Merge pull request #215 from kiichi7/master
Add RPM package build files.
This commit is contained in:
104
rpm/SPECS/shadowsocks-simple-obfs.spec.in
Normal file
104
rpm/SPECS/shadowsocks-simple-obfs.spec.in
Normal file
@@ -0,0 +1,104 @@
|
||||
%global requires pcre shadowsocks-libev >= 3.0.5 libev
|
||||
%global conflicts python-shadowsocks python3-shadowsocks
|
||||
%if 0%{?fedora} || 0%{?rhel}
|
||||
%global requires %{?requires} libcap
|
||||
%endif
|
||||
%if 0%{?suse_version}
|
||||
%global requires %{?requires} libcap-progs
|
||||
%endif
|
||||
%global project_desc shadowsocks-simple-obfs is a simple obfusacting tool, designed as plugin server of shadowsocks.
|
||||
|
||||
%if 0%{?fedora} >= 15 || 0%{?rhel} >=7 || 0%{?suse_version} >= 1210
|
||||
%global use_systemd 1
|
||||
%else
|
||||
%global use_systemd 0
|
||||
%endif
|
||||
|
||||
Name: @NAME@
|
||||
Version: @VERSION@
|
||||
Release: @RELEASE@%{?dist}
|
||||
Summary: A simple obfusacting tool, designed as plugin server of shadowsocks
|
||||
|
||||
Group: Applications/Internet
|
||||
License: GPLv3+
|
||||
URL: https://github.com/shadowsocks/simple-obfs
|
||||
Source0: @SOURCE@
|
||||
|
||||
BuildRequires: make gcc pcre-devel asciidoc xmlto automake libtool mbedtls-devel libsodium-devel >= 1.0.4 libev-devel c-ares-devel
|
||||
|
||||
AutoReq: no
|
||||
Conflicts: %{?conflicts}
|
||||
Requires: %{?requires}
|
||||
|
||||
%if 0%{?use_systemd}
|
||||
%{?systemd_requires}
|
||||
%if 0%{?suse_version}
|
||||
BuildRequires: systemd-rpm-macros
|
||||
%else
|
||||
BuildRequires: systemd
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%description
|
||||
%{?project_desc}
|
||||
|
||||
%prep
|
||||
%setup -q -n @NAME_VERSION@
|
||||
|
||||
%build
|
||||
./autogen.sh
|
||||
|
||||
%if 0%{?use_system_lib}
|
||||
%configure --enable-shared --enable-system-shared-lib
|
||||
%else
|
||||
%configure --enable-shared
|
||||
%endif
|
||||
make %{?_smp_mflags}
|
||||
|
||||
|
||||
%install
|
||||
make install DESTDIR=%{buildroot}
|
||||
mkdir -p %{buildroot}/etc/shadowsocks-libev
|
||||
install -m 644 %{_builddir}/%{buildsubdir}/debian/config.json %{buildroot}%{_sysconfdir}/shadowsocks-libev/simple-obfs.json
|
||||
|
||||
%pre
|
||||
|
||||
|
||||
%post
|
||||
setcap cap_net_bind_service+ep %{_bindir}/obfs-server \
|
||||
cap_net_bind_service+ep %{_bindir}/obfs-local
|
||||
|
||||
|
||||
%preun
|
||||
%if ! 0%{?use_systemd}
|
||||
if [ $1 -eq 0 ]; then
|
||||
/sbin/service shadowsocks-libev stop > /dev/null 2>&1 || :
|
||||
fi
|
||||
%else
|
||||
%if 0%{?suse_version}
|
||||
%service_del_preun shadowsocks-libev.service
|
||||
%service_del_preun shadowsocks-libev-local.service
|
||||
%else
|
||||
%systemd_preun shadowsocks-libev.service
|
||||
%systemd_preun shadowsocks-libev-local.service
|
||||
if [ $1 -eq 0 ] ; then
|
||||
# Package removal, not upgrade
|
||||
systemctl stop shadowsocks-libev-server@'*'.service > /dev/null 2>&1 || :
|
||||
systemctl stop shadowsocks-libev-local@'*'.service > /dev/null 2>&1 || :
|
||||
systemctl stop shadowsocks-libev-tunnel@'*'.service > /dev/null 2>&1 || :
|
||||
systemctl stop shadowsocks-libev-redir@'*'.service > /dev/null 2>&1 || :
|
||||
fi
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%postun
|
||||
echo "Update your shadowsocks-libev configure file, and restart it maunally."
|
||||
|
||||
%files
|
||||
%doc %{_docdir}/simple-obfs/*.html
|
||||
%{_bindir}/*
|
||||
%config(noreplace) %{_sysconfdir}/shadowsocks-libev/simple-obfs.json
|
||||
%doc %{_mandir}/man*/*
|
||||
|
||||
|
||||
%changelog
|
||||
95
rpm/genrpm.sh
Executable file
95
rpm/genrpm.sh
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
NAME=shadowsocks-simple-obfs
|
||||
|
||||
SELF=$(readlink -f -- "$0")
|
||||
HERE=$(dirname -- "$SELF")
|
||||
|
||||
SOURCES="${HERE}"/SOURCES
|
||||
SPEC_TEMPLATE="${HERE}"/SPECS/${NAME}.spec.in
|
||||
SPEC_FILE="${SPEC_TEMPLATE%%.in}"
|
||||
|
||||
GIT_VERSION=$("${HERE}"/../scripts/git_version.sh)
|
||||
|
||||
OPT_OUTDIR="${HERE}/SRPMS"
|
||||
OPT_USE_SYSTEM_LIB=0
|
||||
OUT_BUILD_RPM=0
|
||||
|
||||
version=$(echo ${GIT_VERSION} | cut -d' ' -f1)
|
||||
release=$(echo ${GIT_VERSION} | cut -d' ' -f2)
|
||||
|
||||
name_version=${NAME}-${version}-${release}
|
||||
source_name=${name_version}.tar.gz
|
||||
|
||||
archive()
|
||||
{
|
||||
"${HERE}"/../scripts/git_archive.sh -o "${SOURCES}" -n ${name_version}
|
||||
}
|
||||
|
||||
build_src_rpm()
|
||||
{
|
||||
rpmbuild -bs "${SPEC_FILE}" \
|
||||
--undefine "dist" \
|
||||
--define "%_topdir ${HERE}" \
|
||||
--define "%_srcrpmdir ${OPT_OUTDIR}"
|
||||
}
|
||||
|
||||
build_rpm()
|
||||
{
|
||||
rpmbuild --rebuild "${OPT_OUTDIR}"/${name_version}.src.rpm \
|
||||
--define "%_topdir ${HERE}" \
|
||||
--define "%use_system_lib ${OPT_USE_SYSTEM_LIB}"
|
||||
}
|
||||
|
||||
create_spec()
|
||||
{
|
||||
sed -e "s/@NAME@/${NAME}/g" \
|
||||
-e "s/@VERSION@/${version}/g" \
|
||||
-e "s/@RELEASE@/${release}/g" \
|
||||
-e "s/@SOURCE@/${source_name}/g" \
|
||||
-e "s/@NAME_VERSION@/${name_version}/g" \
|
||||
"${SPEC_TEMPLATE}" > "${SPEC_FILE}"
|
||||
}
|
||||
|
||||
show_help()
|
||||
{
|
||||
echo -e "$(basename $0) [OPTION...]"
|
||||
echo -e "Create and build shadowsocks-simple-obfs SRPM"
|
||||
echo
|
||||
echo -e "Options:"
|
||||
echo -e " -h show this help."
|
||||
echo -e " -b use rpmbuld to build resulting SRPM"
|
||||
echo -e " -s use system shared libraries (RPM only)"
|
||||
echo -e " -o output directory"
|
||||
}
|
||||
|
||||
while getopts "hbso:" opt
|
||||
do
|
||||
case ${opt} in
|
||||
h)
|
||||
show_help
|
||||
exit 0
|
||||
;;
|
||||
b)
|
||||
OPT_BUILD_RPM=1
|
||||
;;
|
||||
s)
|
||||
OPT_USE_SYSTEM_LIB=1
|
||||
;;
|
||||
o)
|
||||
OPT_OUTDIR=$(readlink -f -- $OPTARG)
|
||||
;;
|
||||
*)
|
||||
show_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
create_spec
|
||||
archive
|
||||
build_src_rpm
|
||||
if [ "${OPT_BUILD_RPM}" = "1" ] ; then
|
||||
build_rpm
|
||||
fi
|
||||
44
scripts/git_archive.sh
Executable file
44
scripts/git_archive.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
archive() {
|
||||
export TARBALL_NAME=$1
|
||||
export TARBALL_OUTDIR=$2
|
||||
|
||||
# archive this repo
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
git archive HEAD --format=tar --prefix="${TARBALL_NAME}/" \
|
||||
-o "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar"
|
||||
# archive submodules
|
||||
git submodule update --init
|
||||
git submodule foreach --quiet 'git archive HEAD --format=tar \
|
||||
--prefix="${TARBALL_NAME}/${path}/" \
|
||||
-o "${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar"
|
||||
tar -n --concatenate --file="${TARBALL_OUTDIR}/${TARBALL_NAME}.tar" \
|
||||
"${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar"'
|
||||
gzip -c "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar" > "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar.gz"
|
||||
|
||||
# clean-up
|
||||
git submodule foreach --quiet 'rm ${TARBALL_OUTDIR}/${TARBALL_NAME}-submodule-${path}-${sha1}.tar'
|
||||
rm "${TARBALL_OUTDIR}/${TARBALL_NAME}.tar"
|
||||
}
|
||||
|
||||
TARGET_TARBALL_NAME=shadowsocks-simple-obfs
|
||||
TARGET_TARBALL_DIR=$(git rev-parse --show-toplevel)
|
||||
|
||||
while getopts "n:o:" opt
|
||||
do
|
||||
case ${opt} in
|
||||
o)
|
||||
TARGET_TARBALL_DIR=$(readlink -f -- $OPTARG)
|
||||
;;
|
||||
n)
|
||||
TARGET_TARBALL_NAME=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
archive "${TARGET_TARBALL_NAME}" "${TARGET_TARBALL_DIR}"
|
||||
21
scripts/git_version.sh
Executable file
21
scripts/git_version.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
# determine version and release number
|
||||
GIT_DESCRIBE=$(git describe --tags --match 'v*' --long)
|
||||
# GIT_DESCRIBE is like v3.0.3-11-g1e3f35c-dirty
|
||||
if [[ ! "$GIT_DESCRIBE" =~ ^v([^-]+)-([0-9]+)-g([0-9a-f]+)$ ]]; then
|
||||
>&2 echo 'ERROR - unrecognized `git describe` output: '"$GIT_DESCRIBE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version=${BASH_REMATCH[1]}
|
||||
commits=${BASH_REMATCH[2]}
|
||||
short_hash=${BASH_REMATCH[3]}
|
||||
|
||||
release=1
|
||||
if [ "${commits}" -gt 0 ] ; then
|
||||
release+=.${commits}.git${short_hash}
|
||||
fi
|
||||
|
||||
echo "${version} ${release}"
|
||||
Reference in New Issue
Block a user