-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake-fakedist
executable file
·116 lines (94 loc) · 2.65 KB
/
make-fakedist
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
#!/bin/sh
## $Id: make-fakedist,v 1.1 2002/12/05 17:04:15 yozo Exp $
## make-fakedist: do fake-distribution and remove not-changed files
## -- yozo. Sat Dec 1 21:38:45 JST 2001
##
## the last message added -- yozo. Sun Dec 30 08:21:41 JST 2001
PATH=/bin:/usr/bin:/sbin:/usr/sbin
## CMPRM=/home/yozo/bin/cmp-and-remove
SRCETC=/usr/src/etc
DESTDIR=/tmp/dist
RMFILES="sys etc/{mail/aliases.db,motd,myname,localtime,rmt,pwd.db,spwd.db}"
##
cmp-and-rm-dir(){
for i in $1/* ; do
## echo "comparing /$1/$i and $1/$i ..."
cmp /$i $i && rm $i && echo "$i removed."
done
}
cmp-and-rm-dirs(){
for j in $* ; do
if [ -d $j ]; then
echo "$0: processing $j"
cmp-and-rm-dir $j
## else
## echo "$0: ignore $j ; it's not a directory."
fi
done
}
##
echo -n "$0: "
date
echo -n "$0: "
uname -a
echo
if [ -d ${DESTDIR} -o -f ${DESTDIR} ]; then
echo "$0: ${DESTDIR} already exists."
echo "$0: clean before executing me!"
exit 1
else
echo "$0: creating ${DESTDIR} and"
echo "$0: \"make DESTDIR=... distribution-etc-root-var\" at /usr/src/etc/."
echo ""
fi
cd ${SRCETC}
cwd=`pwd`
echo "$0: the current directory is ${cwd}"
echo "$0: doing \"make DESTIDR=${DESTDIR} distribution-etc-root-var\"..."
make DESTDIR=${DESTDIR} distribution-etc-root-var
cd ${DESTDIR}
cwd=`pwd`
echo "$0: the current directory is ${cwd}"
echo "removing ${RMFILES}"
rm -f ${RMFILES}
echo "$0: removing empty files..."
find . -type f -empty -print -exec rm {} \;
echo "$0: removing empty directories..."
for i in 1 2 3 4 5 6 7 8 ; do
echo "$0: removing empty directories ($i)..."
find . -type d -empty -exec rmdir {} \;
done
for f in .cshrc .profile ; do
cmp /$f ./$f && rm ./$f && echo "$f removed."
done
if [ -d root ]; then
for f in `ls root` ; do
cmp /root/$f ./root/$f && rm ./root/$f && echo "root/$f removed."
done
fi
## removing root directory
find . -type d -empty -exec rmdir {} \;
for f in MAKEDEV MAKEDEV.local ; do
cmp /dev/$f ./dev/$f && rm ./dev/$f
done
## removing dev directory
find . -type d -empty -exec rmdir {} \;
cmp-and-rm-dirs usr/*/* usr/* usr var/*/*/*/*/* var/*/*/*/* var/*/*/* var/*/* var/* var etc/* etc
if [ -d etc/mail ]; then
for f in `ls etc/mail` ; do
cmp /etc/mail/$f ./etc/mail/$f && rm ./etc/mail/$f && echo "etc/mail/$f removed."
done
fi
if [ -d etc/skel ]; then
for f in `ls etc/skel` ; do
cmp /etc/skel/$f ./etc/skel/$f && rm ./etc/skel/$f && echo "etc/skel/$f removed."
done
fi
echo "$0: removing empty directories..."
for i in 1 2 3 4 5 6 7 8 ; do
echo "$0: removing empty directories ($i)..."
find . -type d -empty -exec rmdir {} \;
done
echo "$0: check remaining files in ${DESTDIR}."
date
exit 0