forked from cirros-dev/cirros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fixup-fs
executable file
·42 lines (35 loc) · 1.07 KB
/
fixup-fs
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
#!/bin/sh
error() { echo "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
rootd=${1}
[ -n "${rootd}" -a -d "${rootd}" ] || exit 1
rm -Rf "$rootd/home/default"
# no need for visudo
rm -f "$rootd/usr/sbin/visudo"
# buildroot symlinks stuff in /var to /tmp
links="lib/pcmcia pcmcia lock cache log spool pcmcia"
for f in $links; do
p="/var/$f"
if [ -L "$rootd/$p" ]; then
rm "$rootd/$p" ||
fail "failed to remove file $p"
elif [ -d "$rootd/$p" ]; then
rmdir "$rootd/$p" ||
fail "rmdir $p failed"
else
[ -e "$rootd/$p" ] &&
fail "don't know what to do with $p. not dir or link"
fi
done
mkdir -p $rootd/var
( cd "$rootd/var" && mkdir -p $links ) ||
fail "failed to create directories in /var"
( cd "$rootd/var" && rm -Rf tmp run &&
ln -s ../run run && ln -s ../run/var.tmp tmp ) ||
fail "failed to make var/run and var/tmp"
rm -f $rootd/etc/resolv.conf &&
ln -sf ../run/resolv.conf "$rootd/etc/resolv.conf" ||
fail "failed to create resolv.conf symlink"
if [ -L "$rootd/sbin/blkid" -a -x "$rootd/usr/sbin/blkid" ]; then
rm -f "$rootd/sbin/blkid"
fi