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 # As a special case, chown=amanda is taken as equivalent to
13 # chown=$(BINARY_OWNER):$(SETUID_GROUP), which may otherwise have problems with
14 # whitespace in the user/group names.
16 # when a filename is seen, the currently active variables are applied.
18 # Note that scripts are data, not executables!
22 # sbin_PROGRAMS = foo bar bing
23 # libexec_PROGRAMS = pro gram
24 # sbin_SCRIPTS = sk ript
25 # INSTALLPERMS_exec = \
26 # dest=$(sbindir) chown=amanda chmod= \
30 # dest=$(libexecdir) chmod= \
32 # INSTALLPERMS_data = \
33 # dest=$(sbindir) chown=amanda chmod= \
36 # This whole operation is not required when making builds for packaging,
37 # and can be disabled with --disable-installperms, via the WANT_INSTALLPERMS
38 # AM_CONDITIONAL. When disabled, the file 'installperms.sh' in the top-level
39 # build directory is populated with a format suitable for shell interpretation,
40 # with lines like this:
41 # installperm "amanda:disk" "04750" "/usr/local/sbin/bing"
42 # the arguments being, respectively, owner:group, mode, and filename. There will
43 # be exactly one line for each file which has specific permissions. The intention
44 # is that this file be used by packaging scripts to set correct permissions at install
45 # time. Note that files which have no special permissions requirements do not appear
46 # in this file at all, due to limitations of Automake.
48 # sed expression to strip leading directories from a filename; this converts e.g.,
49 # src/foo/bar.so to bar.so.
50 strip_leading_dirs=s|^.*/||
52 # define a snippet of the scripts below to either perform a chown/chmod operation,
53 # or record that operation in the logfile. On entry to the snippet, $$dest is the
54 # destination directory, $$cmd is the srcdir-relative pathname of the target file,
55 # $$chown is the ownership, and $$chmod is the permission pattern.
57 do_file=pa="$(DESTDIR)$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
58 if test -n "$$chown"; then \
59 echo chown "$$chown" "$$pa"; \
60 chown "$$chown" "$$pa" || exit 1; \
62 if test -n "$$chmod"; then \
63 echo chmod "$$chmod" "$$pa"; \
64 chmod "$$chmod" "$$pa" || exit 1; \
67 installperms_sh="$(top_builddir)/installperms.sh"
68 do_file=pa="$$dest"/`echo "$$cmd"|sed '$(strip_leading_dirs)'|sed '$(transform)'`; \
69 echo "installperm \"$$chown\" \"$$chmod\" \"$$pa\"" >> "$(installperms_sh)"
70 DISTCLEANFILES += $(installperms_sh)
74 @installperms="$(INSTALLPERMS_exec)"; \
75 test -n "$$installperms" && echo "Setting installation permissions on executables"; \
76 dest=; chown=; chmod=; \
77 for cmd in $$installperms; do \
80 echo " ($$cmd)"; chown="$(BINARY_OWNER):$(SETUID_GROUP)";; \
81 dest=*|chown=*|chmod=*) \
82 echo " ($$cmd)"; eval $$cmd;; \
88 @installperms="$(INSTALLPERMS_data)"; \
89 dest=; chown=; chmod=; \
90 for cmd in $$installperms; do \
93 echo " ($$cmd)"; chown="$(BINARY_OWNER):$(SETUID_GROUP)";; \
94 dest=*|chown=*|chmod=*) \
95 echo " ($$cmd)"; eval $$cmd;; \
100 install-exec-hook: installperms-exec
101 install-data-hook: installperms-data
103 # define a rule to initialize the installperms manifest file
108 rm -f "$(installperms_sh)"