3 # Adjust post-install permissions settings. This rule works off two
4 # specially-formatted variables, INSTALLPERMS_exec and INSTALLPERMS_data.
5 # Each is a whitespace-separated list of commands, all of which are either
6 # a variable assignment or a filename. Three variables are available:
8 # - dest= sets the destination directory to e.g., $(sbindir)
9 # - chown= controls changes in ownership; value is first argument to chown
10 # - chmod= controls changes in permissions; value is first argument to chmod
12 # The following special cases are available:
13 # amanda:setuid = $(BINARY_OWNER):$(SETUID_GROUP)
14 # root:setuid = root:$(SETUID_GROUP)
15 # These variables might otherwise have problems with whitespace in the user/group
18 # when a filename is seen, the currently active variables are applied.
20 # Note that scripts are data, not executables!
24 # sbin_PROGRAMS = foo bar bing
25 # libexec_PROGRAMS = pro gram
26 # sbin_SCRIPTS = sk ript
27 # INSTALLPERMS_exec = \
28 # dest=$(sbindir) chown=amanda chmod= \
32 # dest=$(libexecdir) chmod= \
34 # INSTALLPERMS_data = \
35 # dest=$(sbindir) chown=amanda chmod= \
38 # This whole operation is not required when making builds for packaging,
39 # and can be disabled with --disable-installperms, via the WANT_INSTALLPERMS
40 # AM_CONDITIONAL. When disabled, the file 'installperms.sh' in the top-level
41 # build directory is populated with a format suitable for shell interpretation,
42 # with lines like this:
43 # installperm "amanda:disk" "04750" "/usr/local/sbin/bing"
44 # the arguments being, respectively, owner:group, mode, and filename. There will
45 # be exactly one line for each file which has specific permissions. The intention
46 # is that this file be used by packaging scripts to set correct permissions at install
47 # time. Note that files which have no special permissions requirements do not appear
48 # in this file at all, due to limitations of Automake.
50 # sed expression to strip leading directories from a filename; this converts e.g.,
51 # src/foo/bar.so to bar.so.
52 strip_leading_dirs=s|^.*/||
54 # define a snippet of the scripts below to either perform a chown/chmod operation,
55 # or record that operation in the logfile. On entry to the snippet, $$dest is the
56 # destination directory, $$cmd is the srcdir-relative pathname of the target file,
57 # $$chown is the ownership, and $$chmod is the permission pattern.
59 do_file=pa="$(DESTDIR)$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
60 if test -n "$$chown"; then \
61 echo chown "$$chown" "$$pa"; \
62 chown "$$chown" "$$pa" || exit 1; \
64 if test -n "$$chmod"; then \
65 echo chmod "$$chmod" "$$pa"; \
66 chmod "$$chmod" "$$pa" || exit 1; \
69 installperms_sh="$(top_builddir)/installperms.sh"
70 do_file=pa="$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
71 echo "installperm \"$$chown\" \"$$chmod\" \"$$pa\"" >> "$(installperms_sh)"
72 DISTCLEANFILES += $(installperms_sh)
75 do_installperms=dest=; chown=; chmod=; \
76 for cmd in $$installperms; do \
78 chown=amanda:setuid) \
79 echo " ($$cmd)"; chown="$(BINARY_OWNER):$(SETUID_GROUP)";; \
81 echo " ($$cmd)"; chown="root:$(SETUID_GROUP)";; \
82 dest=*|chown=*|chmod=*) \
83 echo " ($$cmd)"; eval $$cmd;; \
89 @installperms="$(INSTALLPERMS_exec)"; \
90 test -n "$$installperms" && echo "Setting installation permissions on executables"; \
94 @installperms="$(INSTALLPERMS_data)"; \
95 test -n "$$installperms" && echo "Setting installation permissions on data"; \
98 install-exec-hook: installperms-exec
99 install-data-hook: installperms-data
101 # define a rule to initialize the installperms manifest file
106 rm -f "$(installperms_sh)"