env: set XDG_DATA_DIRS for wayland et.al. #3398

Merged
merged 8 commits into from Aug 30, 2017
View
@@ -38,6 +38,7 @@ data/systemd/*.service
data/dbus/*.service
data/info
+data/env/snapd.sh
# test-driver
*.log
View
@@ -1,3 +1,4 @@
all install clean:
$(MAKE) -C systemd $@
$(MAKE) -C dbus $@
+ $(MAKE) -C env $@
View
@@ -25,7 +25,9 @@ SERVICES := ${SERVICES_GENERATED}
all: ${SERVICES}
install: ${SERVICES}
- install -D -m 0644 -t ${DESTDIR}/${DBUSSERVICESDIR} $^
+ # NOTE: old (e.g. 14.04) GNU coreutils doesn't -D with -t
+ install -d -m 0755 ${DESTDIR}/${DBUSSERVICESDIR}
+ install -m 0644 -t ${DESTDIR}/${DBUSSERVICESDIR} $^
clean:
rm -f ${SERVICES_GENERATED}
View
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2017 Canonical Ltd
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 3 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+SNAP_MOUNT_DIR := /snap
+ENVD := /etc/profile.d
+
+%.sh: %.sh.in
+ sed < $< > $@ \
+ s:@SNAP_MOUNT_DIR@:${SNAP_MOUNT_DIR}:g
+
+GENERATED = snapd.sh
+
+
+all: ${GENERATED}
+.PHONY: all
+
+install: ${GENERATED}
+ # NOTE: old (e.g. 14.04) GNU coreutils doesn't -D with -t
+ install -d -m 0755 ${DESTDIR}/${ENVD}
+ install -m 0644 -t ${DESTDIR}/${ENVD} $^
+.PHONY: install
+
+clean:
+ $(RM) ${GENERATED}
+.PHONY: clean
View
@@ -0,0 +1,14 @@
+#!/bin/sh --this-shebang-is-just-here-to-inform-shellcheck--
+
+# Expand $PATH to include the directory where snappy applications go.
+if [ "${PATH#*/snap/bin}" = "${PATH}" ]; then
+ export PATH=$PATH:@SNAP_MOUNT_DIR@/bin
+fi
+
+# desktop files (used by desktop environments within both X11 and Wayland) are
+# looked for in XDG_DATA_DIRS; make sure it includes the relevant directory for
+# snappy applications' desktop files.
+if [ "${XDG_DATA_DIRS#*/snapd/desktop}" = "${XDG_DATA_DIRS}" ]; then
+ export XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}:/var/lib/snapd/desktop"
+fi
+
View
@@ -33,8 +33,10 @@ SYSTEMD_UNITS := ${SYSTEMD_UNITS_GENERATED} $(wildcard *.timer) $(wildcard *.soc
all: ${SYSTEMD_UNITS}
install: $(SYSTEMD_UNITS)
- install -D -m 0644 -t ${DESTDIR}/${SYSTEMDSYSTEMUNITDIR} $^
- install -D -m 0755 -t ${DESTDIR}/${LIBEXECDIR}/snapd snapd.core-fixup.sh
+ # NOTE: old (e.g. 14.04) GNU coreutils doesn't -D with -t
+ install -d -m 0755 ${DESTDIR}/${SYSTEMDSYSTEMUNITDIR}
+ install -m 0644 -t ${DESTDIR}/${SYSTEMDSYSTEMUNITDIR} $^
+ install -m 0755 -t ${DESTDIR}/${LIBEXECDIR}/snapd snapd.core-fixup.sh
clean:
rm -f ${SYSTEMD_UNITS_GENERATED}
@@ -1,12 +0,0 @@
-# This file is sourced by Xsession(5), not executed.
-# Add the additional snappy desktop path
-
-if [ -z "$XDG_DATA_DIRS" ]; then
- # 60x11-common_xdg_path does not always set XDG_DATA_DIRS
- # so we ensure we have sensible defaults here (LP: #1575014)
- # as a workaround
- XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
-else
- XDG_DATA_DIRS="$XDG_DATA_DIRS":/var/lib/snapd/desktop
-fi
-export XDG_DATA_DIRS
@@ -1,3 +0,0 @@
-# Expand the $PATH to include /snap/bin which is what snappy applications
-# use
-PATH=$PATH:/snap/bin
View
@@ -14,10 +14,8 @@ checkdepends=('python' 'squashfs-tools' 'indent' 'shellcheck')
options=('!strip' 'emptydirs')
install=snapd.install
-source=("git+https://github.com/snapcore/$pkgname.git"
- 'snapd.sh')
-md5sums=('SKIP'
- '8e9b8108165d5b2ae911de9caefb37ce')
+source=("git+https://github.com/snapcore/$pkgname.git")
+md5sums=('SKIP')
_gourl=github.com/snapcore/snapd
@@ -123,8 +121,8 @@ package() {
install -m 755 "$GOPATH/bin/snapd" "$pkgdir/usr/lib/snapd/"
# Install snap-confine
make -C "$srcdir/$pkgbase/cmd" install DESTDIR="$pkgdir/"
- # Install script to export binaries paths of snaps
- install -Dm 755 "$srcdir/snapd.sh" "$pkgdir/etc/profile.d/apps-bin-path.sh"
+ # Install script to export binaries paths of snaps and XDG_DATA_DIRS for their .desktop files
+ make -C "$srcdir/$pkgbase/data/env" install DESTDIR="$pkgdir"
# Install the bash tab completion files
install -Dm 755 "$GOPATH/src/${_gourl}/data/completion/snap" "$pkgdir/usr/share/bash-completion/completions/snap"
install -Dm 755 "$GOPATH/src/${_gourl}/data/completion/complete.sh" "$pkgdir/usr/lib/snapd/complete.sh"
View
@@ -1,10 +0,0 @@
-# Expand the $PATH to include /snaps/bin which is what snappy applications
-# use
-PATH=$PATH:/var/lib/snapd/snap/bin
-
-if [ -z "$XDG_DATA_DIRS" ]; then
- XDG_DATA_DIRS=/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
-else
- XDG_DATA_DIRS="$XDG_DATA_DIRS":/var/lib/snapd/desktop
-fi
-export XDG_DATA_DIRS
@@ -391,6 +391,9 @@ make BINDIR="%{_bindir}" LIBEXECDIR="%{_libexecdir}" \
SNAPD_ENVIRONMENT_FILE="%{_sysconfdir}/sysconfig/snapd"
popd
+# Build environ-tweaking snippet
+make -C data/env SNAP_MOUNT_DIR="%{_sharedstatedir}/snapd/snap"
+
%install
install -d -p %{buildroot}%{_bindir}
install -d -p %{buildroot}%{_libexecdir}/snapd
@@ -456,17 +459,10 @@ popd
# Remove snappy core specific scripts
rm %{buildroot}%{_libexecdir}/snapd/snapd.core-fixup.sh
-# Put /var/lib/snapd/snap/bin on PATH
-# Put /var/lib/snapd/desktop on XDG_DATA_DIRS
-cat << __SNAPD_SH__ > %{buildroot}%{_sysconfdir}/profile.d/snapd.sh
-PATH=\$PATH:/var/lib/snapd/snap/bin
-if [ -z "\$XDG_DATA_DIRS" ]; then
- XDG_DATA_DIRS=/usr/share/:/usr/local/share/:/var/lib/snapd/desktop
-else
- XDG_DATA_DIRS="\$XDG_DATA_DIRS":/var/lib/snapd/desktop
-fi
-export XDG_DATA_DIRS
-__SNAPD_SH__
+# Install environ-tweaking snippet
+pushd ./data/env
+%make_install
+popd
# Disable re-exec by default
echo 'SNAP_REEXEC=0' > %{buildroot}%{_sysconfdir}/sysconfig/snapd
@@ -174,8 +174,8 @@ mv %{buildroot}/usr/bin/snap-exec %{buildroot}%{_libexecdir}/snapd/snap-exec
mv %{buildroot}/usr/bin/snap-update-ns %{buildroot}%{_libexecdir}/snapd/snap-update-ns
mv %{buildroot}/usr/bin/snap-seccomp %{buildroot}%{_libexecdir}/snapd/snap-seccomp
# Install profile.d-based PATH integration for /snap/bin
-install -m 755 -d %{buildroot}/etc/profile.d/
-install -m 644 etc/profile.d/apps-bin-path.sh %{buildroot}/etc/profile.d/snapd.sh
+# and XDG_DATA_DIRS for /var/lib/snapd/desktop
+make -C data/env install DESTDIR=%{buildroot}
# Generate and install man page for snap command
install -m 755 -d %{buildroot}%{_mandir}/man1
@@ -18,8 +18,8 @@ Build-Depends: autoconf,
gnupg2,
golang-any (>=2:1.6) | golang-1.6,
indent,
- libcap-dev,
init-system-helpers,
+ libcap-dev,
libapparmor-dev,
libglib2.0-dev,
libseccomp-dev (>= 2.1.1-1ubuntu1~trusty4),
@@ -71,8 +71,8 @@ Depends: adduser,
util-linux (>=2.20.1-5.1ubuntu20.9),
${misc:Depends},
${shlibs:Depends}
-Replaces: ubuntu-snappy (<< 1.9), ubuntu-snappy-cli (<< 1.9), snap-confine (<< 2.23~14.04)
-Breaks: ubuntu-snappy (<< 1.9), ubuntu-snappy-cli (<< 1.9), snap-confine (<< 2.23~14.04)
+Replaces: ubuntu-snappy (<< 1.9), ubuntu-snappy-cli (<< 1.9), snap-confine (<< 2.23), ubuntu-core-launcher (<< 2.22), snapd-xdg-open (<< 0.0.0)
+Breaks: ubuntu-snappy (<< 1.9), ubuntu-snappy-cli (<< 1.9), snap-confine (<< 2.23), ubuntu-core-launcher (<< 2.22), snapd-xdg-open (<< 0.0.0)
Conflicts: snap (<< 2013-11-29-1ubuntu1)
Built-Using: ${Built-Using} ${misc:Built-Using}
Description: Tool to interact with Ubuntu Core Snappy.
@@ -114,10 +114,10 @@ Description: Transitional package for snapd
Package: ubuntu-core-launcher
Architecture: any
-Depends: snap-confine (= ${binary:Version}), ${misc:Depends}
-Section: oldlibs
+Depends: snapd (= ${binary:Version}), ${misc:Depends}
+Section: oldlibs
Pre-Depends: dpkg (>= 1.15.7.2)
-Description: Transitional package for snap-confine
+Description: Transitional package for snapd
@mvo5

mvo5 Aug 29, 2017

Collaborator

❤️

This is a transitional dummy package. It can safely be removed.
Package: snapd-xdg-open
@@ -1,5 +1,15 @@
#!/usr/bin/make -f
# -*- makefile -*-
+#
+# These rules should work for any debian-ish distro that is *not*
+# systemd based but can use a tweaked, deputy systemd. This includes
+# just Ubuntu 14.04 ("trusty"), to our knowledge (let us know if
+# you're using this elsewhere!). The more general, systemd-based one
+# is the 16.04 rule.
+#
+# Please keep the diff between that and this relatively small, even if
+# it means having suboptimal code; these need to be kept in sync by
+# sentient bags of meat.
#export DH_VERBOSE=1
export DH_OPTIONS
@@ -14,21 +24,30 @@ export PATH:=/usr/lib/go-1.6/bin:${PATH}
include /etc/os-release
-# We are relying on a deputy systemd setup for trusty,
-# in which systemd does not run as PID 1. To solve the
-# problem of services shipping systemd units and upstart jobs
-# being started twice, we altered systemd on trusty to ignore
-# /lib/systemd/system and instead consider only selected units from
-# /lib/systemd/upstart.
+# On trusty we are relying on a deputy systemd, which does not run as
+# PID 1. To solve the problem of services shipping systemd units and
+# upstart jobs being started twice, we altered systemd on trusty to
+# ignore /lib/systemd/system and instead consider only selected units
+# from /lib/systemd/upstart.
SYSTEMD_UNITS_DESTDIR="lib/systemd/upstart/"
+
# make sure that trusty's golang-1.6 is picked up correctly.
export PATH:=/usr/lib/go-1.6/bin:${PATH}
# The go tool does not fully support vendoring with gccgo, but we can
# work around that by constructing the appropriate -I flag by hand.
GCCGO := $(shell go tool dist env > /dev/null 2>&1 && echo no || echo yes)
-BUILDFLAGS:=-buildmode=pie -pkgdir=$(CURDIR)/_build/std
+# Disable -buildmode=pie mode on i386 as can panics in spectacular
+# ways (LP: #1711052).
+# See also https://forum.snapcraft.io/t/artful-i386-panics/
+# Note while the panic is only on artful, that's because artful
+# detects it; the issue potentially there on older things.
+BUILDFLAGS:=-pkgdir=$(CURDIR)/_build/std
+ifneq ($(shell dpkg-architecture -qDEB_HOST_ARCH),i386)
+BUILDFLAGS+= -buildmode=pie
+endif
+
GCCGOFLAGS=
ifeq ($(GCCGO),yes)
GOARCH := $(shell go env GOARCH)
@@ -53,7 +72,8 @@ BUILT_USING_PACKAGES=
# because derivatives may have different kernels that don't support all the
# required confinement features and we don't to mislead anyone about the
# security of the system. Discuss a proper approach to this for downstreams
-# if and when they approach us
+# if and when they approach us.
+# NOTE this could be simpler for trusty, but this way keeps the diff down.
ifeq ($(shell dpkg-vendor --query Vendor),Ubuntu)
# On Ubuntu 16.04 we need to produce a build that can be used on wide
# variety of systems. As such we prefer static linking over dynamic linking
@@ -72,31 +92,14 @@ endif
endif
BUILT_USING=$(shell dpkg-query -f '$${source:Package} (= $${source:Version}), ' -W $(BUILT_USING_PACKAGES))
-# export DEB_BUILD_MAINT_OPTIONS = hardening=+all
-# DPKG_EXPORT_BUILDFLAGS = 1
-# include /usr/share/dpkg/buildflags.mk
-
-# Currently, we enable confinement for Ubuntu only, not for derivatives,
-# because derivatives may have different kernels that don't support all the
-# required confinement features and we don't to mislead anyone about the
-# security of the system. Discuss a proper approach to this for downstreams
-# if and when they approach us
-ifeq ($(shell dpkg-vendor --query Vendor),Ubuntu)
- # On Ubuntu 14.04 snapd cannot add the libcap dependency because of a
- # feature/bug in apt where this would stop updates for some people (apt
- # tries not to install new packages unless `dist-upgrade' command is used).
- # As a work-around we link to libcap statically.
- VENDOR_ARGS=--enable-nvidia-ubuntu --enable-static-libcap
-else
- VENDOR_ARGS=--disable-apparmor
-endif
-
%:
dh $@ --buildsystem=golang --with=golang --fail-missing --builddirectory=_build
override_dh_fixperms:
dh_fixperms -Xusr/lib/snapd/snap-confine
+
+# trusty doesn't need the .real workaround
override_dh_installdeb:
dh_apparmor --profile-name=usr.lib.snapd.snap-confine -psnapd
dh_installdeb
@@ -114,9 +117,9 @@ ifneq (,$(TEST_GITHUB_AUTOPKGTEST))
)
endif
dh_clean
+ $(MAKE) -C data clean
# XXX: hacky
$(MAKE) -C cmd distclean || true
- $(MAKE) -C data/systemd clean
override_dh_auto_build:
# usually done via `go generate` but that is not supported on powerpc
@@ -130,6 +133,9 @@ override_dh_auto_build:
cd cmd && ( ./configure --prefix=/usr --libexecdir=/usr/lib/snapd $(VENDOR_ARGS))
$(MAKE) -C cmd all
+ # Generate the real systemd/dbus/env config files
+ $(MAKE) -C data all
+
override_dh_auto_test:
dh_auto_test -- $(GCCGOFLAGS)
# a tested default (production) build should have no test keys
@@ -143,6 +149,8 @@ ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
$(MAKE) -C cmd check
endif
+# no dh_systemd in trusty
+
override_dh_install:
# we do not need this in the package, its just needed during build
rm -rf ${CURDIR}/debian/tmp/usr/bin/xgettext-go
@@ -155,18 +163,22 @@ override_dh_install:
if [ -d share/locale ]; then \
cp -R share/locale debian/snapd/usr/share; \
fi
- # we install snapd's systemd units
- mkdir -p debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- install --mode=0644 debian/snapd.refresh.timer debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- install --mode=0644 debian/snapd.refresh.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- install --mode=0644 debian/snapd.autoimport.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- install --mode=0644 debian/*.socket debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- install --mode=0644 debian/snapd.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
+
+ # install snapd's systemd units / upstart jobs, done
+ # here instead of debian/snapd.install because the
+ # ubuntu/14.04 release branch adds/changes bits here
+ $(MAKE) -C data install DESTDIR=$(CURDIR)/debian/snapd/ \
+ SYSTEMDSYSTEMUNITDIR=$(SYSTEMD_UNITS_DESTDIR)
+ # we called this apps-bin-path.sh instead of snapd.sh, and
+ # it's a conf file so we're stuck with it
+ mv debian/snapd/etc/profile.d/snapd.sh debian/snapd/etc/profile.d/apps-bin-path.sh
+
install --mode=0644 debian/snap.mount.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
- # and now the normal install rules
- install --mode=0644 debian/snapd.system-shutdown.service debian/snapd/$(SYSTEMD_UNITS_DESTDIR)
+
$(MAKE) -C cmd install DESTDIR=$(CURDIR)/debian/tmp
+ # trusty doesn't need the .real workaround
+
dh_install
override_dh_auto_install: snap.8
@@ -1,10 +0,0 @@
-[Unit]
@mvo5

mvo5 Aug 29, 2017

Collaborator

❤️ ❤️

-Description=Auto import assertions from block devices
-After=snapd.service snapd.socket
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/snap auto-import
-
-[Install]
-WantedBy=multi-user.target
Oops, something went wrong.