File: test-9f5eeb72.sh

package info (click to toggle)
proot 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,012 kB
  • sloc: ansic: 18,627; sh: 1,662; python: 108; asm: 41; makefile: 16; awk: 6
file content (157 lines) | stat: -rw-r--r-- 3,884 bytes parent folder | download | duplicates (4)
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
157
if [ -z `which mkdir` ] || [ -z `which chmod` ] || [ -z `which touch` ] || [ -z `which ln` ] || [ -z `which cpio` ] || [ -z `which stat` ] || [ -z `which cat` ] || [ -z `which readlink` ] || [ -z `which mcookie` ] || [ -z `which mknod` ]; then
    exit 125;
fi

if [ ! -e $CARE ]; then
    exit 125;
fi
unset PROOT

TMP=/tmp/$(mcookie)
mkdir ${TMP}
cd ${TMP}

export LANG=en_US.UTF-8
mkdir a
echo "I'm a bee" > a/b
echo "I'm a sea" > a/c
chmod -w a
touch ł
ln ł d
ln -s dangling_symlink e
mknod f p
mkdir -p   x/y
chmod -rwx x

for BUNCH in \
    "FORMAT=/              EXTRACT=''" \
    "FORMAT=.raw           EXTRACT='${CARE} -x'" \
    "FORMAT=.cpio          EXTRACT='${CARE} -x'" \
    "FORMAT=.cpio.gz       EXTRACT='${CARE} -x'" \
    "FORMAT=.cpio.lzo      EXTRACT='${CARE} -x'" \
    "FORMAT=.tar           EXTRACT='${CARE} -x'" \
    "FORMAT=.tgz           EXTRACT='${CARE} -x'" \
    "FORMAT=.tar.gz        EXTRACT='${CARE} -x'" \
    "FORMAT=.tzo           EXTRACT='${CARE} -x'" \
    "FORMAT=.tar.lzo       EXTRACT='${CARE} -x'" \
    "FORMAT=.bin           EXTRACT='${CARE} -x'" \
    "FORMAT=.bin           EXTRACT='sh -c'" \
    "FORMAT=.gz.bin        EXTRACT='sh -c'" \
    "FORMAT=.lzo.bin       EXTRACT='sh -c'" \
    "FORMAT=.cpio.bin      EXTRACT='sh -c'" \
    "FORMAT=.cpio.gz.bin   EXTRACT='sh -c'" \
    "FORMAT=.cpio.lzo.bin  EXTRACT='sh -c'" \
    "FORMAT=.tar.bin       EXTRACT='sh -c'" \
    "FORMAT=.tgz.bin       EXTRACT='sh -c'" \
    "FORMAT=.tzo.bin       EXTRACT='sh -c'" \
    "FORMAT=.tar.gz.bin    EXTRACT='sh -c'" \
    "FORMAT=.tar.lzo.bin   EXTRACT='sh -c'"
do
    eval $BUNCH
    CWD=${PWD}

    if echo ${FORMAT} | grep '.bin' && ${CARE} -V | grep '(.bin): no'; then
	continue
    fi

    # Check: permissions, unordered archive, UTF-8, hard-links
    ${CARE} -o test${FORMAT} cat a/b ł d a/c

    if [ -n "${EXTRACT}" ]; then
	! chmod +rwx -R test-${FORMAT}-1
	rm -fr test-${FORMAT}-1
	mkdir test-${FORMAT}-1
	cd test-${FORMAT}-1
	${EXTRACT} ../test${FORMAT}
    fi

    test -d test/rootfs/${CWD}/a
    test -f test/rootfs/${CWD}/a/b
    test -f test/rootfs/${CWD}/a/c
    test -f test/rootfs/${CWD}/ł
    test -f test/rootfs/${CWD}/d

    INODE1=$(stat -c %i test/rootfs/${CWD}/d)
    INODE2=$(stat -c %i test/rootfs/${CWD}/ł)
    [ $INODE1 -eq $INODE2 ]

    PERM1=$(stat -c %a ${CWD}/a)
    PERM2=$(stat -c %a test/rootfs/${CWD}/a)
    [ $PERM1 -eq $PERM2 ]

    if [ -n "${EXTRACT}" ]; then
	cd ..
    else
	! chmod +rwx -R test
	rm -fr test
    fi

    # Check: last archived version wins, symlinks
    ${CARE} -o test${FORMAT} sh -c 'ls a; ls a/b; ls -l e'

    if [ -n "${EXTRACT}" ]; then
	! chmod +rwx -R test-${FORMAT}-2
	rm -fr test-${FORMAT}-2
	mkdir test-${FORMAT}-2
	cd test-${FORMAT}-2
	${EXTRACT} ../test${FORMAT}
    fi

    B=$(cat test/rootfs/${CWD}/a/b)
    [ x"$B" != x ]
    [ "$B" = "I'm a bee" ]

    test -L test/rootfs/${CWD}/e

    F=$(readlink test/rootfs/${CWD}/e)
    [ x"$F" != x ]
    [ "$F" = "dangling_symlink" ]

    if [ -n "${EXTRACT}" ]; then
	cd ..
    else
	! chmod +rwx -R test
	rm -fr test
    fi

    # Check: non-regular files are archived/extractable
    ${CARE} -d -p /dev -p /proc -o test${FORMAT} sh -c 'ls -l f'

    if [ -n "${EXTRACT}" ]; then
	! chmod +rwx -R test-${FORMAT}-1
	rm -fr test-${FORMAT}-1
	mkdir test-${FORMAT}-1
	cd test-${FORMAT}-1
	${EXTRACT} ../test${FORMAT}
    fi

    [ "fifo" = "$(stat -c %F test/rootfs/${CWD}/f)" ]

    if [ -n "${EXTRACT}" ]; then
	cd ..
    else
	! chmod +rwx -R test
	rm -fr test
    fi

    # Check: extractable archive
    ${CARE} -o test${FORMAT} chmod -R +rwx x

    if [ -n "${EXTRACT}" ]; then
	! chmod +rwx -R test-${FORMAT}-3
	rm -fr test-${FORMAT}-3
	mkdir test-${FORMAT}-3
	cd test-${FORMAT}-3
	${EXTRACT} ../test${FORMAT}

	cd ..
    else
	! chmod +rwx -R test
	rm -fr test
    fi
done

cd ..
chmod +rwx -R ${TMP}
rm -fr ${TMP}