aboutsummaryrefslogtreecommitdiff
path: root/core/baselayout/build
blob: b94b05be9071ca749dd23ee385b5728fb2ee2bad (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
#!/bin/sh -e
# All directories are created sequentially, so we can ignore 'mkdir -pm' here.
# shellcheck disable=2174

# The fallback is for backwards compatibility, this will be dropped later.
sys_arch=${3:-$(uname -m)}

kinstall_t() {
    mod=$1 dir=$2; mkdir -p "$2"
    shift 2
    for file do cp "$file" "$dir"; chmod "$mod" "$file"; done
}

# Setup base directories.
for d in boot dev etc home mnt usr var opt run; do
    mkdir -pm 755 "$1/$d"
done

mkdir -pm 555  "$1/proc"
mkdir -pm 555  "$1/sys"
mkdir -pm 0750 "$1/root"
mkdir -pm 1777 "$1/tmp"

# Setup /usr hierarchy.
for d in bin include lib lib32 local share share/man src; do
    mkdir -pm 755 "$1/usr/$d"
done

# Setup manpages directories.
for d in 1 2 3 4 5 6 7 8; do
    mkdir -pm 755 "$1/usr/share/man/man$d"
done

# Add symlinks.
ln -s usr/bin "$1/bin"
ln -s usr/bin "$1/sbin"
ln -s bin     "$1/usr/sbin"
ln -s usr/lib "$1/lib"

# Unless we are on i*86, create lib64 symlinks. Obviously, i*86
# is not the only 32-bit architecture, but it is currently the
# only supported one.
[ "${sys_arch#i?86}" ] && {
    ln -s usr/lib "$1/lib64"
    ln -s lib     "$1/usr/lib64"
}

# Setup /var.
for d in cache local opt log log/old lib lib/misc empty service; do
    mkdir -pm 755 "$1/var/$d"
done

for d in tmp spool spool/mail; do
    mkdir -pm 1777 "$1/var/$d"
done

ln -s spool/mail  "$1/var/mail"
ln -s ../run      "$1/var/run"
ln -s ../run/lock "$1/var/lock"

# Setup /usr/local (usually for any programs installed outside package manager).
for d in bin etc games include lib man sbin share src; do
    mkdir -pm 755 "$1/usr/local/$d"
done

ln -s ../man "$1/usr/local/share/man"

# /etc skeleton files.
kinstall_t 644 "$1/etc" fstab group host.conf hosts issue keymap os-release \
                        passwd profile securetty shells mime.types
kinstall_t 600 "$1/etc" crypttab shadow

ln -s /proc/self/mounts "$1/etc/mtab"