summaryrefslogtreecommitdiff
path: root/nonsystemd/openrc/PKGBUILD
blob: de26ef668b1cd35b4ecc73db1f2183ece772e607 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>
# Maintainer: David P. <megver83@parabola.nu>
# Contributor: Luke Shumaker <lukeshu@parabola.nu>

# Maintainer (Artix): artoo <artoo@artixlinux.org>
# Maintainer (Artix): Chris Cromer <cromer@artixlinux.org>
# Contributor (Artix): williamh <williamh@gentoo.org>

_url="https://github.com/OpenRC/openrc/archive"

pkgbase=openrc
pkgname=('openrc' 'openrc-bash-completions' 'openrc-zsh-completions'
         'openrc-init' 'openrc-sysvinit')
pkgver=0.42.1
pkgrel=1
pkgdesc="Gentoo's universal init system"
arch=('x86_64' 'i686' 'armv7h')
url="http://www.gentoo.org/proj/en/base/openrc/"
license=('BSD2')
makedepends=('psmisc' 'pam' 'netifrc' 'opentmpfiles' 'zsh')
source=("${pkgbase}-${pkgver}.tar.gz::${_url}/${pkgver}.tar.gz"
        "${pkgbase}.logrotate"
        'openrc-hook'
        '30-openrc-upgrade.hook'
        '30-sysctl.hook'
        'sysctl.conf'
        '30-binfmt.hook'
        'opentmpfiles-dev.initd'
        'opentmpfiles-setup.initd'
        'opentmpfiles-dev.confd'
        'opentmpfiles-setup.confd'
        'opensysusers.initd'
        'kmod-static-nodes.initd'
        'binfmt-sh.patch')
sha256sums=('91a01ca6d930a0688fb91338209985de57cac7aa2d37feddacb78fd3d95308e2'
            '0b44210db9770588bd491cd6c0ac9412d99124c6be4c9d3f7d31ec8746072f5c'
            '6eaabc9dc1bdfa05677473aa5f0643c2079849be51bf0dee36e0906702cffebe'
            '3ef8682540a038c239c4e07881cb084501d7996df2e0395b70a0a3953c7d00b2'
            'cb5bc649c2c9998300aff1e9862a9404b44e53178d153d68288603e99c5aaefe'
            '4170bcf3655ff6fb32b35fc592a4294a64d25df98d2f0f09f467689ed1ad54ea'
            '1f4cd15749ff89fd564e216ff0c1f9ff085e0200dba24d74e3de948f681bd80f'
            'c357e37ef59845954add9ccf89eff07beae0bd5274fdaa3ebf32da61c9d38436'
            '68779b6f4d8f4bcc206ff0e7ddab2c4cbff029727404cffa94079c1bf06094c8'
            '505b7fa013d90b1775439c06b6b0d420f877768cc59eaff5ffb1493a9e28b4ba'
            '505b7fa013d90b1775439c06b6b0d420f877768cc59eaff5ffb1493a9e28b4ba'
            '6476fd66ead2ad43129e3135656f4fde64addddabb6b7405665b3cf8db4aa6ad'
            '3ecbe7761b92a123a5a3d395ec3d9e090b0dfba7910a5987b4a2298c20a7e571'
            '3680546deb196de39a2ea4f7a3b30977773be011cc1f0285e64015f41c18e853')

_args=(
    SYSCONFDIR=/etc
    PREFIX=/usr
    SBINDIR=/usr/bin
    LIBEXECDIR=/usr/lib/openrc
    MKSELINUX=no
    MKPAM=pam
    MKTERMCAP=ncurses
    MKNET=no
    MKSYSVINIT=yes
    MKBASHCOMP=yes
    MKZSHCOMP=yes
    MKPKGCONFIG=yes
)

if [ -f /usr/lib/os-release ]; then
    . /usr/lib/os-release
    _args+=(BRANDING="${NAME}")
else
    _args+=(BRANDING='Unknown Linux')
fi

prepare(){
    cd "${srcdir}/${pkgbase}-${pkgver}"
    sed -i 's:0444:0644:' mk/sys.mk
    patch -Np 1 -i ../binfmt-sh.patch
}

check(){
    cd "${srcdir}/${pkgbase}-${pkgver}"
    make -k check
}

build(){
    cd "${pkgbase}-${pkgver}"
    make "${_args[@]}"
}

