-
Notifications
You must be signed in to change notification settings - Fork 38
Setup LXD based on a feature pull request
mas-who edited this page Feb 26, 2024
·
4 revisions
This guide details the steps for setting up lxd your lxd build based on a feature pull request that is not yet released via snapd.
- Make sure you have lxd snap installed, if not, refer to HACKING.md for instructions.
- Create and launch a container instance with
ubuntu:22.04
, name itbuilder
or something suitable. The container will be used to compile lxd and lxc binaries and will ensure that dependencies are the same as those used in the published snaps. - Once the container is running, navigate to its terminal:
3.1 update and upgrade apt with:
apt update apt -y upgrade
3.2 install package dependencies for lxd
apt -y install acl attr autoconf automake dnsmasq-base git libacl1-dev libcap-dev liblxc1 liblxc-dev libsqlite3-dev libtool libudev-dev liblz4-dev libuv1-dev make pkg-config rsync squashfs-tools tar tcl xz-utils ebtables apt -y install lvm2 thin-provisioning-tools apt -y install btrfs-progs apt -y install curl gettext jq sqlite3 socat bind9-dnsutils apt -y install shellcheck
3.3 install go
apt -y install snapd snap install go --classic
3.4 clone the source code
git clone https://github.com/canonical/lxd cd lxd
3.5 check out a specific pull request from the lxd repo. You will need the pull request id and replace
pull_id
in the command belowgit fetch origin pull/[pull_id]/head:[branch_name] && git switch [branch_name]
3.6 build lxd dependencies, make sure you are inside the
/lxd
directorymake deps
3.7 at the end of step 3.6, there will be some instructions displayed in the shell output for setting up environment variables. Copy those and run them to set them up, an example is shown below:
export CGO_CFLAGS="-I/root/go/deps/raft/include/ -I/root/go/deps/dqlite/include/" export CGO_LDFLAGS="-L/root/go/deps/raft/.libs -L/root/go/deps/dqlite/.libs/" export LD_LIBRARY_PATH="/root/go/deps/raft/.libs/:/root/go/deps/dqlite/.libs/" export CGO_LDFLAGS_ALLOW="(-Wl,-wrap,pthread_create)|(-Wl,-z,now)"
3.8 finally we can now build the lxd and lxc binaries, once done, exit the container
make exit
- Get the binaries from the container
lxc file pull builder/root/go/bin/lxd lxd.debug
lxc file pull builder/root/go/bin/lxc lxc.debug
- Push the newly compiled binaries to your existing lxd snap working environment
sudo mv lx[cd].debug /var/snap/lxd/common
- Restart lxd daemon, NB: note if the new binaries compiled includes feature changes that require a database schema change, then you will need to revert those database changes manually later when removing the debug binaries. Alternatively, you can also completely purge your local lxd snap installation and reinstall again.
sudo systemctl reload snap.lxd.daemon
- Revert or purge if db schema changed
sudo rm /var/snap/lxd/common/lx[cd].debug
sudo systemctl reload snap.lxd.daemon
or
sudo snap remove --purge lxd