Skip to content

Instantly share code, notes, and snippets.

@qiaohaijun
Forked from apeyser/protobuf3.spec
Created January 4, 2018 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qiaohaijun/baeee2e0465f5b40549c4eb8c34ba751 to your computer and use it in GitHub Desktop.
Save qiaohaijun/baeee2e0465f5b40549c4eb8c34ba751 to your computer and use it in GitHub Desktop.
RPM spec file for building protobuf version 3.0.0-beta-1 into /opt in parallel to old, old versions of protobuf
#
%global srcvers 3.0.0-beta-1
%global srcname protobuf-%{srcvers}
%global _prefix /opt/%{srcname}
#
Summary: Protocol Buffers Google''s data interchange format
Name: protobuf3
Version: 3.0.0
Release: beta.1%{?dist}
License: BSD
Group: Development/Libraries
Source: https://github.com/google/protobuf/archive/v%{srcvers}.tar.gz
URL: https://github.com/google/protobuf
BuildRequires: automake autoconf libtool pkgconfig zlib-devel
#
%description
Protocol Buffers are a way of encoding structured data in an efficient
yet extensible format. Google uses Protocol Buffers for almost all of
its internal RPC protocols and file formats.
Protocol buffers are a flexible, efficient, automated mechanism for
serializing structured data – think XML, but smaller, faster, and
simpler. You define how you want your data to be structured once, then
you can use special generated source code to easily write and read
your structured data to and from a variety of data streams and using a
variety of languages. You can even update your data structure without
breaking deployed programs that are compiled against the "old" format.
#
%package compiler
Summary: Protocol Buffers compiler
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%description compiler
This package contains Protocol Buffers compiler for all programming
languages
#
%package devel
Summary: Protocol Buffers C++ headers and libraries
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: %{name}-compiler = %{version}-%{release}
Requires: pkgconfig
%description devel
This package contains Protocol Buffers compiler for all languages and
C++ headers and libraries
#
%package static
Summary: Static development files for %{name}
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
%description static
Static libraries for Protocol Buffers
#
%package lite
Summary: Protocol Buffers LITE_RUNTIME libraries
Group: Development/Libraries
%description lite
Protocol Buffers built with optimize_for = LITE_RUNTIME.
The "optimize_for = LITE_RUNTIME" option causes the compiler to generate code
which only depends libprotobuf-lite, which is much smaller than libprotobuf but
lacks descriptors, reflection, and some other features.
#
%package lite-devel
Summary: Protocol Buffers LITE_RUNTIME development libraries
Requires: %{name}-devel = %{version}-%{release}
Requires: %{name}-lite = %{version}-%{release}
%description lite-devel
This package contains development libraries built with
optimize_for = LITE_RUNTIME.
The "optimize_for = LITE_RUNTIME" option causes the compiler to generate code
which only depends libprotobuf-lite, which is much smaller than libprotobuf but
lacks descriptors, reflection, and some other features.
#
%package lite-static
Summary: Static development files for %{name}-lite
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
%description lite-static
This package contains static development libraries built with
optimize_for = LITE_RUNTIME.
The "optimize_for = LITE_RUNTIME" option causes the compiler to generate code
which only depends libprotobuf-lite, which is much smaller than libprotobuf but
lacks descriptors, reflection, and some other features.
#
%package python2
Summary: Python bindings for Google Protocol Buffers
Group: Development/Languages
BuildRequires: python-devel
BuildRequires: python-setuptools
Conflicts: %{name}-compiler > %{version}
Conflicts: %{name}-compiler < %{version}
%description python2
This package contains Python libraries for Google Protocol Buffers
#
%package python3
Summary: Python bindings for Google Protocol Buffers
Group: Development/Languages
BuildRequires: python3-devel
BuildRequires: python3-setuptools
Conflicts: %{name}-compiler > %{version}
Conflicts: %{name}-compiler < %{version}
%description python3
This package contains Python libraries for Google Protocol Buffers
#
%prep
%setup -q -n %{srcname}
chmod 644 examples/*
#
%build
iconv -f iso8859-1 -t utf-8 CONTRIBUTORS.txt > CONTRIBUTORS.txt.utf8
mv CONTRIBUTORS.txt.utf8 CONTRIBUTORS.txt
export PTHREAD_LIBS="-lpthread"
./autogen.sh
%configure
make %{?_smp_mflags}
pushd python
%py2_build
%py3_build
popd
#
%check
#make %{?_smp_mflags} check
#
%install
rm -rf %{buildroot}
make %{?_smp_mflags} install DESTDIR=%{buildroot} STRIPBINARIES=no INSTALL="%{__install} -p" CPPROG="cp -p"
find %{buildroot} -type f -name "*.la" -exec rm -f {} \;
pushd python
%py2_install
%py3_install
popd
#
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
%post lite -p /sbin/ldconfig
%postun lite -p /sbin/ldconfig
%post compiler -p /sbin/ldconfig
%postun compiler -p /sbin/ldconfig
#
%files
%{_libdir}/libprotobuf.so.*
%doc CHANGES.txt CONTRIBUTORS.txt README.md
%license LICENSE
%files compiler
%{_bindir}/protoc
%{_libdir}/libprotoc.so.*
%doc README.md
%license LICENSE
%files devel
%dir %{_includedir}/google
%{_includedir}/google/protobuf/
%{_libdir}/libprotobuf.so
%{_libdir}/libprotoc.so
%{_libdir}/pkgconfig/protobuf.pc
%doc examples/add_person.cc examples/addressbook.proto examples/list_people.cc examples/Makefile examples/README.txt
%files static
%{_libdir}/libprotobuf.a
%{_libdir}/libprotoc.a
%files lite
%{_libdir}/libprotobuf-lite.so.*
%files lite-devel
%{_libdir}/libprotobuf-lite.so
%{_libdir}/pkgconfig/protobuf-lite.pc
%files lite-static
%{_libdir}/libprotobuf-lite.a
%files python2
%{python2_sitelib}/*
%doc python/README.md
%doc examples/add_person.py examples/list_people.py examples/addressbook.proto
%files python3
%{python3_sitelib}/*
%doc python/README.md
%doc examples/add_person.py examples/list_people.py examples/addressbook.proto
#
%changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment