diff --git a/lxd.changes b/lxd.changes index 295918a..099fed8 100644 --- a/lxd.changes +++ b/lxd.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Mar 28 01:54:01 UTC 2019 - Aleksa Sarai + +- 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 diff --git a/lxd.spec b/lxd.spec index cc1310c..30c3d78 100644 --- a/lxd.spec +++ b/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