From 5a757b0f96c60e3d894e8c5a9fd335f91fffb7f9 Mon Sep 17 00:00:00 2001 From: B Stack Date: Tue, 29 Sep 2020 21:05:42 -0400 Subject: WIP: improve rpm packaging, fix desktop files --- README.md | 5 +++ myautomount.spec | 38 +++++++++++++--------- src/Makefile | 7 +++- src/etc/xdg/autostart/myautomount-trayicon.desktop | 11 +------ src/etc/xdg/autostart/myautomountd.desktop | 11 +------ .../libexec/myautomount/myautomount-initialize.sh | 6 ++-- .../applications/myautomount-trayicon.desktop | 10 ++++++ src/usr/share/applications/myautomountd.desktop | 10 ++++++ 8 files changed, 59 insertions(+), 39 deletions(-) mode change 100644 => 120000 src/etc/xdg/autostart/myautomount-trayicon.desktop mode change 100644 => 120000 src/etc/xdg/autostart/myautomountd.desktop create mode 100644 src/usr/share/applications/myautomount-trayicon.desktop create mode 100644 src/usr/share/applications/myautomountd.desktop diff --git a/README.md b/README.md index 547db00..e275aa7 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,11 @@ Use environment variable `MYA_PREFIX` for testing. export MYA_PREFIX=~/dev/myautomount/src sudo DEBUG=1 MYA_PREFIX=~/dev/myautomount/src sh -x usr/libexec/myautomount/myautomount-initialize.sh +## TODO +A number of steps are still required before this package is production-worthy. +* add sudo rule +* make daemon invoke initialize script with sudo. This has to happen so the uid= in the autofs definition is the current user. So multi-seat usage could break the functionality, but that would also break regular file permissions. + # References [1]: https://github.com/project-trident/trident-utilities/blame/master/src-go/automount/main.go [2]: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html diff --git a/myautomount.spec b/myautomount.spec index d3e49dd..2079034 100644 --- a/myautomount.spec +++ b/myautomount.spec @@ -13,33 +13,38 @@ # Documentation: # Dependencies: -%global use_master 0 -%if !0%{?use_master} -%global git_date 20200929 -%global git_commit 8b9bc25cc615f7e8ba86ce51d2dd83220a4e084f +%global use_local 1 +%global use_commit 1 +%define date %(/usr/bin/date +%%Y%%m%%d) +%if 0%{?use_commit} +%global git_commit fc6313650f03b2c1bb097d7619478aa1fac6a39c %{?git_commit:%global git_commit_hash %(c=%{git_commit}; echo ${c:0:7})} %else +%global git_commit 0.0.1 %endif +%global releasenum 1 %define debug_package %{nil} %global _python_bytecompile_errors_terminate_build 0 Summary: tray icon for removable media Name: myautomount -%if ! 0%{?use_master} -Version: %{git_date} -Release: 1.git%{git_commit_hash} +%if 0%{?use_local} +Version: %{date} +Release: %{releasenum} +Source: %{name}.tar.gz %else -Version: %( date "+%F" ) -Release: 1 +%if 0{%?use_commit} +Version: %{date} +Release: %{releasenum}.git%{git_commit_hash} +%else +Version: %{git_commit} +Release: %{releasenum} %endif -License: CC BY-SA 4.0 and BSD-2-Clause -Group: Applications/System -%if ! 0%{?use_master} Source: https://gitlab.com/bgstack15/%{name}/-/archive/%{git_commit}/%{name}-%{git_commit}.tar.gz -%else -Source: https://gitlab.com/bgstack15/%{name}/-/archive/master/%{name}-master.tar.gz %endif +License: CC BY-SA 4.0 and BSD-2-Clause +Group: Applications/System URL: https://bgstack15.wordpress.com/ Packager: B Stack Requires: autofs @@ -73,9 +78,12 @@ exit 0 %postun %files -%config %attr(666, -, -) %{_sysconfdir}/%{name}.conf +%config %attr(0644, -, -) %{_sysconfdir}/%{name}.conf %{_sysconfdir}/xdg/autostart +%config %attr(0644, -, -) %{_sysconfdir}/autofs.%{name} +%config %attr(0644, -, -) %{_sysconfdir}/auto.master.d/* %{_bindir}/* +%{_datadir}/applications/* %{_libexecdir}/%{name}/* %doc %{_mandir}/man1/* %doc %{_pkgdocdir}/* diff --git a/src/Makefile b/src/Makefile index ef66dfe..58f89c5 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,6 +41,7 @@ findbin :=$(shell which find) grepbin :=$(shell which grep) gzipbin :=$(shell which gzip) installbin :=$(shell which install) +lnbin :=$(shell which ln) rmbin :=$(shell which rm) rmdirbin :=$(shell which rmdir) sedbin :=$(shell which sed) @@ -52,6 +53,8 @@ xargsbin :=$(shell which xargs) with_man ?= YES +APPSDIR_SHORT := $(shell ${echobin} "${APPSDIR}" | ${sedbin} -r -e "s:$(DESTDIR)/?::" ) + all: build_man ifeq ($(with_man),YES) @@ -80,7 +83,9 @@ install_files: @ls usr/share/man/man*/*gz 1>/dev/null 2>&1 && echo "Including man pages." || : @${echobin} Installing files to ${DESTDIR} for td in $$( ${findbin} ${SRCDIR} -type d ! -name '.*.swp' ! -name 'Makefile' -printf '%P\n' | ${sedbin} -r -e "s:etc/sysconfig:${DEFAULTDIR}:" -e "s:${DESTDIR}/?::" ) ; do ${installbin} -m0755 -d ${DESTDIR}/$${td} ; done - for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -name '.*.swp' ! -name 'Makefile' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated)\/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done + for tf in $$( ${findbin} ${SRCDIR} ! -type d ! -type l ! -name '.*.swp' ! -name 'Makefile' ! \( -path '*/man/*' -name '*.txt' \) ! -path '*/sysconfig/*' -printf '%P\n' ) ; do MODE=0644 ; echo "$${tf}" | grep -qE "(bin|libexec|deprecated)\/" && MODE=0755 ; ${installbin} -m$${MODE} ${SRCDIR}/$${tf} ${DESTDIR}/$${tf} ; done + ${lnbin} -s ../../../${APPSDIR_SHORT}/myautomountd.desktop ${XDGAUTODIR}/myautomountd.desktop + ${lnbin} -s ../../../${APPSDIR_SHORT}/myautomount-trayicon.desktop ${XDGAUTODIR}/myautomount-trayicon.desktop MAN_TXT:=$(wildcard usr/share/man/man*/*.txt) MAN_GZ:= $(subst .txt,.gz,$(MAN_TXT)) diff --git a/src/etc/xdg/autostart/myautomount-trayicon.desktop b/src/etc/xdg/autostart/myautomount-trayicon.desktop deleted file mode 100644 index 061454d..0000000 --- a/src/etc/xdg/autostart/myautomount-trayicon.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Comment=Tray icon for managing removable media -Exec=/usr/bin/myautomount-trayicon -GenericName=Automount helper tray icon -Icon=media-removable -Keywords=automount; -Name=MyAutoMount tray icon -NoDisplay=true -Terminal=false -Type=Application diff --git a/src/etc/xdg/autostart/myautomount-trayicon.desktop b/src/etc/xdg/autostart/myautomount-trayicon.desktop new file mode 120000 index 0000000..80819a7 --- /dev/null +++ b/src/etc/xdg/autostart/myautomount-trayicon.desktop @@ -0,0 +1 @@ +../../../usr/share/applications/myautomount-trayicon.desktop \ No newline at end of file diff --git a/src/etc/xdg/autostart/myautomountd.desktop b/src/etc/xdg/autostart/myautomountd.desktop deleted file mode 100644 index 57a147a..0000000 --- a/src/etc/xdg/autostart/myautomountd.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Comment=Monitor udevadm for removable media -Exec=/usr/bin/myautomountd -GenericName=Automount helper daemon -Icon=media-removable -Keywords=automount; -Name=MyAutoMount daemon -NoDisplay=true -Terminal=false -Type=Application diff --git a/src/etc/xdg/autostart/myautomountd.desktop b/src/etc/xdg/autostart/myautomountd.desktop new file mode 120000 index 0000000..c3007ef --- /dev/null +++ b/src/etc/xdg/autostart/myautomountd.desktop @@ -0,0 +1 @@ +../../../usr/share/applications/myautomountd.desktop \ No newline at end of file diff --git a/src/usr/libexec/myautomount/myautomount-initialize.sh b/src/usr/libexec/myautomount/myautomount-initialize.sh index e1cc6a8..67fe2f3 100644 --- a/src/usr/libexec/myautomount/myautomount-initialize.sh +++ b/src/usr/libexec/myautomount/myautomount-initialize.sh @@ -1,7 +1,7 @@ #!/bin/sh # SPDX-License-Identifier: BSD-2-Clause -# Only needs to be run once. This is more for reference than for using. The package should handle these tasks. -# MYA_SKIP_RESTART is for when you are building a package +# The daemon will call this once upon starting. +# MYA_SKIP_RESTART is for when you are building a package. Set it to any value, to skip the `service autofs restart`. fail() { echo "${@}" 1>&2 @@ -19,7 +19,7 @@ setupSystem() { { touch "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" && echo "${AUTOMOUNT_BROWSEDIR} ${AUTOMOUNT_FILE} --timeout=5 " > "${MYA_PREFIX}${AUTOMOUNT_DIR_FILE}" ; } || fail "Could not setup autofs rules! Check if this is being run as root?" _needrestart=1 } - test ${_needrestart} -eq 1 && test -n "${MYA_SKIP_RESTART}" eval "service autofs restart" + test ${_needrestart} -eq 1 && test -z "${MYA_SKIP_RESTART}" && eval "service autofs restart" } . ${MYA_PREFIX}/etc/myautomount.conf diff --git a/src/usr/share/applications/myautomount-trayicon.desktop b/src/usr/share/applications/myautomount-trayicon.desktop new file mode 100644 index 0000000..061454d --- /dev/null +++ b/src/usr/share/applications/myautomount-trayicon.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Comment=Tray icon for managing removable media +Exec=/usr/bin/myautomount-trayicon +GenericName=Automount helper tray icon +Icon=media-removable +Keywords=automount; +Name=MyAutoMount tray icon +NoDisplay=true +Terminal=false +Type=Application diff --git a/src/usr/share/applications/myautomountd.desktop b/src/usr/share/applications/myautomountd.desktop new file mode 100644 index 0000000..57a147a --- /dev/null +++ b/src/usr/share/applications/myautomountd.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Comment=Monitor udevadm for removable media +Exec=/usr/bin/myautomountd +GenericName=Automount helper daemon +Icon=media-removable +Keywords=automount; +Name=MyAutoMount daemon +NoDisplay=true +Terminal=false +Type=Application -- cgit