summaryrefslogtreecommitdiffstats
path: root/tests/t-switch-dir-to-symlink-rel/Makefile
blob: 833ac38329711950fc4c626e74f4a4f62a68054c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
TESTS_DEB := \
	pkg-dir-conffile-0 pkg-dir-conffile-1 \
	pkg-dir-file-other pkg-dir-symlink-int-0 pkg-dir-symlink-int-1 \
	pkg-dir-file-moved pkg-dir-symlink-ext-0 pkg-dir-symlink-ext-1

include ../Test.mk

build-hook:
	mkdir -p pkg-dir-conffile-1/test-path
	ln -sfT ../test-dir pkg-dir-conffile-1/test-path/test-subpath
	mkdir -p pkg-dir-symlink-ext-1/test-path
	ln -sfT ../test-dir pkg-dir-symlink-ext-1/test-path/test-subpath
	mkdir -p pkg-dir-symlink-int-1/test-path
	ln -sfT ../test-dir pkg-dir-symlink-int-1/test-path/test-subpath

clean-hook:
	$(RM) pkg-dir-conffile-1/test-path/test-subpath
	-rmdir pkg-dir-conffile-1/test-path
	$(RM) pkg-dir-symlink-ext-1/test-path/test-subpath
	-rmdir pkg-dir-symlink-ext-1/test-path
	$(RM) pkg-dir-symlink-int-1/test-path/test-subpath
	-rmdir pkg-dir-symlink-int-1/test-path

test-case:
	# Cannot switch a directory containing conffiles
	$(DPKG_INSTALL) pkg-dir-conffile-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! $(DPKG_INSTALL) pkg-dir-conffile-1.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_PURGE) pkg-dir-conffile

	# Cannot switch a directory containing files owned by another package
	$(DPKG_INSTALL) pkg-dir-file-other.deb
	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_PURGE) pkg-dir-symlink-int
	$(DPKG_PURGE) pkg-dir-file-other

	# Cannot switch a directory containing local files
	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	touch '$(DPKG_INSTDIR)/test-path/test-subpath/local file'
	! $(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	rm '$(DPKG_INSTDIR)/test-path/test-subpath/local file'
	$(DPKG_PURGE) pkg-dir-symlink-int

	#
	# Otherwise allow the switch
	#

	# Switch a directory to a symlink, contents moved within the package,
	# with intermediate full installs.
	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_INSTALL) pkg-dir-symlink-int-1.deb
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_PURGE) pkg-dir-symlink-int
	! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'

	# Switch a directory to a symlink, contents moved within the package,
	# with full install, upgrade with upack and configure.
	$(DPKG_INSTALL) pkg-dir-symlink-int-0.deb
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_CONFIGURE) pkg-dir-symlink-int
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_PURGE) pkg-dir-symlink-int
	! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'

	# Switch a directory to a symlink, contents moved within the package,
	# with two unpacks and configure.
	$(DPKG_UNPACK) pkg-dir-symlink-int-0.deb
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_UNPACK) pkg-dir-symlink-int-1.deb
	! test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_CONFIGURE) pkg-dir-symlink-int
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_PURGE) pkg-dir-symlink-int
	! test -e '$(DPKG_INSTDIR)/test-path/test-subpath'

	# Switch a directory to a symlink, contents moved to another package,
	# with intermediate full installs.
	$(DPKG_INSTALL) pkg-dir-symlink-ext-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_INSTALL) pkg-dir-file-moved.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-dir'
	$(DPKG_INSTALL) pkg-dir-symlink-ext-1.deb
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../test-dir"
	! test -h '$(DPKG_INSTDIR)/test-dir'
	test -d '$(DPKG_INSTDIR)/test-dir'
	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
	$(DPKG_PURGE) pkg-dir-symlink-ext
	$(DPKG_PURGE) pkg-dir-file-moved

	# Switch a directory to a symlink, contents moved to another package,
	# with full installs, upgrade with upack and configure.
	$(DPKG_INSTALL) pkg-dir-symlink-ext-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_INSTALL) pkg-dir-file-moved.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-dir'
	$(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-dir'
	$(DPKG_CONFIGURE) -a
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../test-dir"
	! test -h '$(DPKG_INSTDIR)/test-dir'
	test -d '$(DPKG_INSTDIR)/test-dir'
	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
	$(DPKG_PURGE) pkg-dir-symlink-ext
	$(DPKG_PURGE) pkg-dir-file-moved

	# Switch a directory to a symlink, contents moved to another package,
	# with three unpacks and configure.
	$(DPKG_UNPACK) pkg-dir-symlink-ext-0.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	$(DPKG_UNPACK) pkg-dir-file-moved.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-dir'
	$(DPKG_UNPACK) pkg-dir-symlink-ext-1.deb
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-dir'
	$(DPKG_CONFIGURE) -a
	test -h '$(DPKG_INSTDIR)/test-path/test-subpath'
	test -d '$(DPKG_INSTDIR)/test-path/test-subpath'
	test "`readlink '$(DPKG_INSTDIR)/test-path/test-subpath'`" = "../test-dir"
	! test -h '$(DPKG_INSTDIR)/test-dir'
	test -d '$(DPKG_INSTDIR)/test-dir'
	test -f '$(DPKG_INSTDIR)/test-dir/file-normal'
	$(DPKG_PURGE) pkg-dir-symlink-ext
	$(DPKG_PURGE) pkg-dir-file-moved

test-clean:
	$(DPKG_PURGE) pkg-dir-conffile
	$(DPKG_PURGE) pkg-dir-symlink-int
	$(DPKG_PURGE) pkg-dir-symlink-ext
	$(DPKG_PURGE) pkg-dir-file-other
	$(DPKG_PURGE) pkg-dir-file-moved