summaryrefslogtreecommitdiffstats
path: root/source/a/elilo/elilo.SlackBuild
blob: 2fa31a7af07834f6b79b96b390d9012aa9d5dffc (plain) (blame)
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
#!/bin/sh

# Copyright 2013, 2014, 2016  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

PKGNAM=elilo
VERSION=${VERSION:-$(echo $PKGNAM*.tar.?z* | rev | cut -f 2 -d - | rev)}
BUILD=${BUILD:-2}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp}
PKG=$TMP/package-$PKGNAM

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf elilo
mkdir elilo
cd elilo
tar xvf $CWD/${PKGNAM}-$VERSION-all.tar.?z* || exit 1
tar xvf elilo-${VERSION}-source.tar.gz || exit 1
# This is a rebuilt version of the x86_64 elilo (which is really the only
# useful one), fetched from $TMP/elilo/elilo-${VERSION}-source/ after
# running this script.  Elilo can be rather fragile, so we don't want to
# rebuild it all the time and risk breaking it.
tar xvf $CWD/elilo.x64.rebuilt.tar.xz || exit 1
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
cd elilo-${VERSION}-source || cd elilo || exit

sed -i "s,/usr/lib,/usr/lib${LIBDIRSUFFIX},g" Make.defaults
sed -i "s,EFICRT0.*= /usr/lib${LIBDIRSUFFIX},EFICRT0    = /usr/lib${LIBDIRSUFFIX}/gnuefi,g" Make.defaults
sed -i "s,dpkg-architecture -qDEB_BUILD_ARCH,uname -m,g" Make.defaults

# We will build this from source.
# However, we will package the pre-built EFI binaries, since we would
# like to include both 32-bit and 64-bit x86 EFI loaders in the
# finished package.

make || exit 1

# Install the files in the package directory:
mkdir -p $PKG/usr/sbin
cp tools/eliloalt $PKG/usr/sbin

# Install eliloconfig, a simple setup script:
cp -a $CWD/eliloconfig $PKG/usr/sbin
chown root:root $PKG/usr/sbin/eliloconfig
chmod 755 $PKG/usr/sbin/eliloconfig
mkdir -p $PKG/var/log/setup
cp -a $CWD/setup.ll.eliloconfig $PKG/var/log/setup
chown root:root $PKG/var/log/setup/setup.ll.eliloconfig
chmod 755 $PKG/var/log/setup/setup.ll.eliloconfig

mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
cp -a \
  ChangeLog LIMITATIONS README README.gnu-efi TODO docs/* \
  examples \
  $PKG/usr/doc/$PKGNAM-$VERSION

# Since it might not be safe to strip the EFI binaries, do this now:
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

cd ..

# Install EFI bootloaders in /boot:
mkdir $PKG/boot
# The ia32 version is pretty much useless, since 32-bit UEFI is nowhere to be
# found.  Maybe it would help old 32-bit Intel Macs though?
cp -a elilo*ia32.efi $PKG/boot/elilo-ia32.efi
# Itanium binary isn't needed here.
#cp -a elilo*ia64.efi $PKG/boot/elilo-ia64.efi
cp -a elilo*x86_64.efi $PKG/boot/elilo-x86_64.efi

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz