summaryrefslogtreecommitdiff
path: root/pcr/openrc/PKGBUILD
blob: 1d103837c22b316a4c9ee9b8de318a64078a89fe (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
# Maintainer (Artix): artoo <artoo@manjaro.org>
# Contributor (Artix): williamh <williamh@gentoo.org>
# Maintainer: Omar Vega Ramos <ovruni@gnu.org.pe>

pkgbase=openrc
pkgname=('openrc' 'openrc-init')
pkgver=0.34.11
pkgrel=1.parabola1
arch=('i686' 'x86_64' 'armv7h')
url="https://wiki.gentoo.org/wiki/Project:OpenRC"
license=('BSD2')
options=('!emptydirs')
source=("${pkgbase}-${pkgver}.tar.gz::https://github.com/OpenRC/openrc/archive/${pkgver}.tar.gz"
        "${pkgbase}.logrotate"
        'openrc-install.hook'
        'openrc-remove.hook')
sha512sums=('76245d31c6fe9e90e5e2f35ce918b915fc88c231674e0c99dc98b8f3fa120e794900eec9919a0ab029a081b206393246eccb9119a79c90ad6e39325d022928be'
            '690612fddfb2c4cf8f6b5ba7239b9faf29eb3d9b152ab4dcf62694aa2852780440d08cee56d98a9597607f446b3697c911269562821a8402bb5747cbbae34bd9'
            'c31c94574f1c604930b572ed74eabdfcbedb344c54668ddeb3214d71de660e9fa8ff445b04ff817f16e62bce43376680d0a1b6c65baa8f6dba30e4ffa230c04a'
            '96bd71dd4fbe1417a640ac7526e83e1b2290732d5e558d7942c87db0dc1ccb7614763d7748b219ac5982b0db66cba9c124506ec939a661d73db4d0b2642f431e')

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

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

prepare(){
    cd "${srcdir}/${pkgbase}-${pkgver}"
    sed -e "s|/sbin|/usr/bin|g" -i support/sysvinit/inittab
    sed -i 's:0444:0644:' mk/sys.mk
}

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

package_openrc() {
    pkgdesc="Gentoo's universal init system"
    install=${pkgbase}.install
    depends=('psmisc' 'pam' 'init')
    optdepends=('netifrc: Network Interface Management Scripts'
                'networkmanager-openrc: NetworkManager')
    backup=('etc/rc.conf'
            'etc/conf.d/consolefont'
            'etc/conf.d/keymaps'
            'etc/conf.d/hostname'
            'etc/conf.d/modules'
            'etc/conf.d/hwclock')
        
    cd "${srcdir}/${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"/' \
        -i "${pkgdir}/etc/rc.conf"

    install -d ${pkgdir}/usr/lib/openrc/cache

    # 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

    # alpm hooks
    for h in openrc-{install,remove}.hook;do
        install -Dm644 ${srcdir}/$h ${pkgdir}/usr/share/libalpm/hooks/$h
    done

    # license
    install -Dm644 ${srcdir}/${pkgbase}-${pkgver}/LICENSE "$pkgdir/usr/share/licenses/${pkgbase}/LICENSE"
    
    # move these to $srcdir    
    for bin in shutdown reboot halt poweroff openrc-init init; do
        mv -v ${pkgdir}/usr/bin/${bin} ${srcdir}/${bin}
    done
    mv -v ${pkgdir}/etc/conf.d/agetty ${srcdir}/agetty.confd
    mv -v ${pkgdir}/etc/init.d/agetty ${srcdir}/agetty.initd
}

package_openrc-init() {
    pkgdesc="OpenRC replacement for /sbin/init"
    depends=('openrc')
    provides=('init')
    groups=('init')
    conflicts=('systemd-sysvcompat' 'sysvinit' 'init')
    replaces=('sysvinit')
    install=${pkgbase}-init.install
    
    cd ${srcdir}
    install -d ${pkgdir}/usr/bin/ \
            -d ${pkgdir}/etc/conf.d/ \
            -d ${pkgdir}/etc/init.d/ \
            -d ${pkgdir}/etc/runlevels/default/
          
    for bin in shutdown reboot halt poweroff openrc-init init; do
        mv -v ${bin} ${pkgdir}/usr/bin/${bin}
    done
    
    mv -v agetty.confd ${pkgdir}/etc/conf.d/agetty
    mv -v agetty.initd ${pkgdir}/etc/init.d/agetty
    for num in 1 2 3 4 5 6;do
        cp -v ${pkgdir}/etc/conf.d/agetty ${pkgdir}/etc/conf.d/agetty.tty$num
        ln -sf /etc/init.d/agetty ${pkgdir}/etc/init.d/agetty.tty$num
        ln -sf /etc/init.d/agetty.tty$num ${pkgdir}/etc/runlevels/default/agetty.tty$num
    done

}