summaryrefslogtreecommitdiff
path: root/distrib/simpleroot/Makefile
blob: e3298576cb9b37aa749e2dcccdcd38ba8bfd376c (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.14 2001/06/23 19:44:56 deraadt Exp $

REV=		${OSrev}

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?=
GZIP?=

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}
	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
	sed -e "s/^ARCH=ARCH$/ARCH=`arch -s`/" \
	    ${.CURDIR}/../${MACHINE}/install.md > ${MOUNT_POINT}/install.md
	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>