Skip to content

Commit

Permalink
Merge pull request canonical#436 from tomponline/latest-candidate
Browse files Browse the repository at this point in the history
nano and microovn fixes (latest-candidate)
  • Loading branch information
tomponline authored Apr 23, 2024
2 parents 10f4115 + d3c96c8 commit 96b6427
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ jobs:
go install github.com/canonical/lxd-ci/lxd-snapcraft@latest
git clone -b "${TARGET}" git+ssh://[email protected]/~canonical-lxd/lxd ~/lxd-pkg-snap-lp
# XXX: `originVer` contains an array with the 2 versions
originVer=($(lxd-snapcraft -get-version -file snapcraft.yaml))
originVer=($(lxd-snapcraft -package lxd -get-version -file snapcraft.yaml))
rsync -a --exclude .git --delete . ~/lxd-pkg-snap-lp/
cd ~/lxd-pkg-snap-lp
lxd-snapcraft -set-version "${originVer[0]}-${localRev:0:7}" -set-source-commit ""
lxd-snapcraft -package lxd -set-version "${originVer[0]}-${localRev:0:7}" -set-source-commit ""
git add --all
git commit --all --quiet -s --allow-empty -m "Automatic upstream build (${TARGET})" -m "Upstream commit: ${localRev}"
git show
Expand Down
10 changes: 10 additions & 0 deletions snapcraft/commands/daemon.start
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,18 @@ sed \
"${SNAP}/etc/lvm/lvm.conf" > /etc/lvm/lvm.conf

# Setup for OVN
echo "==> Cleaning up OVN configuration"
if [ -L /etc/ovn ]; then
echo "=> Removing /etc/ovn symlink"
rm -f /etc/ovn
elif [ -d /etc/ovn ]; then
echo "=> Removing /etc/ovn directory"
rm -rf /etc/ovn
fi

echo "==> Setting up OVN configuration"
if [ "${ovn_builtin:-"false"}" = "true" ]; then
echo "=> Using builtin OVN"
mkdir -p "${SNAP_COMMON}/ovn"
ln -s "${SNAP_COMMON}/ovn" /etc/ovn
elif [ -d "${SNAP_DATA}/microovn/certificates/pki" ]; then
Expand Down
8 changes: 7 additions & 1 deletion snapcraft/hooks/connect-plug-ovn-certificates
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ get_bool() {
if [ -e "/etc/.lxd_generated" ]; then
ovn_builtin=$(get_bool "$(snapctl get ovn.builtin)")

if test -d /etc/ovn ; then
echo "==> Cleaning up OVN configuration"
if [ -L /etc/ovn ]; then
echo "=> Removing /etc/ovn symlink"
rm -f /etc/ovn
elif [ -d /etc/ovn ]; then
echo "=> Removing /etc/ovn directory"
rm -rf /etc/ovn
fi

if ! [ "${ovn_builtin:-"false"}" = "true" ]; then
echo "=> Configuring MicroOVN Content Interface"
mkdir -p /etc/ovn
ln -snf "${SNAP_DATA}/microovn/certificates/pki/client-cert.pem" /etc/ovn/cert_host
ln -snf "${SNAP_DATA}/microovn/certificates/pki/client-privkey.pem" /etc/ovn/key_host
Expand Down
13 changes: 9 additions & 4 deletions snapcraft/wrappers/editor
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ run_cmd() {
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
[ -z "${XDG_DATA_HOME:-}" ] && export XDG_DATA_HOME="${HOME}/.local/share/"
[ -z "${XDG_CONFIG_HOME:-}" ] && export XDG_CONFIG_HOME="${HOME}/.config/"
[ -z "${XDG_STATE_HOME:-}" ] && export XDG_STATE_HOME="${HOME}/.local/state/"
IGNORERCFILES=""
if [ "${HOME}" != "/root" ] && [ "${CMD}" = "nano" ]; then
export XDG_DATA_HOME="${HOME}/.local/share"
if [ ! -d "/var/lib/snapd/hostfs/${XDG_DATA_HOME}" ]; then
echo "Instructing nano to ignore RC files due to missing directory: \"${XDG_DATA_HOME}\""
IGNORERCFILES="--ignorercfiles"
fi
fi

# shellcheck disable=SC2145
exec unshare --kill-child -U -m -p -r -f --root="/var/lib/snapd/hostfs/" "/bin/sh" -c "mount -t proc proc /proc 2>/dev/null || true; exec \"${CMD}\" \"$@\""
exec unshare --kill-child -U -m -p -r -f --root="/var/lib/snapd/hostfs/" "/bin/sh" -c "mount -t proc proc /proc 2>/dev/null || true; exec \"${CMD}\" ${IGNORERCFILES} \"$@\""
}

# Detect base name
Expand Down
3 changes: 0 additions & 3 deletions snapcraft/wrappers/remote-viewer
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ run_cmd() {
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
[ -z "${XDG_DATA_HOME:-}" ] && export XDG_DATA_HOME="${HOME}/.local/share/"
[ -z "${XDG_CONFIG_HOME:-}" ] && export XDG_CONFIG_HOME="${HOME}/.config/"
[ -z "${XDG_STATE_HOME:-}" ] && export XDG_STATE_HOME="${HOME}/.local/state/"

exec unshare -U -r chroot "/var/lib/snapd/hostfs/" "${CMD}" "$@"
}
Expand Down

0 comments on commit 96b6427

Please sign in to comment.