257a7a9a11365a0786e51fea98d216e8cb1f0713
[gentoo.git] / sys-boot / lilo / lilo-22.8-r2.ebuild
1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3
4 inherit eutils flag-o-matic toolchain-funcs
5
6 DOLILO_V="0.5"
7 IUSE="static minimal pxeserial device-mapper"
8
9 DESCRIPTION="Standard Linux boot loader"
10 HOMEPAGE="http://lilo.go.dyndns.org/pub/linux/lilo/"
11 DOLILO_TAR="dolilo-${DOLILO_V}.tar.bz2"
12 MY_P=${P}.src
13
14 SRC_URI="http://home.san.rr.com/johninsd/pub/linux/lilo/${MY_P}.tar.gz
15         ftp://metalab.unc.edu/pub/Linux/system/boot/lilo/${MY_P}.tar.gz
16         ftp://metalab.unc.edu/pub/Linux/system/boot/lilo/obsolete/${MY_P}.tar.gz
17         mirror://gentoo/${DOLILO_TAR}"
18
19 SLOT="0"
20 LICENSE="BSD GPL-2"
21 KEYWORDS="-* amd64 x86"
22
23 DEPEND=">=sys-devel/bin86-0.15.5"
24 RDEPEND="device-mapper? ( >=sys-fs/lvm2-2.02.45 )"
25
26 src_unpack() {
27         unpack ${MY_P}.tar.gz
28
29         cd "${S}"
30
31         # Correctly document commandline options -v and -V, bug #43554
32         epatch "${FILESDIR}/${P}-correct-usage-info.patch"
33         # Install manpages to correct location, do not rely on incorrect manpath output, bug #117135
34         # Do not strip the main binary, it upsets portage, bug #140210
35         # Do not install diag1.img, bug #149887
36         epatch "${FILESDIR}/${P}-makefile.patch"
37
38         # this patch is needed when booting PXE and the device you're using
39         # emulates vga console via serial console.
40         # IE..  B.B.o.o.o.o.t.t.i.i.n.n.g.g....l.l.i.i.n.n.u.u.x.x and stair stepping.
41         use pxeserial && epatch "${FILESDIR}/${P}-novga.patch"
42         use device-mapper || epatch "${FILESDIR}/${P}-nodevmapper.patch"
43
44         unpack ${DOLILO_TAR}
45 }
46
47 src_compile() {
48         # lilo needs this. bug #140209
49         export LC_ALL=C
50
51         # we explicitly prevent the custom CFLAGS for stability reasons
52         if use static; then
53                 emake CC="$(tc-getCC)" lilo.static || die
54                 mv lilo.static lilo || die
55         else
56                 emake CC="$(tc-getCC)" lilo || die
57         fi
58 }
59
60 src_install() {
61         keepdir /boot
62         make ROOT="${D}" install || die
63
64         if use !minimal; then
65                 into /
66                 dosbin "${S}"/dolilo/dolilo
67
68                 into /usr
69                 dosbin keytab-lilo.pl
70
71                 insinto /etc
72                 newins "${FILESDIR}"/lilo.conf lilo.conf.example
73
74                 newconfd "${S}"/dolilo/dolilo.conf.d dolilo.example
75
76                 doman manPages/*.[5-8]
77                 dodoc CHANGES INCOMPAT README*
78                 docinto samples ; dodoc sample/*
79         fi
80 }
81
82 # Check whether LILO is installed
83 # This function is from /usr/sbin/mkboot from debianutils, with copyright:
84 #
85 #   Debian GNU/Linux
86 #   Copyright 1996-1997 Guy Maor <maor@debian.org>
87 #
88 # Modified for Gentoo for use with the lilo ebuild by:
89 #   Martin Schlemmer <azarah@gentoo.org> (16 Mar 2003)
90 #
91 lilocheck () {
92         local bootpart=
93         local rootpart="$(mount | grep -v "tmpfs" | grep -v "rootfs" | grep "on / " | cut -f1 -d " ")"
94
95         echo
96         einfon "Checking for LILO ..."
97
98         if [ "$(whoami)" != "root" ]
99         then
100                 echo; echo
101                 eerror "Only root can check for LILO!"
102                 return 1
103         fi
104
105         if [ -z "${rootpart}" ]
106         then
107                 echo; echo
108                 eerror "Could not determine root partition!"
109                 return 1
110         fi
111
112         if [ ! -f /etc/lilo.conf -o ! -x /sbin/lilo ]
113         then
114                 echo " No"
115                 return 1
116         fi
117
118         bootpart="$(sed -n "s:^boot[ ]*=[ ]*\(.*\)[ ]*:\1:p" /etc/lilo.conf)"
119
120         if [ -z "${bootpart}" ]
121         then
122                 # lilo defaults to current root when 'boot=' is not present
123                 bootpart="${rootpart}"
124         fi
125
126         if ! dd if=${bootpart} ibs=16 count=1 2>&- | grep -q 'LILO'
127         then
128                 echo; echo
129                 ewarn "Yes, but I couldn't find a LILO signature on ${bootpart}"
130                 ewarn "Check your /etc/lilo.conf, or run /sbin/lilo by hand."
131                 return 1
132         fi
133
134         echo " Yes, on ${bootpart}"
135
136         return 0
137 }
138
139 pkg_postinst() {
140         if [ ! -e "${ROOT}/boot/boot.b" -a ! -L "${ROOT}/boot/boot.b" ]
141         then
142                 [ -f "${ROOT}/boot/boot-menu.b" ] && \
143                         ln -snf boot-menu.b "${ROOT}/boot/boot.b"
144         fi
145
146         if [ "${ROOT}" = "/" ] && use !minimal;
147         then
148                 if lilocheck
149                 then
150                         einfo "Running DOLILO to complete the install ..."
151                         # do not redirect to /dev/null because it may display some input
152                         # prompt
153                         /sbin/dolilo
154                         if [ "$?" -ne 0 ]
155                         then
156                                 echo
157                                 ewarn "Running /sbin/dolilo failed!  Please check what the problem is"
158                                 ewarn "before your next reboot."
159
160                                 ebeep 5
161                                 epause 5
162                         fi
163                 fi
164                 echo
165         fi
166         if use !minimal; then
167                 echo
168                 einfo "Issue 'dolilo' instead of 'lilo' to have a friendly wrapper that"
169                 einfo "handles mounting and unmounting /boot for you. It can do more then"
170                 einfo "that when asked, edit /etc/conf.d/dolilo to harness it's full potential."
171                 ebeep 5
172                 epause 3
173                 echo
174         fi
175 }