summaryrefslogtreecommitdiffstats
path: root/install/base
blob: 7eff431084cb7c9ab7406a85b8283c14c42792a9 (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
#!/bin/bash

build() {
    local dir applet

    for dir in new_root proc sys dev run tmp usr/bin; do
        add_dir "/$dir"
    done

    add_symlink /lib usr/lib
    add_symlink /sbin usr/bin
    add_symlink /bin usr/bin
    add_symlink /usr/sbin bin

    add_binary /usr/lib/initcpio/busybox /bin/busybox

    for applet in $(/usr/lib/initcpio/busybox --list); do
        add_symlink "/usr/bin/$applet" busybox
    done

    # add kmod with applet symlinks
    add_binary kmod
    for applet in {dep,ins,rm,ls}mod mod{probe,info}; do
        add_symlink "/usr/bin/$applet" kmod
    done

    add_binary blkid
    add_binary mount
    add_binary switch_root
    add_binary findmnt

    add_symlink "/etc/mtab" "/proc/self/mounts"

    # Add an empty fstab for mount and fsck
    >"$BUILDROOT/etc/fstab"

    add_file "/usr/lib/initcpio/init_functions" "/init_functions"
    add_file "/usr/lib/initcpio/init" "/init"
    add_file "/usr/lib/modprobe.d/usb-load-ehci-first.conf"

    # write a new config file. re-source the config as we can't guarantee the
    # environment hasn't been modified, but subshell it so it doesn't disturb
    # anyone else.
    (
        . "$CONFIG"

        # sanitize of any extra whitespace
        read -r -a modules <<< "$MODULES"

        {
            (( ${#modules[*]} )) && printf 'MODULES="%s"\n' "${modules[*]%\?}"
            (( ${#hooks[*]} )) && printf 'HOOKS="%s"\n' "${hooks[*]}"
        } >"$BUILDROOT/config"
    )
}

help() {
    cat <<HELPEOF
This hook sets up all initial directories and installs base utilities. DO NOT
remove this one unless you know what you're doing.
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et: