2019-03-27 18:26:15 +01:00
|
|
|
#
|
|
|
|
# spec file for package lxd
|
|
|
|
#
|
2022-05-05 06:24:51 +02:00
|
|
|
# Copyright (c) 2022 SUSE LLC
|
2019-03-27 18:26:15 +01:00
|
|
|
#
|
|
|
|
# All modifications and additions to the file contributed by third parties
|
|
|
|
# remain the property of their copyright owners, unless otherwise agreed
|
|
|
|
# upon. The license for this file, and modifications and additions to the
|
|
|
|
# file, is the same license as for the pristine package itself (unless the
|
|
|
|
# license for the pristine package is not an Open Source License, in which
|
|
|
|
# case the license is the MIT License). An "Open Source License" is a
|
|
|
|
# license that conforms to the Open Source Definition (Version 1.9)
|
|
|
|
# published by the Open Source Initiative.
|
|
|
|
|
|
|
|
# Please submit bugfixes or comments via https://bugs.opensuse.org/
|
|
|
|
#
|
2021-09-12 18:39:39 +02:00
|
|
|
# nodebuginfo
|
2019-03-27 18:26:15 +01:00
|
|
|
|
2019-06-12 17:02:58 +02:00
|
|
|
|
2021-09-12 18:39:39 +02:00
|
|
|
%go_nostrip
|
|
|
|
|
2019-04-09 15:11:48 +02:00
|
|
|
%define _buildshell /bin/bash
|
2019-03-27 18:26:15 +01:00
|
|
|
%define import_path github.com/lxc/lxd
|
|
|
|
|
2021-03-18 05:08:21 +01:00
|
|
|
%define lxd_datadir %{_datadir}/lxd
|
|
|
|
%define lxd_ovmfdir %{lxd_datadir}/ovmf
|
2021-03-06 01:12:59 +01:00
|
|
|
|
2021-06-01 22:33:53 +02:00
|
|
|
# We need OVMF in order to support VMs with LXD. At the moment this means we
|
|
|
|
# can only support it on x86_64.
|
|
|
|
%ifarch x86_64
|
|
|
|
%define arch_vm_support 1
|
|
|
|
%else
|
|
|
|
%define arch_vm_support 0
|
|
|
|
%endif
|
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
Name: lxd
|
2022-05-05 06:24:51 +02:00
|
|
|
Version: 4.24
|
2019-03-27 18:26:15 +01:00
|
|
|
Release: 0
|
|
|
|
Summary: Container hypervisor based on LXC
|
|
|
|
License: Apache-2.0
|
|
|
|
Group: System/Management
|
|
|
|
URL: https://linuxcontainers.org/lxd
|
|
|
|
Source: https://linuxcontainers.org/downloads/%{name}/%{name}-%{version}.tar.gz
|
|
|
|
Source1: https://linuxcontainers.org/downloads/%{name}/%{name}-%{version}.tar.gz.asc
|
|
|
|
Source2: %{name}.keyring
|
2019-04-03 15:40:10 +02:00
|
|
|
Source3: %{name}-rpmlintrc
|
2019-03-27 18:26:15 +01:00
|
|
|
# LXD upstream doesn't use systemd, they use snapd.
|
|
|
|
Source100: %{name}.service
|
2021-04-12 07:54:31 +02:00
|
|
|
# LXD upstream doesn't have a sample config file.
|
|
|
|
Source101: %{name}-config.yml
|
2019-03-27 18:26:15 +01:00
|
|
|
# Additional runtime configuration.
|
|
|
|
Source200: %{name}.sysctl
|
|
|
|
Source201: %{name}.dnsmasq
|
2019-06-12 17:02:58 +02:00
|
|
|
BuildRequires: fdupes
|
2019-03-27 18:26:15 +01:00
|
|
|
BuildRequires: golang-packaging
|
|
|
|
BuildRequires: libacl-devel
|
|
|
|
BuildRequires: libcap-devel
|
2021-06-07 09:55:02 +02:00
|
|
|
BuildRequires: liblz4-devel
|
2019-03-28 04:20:03 +01:00
|
|
|
BuildRequires: patchelf
|
2019-06-12 17:02:58 +02:00
|
|
|
BuildRequires: pkg-config
|
2020-01-22 12:17:28 +01:00
|
|
|
BuildRequires: rsync
|
2020-11-13 07:38:16 +01:00
|
|
|
BuildRequires: sqlite3-devel >= 3.25
|
2021-06-07 09:55:02 +02:00
|
|
|
BuildRequires: pkgconfig(libudev)
|
2022-05-05 06:24:51 +02:00
|
|
|
BuildRequires: pkgconfig(lxc) >= 4.0.0
|
2020-06-09 18:47:50 +02:00
|
|
|
# Due to a limitation in openSUSE's Go packaging we cannot have a BuildRequires
|
2020-08-01 09:34:46 +02:00
|
|
|
# for 'golang(API) >= 1.14' here, so just require 1.14 exactly. bsc#1172608
|
2022-05-05 06:24:51 +02:00
|
|
|
BuildRequires: golang(API) = 1.17
|
2020-09-22 08:06:45 +02:00
|
|
|
# Needed to build dqlite and raft.
|
2019-03-27 18:26:15 +01:00
|
|
|
BuildRequires: autoconf
|
|
|
|
BuildRequires: libtool
|
2019-04-06 16:57:48 +02:00
|
|
|
BuildRequires: pkgconfig(libuv) >= 1.8.0
|
2019-03-27 18:26:15 +01:00
|
|
|
# Bits required for images and other things at runtime.
|
|
|
|
Requires: acl
|
2019-06-12 17:02:58 +02:00
|
|
|
Requires: ebtables
|
2019-03-27 18:26:15 +01:00
|
|
|
BuildRequires: dnsmasq
|
2019-06-12 17:02:58 +02:00
|
|
|
Requires: criu >= 2.0
|
2019-03-27 18:26:15 +01:00
|
|
|
Requires: dnsmasq
|
2019-03-28 10:05:54 +01:00
|
|
|
Requires: lxcfs
|
2019-06-09 10:24:02 +02:00
|
|
|
Requires: lxcfs-hooks-lxc
|
2019-03-27 18:26:15 +01:00
|
|
|
Requires: rsync
|
|
|
|
Requires: squashfs
|
2019-03-28 10:05:54 +01:00
|
|
|
Requires: tar
|
|
|
|
Requires: xz
|
2021-06-01 22:33:53 +02:00
|
|
|
%if 0%{arch_vm_support} != 0
|
2021-03-06 01:12:59 +01:00
|
|
|
# Needed for VM support.
|
|
|
|
Requires: qemu-ovmf-x86_64
|
|
|
|
BuildRequires: qemu-ovmf-x86_64
|
2021-03-06 08:37:47 +01:00
|
|
|
# QEMU spice became a separate package for QEMU 5.2, which is not in Leap 15.2.
|
|
|
|
# But it exists in Tumbleweed so only require this in Tumbleweed.
|
|
|
|
%if 0%{?suse_version} > 1500 || 0%{?sle_version} == 150300
|
2021-03-06 01:12:59 +01:00
|
|
|
Requires: qemu-ui-spice-core
|
2021-03-06 08:37:47 +01:00
|
|
|
%else
|
|
|
|
Requires: qemu-ui-spice-app
|
|
|
|
%endif
|
2021-06-01 22:36:27 +02:00
|
|
|
%ifarch %ix86 x86_64
|
2021-03-06 01:12:59 +01:00
|
|
|
Requires: qemu-x86
|
2021-06-01 22:33:53 +02:00
|
|
|
%endif
|
2021-06-01 22:36:27 +02:00
|
|
|
%ifarch aarch64 %arm
|
|
|
|
Requires: qemu-arm
|
|
|
|
%endif
|
|
|
|
%endif
|
2019-03-27 18:26:15 +01:00
|
|
|
# Storage backends -- we don't recommend ZFS since it's not *technically* a
|
|
|
|
# blessed configuration.
|
|
|
|
Recommends: lvm2
|
|
|
|
Recommends: btrfsprogs
|
2021-03-18 05:12:38 +01:00
|
|
|
Recommends: thin-provisioning-tools
|
2019-03-27 18:26:15 +01:00
|
|
|
Suggests: zfs
|
|
|
|
|
|
|
|
%description
|
2019-06-09 08:45:04 +02:00
|
|
|
LXD is a system container manager. It offers a user experience
|
|
|
|
similar to virtual machines but uses Linux containers (LXC) instead.
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
%package bash-completion
|
|
|
|
Summary: Bash Completion for %{name}
|
|
|
|
Group: System/Management
|
|
|
|
Requires: %{name} = %{version}
|
2021-09-09 02:48:07 +02:00
|
|
|
Supplements: (%{name} and bash-completion)
|
2019-03-27 18:26:15 +01:00
|
|
|
BuildArch: noarch
|
|
|
|
|
|
|
|
%description bash-completion
|
|
|
|
Bash command line completion support for %{name}.
|
|
|
|
|
|
|
|
%prep
|
|
|
|
%setup -q
|
2019-06-20 04:58:19 +02:00
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
%build
|
|
|
|
# Make sure any leftover go build caches are gone.
|
|
|
|
go clean -cache
|
|
|
|
|
2019-09-25 13:20:13 +02:00
|
|
|
# Set up temporary installation paths.
|
2021-09-09 02:48:07 +02:00
|
|
|
export INSTALL_ROOT="$PWD/.install"
|
2019-09-25 13:20:13 +02:00
|
|
|
export INSTALL_INCLUDEDIR="$INSTALL_ROOT/%{_includedir}"
|
|
|
|
export INSTALL_LIBDIR="$INSTALL_ROOT/%{_libdir}/%{name}"
|
|
|
|
|
|
|
|
# We first need to build all of the LXD-specific dependencies. To avoid binary
|
|
|
|
# bloat, we build them as dylibs -- but we then later need to mess around with
|
|
|
|
# the ELF headers to stop the openSUSE packaging scripts from freaking out.
|
2019-03-27 18:26:15 +01:00
|
|
|
export CFLAGS="%{optflags} -fPIC -DPIC"
|
|
|
|
|
2019-09-25 13:20:13 +02:00
|
|
|
# We have a temporary-install directory which contains all of the dylib deps.
|
|
|
|
export PKG_CONFIG_SYSROOT_DIR="$INSTALL_ROOT"
|
|
|
|
export PKG_CONFIG_PATH="$INSTALL_LIBDIR/pkgconfig"
|
2020-10-17 11:30:56 +02:00
|
|
|
# For some reason, Leap need us to specify this explicitly now.
|
|
|
|
export CPPFLAGS="-I$INSTALL_INCLUDEDIR"
|
2019-09-24 15:02:14 +02:00
|
|
|
|
|
|
|
# raft
|
2021-09-09 02:48:07 +02:00
|
|
|
pushd "vendor/raft"
|
2019-09-24 15:02:14 +02:00
|
|
|
autoreconf -fiv
|
|
|
|
%configure \
|
|
|
|
--libdir="%{_libdir}/%{name}" \
|
|
|
|
--disable-static
|
|
|
|
make %{?_smp_mflags}
|
2019-09-25 13:20:13 +02:00
|
|
|
make DESTDIR="$INSTALL_ROOT" install
|
2019-03-27 18:26:15 +01:00
|
|
|
popd
|
|
|
|
|
|
|
|
# dqlite
|
2021-09-09 02:48:07 +02:00
|
|
|
pushd "vendor/dqlite"
|
2019-03-27 18:26:15 +01:00
|
|
|
(
|
|
|
|
autoreconf -fiv
|
|
|
|
%configure \
|
2019-03-28 04:20:03 +01:00
|
|
|
--libdir="%{_libdir}/%{name}" \
|
2019-06-09 08:45:04 +02:00
|
|
|
--disable-static
|
2019-03-27 18:26:15 +01:00
|
|
|
make clean
|
|
|
|
make %{?_smp_mflags}
|
2019-09-25 13:20:13 +02:00
|
|
|
make DESTDIR="$INSTALL_ROOT" install
|
2019-03-27 18:26:15 +01:00
|
|
|
)
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Find all of the main packages using go-list.
|
|
|
|
readarray -t mainpkgs \
|
|
|
|
<<<"$(go list -f '{{.Name}}:{{.ImportPath}}' %{import_path}/... | \
|
|
|
|
awk -F: '$1 == "main" { print $2 }' | \
|
|
|
|
grep -Ev '^github.com/lxc/lxd/(test|shared)')"
|
|
|
|
|
2021-07-31 08:19:20 +02:00
|
|
|
# Needed because lxd and deps use funky #cgo LDFLAGS that Go blocks by default.
|
|
|
|
export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
|
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
# And now we can finally build LXD and all of the related binaries.
|
|
|
|
mkdir bin
|
|
|
|
for mainpkg in "${mainpkgs[@]}"
|
|
|
|
do
|
2021-03-06 09:04:46 +01:00
|
|
|
# Make sure all binaries *except* "lxc" have an lxd- prefix.
|
2019-03-27 18:26:15 +01:00
|
|
|
binary="$(basename "$mainpkg")"
|
2021-03-06 09:04:46 +01:00
|
|
|
if ( echo "$binary" | grep -Eqv '^lx[cd].*$' )
|
|
|
|
then
|
|
|
|
binary="lxd-$binary"
|
|
|
|
fi
|
2021-06-16 05:13:50 +02:00
|
|
|
case "$binary" in
|
|
|
|
lxd-agent)
|
|
|
|
build_static=1
|
|
|
|
build_tags="agent,netgo"
|
|
|
|
;;
|
|
|
|
lxd-p2c)
|
|
|
|
build_static=1
|
|
|
|
build_tags="netgo"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
build_static=
|
|
|
|
build_tags="libsqlite3"
|
|
|
|
;;
|
|
|
|
esac
|
2019-03-28 04:20:03 +01:00
|
|
|
(
|
2020-01-22 12:17:28 +01:00
|
|
|
# We need to link against our particular dylib deps.
|
|
|
|
export \
|
2019-09-25 13:20:13 +02:00
|
|
|
CGO_CFLAGS="-I $INSTALL_INCLUDEDIR" \
|
|
|
|
CGO_LDFLAGS="-L $INSTALL_LIBDIR" ||:
|
2021-06-16 05:13:50 +02:00
|
|
|
|
|
|
|
if [ -n "$build_static" ]
|
|
|
|
then
|
|
|
|
CGO_ENABLED=0 go build -ldflags "-extldflags -static" \
|
|
|
|
-tags "$build_tags" -o "bin/$binary" "$mainpkg"
|
|
|
|
else
|
|
|
|
go build -buildmode=pie \
|
|
|
|
-tags "$build_tags" -o "bin/$binary" "$mainpkg"
|
|
|
|
fi
|
2019-03-28 04:20:03 +01:00
|
|
|
)
|
2019-03-27 18:26:15 +01:00
|
|
|
done
|
|
|
|
|
2019-03-28 10:05:54 +01:00
|
|
|
# This part is quite ugly, so I apologise upfront.
|
|
|
|
#
|
2021-09-09 02:48:07 +02:00
|
|
|
# We want to have our vendor/* libraries be dylibs so that we don't bloat our
|
|
|
|
# lxd binary. Unfortunately, we are presented with a few challenges:
|
2019-03-28 10:05:54 +01:00
|
|
|
#
|
|
|
|
# * Doing this naively (put it in {_libdir}) results in sqlite3 package
|
|
|
|
# conflicts -- and we aren't going to maintain sqlite3 for all of openSUSE
|
|
|
|
# here.
|
|
|
|
#
|
|
|
|
# * Putting everything in a hidden {_libdir}/{name} with RUNPATH configured
|
|
|
|
# accordingly works a little better, but still results in lxd ending up with
|
|
|
|
# {Provides,Requires}: libsqlite3.so.0. This results in more esoteric
|
|
|
|
# conflicts but is still an issue (we'd need to add Prefer: libsqlite3-0
|
|
|
|
# everywhere).
|
|
|
|
#
|
|
|
|
# So, the only reasonable choice left is to use absolute paths as DT_NEEDED
|
|
|
|
# entries -- which bypasses the need for RUNPATH and allows us to set garbage
|
2021-09-09 02:48:07 +02:00
|
|
|
# sonames for our vendor/* libraries. Absolute paths for DT_NEEDED is
|
2019-09-24 15:02:14 +02:00
|
|
|
# *slightly* undefined behaviour, but glibc has had this behaviour for a very
|
|
|
|
# long time -- and others have considered using it in a similar manner[1].
|
2019-03-28 10:05:54 +01:00
|
|
|
#
|
|
|
|
# What F U N.
|
|
|
|
#
|
|
|
|
# [1]: https://github.com/NixOS/nixpkgs/issues/24844
|
|
|
|
|
2019-06-20 10:36:13 +02:00
|
|
|
(
|
|
|
|
# A simple check that lxd isn't broken. We can't do this after patchelf
|
|
|
|
# because we'd need to chroot(2) into {buildroot} which isn't permitted due
|
|
|
|
# to user namespaces being blocked inside rpmbuild. boo#1138769
|
2019-09-25 13:20:13 +02:00
|
|
|
export LD_LIBRARY_PATH="$INSTALL_LIBDIR"
|
|
|
|
./bin/lxd help
|
2019-06-20 10:36:13 +02:00
|
|
|
)
|
|
|
|
|
2019-09-25 13:20:13 +02:00
|
|
|
for lib in "$INSTALL_LIBDIR"/lib*.so
|
2019-09-24 15:02:14 +02:00
|
|
|
do
|
|
|
|
# Strip off last two version digits.
|
|
|
|
name="$(basename "$(readlink "$lib")" | sed -E 's/\.[0-9]+\.[0-9]+$//')"
|
|
|
|
# Give our libraries unrecognisable DT_SONAME entries.
|
|
|
|
patchelf --set-soname "._LXD_INTERNAL-$name" "$lib"
|
2019-09-25 13:20:13 +02:00
|
|
|
# Make sure they're executable.
|
|
|
|
chmod +x "$lib"
|
2019-09-24 15:02:14 +02:00
|
|
|
done
|
|
|
|
|
|
|
|
# Switch to absolute DT_NEEDED for all dylibs we have as well as the main LXD
|
|
|
|
# binary. We do this for all dylibs to make sure we don't end up with weird
|
|
|
|
# chain-loading problems.
|
2020-01-23 05:52:42 +01:00
|
|
|
for target in bin/* "$INSTALL_LIBDIR"/lib*.so
|
2019-09-24 15:02:14 +02:00
|
|
|
do
|
2021-06-16 05:13:50 +02:00
|
|
|
case "$(basename "$target")" in
|
|
|
|
lxd-agent|lxd-p2c)
|
|
|
|
# Cannot patch static binaries, and the patching isn't necessary
|
|
|
|
# for them anyway.
|
|
|
|
continue
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2019-09-24 15:02:14 +02:00
|
|
|
# Drop RPATH in case it got included during builds.
|
|
|
|
patchelf --remove-rpath "$target"
|
|
|
|
# And now replace all the possible DT_NEEDEDs to absolute paths.
|
2019-09-25 13:20:13 +02:00
|
|
|
for lib in "$INSTALL_LIBDIR"/lib*.so
|
2019-09-24 15:02:14 +02:00
|
|
|
do
|
|
|
|
# Strip off last two version digits.
|
|
|
|
name="$(basename "$(readlink "$lib")" | sed -E 's/\.[0-9]+\.[0-9]+$//')"
|
|
|
|
patchelf --replace-needed {,%{_libdir}/%{name}/}"$name" "$target"
|
|
|
|
done
|
|
|
|
done
|
2019-03-28 04:20:03 +01:00
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
# Generate man pages.
|
|
|
|
mkdir man
|
|
|
|
./bin/lxc manpage man/
|
|
|
|
|
2021-03-06 09:04:46 +01:00
|
|
|
# Final sanity-check during build.
|
2019-06-20 10:36:13 +02:00
|
|
|
pushd bin/
|
|
|
|
for bin in *
|
|
|
|
do
|
2021-06-16 05:13:50 +02:00
|
|
|
# Ensure that all our binaries are dynamic (except for lxd-p2c and
|
|
|
|
# lxd-agent, which must be static). boo#1138769
|
|
|
|
case "$(basename $bin)" in
|
|
|
|
lxd-agent|lxd-p2c)
|
|
|
|
file "$bin" | grep 'statically linked'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
file "$bin" | grep 'dynamically linked'
|
|
|
|
# Check what they are linked against.
|
|
|
|
ldd "$bin"
|
|
|
|
;;
|
|
|
|
esac
|
2019-06-20 10:36:13 +02:00
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
%install
|
2021-09-09 02:48:07 +02:00
|
|
|
export INSTALL_LIBDIR="$PWD/.install/%{_libdir}/%{name}"
|
2019-03-28 04:20:03 +01:00
|
|
|
|
|
|
|
install -d -m 0755 %{buildroot}%{_libdir}/%{name}
|
|
|
|
# We can't use install because *.so.$n are symlinks.
|
2019-09-25 13:20:13 +02:00
|
|
|
cp -avt %{buildroot}%{_libdir}/%{name}/ "$INSTALL_LIBDIR"/lib*.so.*
|
2019-03-28 04:20:03 +01:00
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
# Install all the binaries.
|
|
|
|
pushd bin/
|
|
|
|
for bin in *
|
|
|
|
do
|
|
|
|
install -D -m 0755 "$bin" "%{buildroot}%{_bindir}/$bin"
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
2021-04-12 07:54:31 +02:00
|
|
|
# System-wide client configuration.
|
|
|
|
install -D -m0644 %{S:101} %{buildroot}/etc/lxd/config.yml
|
|
|
|
install -d -m0755 %{buildroot}/etc/lxd/servercerts
|
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
# Install man pages.
|
|
|
|
pushd man/
|
|
|
|
for man in *
|
|
|
|
do
|
|
|
|
section="${man##*.}"
|
|
|
|
install -D -m 0644 "$man" "%{buildroot}%{_mandir}/man$section/$man"
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
|
|
|
|
# bash-completion.
|
2020-02-02 00:41:43 +01:00
|
|
|
install -D -m 0644 scripts/bash/lxd-client %{buildroot}%{_datadir}/bash-completion/completions/lxc
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
# sysv-init and systemd setup.
|
|
|
|
install -D -m 0644 %{S:100} %{buildroot}%{_unitdir}/%{name}.service
|
|
|
|
mkdir -p %{buildroot}%{_sbindir}
|
|
|
|
ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name}
|
|
|
|
|
|
|
|
# Run-time configuration.
|
|
|
|
install -D -m 0644 %{S:200} %{buildroot}%{_sysctldir}/60-lxd.conf
|
|
|
|
install -D -m 0644 %{S:201} %{buildroot}%{_sysconfdir}/dnsmasq.d/60-lxd.conf
|
|
|
|
|
|
|
|
# Run-time directories.
|
|
|
|
install -d -m 0711 %{buildroot}%{_localstatedir}/lib/%{name}
|
|
|
|
install -d -m 0755 %{buildroot}%{_localstatedir}/log/%{name}
|
|
|
|
|
2021-06-01 22:33:53 +02:00
|
|
|
%if 0%{arch_vm_support} != 0
|
2021-03-06 01:12:59 +01:00
|
|
|
# In order for VM support in LXD to function, you need to have OVMF configured
|
|
|
|
# in the way it expects. In particular, LXD depends on specific filenames for
|
|
|
|
# the firmware files so we create fake ones with symlinks.
|
2021-03-18 05:08:21 +01:00
|
|
|
mkdir -p %{buildroot}%{lxd_ovmfdir}
|
2021-04-21 03:35:46 +02:00
|
|
|
ln -s %{_datarootdir}/qemu/ovmf-x86_64-code.bin %{buildroot}%{lxd_ovmfdir}/OVMF_CODE.fd
|
2021-03-18 05:08:21 +01:00
|
|
|
ln -s %{_datarootdir}/qemu/ovmf-x86_64-vars.bin %{buildroot}%{lxd_ovmfdir}/OVMF_VARS.fd
|
2021-04-21 03:35:46 +02:00
|
|
|
ln -s OVMF_VARS.fd %{buildroot}%{lxd_ovmfdir}/OVMF_VARS.ms.fd
|
2021-06-01 22:33:53 +02:00
|
|
|
%endif
|
2021-03-06 01:12:59 +01:00
|
|
|
|
2019-03-28 04:20:03 +01:00
|
|
|
%fdupes %{buildroot}
|
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
%pre
|
2019-04-03 15:40:10 +02:00
|
|
|
# Group which owns the lxd socket, which allows people to administer it.
|
2019-04-09 15:11:48 +02:00
|
|
|
getent group %{name} >/dev/null || groupadd -r %{name}
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
# /etc/sub[ug]id should exist already (it's part of shadow-utils), but older
|
|
|
|
# distros don't have it. LXD just parses it and doesn't need any special
|
|
|
|
# shadow-utils helpers.
|
2019-04-09 16:29:01 +02:00
|
|
|
touch /etc/subuid /etc/subgid ||:
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
# Add sub[ug]ids for LXD's unprivileged containers -- in order to support
|
|
|
|
# isolated containers we add quite a few subuids. Since LXD runs as root we add
|
2019-04-03 15:40:10 +02:00
|
|
|
# them for the root user (not the lxd group). We only bother if there aren't
|
|
|
|
# any mappings available already.
|
2019-03-27 18:26:15 +01:00
|
|
|
#
|
|
|
|
# We have no guarantee that the range we pick will be unique -- which ideally
|
|
|
|
# we would want it to be. There isn't a nice way to do this without
|
|
|
|
# reimplementing a bunch of range-handling code for /etc/sub[ug]id in bash. So
|
2019-04-03 15:40:10 +02:00
|
|
|
# we just pick the 400-900 million range, and hope for the best (most tutorials
|
2019-03-27 18:26:15 +01:00
|
|
|
# use the 1-million range, so we avoid that pitfall).
|
2019-04-03 15:40:10 +02:00
|
|
|
#
|
|
|
|
# This default setting of 500 million is enough for ~8000 isolated containers,
|
|
|
|
# which should be enough for most users.
|
2019-04-09 16:29:01 +02:00
|
|
|
grep -q '^root:' /etc/subuid || \
|
2019-12-12 01:12:45 +01:00
|
|
|
usermod -v 400000000-900000000 root &>/dev/null || \
|
|
|
|
echo "root:400000000:500000001" >>/etc/subuid ||:
|
2019-04-09 16:29:01 +02:00
|
|
|
grep -q '^root:' /etc/subgid || \
|
2019-12-12 01:12:45 +01:00
|
|
|
usermod -w 400000000-900000000 root &>/dev/null || \
|
|
|
|
echo "root:400000000:500000001" >>/etc/subgid ||:
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
%service_add_pre %{name}.service
|
|
|
|
|
|
|
|
%post
|
|
|
|
%sysctl_apply
|
|
|
|
%service_add_post %{name}.service
|
|
|
|
|
|
|
|
%preun
|
|
|
|
%service_del_preun %{name}.service
|
|
|
|
|
|
|
|
%postun
|
|
|
|
%sysctl_apply
|
|
|
|
%service_del_postun %{name}.service
|
|
|
|
|
|
|
|
%files
|
|
|
|
%defattr(-,root,root)
|
|
|
|
%doc AUTHORS README.md doc/
|
|
|
|
%license COPYING
|
2021-03-06 09:04:46 +01:00
|
|
|
%{_bindir}/lx{c,d}*
|
2019-03-27 18:26:15 +01:00
|
|
|
%{_mandir}/man*/*
|
2019-03-28 04:20:03 +01:00
|
|
|
%{_libdir}/%{name}
|
2019-03-27 18:26:15 +01:00
|
|
|
|
2021-04-12 07:54:31 +02:00
|
|
|
%dir /etc/lxd
|
|
|
|
%config(noreplace) /etc/lxd/config.yml
|
|
|
|
%dir /etc/lxd/servercerts
|
|
|
|
|
2021-06-01 22:33:53 +02:00
|
|
|
%if 0%{arch_vm_support} != 0
|
2021-03-18 05:08:21 +01:00
|
|
|
%{lxd_datadir}
|
2021-06-01 22:33:53 +02:00
|
|
|
%endif
|
2021-03-18 05:08:21 +01:00
|
|
|
|
2019-03-27 18:26:15 +01:00
|
|
|
%{_sbindir}/rc%{name}
|
|
|
|
%{_unitdir}/%{name}.service
|
|
|
|
|
|
|
|
%dir %{_localstatedir}/lib/%{name}
|
|
|
|
%dir %{_localstatedir}/log/%{name}
|
|
|
|
|
2019-06-12 09:06:53 +02:00
|
|
|
%{_sysctldir}/60-lxd.conf
|
2019-06-19 05:22:06 +02:00
|
|
|
%config(noreplace) %{_sysconfdir}/dnsmasq.d/60-lxd.conf
|
2019-03-27 18:26:15 +01:00
|
|
|
|
|
|
|
%files bash-completion
|
|
|
|
%defattr(-,root,root)
|
|
|
|
%{_datadir}/bash-completion/
|
|
|
|
|
|
|
|
%changelog
|