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

pkgbase=openrc
pkgname=('openrc' 'openrc-init')
pkgver=0.35.5
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=('655a0a32650ed46998ae84473e8a82aadd9de09904c5173cd9b9e2500fc8935e96539672b513a883c077ae862ece12ab768d4f379dbeb4389a7067ce7121dc0d'
            '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' 'opentmpfiles' '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'
            etc/conf.d/agetty.tty{1,2,3,4,5,6})
        
    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 openrc-shutdown; 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 openrc-shutdown; 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

}