Merge from vendor branch TNF:
[pkgsrcv2.git] / regress / bootstrap-install-sh / Makefile
1 # $NetBSD$
2
3 DISTNAME=       bootstrap-install-sh-0.0
4 CATEGORIES=     regress
5 WRKSRC=         ${WRKDIR}
6 MASTER_SITES=   # empty
7 DISTFILES=      # empty
8
9 MAINTAINER=     jlam@NetBSD.org
10 COMMENT=        Test functionality of bootstrap install-sh
11
12 EXTRACT_ONLY=   # empty
13 NO_CONFIGURE=   yes
14 NO_INSTALL=     yes
15 NO_PACKAGE=     yes
16
17 INSTALL_SH=     ${WRKSRC}/install-sh
18
19 regress: extract
20 post-extract:
21         ${CP} ${FILESDIR}/install-sh ${INSTALL_SH}
22         ${CHMOD} +x ${INSTALL_SH}
23
24 # create one directory using -d
25 regress: test-d1
26 test-d1:
27         ${INSTALL_SH} -d ${WRKSRC}/d1_dir
28         ${TEST} -d ${WRKSRC}/d1_dir || exit 1
29
30 # create two directories using -d
31 regress: test-d2
32 test-d2:
33         ${INSTALL_SH} -d ${WRKSRC}/d2_dir1 ${WRKSRC}/d2_dir2
34         ( ${TEST} -d ${WRKSRC}/d2_dir1 && \
35           ${TEST} -d ${WRKSRC}/d2_dir2 ) || exit 1
36
37 # create three directories using -d
38 regress: test-d3
39 test-d3:
40         ${INSTALL_SH} -d ${WRKSRC}/d3_dir1 ${WRKSRC}/d3_dir2 ${WRKSRC}/d3_dir3
41         ( ${TEST} -d ${WRKSRC}/d3_dir1 && \
42           ${TEST} -d ${WRKSRC}/d3_dir2 && \
43           ${TEST} -d ${WRKSRC}/d3_dir3 ) || exit 1
44
45 # copy one existing file to nonexistent file
46 regress: test-c1
47 test-c1:
48         ${ECHO} "Test data" > ${WRKSRC}/c1_file1
49         ${INSTALL_SH} -c ${WRKSRC}/c1_file1 ${WRKSRC}/c1_file2
50         ${CMP} ${WRKSRC}/c1_file1 ${WRKSRC}/c1_file2 || exit 1
51
52 # copy one existing file into existing directory
53 regress: test-c2
54 test-c2:
55         ${ECHO} "Test data" > ${WRKSRC}/c2_file
56         ${MKDIR} ${WRKSRC}/c2_dir
57         ${INSTALL_SH} -c ${WRKSRC}/c2_file ${WRKSRC}/c2_dir
58         ${CMP} -s ${WRKSRC}/c2_file ${WRKSRC}/c2_dir/c2_file || exit 1
59
60 # copy two existing files into existing directory
61 regress: test-c3
62 test-c3:
63         ${ECHO} "Test data 1" > ${WRKSRC}/c3_file1
64         ${ECHO} "Test data 2" > ${WRKSRC}/c3_file2
65         ${MKDIR} ${WRKSRC}/c3_dir
66         ${INSTALL_SH} -c ${WRKSRC}/c3_file1 ${WRKSRC}/c3_file2 ${WRKSRC}/c3_dir
67         ( ${CMP} -s ${WRKSRC}/c3_file1 ${WRKSRC}/c3_dir/c3_file1 && \
68           ${CMP} -s ${WRKSRC}/c3_file2 ${WRKSRC}/c3_dir/c3_file2 ) || exit 1
69
70 # copy three existing files into existing directory
71 regress: test-c4
72 test-c4:
73         ${ECHO} "Test data 1" > ${WRKSRC}/c4_file1
74         ${ECHO} "Test data 2" > ${WRKSRC}/c4_file2
75         ${ECHO} "Test data 3" > ${WRKSRC}/c4_file3
76         ${MKDIR} ${WRKSRC}/c4_dir
77         ${INSTALL_SH} -c ${WRKSRC}/c4_file1 ${WRKSRC}/c4_file2 \
78                 ${WRKSRC}/c4_file3 ${WRKSRC}/c4_dir
79         ( ${CMP} -s ${WRKSRC}/c4_file1 ${WRKSRC}/c4_dir/c4_file1 && \
80           ${CMP} -s ${WRKSRC}/c4_file2 ${WRKSRC}/c4_dir/c4_file2 && \
81           ${CMP} -s ${WRKSRC}/c4_file3 ${WRKSRC}/c4_dir/c4_file3 ) || exit 1
82
83 MODES=  0 1 2 3 4 5 6 7
84 MODE_0= ---
85 MODE_1= --x
86 MODE_2= -w-
87 MODE_3= -wx
88 MODE_4= r--
89 MODE_5= r-x
90 MODE_6= rw-
91 MODE_7= rwx
92
93 # test mode permissions on installing file to nonexisting file
94 regress: test-m1
95 test-m1:
96 .for _u_ in ${MODES}
97 .  for _g_ in ${MODES}
98 .    for _o_ in ${MODES}
99         ${ECHO} "Test data" > ${WRKSRC}/m${_u_}${_g_}${_o_}_file1
100         ${INSTALL_SH} -m ${_u_}${_g_}${_o_} ${WRKSRC}/m${_u_}${_g_}${_o_}_file1 ${WRKSRC}/m${_u_}${_g_}${_o_}_file2
101         ${LS} -l ${WRKSRC}/m${_u_}${_g_}${_o_}_file2 |                  \
102         while read a b; do                                              \
103                 case "$$a" in                                           \
104                 -${MODE_${_u_}}${MODE_${_g_}}${MODE_${_o_}})            \
105                         exit 0 ;;                                       \
106                 *)      exit 1 ;;                                       \
107                 esac;                                                   \
108         done
109 .    endfor
110 .  endfor
111 .endfor
112
113 # test mode permissions on creating directory
114 regress: test-m2
115 test-m2:
116 .for _u_ in ${MODES}
117 .  for _g_ in ${MODES}
118 .    for _o_ in ${MODES}
119         ${INSTALL_SH} -m 357 -d ${WRKSRC}/m357_dir
120         ${INSTALL_SH} -m ${_u_}${_g_}${_o_} -d ${WRKSRC}/m${_u_}${_g_}${_o_}_dir
121         ${LS} -l ${WRKSRC}/m${_u_}${_g_}${_o_}_file2 |                  \
122         while read a b; do                                              \
123                 case "$$a" in                                           \
124                 -${MODE_${_u_}}${MODE_${_g_}}${MODE_${_o_}})            \
125                         exit 0 ;;                                       \
126                 *)      exit 1 ;;                                       \
127                 esac;                                                   \
128         done
129 .    endfor
130 .  endfor
131 .endfor
132
133 pre-clean:
134         ${TEST} "`${ECHO} ${WRKSRC}/*`" = "${WRKSRC}/*" ||              \
135                 ${CHMOD} -R u+rwx ${WRKSRC}/*
136
137 .include "../../mk/bsd.pkg.mk"