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>
|
Tue Mar 26 02:44:05 UTC 2019 - Aleksa Sarai <asarai@suse.com>
|
||||||
|
|
||||||
|
42
lxd.spec
42
lxd.spec
@ -38,6 +38,8 @@ BuildRequires: pkg-config
|
|||||||
BuildRequires: pkgconfig(lxc) >= 3.0.0
|
BuildRequires: pkgconfig(lxc) >= 3.0.0
|
||||||
BuildRequires: libacl-devel
|
BuildRequires: libacl-devel
|
||||||
BuildRequires: libcap-devel
|
BuildRequires: libcap-devel
|
||||||
|
BuildRequires: patchelf
|
||||||
|
BuildRequires: fdupes
|
||||||
# Needed to build the sqlite fork and dqlite.
|
# Needed to build the sqlite fork and dqlite.
|
||||||
BuildRequires: autoconf
|
BuildRequires: autoconf
|
||||||
BuildRequires: libtool
|
BuildRequires: libtool
|
||||||
@ -99,8 +101,8 @@ export CFLAGS="%{optflags} -fPIC -DPIC"
|
|||||||
pushd "$PKGDIR/dist/sqlite"
|
pushd "$PKGDIR/dist/sqlite"
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
%configure \
|
%configure \
|
||||||
--enable-static \
|
--libdir="%{_libdir}/%{name}" \
|
||||||
--disable-shared \
|
--disable-static \
|
||||||
--enable-replication \
|
--enable-replication \
|
||||||
--disable-tcl \
|
--disable-tcl \
|
||||||
make clean
|
make clean
|
||||||
@ -117,11 +119,14 @@ export LDFLAGS="-L$PWD/../sqlite/.libs/"
|
|||||||
|
|
||||||
autoreconf -fiv
|
autoreconf -fiv
|
||||||
%configure \
|
%configure \
|
||||||
--enable-static \
|
--libdir="%{_libdir}/%{name}" \
|
||||||
--disable-shared \
|
--disable-static \
|
||||||
--with-pic
|
--with-pic
|
||||||
make clean
|
make clean
|
||||||
make %{?_smp_mflags}
|
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
|
popd
|
||||||
|
|
||||||
@ -136,21 +141,37 @@ mkdir bin
|
|||||||
for mainpkg in "${mainpkgs[@]}"
|
for mainpkg in "${mainpkgs[@]}"
|
||||||
do
|
do
|
||||||
binary="$(basename "$mainpkg")"
|
binary="$(basename "$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_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"
|
export PKG_CONFIG_PATH="$PKGDIR/dist/sqlite:$PKGDIR/dist/dqlite"
|
||||||
export LD_LIBRARY_PATH="$PKGDIR/dist/sqlite/.libs:$PKGDIR/dist/dqlite/.libs"
|
fi
|
||||||
[[ "$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"
|
go build -buildmode=pie -tags "libsqlite3" -o "bin/$binary" "$mainpkg"
|
||||||
|
)
|
||||||
done
|
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.
|
# Generate man pages.
|
||||||
mkdir man
|
mkdir man
|
||||||
./bin/lxc manpage man/
|
./bin/lxc manpage man/
|
||||||
|
|
||||||
%install
|
%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.
|
# Install all the binaries.
|
||||||
pushd bin/
|
pushd bin/
|
||||||
for bin in *
|
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 0711 %{buildroot}%{_localstatedir}/lib/%{name}
|
||||||
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
|
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
|
||||||
|
|
||||||
|
%fdupes %{buildroot}
|
||||||
|
|
||||||
%pre
|
%pre
|
||||||
# Set up a user with subuid mappings so we can
|
# Set up a user with subuid mappings so we can
|
||||||
getent group %{name} &>/dev/null || groupadd -r %{name}
|
getent group %{name} &>/dev/null || groupadd -r %{name}
|
||||||
@ -226,6 +249,7 @@ grep '^root:' /etc/subgid &>/dev/null || \
|
|||||||
%license COPYING
|
%license COPYING
|
||||||
%{_bindir}/*
|
%{_bindir}/*
|
||||||
%{_mandir}/man*/*
|
%{_mandir}/man*/*
|
||||||
|
%{_libdir}/%{name}
|
||||||
|
|
||||||
%{_sbindir}/rc%{name}
|
%{_sbindir}/rc%{name}
|
||||||
%{_unitdir}/%{name}.service
|
%{_unitdir}/%{name}.service
|
||||||
|
Loading…
Reference in New Issue
Block a user