2 # Ensure "install -C" works. (basic tests)
4 # Copyright (C) 2008-2024 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 .
"${srcdir=.}/tests/init.sh"; path_prepend_ .
/src
22 skip_if_nondefault_group_
24 # Note if a group is not specified, install(1) will assume that a file
25 # would be installed with the current user's group ID, and thus if the
26 # file is the same except that it does have a different group due to
27 # its parent directory being g+s for example, then the copy will be
28 # done again redundantly in a futile attempt to reset the group ID to
29 # that of the current user.
31 # install -d -g wheel -m 2775 test # Create setgid dir
32 # touch test/a # Create source
33 # install -Cv -m664 test/a test/i1 # install source with mode
34 # install -Cv -m664 test/i1 test/i2 # install dest
35 # install -Cv -m664 test/i1 test/i2 # again to see redundant install
37 # Similarly if an existing file exists that is the same and has the
38 # current users group ID, but when an actual install of the file would
39 # reset to a different group ID due to the directory being g+s for example,
40 # then the install will not be done when it should.
42 # install -Cv -m664 -g "$(id -nrg)" test/i1 test/i2 # set i2 to uesr's gid
43 # install -Cv -m664 test/i1 test/i2 # this should install but doesn't
45 # Therefore we skip the test in the presence of setgid dirs
46 # An additional complication on HFS is that it...
53 echo test > a || framework_failure_
54 echo "'a' -> 'b'" > out_installed_first || framework_failure_
56 'a' -> 'b'" > out_installed_second || framework_failure_
57 > out_empty || framework_failure_
59 # destination file does not exist
60 ginstall
-Cv -m$mode1 a b
> out || fail
=1
61 compare out out_installed_first || fail
=1
63 # destination file exists
64 ginstall
-Cv -m$mode1 a b
> out || fail
=1
65 compare out out_empty || fail
=1
67 # destination file exists (long option)
68 ginstall
-v --compare -m$mode1 a b
> out || fail
=1
69 compare out out_empty || fail
=1
71 # destination file exists but -C is not given
72 ginstall
-v -m$mode1 a b
> out || fail
=1
73 compare out out_installed_second || fail
=1
75 # option -C ignored if any non-permission mode should be set
76 ginstall
-Cv -m$mode3 a b
> out || fail
=1
77 compare out out_installed_second || fail
=1
78 ginstall
-Cv -m$mode3 a b
> out || fail
=1
79 compare out out_installed_second || fail
=1
81 # files are not regular files
82 ln -s a c || framework_failure_
83 ln -s b d || framework_failure_
84 ginstall
-Cv -m$mode1 c d
> out || fail
=1
86 'c' -> 'd'" > out_installed_second_cd
87 compare out out_installed_second_cd || fail
=1
89 # destination file exists but content differs
90 echo test1
> a || framework_failure_
91 ginstall
-Cv -m$mode1 a b
> out || fail
=1
92 compare out out_installed_second || fail
=1
93 ginstall
-Cv -m$mode1 a b
> out || fail
=1
94 compare out out_empty || fail
=1
96 # destination file exists but content differs (same size)
97 echo test2
> a || framework_failure_
98 ginstall
-Cv -m$mode1 a b
> out || fail
=1
99 compare out out_installed_second || fail
=1
100 ginstall
-Cv -m$mode1 a b
> out || fail
=1
101 compare out out_empty || fail
=1
103 # destination file exists but mode differs
104 ginstall
-Cv -m$mode2 a b
> out || fail
=1
105 compare out out_installed_second || fail
=1
106 ginstall
-Cv -m$mode2 a b
> out || fail
=1
107 compare out out_empty || fail
=1
109 # options -C and --preserve-timestamps are mutually exclusive
110 returns_
1 ginstall
-C --preserve-timestamps a b || fail
=1
112 # options -C and --strip are mutually exclusive
113 returns_
1 ginstall
-C --strip --strip-program=echo a b || fail
=1