summaryrefslogtreecommitdiff
path: root/extra/refind-efi/PKGBUILD
blob: 028af2afdd209dd626f148ffb3b2a96f7f6031ce (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
# $Id: PKGBUILD 188814 2013-06-21 19:48:54Z tpowa $
# Maintainer: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: Keshav Padram <(the.ridikulus.rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>

#######
_TIANOCORE_SVN_URL="https://svn.code.sf.net/p/edk2/code/branches/UDK2010.SR1"
# BaseTools MdePkg MdeModulePkg IntelFrameworkPkg IntelFrameworkModulePkg
_TIANO_DIR_="tianocore-udk-svn"
#######

#######
_TIANOCORE_PKG="Mde"
_TIANOCORE_TARGET="RELEASE"
_UDK_TARGET="${_TIANOCORE_PKG}Pkg/${_TIANOCORE_PKG}Pkg.dsc"
_COMPILER="GCC46"
#######

pkgname="refind-efi"
pkgver="0.6.12"
pkgrel="2"
pkgdesc="Rod Smith's fork of rEFIt UEFI Boot Manager - built with Tianocore UDK libs"
url="http://www.rodsbooks.com/refind/index.html"
arch=('x86_64' 'i686')
license=('GPL3' 'custom')

makedepends=('subversion' 'python2')
depends=('dosfstools' 'efibootmgr')
optdepends=('mactel-boot: For bless command in Apple Mac systems'
            'bash: For /usr/bin/refind-mkfont script'
            'imagemagick: For /usr/bin/refind-mkfont script')

options=('!strip' 'docs' '!makeflags')

install="${pkgname}.install"

source=("http://downloads.sourceforge.net/refind/refind-src-${pkgver}.zip"
        'UDK-MdePkg-Revert-PathNodeCount.patch'
        'refind_linux.conf')

for _DIR_ in BaseTools MdePkg MdeModulePkg IntelFrameworkPkg IntelFrameworkModulePkg ; do
	source+=("${_TIANO_DIR_}/${_DIR_}::svn+${_TIANOCORE_SVN_URL}/${_DIR_}")
done

sha1sums=('aabac34b2a30e16c5fd105777b9245c2ed0496e4'
          '4d1992699f9b48dd2b7e6bd6c0b25fc065f75894'
          '3d53eb615c3363d45feb95b9bfbf1d5491bf1c24'
          'SKIP'
          'SKIP'
          'SKIP'
          'SKIP'
          'SKIP')

[[ "${CARCH}" == "x86_64" ]] && _TIANO_ARCH="X64"
[[ "${CARCH}" == "i686" ]] && _TIANO_ARCH="IA32"

[[ "${CARCH}" == "x86_64" ]] && _TIANO_S_ARCH="x64"
[[ "${CARCH}" == "i686" ]] && _TIANO_S_ARCH="ia32"

_tianocore_udk_common() {
	
	## Unset all FLAGS
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS
	
	## Setup UDK Environment variables
	export _UDK_DIR="${srcdir}/${_TIANO_DIR_}_build"
	export EDK_TOOLS_PATH="${_UDK_DIR}/BaseTools"
	
	rm -rf "${_UDK_DIR}/" || true
	mkdir -p "${_UDK_DIR}/"
	
	for _DIR_ in BaseTools MdePkg MdeModulePkg IntelFrameworkPkg IntelFrameworkModulePkg ; do
		mv "${srcdir}/${_DIR_}" "${_UDK_DIR}/${_DIR_}"
	done
	
	cd "${_UDK_DIR}/"
	
	## Fix PcdMaximumPathNodeCount compile error
	patch -Np1 -R -i "${srcdir}/UDK-MdePkg-Revert-PathNodeCount.patch"
	echo
	
	## Cleanup UDK config files
	rm -rf "${_UDK_DIR}/Build/" || true
	rm -rf "${_UDK_DIR}/Conf/" || true
	mkdir -p "${_UDK_DIR}/Conf/"
	mkdir -p "${_UDK_DIR}/Build/"
	
	## UDK BaseTools requires python2
	sed 's|python |python2 |g' -i "${EDK_TOOLS_PATH}/BinWrappers/PosixLike"/* || true
	sed 's|python |python2 |g' -i "${EDK_TOOLS_PATH}/Tests/GNUmakefile"
	
	## Fix GCC Warning as error
	sed 's|-Werror |-Wno-error -Wno-unused-but-set-variable |g' -i "${EDK_TOOLS_PATH}/Source/C/Makefiles/header.makefile" || true
	sed 's|-Werror |-Wno-error -Wno-unused-but-set-variable |g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	
	## Fix GCC >=4.7 error - gcc: error: unrecognized command line option '-melf_x86_64'
	sed 's| -m64 --64 -melf_x86_64| -m64|g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	sed 's|--64 | |g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	sed 's| -m64 -melf_x86_64| -m64|g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	
	## Remove GCC -g debug option and add -0s -mabi=ms
	sed 's|DEFINE GCC_ALL_CC_FLAGS            = -g |DEFINE GCC_ALL_CC_FLAGS            = -Os -mabi=ms |g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	sed 's|DEFINE GCC44_ALL_CC_FLAGS            = -g |DEFINE GCC44_ALL_CC_FLAGS            = -Os -mabi=ms |g' -i "${EDK_TOOLS_PATH}/Conf/tools_def.template" || true
	
	## Fix UDK Target Platform
	sed "s|ACTIVE_PLATFORM       = Nt32Pkg/Nt32Pkg.dsc|ACTIVE_PLATFORM       = ${_UDK_TARGET}|g" -i "${EDK_TOOLS_PATH}/Conf/target.template" || true
	sed "s|TARGET                = DEBUG|TARGET                = ${_TIANOCORE_TARGET}|g" -i "${EDK_TOOLS_PATH}/Conf/target.template" || true
	sed "s|TOOL_CHAIN_TAG        = MYTOOLS|TOOL_CHAIN_TAG        = ${_COMPILER}|g" -i "${EDK_TOOLS_PATH}/Conf/target.template" || true
	
	## Setup UDK Environment
	chmod +x "${_UDK_DIR}/BaseTools/BuildEnv"
	source "${_UDK_DIR}/BaseTools/BuildEnv" BaseTools
	echo
	
	## Compile UDK BaseTools
	make -C "${EDK_TOOLS_PATH}"
	echo
	
	## Compile UDK x86_64-UEFI Libraries
	"${EDK_TOOLS_PATH}/BinWrappers/PosixLike/build" -p "${_UDK_TARGET}" -a "${_TIANO_ARCH}" -b "${_TIANOCORE_TARGET}" -t "${_COMPILER}"
	echo
	
	## Fix UDK Target ARCH for rEFInd
	sed "s|IA32|${_TIANO_ARCH}|g" -i "${_UDK_DIR}/Conf/target.txt" || true
	
}

build() {
	
	_tianocore_udk_common
	echo
	
	cd "${srcdir}/refind-${pkgver}/"
	
	## Fix UDK Path in rEFInd Makefiles
	sed "s|EDK2BASE = /usr/local/UDK2010/MyWorkSpace|EDK2BASE = ${_UDK_DIR}|g" -i "${srcdir}/refind-${pkgver}/Make.tiano" || true
	sed "s|EDK2BASE = /usr/local/UDK2010/MyWorkSpace|EDK2BASE = ${_UDK_DIR}|g" -i "${srcdir}/refind-${pkgver}/filesystems/Make.tiano" || true
	sed "s|EDK2BASE = /usr/local/UDK2010/MyWorkSpace|EDK2BASE = ${_UDK_DIR}|g" -i "${srcdir}/refind-${pkgver}/gptsync/Make.tiano" || true
	
	## Unset all FLAGS
	unset CFLAGS
	unset CPPFLAGS
	unset CXXFLAGS
	unset LDFLAGS
	unset MAKEFLAGS
	
	## Compile refind.efi
	make tiano
	
	## Compile UEFI FS drivers
	make fs
	
}

package() {
	
	## Install the rEFInd UEFI application
	install -d "${pkgdir}/usr/lib/refind/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/refind/refind_${_TIANO_S_ARCH}.efi" "${pkgdir}/usr/lib/refind/refind_${_TIANO_S_ARCH}.efi"
	
	## Install UEFI drivers built from rEFInd
	install -d "${pkgdir}/usr/lib/refind/drivers_${_TIANO_S_ARCH}/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/drivers_${_TIANO_S_ARCH}"/*.efi "${pkgdir}/usr/lib/refind/drivers_${_TIANO_S_ARCH}/"
	
	## Install UEFI applications built from rEFInd
	install -d "${pkgdir}/usr/lib/refind/tools_${_TIANO_S_ARCH}"
	install -D -m0644 "${srcdir}/refind-${pkgver}/gptsync/gptsync_${_TIANO_S_ARCH}.efi" "${pkgdir}/usr/lib/refind/tools_${_TIANO_S_ARCH}/gptsync_${_TIANO_S_ARCH}.efi"
	
	## Install the rEFInd config file
	install -d "${pkgdir}/usr/lib/refind/config/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/refind.conf-sample" "${pkgdir}/usr/lib/refind/config/refind.conf"
	install -D -m0644 "${srcdir}/refind_linux.conf" "${pkgdir}/usr/lib/refind/config/refind_linux.conf"
	
	## Install the rEFInd docs
	install -d "${pkgdir}/usr/share/refind/docs/html/"
	install -d "${pkgdir}/usr/share/refind/docs/Styles/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/docs/refind"/* "${pkgdir}/usr/share/refind/docs/html/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/docs/Styles"/* "${pkgdir}/usr/share/refind/docs/Styles/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/README.txt" "${pkgdir}/usr/share/refind/docs/README"
	install -D -m0644 "${srcdir}/refind-${pkgver}/NEWS.txt" "${pkgdir}/usr/share/refind/docs/NEWS"
	rm -f "${pkgdir}/usr/share/refind/docs/html/.DS_Store" || true
	
	## Install the rEFInd fonts
	install -d "${pkgdir}/usr/share/refind/fonts/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/fonts"/* "${pkgdir}/usr/share/refind/fonts/"
	rm -f "${pkgdir}/usr/share/refind/fonts/mkfont.sh"
	
	## Install the rEFInd mkfont.sh
	install -d "${pkgdir}/usr/bin/"
	install -D -m0755 "${srcdir}/refind-${pkgver}/fonts/mkfont.sh" "${pkgdir}/usr/bin/refind-mkfont"
	
	## Install the rEFInd icons
	install -d "${pkgdir}/usr/share/refind/icons/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/icons"/* "${pkgdir}/usr/share/refind/icons/"
	
	## Install the rEFInd images
	install -d "${pkgdir}/usr/share/refind/images/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/images"/*.{png,bmp} "${pkgdir}/usr/share/refind/images/"
	
	## Install the rEFInd keys
	install -d "${pkgdir}/usr/share/refind/keys/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/keys"/* "${pkgdir}/usr/share/refind/keys/"
	
	## Install the rEFIt license file, since rEFInd is a fork of rEFIt
	install -d "${pkgdir}/usr/share/licenses/refind/"
	install -D -m0644 "${srcdir}/refind-${pkgver}/LICENSE.txt" "${pkgdir}/usr/share/licenses/refind/LICENSE"
	
}