1
0
mirror of https://github.com/abraunegg/onedrive.git synced 2026-10-29 04:15:11 +03:00
Files
onedrive/Makefile.in
abraunegg 110fc80bbc Fix systemd user service installation paths on RHEL-based distributions (#3917)
## Summary

Remove legacy RHEL/CentOS systemd installation handling that incorrectly installs the `onedrive.service` user unit into the system-level service directory.

This behaviour originated from compatibility requirements for older RHEL/CentOS releases that are now end-of-life.

## Changes

- **Makefile.in**
  - Install `onedrive.service` into `systemduserunitdir`.
  - Install `onedrive@.service` into `systemdsystemunitdir`.
  - Correct the corresponding uninstall rules.
  - Remove the obsolete RHEL-specific installation exception.

- **contrib/spec/onedrive.spec.in**
  - Remove the legacy `rhel_unitdir` conditional.
  - Use `%{_userunitdir}` and `%{_unitdir}` for their respective service files.
  - Align RPM file ownership with the corrected installation paths.

## Expected Behaviour

Modern RHEL, CentOS Stream and Fedora installations will place systemd units into their appropriate locations, allowing both system-level and user-level service management.

This change is limited to installation and packaging behaviour. No application runtime functionality is modified.

## Validation

Installation and packaging verification will be performed on RHEL 9.8 and RHEL 10.2, with regression coverage for Fedora and Ubuntu.
2026-10-14 15:30:20 +11:00

188 lines
6.8 KiB
Makefile

package = @PACKAGE_NAME@
version = @PACKAGE_VERSION@
prefix = @prefix@
# we don't use @exec_prefix@ because it usually contains '${prefix}' literally
# but we use @prefix@/bin/onedrive in the systemd unit files which are generated
# from the configure script.
# Thus, set exec_prefix unconditionally to prefix
# Alternative approach would be add dep on sed, and do manual generation in the Makefile.
# exec_prefix = @exec_prefix@
exec_prefix = @prefix@
datarootdir = @datarootdir@
datadir = @datadir@
srcdir = @srcdir@
bindir = @bindir@
mandir = @mandir@
sysconfdir = @sysconfdir@
docdir = $(datadir)/doc/$(package)
VPATH = @srcdir@
INSTALL = @INSTALL@
# Icon install locations (system-wide hicolor theme)
ICON_THEMEDIR = $(datadir)/icons/hicolor
ICON_PLACES_DIR = $(ICON_THEMEDIR)/scalable/places
ICON_APPS_DIR = $(ICON_THEMEDIR)/scalable/apps
ICON_TARGET_SVG = onedrive.svg
ICON_APP_TARGET_SVG = onedrive-notifications.svg
ICON_SOURCE_SVG = contrib/images/$(ICON_TARGET_SVG)
ICON_APP_SOURCE_SVG = contrib/images/$(ICON_APP_TARGET_SVG)
NOTIFICATIONS = @NOTIFICATIONS@
HAVE_SYSTEMD = @HAVE_SYSTEMD@
systemduserunitdir = @systemduserunitdir@
systemdsystemunitdir = @systemdsystemunitdir@
all_libs = @curl_LIBS@ @sqlite_LIBS@ @dbus_LIBS@ @notify_LIBS@ @bsd_inotify_LIBS@ @dynamic_linker_LIBS@
COMPLETIONS = @COMPLETIONS@
BASH_COMPLETION_DIR = @BASH_COMPLETION_DIR@
ZSH_COMPLETION_DIR = @ZSH_COMPLETION_DIR@
FISH_COMPLETION_DIR = @FISH_COMPLETION_DIR@
DEBUG = @DEBUG@
DC = @DC@
DCFLAGS = @DCFLAGS@
DEBUG_DCFLAGS = @DEBUG_DCFLAGS@
RELEASE_DCFLAGS = @RELEASE_DCFLAGS@
VERSION_DCFLAG = @VERSION_DCFLAG@
LINKER_DCFLAG = @LINKER_DCFLAG@
OUTPUT_DCFLAG = @OUTPUT_DCFLAG@
WERROR_DCFLAG = @WERROR_DCFLAG@
DCFLAGS += $(WERROR_DCFLAG)
ifeq ($(DEBUG),yes)
DCFLAGS += $(DEBUG_DCFLAGS)
else
DCFLAGS += $(RELEASE_DCFLAGS)
endif
ifeq ($(NOTIFICATIONS),yes)
GUI_NOTIFICATIONS = $(addprefix $(VERSION_DCFLAG)=,NoPragma NoGdk Notifications)
endif
system_unit_files = contrib/systemd/onedrive@.service
user_unit_files = contrib/systemd/onedrive.service
DOCFILES = readme.md config LICENSE changelog.md docs/advanced-usage.md docs/application-config-options.md docs/application-security.md docs/business-shared-items.md docs/client-architecture.md docs/contributing.md docs/docker.md docs/install.md docs/national-cloud-deployments.md docs/podman.md docs/privacy-policy.md docs/sharepoint-libraries.md docs/terms-of-service.md docs/ubuntu-package-install.md docs/usage.md docs/known-issues.md docs/webhooks.md docs/server-side-filtering-limitations.md docs/end_to_end_testing.md
ifneq ("$(wildcard /etc/redhat-release)","")
RHEL = $(shell cat /etc/redhat-release | grep -E "(Red Hat Enterprise Linux|CentOS|AlmaLinux)" | wc -l)
RHEL_VERSION = $(shell rpm --eval "%{rhel}")
else
RHEL = 0
RHEL_VERSION = 0
endif
SOURCES = \
src/main.d \
src/config.d \
src/log.d \
src/util.d \
src/time.d \
src/qxor.d \
src/curlEngine.d \
src/onedrive.d \
src/webhook.d \
src/sync.d \
src/itemdb.d \
src/sqlite.d \
src/clientSideFiltering.d \
src/monitor.d \
src/arsd/cgi.d \
src/xattr.d \
src/intune.d \
src/socketio.d \
src/curlWebsockets.d \
src/localAuth.d
ifeq ($(NOTIFICATIONS),yes)
SOURCES += src/notifications/notify.d src/notifications/dnotify.d
endif
all: onedrive
clean:
rm -f onedrive onedrive.o version
rm -rf autom4te.cache
rm -f config.log config.status
# Remove files generated via ./configure
distclean: clean
rm -f Makefile contrib/pacman/PKGBUILD contrib/spec/onedrive.spec onedrive.1 $(system_unit_files) $(user_unit_files)
onedrive: $(SOURCES)
if [ -d .git ] || [ -f .git ]; then \
git describe --tags > version ; \
else \
echo $(version) > version ; \
fi
$(DC) -J. $(GUI_NOTIFICATIONS) $(DCFLAGS) $^ $(addprefix $(LINKER_DCFLAG),$(all_libs)) $(OUTPUT_DCFLAG)$@
install: all
mkdir -p $(DESTDIR)$(bindir)
$(INSTALL) onedrive $(DESTDIR)$(bindir)/onedrive
mkdir -p $(DESTDIR)$(mandir)/man1
$(INSTALL) -m 0644 onedrive.1 $(DESTDIR)$(mandir)/man1/onedrive.1
mkdir -p $(DESTDIR)$(sysconfdir)/logrotate.d
$(INSTALL) -m 0644 contrib/logrotate/onedrive.logrotate $(DESTDIR)$(sysconfdir)/logrotate.d/onedrive
mkdir -p $(DESTDIR)$(docdir)
for file in $(DOCFILES); do \
$(INSTALL) -m 0644 $$file $(DESTDIR)$(docdir); \
done
ifeq ($(HAVE_SYSTEMD),yes)
mkdir -p $(DESTDIR)$(systemduserunitdir)
mkdir -p $(DESTDIR)$(systemdsystemunitdir)
$(INSTALL) -m 0644 $(system_unit_files) $(DESTDIR)$(systemdsystemunitdir)
$(INSTALL) -m 0644 $(user_unit_files) $(DESTDIR)$(systemduserunitdir)
else
ifeq ($(RHEL_VERSION),6)
$(INSTALL) contrib/init.d/onedrive.init $(DESTDIR)/etc/init.d/onedrive
$(INSTALL) contrib/init.d/onedrive_service.sh $(DESTDIR)$(bindir)/onedrive_service.sh
endif
endif
ifeq ($(COMPLETIONS),yes)
mkdir -p $(DESTDIR)$(ZSH_COMPLETION_DIR)
$(INSTALL) -m 0644 contrib/completions/complete.zsh $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
mkdir -p $(DESTDIR)$(BASH_COMPLETION_DIR)
$(INSTALL) -m 0644 contrib/completions/complete.bash $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
mkdir -p $(DESTDIR)$(FISH_COMPLETION_DIR)
$(INSTALL) -m 0644 contrib/completions/complete.fish $(DESTDIR)$(FISH_COMPLETION_DIR)/onedrive.fish
endif
# --- OneDrive folder icon (hicolor) ---
mkdir -p $(DESTDIR)$(ICON_PLACES_DIR)
$(INSTALL) -m 0644 $(ICON_SOURCE_SVG) $(DESTDIR)$(ICON_PLACES_DIR)/$(ICON_TARGET_SVG)
# --- OneDrive application icon (notifications / desktop integration) ---
mkdir -p $(DESTDIR)$(ICON_APPS_DIR)
$(INSTALL) -m 0644 $(ICON_APP_SOURCE_SVG) $(DESTDIR)$(ICON_APPS_DIR)/$(ICON_APP_TARGET_SVG)
# Refresh icon cache only when installing to the live system, not during staged DESTDIR installs
if [ -z "$(DESTDIR)" ] && command -v gtk-update-icon-cache >/dev/null 2>&1; then \
gtk-update-icon-cache -q -t -f -i "$(ICON_THEMEDIR)" || true; \
fi
uninstall:
rm -f $(DESTDIR)$(bindir)/onedrive
rm -f $(DESTDIR)$(mandir)/man1/onedrive.1
rm -f $(DESTDIR)$(sysconfdir)/logrotate.d/onedrive
ifeq ($(HAVE_SYSTEMD),yes)
rm -f $(DESTDIR)$(systemdsystemunitdir)/onedrive*.service
rm -f $(DESTDIR)$(systemduserunitdir)/onedrive*.service
else
ifeq ($(RHEL_VERSION),6)
rm -f $(DESTDIR)/etc/init.d/onedrive
rm -f $(DESTDIR)$(bindir)/onedrive_service.sh
endif
endif
for i in $(DOCFILES) ; do rm -f $(DESTDIR)$(docdir)/$$i ; done
ifeq ($(COMPLETIONS),yes)
rm -f $(DESTDIR)$(ZSH_COMPLETION_DIR)/_onedrive
rm -f $(DESTDIR)$(BASH_COMPLETION_DIR)/onedrive
rm -f $(DESTDIR)$(FISH_COMPLETION_DIR)/onedrive.fish
endif
# --- OneDrive folder icon (hicolor) ---
rm -f $(DESTDIR)$(ICON_PLACES_DIR)/$(ICON_TARGET_SVG)
# --- OneDrive application icon (notifications / desktop integration) ---
rm -f $(DESTDIR)$(ICON_APPS_DIR)/$(ICON_APP_TARGET_SVG)
# Refresh icon cache only when removing from the live system, not during staged DESTDIR installs
if [ -z "$(DESTDIR)" ] && command -v gtk-update-icon-cache >/dev/null 2>&1; then \
gtk-update-icon-cache -q -t -f -i "$(ICON_THEMEDIR)" || true; \
fi