blob: 1a5e90e25f92d0d10104b6e8dd9725dcf262fc29 (
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
|
#!/bin/sh
# usage: $0 DIRNAME PHASE
# PHASE is 1 (checksum) or 2 (package)
dir=$1
phase=$2
if [ $phase = 1 ]; then
cd $dir || exit 1
echo "maintained by: $(make maintainer)"
echo "build started at $(date)"
cd /tmp/depends
export PKG_PATH=/tmp/depends
if [ "$(echo $(/bin/ls | wc -c))" != 0 ]; then
echo "adding dependencies"
for i in *.t[bg]z; do
echo "pkg_add $i"
base=$(basename $i .tgz)
base=$(basename $base .tbz)
if pkg_info -q -e $base; then
echo "skipping $base, already added"
else
if ! pkg_add $i; then
echo "error in dependency $i, exiting"
echo "1" > /tmp/status
exit 1
fi
fi
done
fi
cd $dir || exit 1
pkgname=$(make package-name)
echo "================================================================"
echo "====================<phase 1: make checksum>===================="
if /pnohang $TIMEOUT /tmp/make.log1 ${pkgname} make checksum; then
cat /tmp/make.log1
echo "0" > /tmp/status
else
cat /tmp/make.log1
echo "1" > /tmp/status
echo "================================================================"
echo -n "build ended at "
date
fi
else
echo "====================<phase 2: make package>====================="
xvfb=0
if which -s Xvfb; then
xvfb=1
pid=$(echo $$ % 32768 | bc)
X11BASE=$(which Xvfb | sed -e 's./bin/Xvfb..')
Xvfb :${pid} -fp ${X11BASE}/lib/X11/fonts/misc &
DISPLAY=:${pid}
export DISPLAY
fi
cd $dir || exit 1
pkgname=$(make package-name)
if /pnohang $TIMEOUT /tmp/make.log2 ${pkgname} make package; then
cat /tmp/make.log2
echo "0" > /tmp/status
prefix=$(make -V PREFIX)
mtreefile=$(make -V MTREE_FILE)
echo "================================================================"
echo "checking installed files"
find ${prefix} \( \( -perm -4000 -o -perm -2000 -a \! -type d \) -o \( -perm -0002 -o -perm -0020 \) \) -a \! -type l -ls | sort > /tmp/list1
echo "pkg_delete ${pkgname}"
pkg_delete ${pkgname}
find ${prefix} \( \( -perm -4000 -o -perm -2000 -a \! -type d \) -o \( -perm -0002 -o -perm -0020 \) \) -a \! -type l -ls | sort > /tmp/list2
if ! diff -qb /tmp/list1 /tmp/list2 2>/dev/null; then
echo "================================================================"
echo "found set[ug]id or world-writable files and directories"
diff -b /tmp/list2 /tmp/list1 | grep '^>'
fi
cd /var/db/pkg
if [ $(echo $(echo * | wc -c)) != 2 ]; then
echo "================================================================"
echo "deleting dependencies"
prevlist=""
count=1
while [ $(echo $(echo * | wc -c)) != 2 -a $(echo $(echo * | wc -c)) != $(echo $(echo $prevlist | wc -c)) ]; do
echo "== phase $count =="
prevlist="$(echo *)"
for i in *; do
echo "pkg_delete $i"
pkg_delete $i
done
count=$(($count + 1))
done
if [ $(echo $(echo * | wc -c)) != 2 ]; then
echo "leftover packages:" *
# for i in *; do
# echo "pkg_delete -f $i"
# pkg_delete -f $i
# done
fi
fi
cd /var/db/pkg
if [ "x${mtreefile}" != "x" ]; then
mtree -f ${mtreefile} -p ${prefix} > /tmp/list3
if [ -s /tmp/list3 ]; then
if [ "x${PLISTCHECK}" != "x" ]; then
echo "1" > /tmp/status
fi
echo "================================================================"
echo "list of extra files and directories in ${prefix}"
cat /tmp/list3
echo "list of all files and directories in ${prefix}"
cd ${prefix}
find . -exec echo -n 'path: ' \; -exec ls -1d \{} \; | sort
echo "ls -alR ${prefix}"
ls -alR ${prefix}
fi
fi
else
cat /tmp/make.log2
echo "1" > /tmp/status
fi
if [ ${xvfb} = 1 ]; then
kill $(jobid %1)
fi
echo "================================================================"
echo -n "build ended at "
date
fi
exit 0
|