summaryrefslogtreecommitdiff
blob: 3da1bbf2d22e85df7129430fbbc41e8c6c0dae3f (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
129
130
131
132
133
134
135
136
137
138
139
140
141
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-boot/arcboot/arcboot-0.3.8.6-r1.ebuild,v 1.3 2007/07/15 02:25:03 mr_bones_ Exp $

inherit eutils

MY_P="${P/-/_}"
ARCVER="1.1"		# Version of the arcboot patch ball

DESCRIPTION="ARCS Bootloader for SGI Machines (IP22, IP32)"
HOMEPAGE="http://packages.qa.debian.org/a/arcboot.html"
SRC_URI="http://http.us.debian.org/debian/pool/main/a/arcboot/${MY_P}.tar.gz
		mirror://gentoo/arcboot-patches-${ARCVER}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="-* ~mips"
IUSE="ip27 ip28 ip30 cobalt"

DEPEND=""
RDEPEND="sys-boot/dvhtool
	 sys-apps/debianutils"

S=${WORKDIR}/${PN}

pkg_setup() {
	# arcboot is for SGI mips machines only, so exclude everyone but them
	if use cobalt; then
		eerror "Arcboot is a bootloader only for MIPS machines running"
		eerror "ARCS firmware, such as SGI Machines.  It is not intended"
		eerror "for other kinds of MIPS machines."
		die "Wrong MIPS Machine Type"
	fi

	# Machines which expect an ELF64 binary to boot can't use arcboot
	if use ip27 || use ip28 || use ip30; then
		eerror "Arcboot does not work on systems that can only boot pure 64bit"
		eerror "ELF binaries.  Arcboot needs some work to be able to compile as"
		eerror "an ELF64 object.  Patches are welcome!"
		die "No ELF64 Support"
	fi

	# Set SGITYPE properly
	case "$(uname -i)" in
		"SGI IP32"|"SGI O2")		SGITYPE="IP32" ;;
		"SGI Indy"|"SGI Indigo2")	SGITYPE="IP22" ;;
		*)
			eerror "Unknown SGI Machine type.  It's possible arcboot is not usable for this machine"
			eerror "type yet.  Feel free to make it work and send patches!"
			die "Unknown SGI Machine Type"
			;;
	esac

	# Lower case SGITYPE
	SGITYPE_L="$(echo "${SGITYPE}" | tr [A-Z] [a-z])"
}

src_unpack() {
	unpack ${A}
	cd ${S}

	# Set the version
	echo "#define __ARCSBOOT_VERSION__ \"${PV}\"" > common/version.h

	# Crazy patches.  One is onion's patch, highly modified, from:
	# http://www.tal.org/~milang/o2/
	#
	# Second is a clean up of bits in onion's patch to make it
	# compile against our headers.
	epatch ${WORKDIR}/patches/${P}-makefile.patch
	epatch ${WORKDIR}/patches/${P}-segaddr.patch
}

src_compile() {
	cd ${S}

	echo -e ""
	einfo ">>> Building for ${SGITYPE} ..."
	echo -e ""

	make SUBARCH="${SGITYPE}" || die
}

src_install() {
	cd ${S}

	# Arcboot
	dodir /usr/lib/arcboot
	cp ext2load/ext2load ${D}/usr/lib/arcboot/arcboot.${SGITYPE_L}

	# Technically, we don't need tip[2|3]2 (attaches initrd to kernel), as
	# MIPS kernels support embedding initrd's into kernels at build time,
	# But maybe this will be useful one day.  Until then, we leave it out.
	dodir /usr/lib/tip22
	cp tip22/t${SGITYPE_L} ${D}/usr/lib/tip22
	cp tip22/tftpload.${SGITYPE}.o ${D}/usr/lib/tip22
	cp tip22/ld.kernel.script.${SGITYPE} ${D}/usr/lib/tip22
	cp tip22/ld.ramdisk.script.${SGITYPE} ${D}/usr/lib/tip22
	cp tip22/ld.script ${D}/usr/lib/tip22
	cp arclib/libarc.a ${D}/usr/lib/tip22

	# Calling scripts for arcboot/tip22
	# We also exclude these, since the logic in the debian script may not
	# work correctly with a gentoo installation.  All the information a
	# user needs is provided in the example arcboot.conf, and in pkg_postinst().
##	dosbin scripts/arcboot
	dosbin tip22/t${SGITYPE_L}

	# Conf file
	dodir /etc
	cp etc/arcboot.conf ${D}/etc/arcboot.conf.example

	# Man pages
	# The arcboot manpage is more for the excluded arcboot script above, but
	# also has info on setting the PROM option properly as well as arcboot.conf
	# examples.
	doman debian/arcboot.8
	doman debian/t${SGITYPE_L}.8
}

pkg_postinst() {
	echo -e ""
	einfo "The arcboot image used to load the kernel from disk has been stored in"
	einfo "/usr/lib/arcboot/arcboot.${SGITYPE}.  To use it, you need to copy this into"
	einfo "the volume header with dvhtool:"
	einfo ""
	einfo "dvhtool --unix-to-vh /usr/lib/arcboot/arcboot.${SGITYPE} arcboot"
	echo -e ""
	einfo "Next, you need to create an arcboot.conf file.  An example arcboot.conf"
	einfo "file has been placed in /etc."
	echo -e ""
	echo -e ""
	ewarn "NOTE: If you put kernels in /boot for arcboot to load, and /boot is on a"
	ewarn "      separate partition, then arcboot.conf MUST go into /boot/etc, and a"
	ewarn "      symlink must be created to point /boot back to itself:"
	ewarn ""
	ewarn "      cd /boot; ln -sf . boot"
	echo -e ""
	einfo "To use arcboot, from the PROM Monitor, simply type \"arcboot\" or \"boot -f arcboot\"."
	echo -e ""
	echo -e ""
}