aboutsummaryrefslogtreecommitdiff
path: root/core/runit/build
blob: 852e37c66eba4c6b8a078ad86cf0fab64841b65e (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
#!/bin/sh -e

sed_i() {
    for file; do :; done
    sed "$@" > _
    cat _ > "$file"; rm -f _
}

read -r version _ < "${0%/*}/version"

for patch in ./*.patch ; do
    patch -p0 < "$patch"
done

cd "runit-$version"

(
    cd src
    
    sed_i 's@sbin/runit@usr/bin/runit@g' runit.h
    printf '%s -D_GNU_SOURCE -static\n' "${CC-cc}" "$CFLAGS" > conf-cc
    printf '%s %s -static -Wl,-z -Wl,noexecstack\n' "${CC-cc}" "$CFLAGS" > conf-ld
    sed_i 's:^char \*varservice ="/service/";$:char \*varservice ="/var/service/";:' sv.c
    
    make
    
    for bin in \
        chpst \
        runit \
        runit-init \
        runsv \
        runsvchdir \
        runsvdir \
        sv \
        svlogd \
        utmpset
    do install -Dm755 "$bin" "$1/usr/bin/$bin"; done

)

for man in man/man*; do
    install -Dm644 "$man" "$1/usr/share/man/man8/${man#man/}"
done

mkdir -p "$1/var/service" "$1/etc/runit"
ln -s runit-init "$1/usr/bin/init"
ln -s /usr/lib/init/rc.boot "$1/etc/runit/1"
ln -s /usr/lib/init/rc.shutdown "$1/etc/runit/3"

install -Dm755 ../2 "$1/etc/runit/2"
install -Dm755 ../poweroff "$1/usr/bin/poweroff"
install -Dm755 ../reboot "$1/usr/bin/reboot"