summaryrefslogtreecommitdiff
path: root/repo/system/openrc.xibuild
blob: ac23b5e5c6736ee402b64b34a3f0d748f620b091 (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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh

MAKEDEPS="make "
DEPS="ifupdown-ng sbase musl"

PKG_VER=0.44.10
SOURCE=https://github.com/OpenRC/openrc/archive/refs/tags/$PKG_VER.zip
ADDITIONAL="
	0001-call-sbin-mkmntdirs-in-localmount-OpenRC-service.patch
	0002-fsck-don-t-add-C0-to-busybox-fsck.patch
	0003-rc-pull-in-sysinit-and-boot-as-stacked-levels-when-n.patch
	0004-make-consolefont-service-compatible-with-busyboxs-se.patch
	0005-Support-early-loading-of-keymap-if-kbd-is-installed.patch
	0006-Add-support-for-starting-services-in-a-specified-VRF.patch
	0007-Clean-up-staticroute-config-remove-irrelevant-parts-.patch
	0008-bootmisc-switch-wipe_tmp-setting-to-no-by-default.patch
	0009-fix-bootmisc-mv-error.patch
	0010-noexec-devfs.patch
	seedrng.patch
	openrc.logrotate
	hostname.initd
	hwdrivers.initd
	modules.initd
	modloop.initd
	networking.initd
	modloop.confd
	sysfsconf.initd
	firstboot.initd
	sysctl.initd
	machine-id.initd
	test-networking.sh
"

DESC="Dependency based init system that works with sysvinit"

# build borrowed from alpine linux
prepare () {
    apply_patches
    sed -i -e '/^sed/d' pkgconfig/Makefile
    find ./ -name "Makefile" | xargs sed -i 's/ln -snf/ln -sf/g'
}

build () {
    export MKZSHCOMP=yes
	export MKBASHCOMP=yes
	make LIBDIR=/lib LIBEXECDIR=/lib/rc MKSYSVINIT=yes
}

check () {
	make check
}

package () {
	make LIBEXECDIR=/lib/rc DESTDIR="$PKG_DEST/" MKSYSVINIT=yes install

    # remove -n from ln in mtab
    sed -i "s/ln -snf/ln -sf/g" $PKG_DEST/etc/init.d/mtab

    ln -s openrc-init $PKG_DEST/sbin/init

	# we still use our ifup/ifdown based net config
	#rm -f "$PKG_DEST"/etc/conf.d/network "$PKG_DEST"/etc/init.d/network

    # our hostname init script reads hostname from /etc/hostname
	rm -f "$pkgdir"/etc/conf.d/hostname


	# we override some of the scripts
	for i in *.initd; do
		j=${i##*/}
		install -Dm755 $i "$PKG_DEST"/etc/init.d/${j%.initd}
	done

	# we override some of the conf.d files
	for i in *.confd; do
		j=${i##*/}
		install -Dm644 $i "$PKG_DEST"/etc/conf.d/${j%.confd}
	done

	# additional documentation considered useful
	mkdir -p "$PKG_DEST"/usr/share/doc/openrc/
	install -m644 ChangeLog ./*.md "$PKG_DEST"/usr/share/doc/openrc/

	# we use a virtual keymaps services to allow users to set their
	# keymaps either with the OpenRC loadkeys service provided by
	# the kbd aport or with the loadkmap service provided by the
	# busybox-initscripts aport.
	rm -f "$PKG_DEST/etc/init.d/keymaps" \
		"$PKG_DEST/etc/conf.d/keymaps"

	install -Dm644 openrc.logrotate $PKG_DEST/etc/logrotate.d/openrc
	install -d "$PKG_DEST"/etc/local.d "$PKG_DEST"/run

	# openrc upstream removed service(8) for whatever reason, put it back
	ln -s /sbin/rc-service $PKG_DEST/sbin/service

	# remove deprecated /sbin/runscript to avoid conflict with minicom
	rm $PKG_DEST/sbin/runscript

    #spawn ttys
    for x in tty1 tty2 tty3 tty4 tty5 tty6; do
      ln -sf agetty $PKG_DEST/etc/init.d/agetty.$x
    done

}

postinstall () {
    mkdir -p /run/openrc
    for dir in /libexec /lib; do
        [ -d $dir/rc/init.d ] || continue

        for i in $dir/rc/init.d/* ; do
            [ -e "$i" ] || continue
            if [ -e /run/openrc/${i##*/} ]; then
                rm -r $i
            else
                mv $i /run/openrc/
            fi
        done

        rmdir $dir/rc/init.d $dir/rc /libexec 2>/dev/null
    done

    # create rc.local compat
    if [ -f /etc/rc.local ]; then
        cat >/etc/local.d/rc.local-compat.start<< EOF
#!/bin/sh

# this is only here for compatibility reasons
if [ -f /etc/rc.local ]; then
    . /etc/rc.local
fi
EOF
        chmod +x /etc/local.d/rc.local-compat.start
    fi
}