summaryrefslogtreecommitdiff
path: root/distrib/simpleroot/Makefile
blob: 3a43b3b1699d686b14946824a92a5a345a3c301e (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
#	$OpenBSD: Makefile,v 1.8 1997/05/15 12:33:06 graichen Exp $

# Revision is 2.1
REV=		21

ARCHDIR=	${.CURDIR}/../${MACHINE}/simpleroot

.if exists(${ARCHDIR}/Makefile.inc)
.include "${ARCHDIR}/Makefile.inc"
.endif

MOUNT_POINT?=	/mnt
VND?=		svnd0
VND_DEV=	/dev/${VND}a
VND_RDEV=	/dev/r${VND}a
DISKTYPE=	simpleroot
PID!=		echo $$$$
IMAGEDIR?=	/var/tmp
REALIMAGE!=	echo ${IMAGEDIR}/image.${PID}
IMAGE?=		${IMAGEDIR}/simpleroot${REV}.fs
NEWFSOPTS?=

LIST=		${ARCHDIR}/list

.ifndef DESTDIR
all:
	@echo setenv DESTDIR before makeing a miniroot!
	@false
.else

all:
	dd if=/dev/zero of=${REALIMAGE} count=${IMAGESIZE}
	vnconfig -v -c ${VND} ${REALIMAGE}
	disklabel -w -r ${VND} ${DISKTYPE}
.ifdef BOOT_DISKLABEL
	disklabel -B ${BOOT_DISKLABEL} ${VND} ${DISKTYPE}
.endif
	newfs ${NEWFSOPTS} ${VND_RDEV} ${DISKTYPE}
	mount ${VND_DEV} ${MOUNT_POINT}
.ifdef BOOT_INSTALLBOOT
	/usr/mdec/installboot -v ${MOUNT_POINT}/boot ${BOOT_INSTALLBOOT} ${VND}
.endif
	cd ${DESTDIR} && tar cf - `cat ${LIST}` | ( cd ${MOUNT_POINT}; \
	  tar xpf - )
	cp ${.CURDIR}/install.sh ${MOUNT_POINT}/install
	chmod 755 ${MOUNT_POINT}/install
	sed "/^VERSION=/s/=.*/=${REV}/" < ${.CURDIR}/install.sub \
	  > ${MOUNT_POINT}/install.sub
	cp ${.CURDIR}/../${MACHINE}/install.md ${MOUNT_POINT}/install.md
	mkdir -p ${MOUNT_POINT}/kern
	mkdir -p ${MOUNT_POINT}/mnt2
.if exists(/sbin/ldconfig)
	/usr/sbin/chroot ${MOUNT_POINT} /sbin/ldconfig
.endif
	( cd ${MOUNT_POINT} && \
	tar cf - .??* * | ${GZIP} ${GZIPFLAGS} \
	  > ${IMAGEDIR}/simpleroot${REV}.tar${GZIPEXT} )
	@echo ""
	@df -i ${MOUNT_POINT}
	@echo ""
	umount ${MOUNT_POINT}
	vnconfig -u ${VND}
	cp ${REALIMAGE} ${IMAGE}
.if (${GZIP} == "gzip")
	${GZIP} ${IMAGE}
.endif
	rm ${REALIMAGE}

unconfig:
	-umount -f ${MOUNT_POINT}
	-vnconfig -u ${VND_DEV}
	-/bin/rm -f ${IMAGE}

clean cleandir:
	/bin/rm -f core ${IMAGE}

beforeinstall:
	cp ${IMAGE} ${DESTDIR}/snapshot

.endif	# DESTDIR check
.include <bsd.obj.mk>
.include <bsd.subdir.mk>