summaryrefslogtreecommitdiff
path: root/pkgtools/rc.d-boot/Makefile
blob: b6eed5ec90032de0d7f64bd6de9d1efde0a4d45e (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
# $NetBSD: Makefile,v 1.8 2018/12/28 20:28:02 schmonz Exp $
#

PKGNAME=		rc.d-boot-20181228
CATEGORIES=		pkgtools

MAINTAINER=		schmonz@NetBSD.org
COMMENT=		Run package rc.d scripts at boot on any supported OS
LICENSE=		2-clause-bsd

ONLY_FOR_PLATFORM=	# empty by default
RCDBOOT_STYLE=		unknown

.include "../../mk/bsd.prefs.mk"

.if exists(/sbin/rcorder)
RCORDER=		/sbin/rcorder
.else
DEPENDS+=		rc.subr>=20181226:../../pkgtools/rc.subr
DEPENDS+=		rcorder-[0-9]*:../../pkgtools/rcorder
RCORDER=		${PREFIX}/sbin/rcorder
.endif

NO_CHECKSUM=		yes
NO_BUILD=		yes

SUBST_CLASSES=		paths
SUBST_STAGE.paths=	pre-configure
SUBST_FILES.paths=	rc.d-boot
SUBST_FILES.paths+=	org.pkgsrc.rc.d-boot.plist \
			pkgsrc-rc.d-boot \
			pkgsrc-rc.d-boot.service
SUBST_VARS.paths=	GREP PKGNAME PREFIX RCD_SCRIPTS_DIR RCORDER

FILES_SUBST+=		RCDBOOT_STYLE=${RCDBOOT_STYLE:Q}
FILES_SUBST+=		RCD_SCRIPTS_DIR=${RCD_SCRIPTS_DIR:Q}

EGDIR=			share/examples/${PKGBASE}

.if ${OPSYS} == "Darwin" && exists(/Library/LaunchDaemons)
RCDBOOT_STYLE=		darwin-launchd
CONF_FILES+=		${PREFIX}/${EGDIR}/org.pkgsrc.rc.d-boot.plist \
			/Library/LaunchDaemons/org.pkgsrc.rc.d-boot.plist
.elif ${OPSYS} == "FreeBSD" && exists(/etc/rc.d)
RCDBOOT_STYLE=		freebsd-native
.elif ${OPSYS} == "Linux" && exists(/run/systemd/system) && exists(/bin/systemctl)
RCDBOOT_STYLE=		linux-systemd
CONF_FILES+=		${PREFIX}/${EGDIR}/pkgsrc-rc.d-boot.service \
			/etc/systemd/system/pkgsrc-rc.d-boot.service
.elif ${OPSYS} == "Linux" && exists(/etc/rc.d/init.d) && exists(/sbin/chkconfig)
RCDBOOT_STYLE=		linux-sysv-redhat
CONF_FILES_PERMS+=	${PREFIX}/${EGDIR}/pkgsrc-rc.d-boot \
			/etc/init.d/pkgsrc-rc.d-boot \
			${REAL_ROOT_USER} ${REAL_ROOT_GROUP} ${RCD_SCRIPTS_MODE}
.elif ${OPSYS} == "Linux" && exists(/etc/init.d) && exists(/usr/sbin/update-rc.d)
RCDBOOT_STYLE=		linux-sysv-debian
CONF_FILES_PERMS+=	${PREFIX}/${EGDIR}/pkgsrc-rc.d-boot \
			/etc/init.d/pkgsrc-rc.d-boot \
			${REAL_ROOT_USER} ${REAL_ROOT_GROUP} ${RCD_SCRIPTS_MODE}
.elif ${OPSYS} == "NetBSD" && exists(/etc/rc.d)
RCDBOOT_STYLE=		netbsd-native
.elif ${OPSYS} == "OpenBSD" && exists(/etc/rc.d/rc.subr)
RCDBOOT_STYLE=		openbsd-rcd
.endif

.if ${RCDBOOT_STYLE} != "unknown"
ONLY_FOR_PLATFORM+=	${OPSYS}-*-*
.else
# Help wanted! Some known boot schemes we'd like to support:
# - https://wiki.gentoo.org/wiki/Project:OpenRC
# - http://smarden.org/runit/
# - https://jdebp.eu/Softwares/nosh/
# - http://upstart.ubuntu.com
NOT_FOR_PLATFORM+=	${OPSYS}-*-*
.endif

BUILD_DEFS+=		RCDBOOT_STYLE RCD_SCRIPTS_DIR
INSTALLATION_DIRS=	sbin ${EGDIR}

do-extract:
	${CP} -R ${FILESDIR} ${WRKSRC}

do-install:
.	for i in org.pkgsrc.rc.d-boot.plist \
		pkgsrc-rc.d-boot.service
		${INSTALL_DATA} ${WRKSRC}/${i} ${DESTDIR}${PREFIX}/${EGDIR}/
.	endfor
.	for i in pkgsrc-rc.d-boot
		${INSTALL_SCRIPT} ${WRKSRC}/${i} ${DESTDIR}${PREFIX}/${EGDIR}/
.	endfor
	${INSTALL_SCRIPT} ${WRKSRC}/rc.d-boot ${DESTDIR}${PREFIX}/sbin/

.include "../../mk/bsd.pkg.mk"