aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/vdb_unmerger_TEST_setup.sh
blob: c9fba882d5236bfbe527c684b98221da9d6b7533 (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
#!/usr/bin/env bash
# vim: set ft=sh sw=4 sts=4 et :

mkdir vdb_unmerger_TEST_dir || exit 2
cd vdb_unmerger_TEST_dir || exit 3

mkdir CONTENTS

mkdir root
cd root

make_file() {
    echo "foo" > "file_$1"

    md5=${2:-$(md5sum "file_$1" | cut -f1 -d' ')}
    mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "file_$1")}
    echo "obj /file_$1 ${md5} ${mtime}" > "../CONTENTS/file_$1"
}

make_sym() {
    src="sym_$1"
    dst=${2:-"sym_$1_dst"}

    > "sym_$1_dst"
    ln -s "${dst}" "${src}"

    mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "sym_$1")}
    echo "sym /${src} -> sym_$1_dst ${mtime}" > "../CONTENTS/sym_$1"
}

make_file "ok"

make_file " with spaces"

make_file " with lots  of   spaces"

make_file " with trailing  space	 "

make_file "bad_type"
rm file_bad_type
mkdir file_bad_type

make_file "bad_md5sum" "bad_md5sum"
make_file "bad_mtime" "" "123"
echo "obj /file_bad_entry foo" > ../CONTENTS/file_bad_entry

mkdir dir_ok
echo "dir /dir_ok" > ../CONTENTS/dir_ok

mkdir "dir_ with spaces"
echo "dir /dir_ with spaces" > "../CONTENTS/dir_ with spaces"

mkdir "dir_ with lots  of   spaces"
echo "dir /dir_ with lots  of   spaces" > "../CONTENTS/dir_ with lots  of   spaces"

> dir_bad_type
echo "dir /dir_bad_type" > ../CONTENTS/dir_bad_type

mkdir -p dir_not_empty/foo
echo "dir /dir_not_empty" > ../CONTENTS/dir_not_empty

make_sym "ok"
make_sym " with spaces"
make_sym " with lots  of   spaces"

> "sym -> with -> many -> arrows -> dst"
ln -s "sym -> with -> many -> arrows -> dst" "sym with many arrows"
mtime=${3:-$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "sym with many arrows")}
echo "sym /sym with many arrows -> sym -> with -> many -> arrows -> dst ${mtime}" > "../CONTENTS/sym with many arrows"

make_sym "bad_type"
rm sym_bad_type
> sym_bad_type

make_sym "bad_dst" "sym_dst_bad"
make_sym "bad_mtime" "" "123"

ln -s foo sym_bad_entry_1
echo "sym /sym_bad_entry_1 -> foo" > "../CONTENTS/sym_bad_entry_1"
ln -s foo sym_bad_entry_2
echo "sym /sym_bad_entry_2 >> foo 123" > "../CONTENTS/sym_bad_entry_2"

mkfifo fifo_ok
echo "fif /fifo_ok" > "../CONTENTS/fifo_ok"

mkfifo "fifo_ with spaces"
echo "fif /fifo_ with spaces" > "../CONTENTS/fifo_ with spaces"

> fifo_bad_type
echo "fif /fifo_bad_type" > "../CONTENTS/fifo_bad_type"

touch protected_file
touch unprotected_file
touch protected_file_not_really

mkdir protected_dir
touch protected_dir/protected_file
touch protected_dir/unprotected_file
touch protected_dir/unprotected_file_not_really

mkdir protected_dir/unprotected_dir
touch protected_dir/unprotected_dir/unprotected_file

mkdir protected_dir/unprotected_dir_not_really
touch protected_dir/unprotected_dir_not_really/protected_file

mkdir protected_dir_not_really
touch protected_dir_not_really/unprotected_file

find . -name '*protected*' -type f -print | while read file; do
    echo obj "${file#.}" "$(md5sum "${file}" | cut -f1 -d' ')" "$(${PALUDIS_EBUILD_DIR}/utils/wrapped_getmtime "${file}")"
done >../CONTENTS/config_protect