Accepting request 689185 from home:cyphar:lxc
- Make sqlite+dqlite both shared libs to avoid bloating RSS -- which requires having a separate RPATH for them. OBS-URL: https://build.opensuse.org/request/show/689185 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/lxd?expand=0&rev=2
This commit is contained in:
parent
8f32132ed4
commit
6f51ca789c
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 28 01:54:01 UTC 2019 - Aleksa Sarai <asarai@suse.com>
|
||||
|
||||
- Make sqlite+dqlite both shared libs to avoid bloating RSS -- which requires
|
||||
having a separate RPATH for them.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Mar 26 02:44:05 UTC 2019 - Aleksa Sarai <asarai@suse.com>
|
||||
|
||||
|
48
lxd.spec
48
lxd.spec
@ -38,6 +38,8 @@ BuildRequires: pkg-config
|
||||
BuildRequires: pkgconfig(lxc) >= 3.0.0
|
||||
BuildRequires: libacl-devel
|
||||
BuildRequires: libcap-devel
|
||||
BuildRequires: patchelf
|
||||
BuildRequires: fdupes
|
||||
# Needed to build the sqlite fork and dqlite.
|
||||
BuildRequires: autoconf
|
||||
BuildRequires: libtool
|
||||
@ -99,8 +101,8 @@ export CFLAGS="%{optflags} -fPIC -DPIC"
|
||||
pushd "$PKGDIR/dist/sqlite"
|
||||
autoreconf -fiv
|
||||
%configure \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--libdir="%{_libdir}/%{name}" \
|
||||
--disable-static \
|
||||
--enable-replication \
|
||||
--disable-tcl \
|
||||
make clean
|
||||
@ -117,11 +119,14 @@ export LDFLAGS="-L$PWD/../sqlite/.libs/"
|
||||
|
||||
autoreconf -fiv
|
||||
%configure \
|
||||
--enable-static \
|
||||
--disable-shared \
|
||||
--libdir="%{_libdir}/%{name}" \
|
||||
--disable-static \
|
||||
--with-pic
|
||||
make clean
|
||||
make %{?_smp_mflags}
|
||||
# We want to set rpath to our fake _libdir -- not $PWD/../sqlite/.libs/.
|
||||
# And we *absolutely* want DT_RPATH.
|
||||
patchelf --force-rpath --set-rpath '%{_libdir}/%{name}' .libs/libdqlite.so
|
||||
)
|
||||
popd
|
||||
|
||||
@ -136,21 +141,37 @@ mkdir bin
|
||||
for mainpkg in "${mainpkgs[@]}"
|
||||
do
|
||||
binary="$(basename "$mainpkg")"
|
||||
|
||||
export CGO_CFLAGS="%{optflags} -I$PKGDIR/dist/sqlite/ -I$PKGDIR/dist/dqlite/include/"
|
||||
export PKG_CONFIG_PATH="$PKGDIR/dist/sqlite:$PKGDIR/dist/dqlite"
|
||||
export LD_LIBRARY_PATH="$PKGDIR/dist/sqlite/.libs:$PKGDIR/dist/dqlite/.libs"
|
||||
[[ "$binary" == "lxd" ]] && EXTRA_LIBS="-lsqlite3 -ldqlite -ldl -luv" ||:
|
||||
export CGO_LDFLAGS="-L$PKGDIR/dist/sqlite/.libs/ -L$PKGDIR/dist/dqlite/.libs/ $EXTRA_LIBS"
|
||||
|
||||
go build -buildmode=pie -tags "libsqlite3" -o "bin/$binary" "$mainpkg"
|
||||
(
|
||||
if [[ "$binary" == "lxd" ]]
|
||||
then
|
||||
# We need to link against sqlite and dqlite only when dealing with lxd proper.
|
||||
export CGO_CFLAGS="%{optflags} -I$PKGDIR/dist/sqlite/ -I$PKGDIR/dist/dqlite/include/"
|
||||
export CGO_LDFLAGS="-L$PKGDIR/dist/sqlite/.libs/ -L$PKGDIR/dist/dqlite/.libs/"
|
||||
export PKG_CONFIG_PATH="$PKGDIR/dist/sqlite:$PKGDIR/dist/dqlite"
|
||||
fi
|
||||
go build -buildmode=pie -tags "libsqlite3" -o "bin/$binary" "$mainpkg"
|
||||
)
|
||||
done
|
||||
|
||||
# We want to set rpath for lxd to our fake _libdir. And we *absolutely* want
|
||||
# DT_RPATH not DT_RUNPATH because we *need* to use our libsqlite3.
|
||||
patchelf --force-rpath --set-rpath '%{_libdir}/%{name}' bin/lxd
|
||||
|
||||
# Generate man pages.
|
||||
mkdir man
|
||||
./bin/lxc manpage man/
|
||||
|
||||
%install
|
||||
export GOPATH="$PWD/.gopath"
|
||||
export PKGDIR="$GOPATH/src/%{import_path}"
|
||||
|
||||
install -d -m 0755 %{buildroot}%{_libdir}/%{name}
|
||||
pushd .gopath/src/%{import_path}
|
||||
# We can't use install because *.so.$n are symlinks.
|
||||
cp -avt %{buildroot}%{_libdir}/%{name}/ dist/sqlite/.libs/libsqlite3.so.*
|
||||
cp -avt %{buildroot}%{_libdir}/%{name}/ dist/dqlite/.libs/libdqlite.so.*
|
||||
popd
|
||||
|
||||
# Install all the binaries.
|
||||
pushd bin/
|
||||
for bin in *
|
||||
@ -184,6 +205,8 @@ install -D -m 0644 %{S:201} %{buildroot}%{_sysconfdir}/dnsmasq.d/60-lxd.conf
|
||||
install -d -m 0711 %{buildroot}%{_localstatedir}/lib/%{name}
|
||||
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
|
||||
|
||||
%fdupes %{buildroot}
|
||||
|
||||
%pre
|
||||
# Set up a user with subuid mappings so we can
|
||||
getent group %{name} &>/dev/null || groupadd -r %{name}
|
||||
@ -226,6 +249,7 @@ grep '^root:' /etc/subgid &>/dev/null || \
|
||||
%license COPYING
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man*/*
|
||||
%{_libdir}/%{name}
|
||||
|
||||
%{_sbindir}/rc%{name}
|
||||
%{_unitdir}/%{name}.service
|
||||
|
Loading…
Reference in New Issue
Block a user