summaryrefslogtreecommitdiff
blob: e6bee2b3f6c643553b179976a10fddccb78cd192 (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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# Copyright 1999-2019 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

inherit flag-o-matic eutils

# Currently tested Systems:
#
# 	Ruffian: UX164, BX164
#

DESCRIPTION="The Alpha MIniLOader, for Alpha Machines without SRM"
HOMEPAGE="http://milo.core-systems.de/"

# ive tested this, and it seems to make little difference
# which kernel version you use, so it makes sense to use the
# latest available 2.2 kernel with the latest bugfixes/drivers/etc.

kernel_version="2.2.25"
milo_version="2.2-18"
ldmilo_patch="20010430"

# milo-2.2-18.tar.bz2 :- latest milo sources
# linux-2.2.25.tar.bz2 :- latest linux 2.2 kernel sources
# ldmilo-patched-20010430 :- Ruffian ldmilo utility, with bugfixes by Jay Eastabrook
# linload.exe :- linload utility (ldmilo equivalent for non-ruffians).

SRC_URI="http://www.suse.de/~stepan/source/milo-${milo_version}.tar.bz2
	https://www.kernel.org/pub/linux/kernel/v2.2/linux-${kernel_version}.tar.bz2
	https://dev.gentoo.org/~taviso/milo/ldmilo-patched-${ldmilo_patch}
	http://ftp.namesys.com/pub/reiserfs-for-2.2/linux-2.2.20-reiserfs-3.5.35.diff.bz2
	https://dev.gentoo.org/~taviso/milo/linload.exe
	http://www.ibiblio.org/pub/Linux/docs/HOWTO/MILO-HOWTO"

#
# milo license is dec palcode license, dec bios emulation license, and gpl-2 rolled
# into one big ugly package.
#
# the dec licenses say you can basically do anything you like, including modify
# and redistribute for profit or non-profit, as long as its for use with Alpha
# architecture.
#

LICENSE="MILO"
SLOT="0"

KEYWORDS="-* ~alpha"
IUSE=""

DEPEND="sys-apps/kbd
	>=sys-apps/sed-4"
RDEPEND="sys-fs/mtools"

S=${WORKDIR}/milo-${milo_version}

# You can change the default MILO serial
# number here, the MILO default is "Linux_is_Great!".
# There are some below that i have made you can
# use if you want, just uncomment the one you like.
#
# if you want to see how this works, to make your own
# look at mkserial_no.c in the filesdir.
#
##### Linux_is_Great! ###################
#milo_serial_number0=0x73695f78756e694c
#milo_serial_number1=0x002174616572475f
#
##### Gentoo Linux. #####################
milo_serial_number0=0x4c206f6f746e6547
milo_serial_number1=0x0000002e78756e69
#
##### Gentoo/Alpha. #####################
#milo_serial_number0=0x412f6f6f746e6547
#milo_serial_number1=0x0000002e6168706c
#
##### Gentoo MILO. ######################
#milo_serial_number0=0x4d206f6f746e6547
#milo_serial_number1=0x000000002e4f4c49
#
##### |d|i|g|i|t|a|l| ###################
#milo_serial_number0=0x697c677c697c647c
#milo_serial_number1=0x007c6c7c617c747c;
#

src_unpack() {
	# unpack everything the kernel and milo sources
	unpack linux-${kernel_version}.tar.bz2
	unpack milo-${milo_version}.tar.bz2
	unpack linux-2.2.20-reiserfs-3.5.35.diff.bz2
}

src_prepare() {
	# gcc3 fixes, and some tweaks to get a build, also
	# reiserfs support for the kernel (and milo).
	cd ${WORKDIR}/linux; eapply "${FILESDIR}"/linux-${kernel_version}-gcc3-milo.diff || die
	cd ${WORKDIR}/linux; eapply "${WORKDIR}"/linux-2.2.20-reiserfs-3.5.35.diff || die
	cd ${S}; eapply "${FILESDIR}"/milo-${milo_version}-gcc3-gentoo.diff || die
	eapply_user
}

src_compile() {
	unset MILO_ARCH
	for arches in	"Alpha-XLT  XLT"		\
			"Alpha-XL   XL"			\
			"AlphaBook1 BOOK1"		\
			"Avanti     AVANTI" 	\
			"Cabriolet  CABRIOLET"	\
			"EB66       EB66"		\
			"EB66+      EB66P"		\
			"EB64+      EB64P"		\
			"EB164      EB164"		\
			"PC164      PC164"		\
			"LX164      LX164"		\
			"SX164      SX164"		\
			"Noname     NONAME"		\
			"Takara     TAKARA"		\
			"Mikasa     MIKASA"		\
			"Alcor      ALCOR"		\
			"Miata      MIATA"		\
			"Ruffian    RUFFIAN"	\
			"Platform2000   P2K"	\
			"UDB        UDB"
	do
		if [ -z "${MILO_IMAGE}" ]; then
			MILO_ARCH="${MILO_ARCH} \"${arches}\""
		else
			if echo ${arches} | grep -i ${MILO_IMAGE}; then
				MILO_ARCH="\"${arches}\""
			fi
		fi
	done

	if [ -z "${MILO_ARCH}" ]; then
		eerror "Sorry, but ${MILO_IMAGE} doesnt look valid to me"
		eerror "Consult the Alpha installation guide, or the ebuild"
		eerror "for a list of available Alphas."
		die "${MILO_IMAGE} not supported, or not recognised."
	fi

	sed -i "s!__MILO_ARCHES__!${MILO_ARCH}!g" ${S}/tools/scripts/build

	ewarn
	ewarn "seriously, this is going to take a while, go get some coffee..."
	ewarn
	einfo "this ebuild will build the standard MILO images, similar to those"
	einfo "distributed with some distributions, and the images provided with"
	einfo "the official MILO sources."
	einfo
	einfo "of course, the beauty of MILO is it can support any device supported"
	einfo "by the linux kernel, so if you need support for non-standard hardware"
	einfo "set the path to the .config you want in \$custom_milo_kernel_config and"
	einfo "i will use it instead of the default."
	ewarn

	# get kernel configured
	cp ${custom_milo_kernel_config:-${S}/Documentation/config/linux-2.2.19-SuSE.config} \
		${WORKDIR}/linux/.config
	cd ${WORKDIR}/linux; yes n | make oldconfig || die "unable to configure kernel."

	# we're building a generic kernel that defaults to ev5, but theres no
	# reason why we cant tweak the instruction set.
	# im not sure if you can actually pull a system performance gain/faster
	# boot from optimising milo, but at least you'll get a faster milo pager ;)
	mcpu_flag="`get-flag mcpu`"
	if [ ! -z "${mcpu_flag}" ]; then
		sed -i "s/\(CFLAGS := \$(CFLAGS) \)-mcpu=ev5$/\1-mcpu=${mcpu_flag:-ev5}/g" \
			${WORKDIR}/linux/arch/alpha/Makefile
	fi

	# build the generic linux kernel, of course if you have
	# hardware not supported by this generic kernel, you are free
	# to hack it (or the .config used here).
	einfo "building a generic kernel for use with milo..."
	unset CC DISTCC_HOSTS; make dep vmlinux || die "unable to build generic kernel for milo."
	cat ${FILESDIR}/objstrip.c > ${WORKDIR}/linux/arch/alpha/boot/tools/objstrip.c

	# make the objstrip utility.
	gcc ${WORKDIR}/linux/arch/alpha/boot/tools/objstrip.c -o \
		${WORKDIR}/linux/arch/alpha/boot/tools/objstrip || die "couldnt build objstrip."
	einfo "kernel build complete."
	einfo "building milo images..."

	# we have a choice here, milo can set the serial number to just about
	# anything we like, the milo author has chosen "Linux_is_Great!", which
	# is a bit cheesy, but we will leave it as default if user hasnt chosen
	# something else.
	# see above for options.

	append-flags -DMILO_SERIAL_NUMBER0="${milo_serial_number0:-0x73695f78756e694c}"
	append-flags -DMILO_SERIAL_NUMBER1="${milo_serial_number1:-0x002174616572475f}"

	# the Makefile missed this :-/
	cd ${S}/tools/common; make || die "couldnt make commonlib."

	# build all the milo images.
	cd ${S}; tools/scripts/build || die "failed to build milo images."

	# put the ldmilo utility there.
	cp ${DISTDIR}/ldmilo-patched-${ldmilo_patch} ${S}/binaries/ldmilo.exe
	cp ${DISTDIR}/linload.exe ${S}/binaries/linload.exe

}

src_install() {

	cd ${S}; dodir /opt/milo
	insinto /opt/milo

	einfo "Installing MILO images..."
	for i in binaries/*
	do
		einfo "	${i}"
		doins ${i}
	done

	cd ${S}/Documentation

	dodoc ChangeLog filesystem Nikita.Todo README.milo Todo README.BSD Stuff WhatIsMilo \
		${FILESDIR}/README-gentoo ${FILESDIR}/mkserial_no.c ${DISTDIR}/MILO-HOWTO

}

pkg_postinst() {
	einfo "The MILO images have been installed into /opt/milo."
	einfo "There are instructions in /usr/share/doc/${P} for making MILO boot floppies."
	einfo "Alternative methods, (flash, srm, debug monitor, etc) are described in the MILO-HOWTO."
	einfo
	einfo "The important docs to read are the README-gentoo and the MILO-HOWTO."
	einfo
	ewarn "PLEASE, PLEASE, PLEASE, let me know if this works or not, i need to know which systems"
	ewarn "need tweaking, and which ones are good to go. You can email me at taviso@gentoo.org"
	einfo
}