package_openrc() {
    depends=('psmisc' 'pam' 'opentmpfiles' 'netifrc' 'openrc-pid1')
    backup=('etc/rc.conf'
            'etc/conf.d/consolefont'
            'etc/conf.d/keymaps'
            'etc/conf.d/hostname'
            'etc/conf.d/modules'
            'etc/conf.d/hwclock'
            'etc/conf.d/opentmpfiles-dev'
            'etc/conf.d/opentmpfiles-setup')
    provides=('kmod-openrc')
    conflicts=('kmod-openrc' 'systemd-tools')
    replaces=('kmod-openrc')

    cd "${pkgbase}-${pkgver}"

    make DESTDIR="${pkgdir}" "${_args[@]}" install

    install -Dm644 "${srcdir}/${pkgbase}".logrotate "${pkgdir}"/etc/logrotate.d/"${pkgbase}"

    sed -e 's/#unicode="NO"/unicode="YES"/' \
        -e 's/#rc_logger="NO"/rc_logger="YES"/' \
        -e 's/#rc_controller_cgroups="YES"/rc_controller_cgroups="YES"/' \
        -e 's|#rc_shell=/bin/sh|rc_shell=/usr/bin/sulogin|' \
        -i "${pkgdir}/etc/rc.conf"

    install -d "${pkgdir}"/usr/lib/{openrc/cache,binfmt.d,sysctl.d}

    # getty
    sed -e 's|#baud=""|baud="38400"|' \
        -e 's|#term_type="linux"|term_type="linux"|' \
        -e 's|#agetty_options=""|agetty_options=""|' \
        -i ${pkgdir}/etc/conf.d/agetty

    # sysctl defaults
    install -m755 "${srcdir}"/sysctl.conf "${pkgdir}"/usr/lib/sysctl.d/50-default.conf

    # pacman hooks
    install -Dm755 "${srcdir}"/openrc-hook "${pkgdir}"/usr/share/libalpm/scripts/openrc-hook
    install -Dm644 -t "${pkgdir}"/usr/share/libalpm/hooks "${srcdir}"/*.hook

    # license
    install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/"${pkgbase}"/LICENSE

    # split bash completions
    install -d "${srcdir}"/_bash-completion/usr/share/bash-completion/completions
    mv -v "${pkgdir}"/usr/share/bash-completion/completions/* "${srcdir}"/_bash-completion/usr/share/bash-completion/completions

    # split zsh completions
    install -d "${srcdir}"/_zsh/usr/share/zsh/site-functions
    mv -v "${pkgdir}"/usr/share/zsh/site-functions/* "${srcdir}"/_zsh/usr/share/zsh/site-functions

    # split init
    for file in \
      etc/init.d/agetty.tty{1..6} \
      etc/runlevels/default/agetty.tty{1..6} \
      {usr,usr/lib/openrc}/bin/shutdown \
      {usr,usr/lib/openrc}/bin/reboot \
      {usr,usr/lib/openrc}/bin/halt \
      {usr,usr/lib/openrc}/bin/poweroff \
      usr/bin/openrc-{init,shutdown} \
      usr/bin/init \
      usr/share/man/man8/openrc-{init,shutdown}.8
    do
        install -d "${srcdir}"/_init/"${file%/*}"
        mv -v "${pkgdir}"/"${file}" "${srcdir}"/_init/"${file}"
    done

    install -d "${srcdir}"/_init/etc/conf.d
    cp -v "${pkgdir}"/etc/conf.d/agetty "${srcdir}"/_init/etc/conf.d/agetty

    # sysusers & tmpfiles
    install -m755 "${srcdir}"/opentmpfiles-dev.confd "${pkgdir}"/etc/conf.d/opentmpfiles-dev
    install -m755 "${srcdir}"/opentmpfiles-dev.initd "${pkgdir}"/etc/init.d/opentmpfiles-dev

    install -m755 "${srcdir}"/opentmpfiles-setup.confd "${pkgdir}"/etc/conf.d/opentmpfiles-setup
    install -m755 "${srcdir}"/opentmpfiles-setup.initd "${pkgdir}"/etc/init.d/opentmpfiles-setup

    install -m755 "${srcdir}"/opensysusers.initd "${pkgdir}"/etc/init.d/opensysusers

    ln -snf /etc/init.d/opensysusers "${pkgdir}"/etc/runlevels/boot/opensysusers
    ln -snf /etc/init.d/opentmpfiles-dev "${pkgdir}"/etc/runlevels/sysinit/opentmpfiles-dev
    ln -snf /etc/init.d/opentmpfiles-setup "${pkgdir}"/etc/runlevels/boot/opentmpfiles-setup

    # kmod staticc nodes
    install -m755 "${srcdir}"/kmod-static-nodes.initd "${pkgdir}"/etc/init.d/kmod-static-nodes
    ln -snf /etc/init.d/kmod-static-nodes "${pkgdir}"/etc/runlevels/sysinit/kmod-static-nodes
}

package_openrc-bash-completions() {
    depends=('openrc' 'bash')
    pkgdesc="OpenRC completions for Bash"

    mv -v "${srcdir}"/_bash-completion/* "${pkgdir}"
}

package_openrc-zsh-completions() {
    depends=('openrc' 'zsh')
    pkgdesc="OpenRC completions for ZSH"

    mv -v "${srcdir}"/_zsh/* "${pkgdir}"
}

package_openrc-init() {
    pkgdesc="OpenRC alternative to sysvinit"
    depends=('openrc')
    provides=('openrc-pid1' 'init')
    conflicts=('openrc-pid1' 'systemd-sysvcompat')
    backup=(etc/conf.d/agetty.tty{1..6})

    cd "${pkgbase}-${pkgver}"

    mv -v "${srcdir}"/_init/* "${pkgdir}"

    # license
    install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/"${pkgname}"/LICENSE

    for num in {1..6};do
        cp -v ${pkgdir}/etc/conf.d/agetty ${pkgdir}/etc/conf.d/agetty.tty$num
    done
    rm ${pkgdir}/etc/conf.d/agetty
}

package_openrc-sysvinit() {
    pkgdesc="OpenRC support for using sysvinit as PID 1"
    depends=('openrc' 'sysvinit')
    backup=('etc/inittab')

    cd "${pkgbase}-${pkgver}"

    # license
    install -Dm644 LICENSE "${pkgdir}"/usr/share/licenses/"${pkgname}"/LICENSE

    # sample sysvinit inittab
    install -Dm644 support/sysvinit/inittab "${pkgdir}"/etc/inittab
}