updated on Tue Jan 10 12:02:00 UTC 2012
[aur-mirror.git] / grub2-efi-bzr / PKGBUILD
blobaae05f027df0af57fff4b9e4143cbb1364295be8
1 # Maintainer : Keshav P R <(the.ridikulus.rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
3 _pkgname="grub2-efi-bzr"
5 pkgname="${_pkgname}"                   ## Dummy pkgname for AUR interface
7 # pkgname="grub2-efi-x86_64-bzr"        ## Uncomment for grub2 BZR Main Trunk for x86_64-UEFI
8 # pkgname="grub2-efi-x86_64-bzr-exp"    ## Uncomment for grub2 BZR Experimental Branch for x86_64-UEFI
9 # pkgname="grub2-efi-i386-bzr"          ## Uncomment for grub2 BZR Main Trunk for i386-UEFI
10 # pkgname="grub2-efi-i386-bzr-exp"      ## Uncomment for grub2 BZR Experimental Branch for i386-UEFI
12 pkgver="3732"
13 url="http://www.gnu.org/software/grub/"
14 arch=('i686' 'x86_64')
15 license=('GPL3')
17 makedepends=('bzr' 'rsync' 'xz' 'bdf-unifont' 'python2' 'autogen' 'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse')
18 depends=('xz' 'freetype2' 'device-mapper' 'fuse' 'gettext' 'dosfstools' 'efibootmgr')
19 optdepends=('libisoburn: provides xorriso for generating grub2 rescue iso using grub-mkrescue'
20             'mtools: for manipulating FAT fs image files')
22 install="${_pkgname}.install"
23 backup=('etc/default/grub' 'etc/grub.d/40_custom')
24 conflicts=('grub2-common')
26 source=('grub.default'
27         'grub.cfg.uefi.example'
28         'grub2_automake_1.11.2_pkglib_to_pkgdata.patch'
29         'grub-mkconfig-Use_outside_GRUB_PREFIX_if_defined.patch'
30         'archlinux_grub2_mkconfig_fixes.patch')
32 sha256sums=('4f895edb21c59ceae02b55d7a5c1d6881e0d0a229f00e4339f4326b5dfffaf3f'
33             '9d2cdb4ca04b6a8ace90f279e4ad52136d12faae881c07152f2871474d0ecbab'
34             '54c9c9aef89005157b9f3b0250a5601fff52db782eff3882fa5d278344ade111'
35             'df1780d3bc136cfdbc4f942a12d2d27e03b5fa95c4067766059aa132254c42c5'
36             '1247d438774b98792d1a3f7bde64d0def05743b0bff68cae7614e7a8454b3f8d')
39 case "${pkgname}" in
40         grub2-efi-x86_64-bzr )
41                 pkgdesc="The GNU GRand Unified Bootloader version 2 - x86_64 UEFI - BZR Main Trunk with grub-extras"
42                 pkgrel="1"
43                 conflicts+=('grub2-efi-x86_64')
44                 provides=('grub2-efi-x86_64')
45                 _UEFI_ARCH="x86_64"
46                 _trns_name="grub2_efi_x86_64_bzr"
47                 _bzrtrunk="bzr://bzr.savannah.gnu.org/grub/trunk/grub/"
48                 # _bzrtrunk="lp:grub/grub2"
49                 _bzrmod="grub2"
50         ;;
51         grub2-efi-x86_64-bzr-exp )
52                 pkgdesc="The GNU GRand Unified Bootloader version 2 - x86_64 UEFI - BZR Experimental branch with grub-extras"
53                 pkgrel="1"
54                 conflicts+=('grub2-efi-x86_64')
55                 provides=('grub2-efi-x86_64')
56                 _UEFI_ARCH="x86_64"
57                 _trns_name="grub2_efi_x86_64_bzr_exp"
58                 _bzrtrunk="bzr://bzr.savannah.gnu.org/grub/branches/experimental/"
59                 # _bzrtrunk="lp:~the-ridikulus-rat/grub/grub2-bzr-exp"
60                 _bzrmod="grub2_exp"
61         ;;
62         grub2-efi-i386-bzr )
63                 pkgdesc="The GNU GRand Unified Bootloader version 2 - i386 UEFI - BZR Main Trunk with grub-extras"
64                 pkgrel="1"
65                 conflicts+=('grub2-efi-i386')
66                 provides=('grub2-efi-i386')
67                 _UEFI_ARCH="i386"
68                 _trns_name="grub2_efi_i386_bzr"
69                 _bzrtrunk="bzr://bzr.savannah.gnu.org/grub/trunk/grub/"
70                 # _bzrtrunk="lp:grub/grub2"
71                 _bzrmod="grub2"
72         ;;
73         grub2-efi-i386-bzr-exp )
74                 pkgdesc="The GNU GRand Unified Bootloader version 2 - i386 UEFI - BZR Experimental branch with grub-extras"
75                 pkgrel="1"
76                 conflicts+=('grub2-efi-i386')
77                 provides=('grub2-efi-i386')
78                 _UEFI_ARCH="i386"
79                 _trns_name="grub2_efi_i386_bzr_exp"
80                 _bzrtrunk="bzr://bzr.savannah.gnu.org/grub/branches/experimental/"
81                 # _bzrtrunk="lp:~the-ridikulus-rat/grub/grub2-bzr-exp"
82                 _bzrmod="grub2_exp"
83         ;;
84         grub2-efi-bzr )
85                 pkgdesc="The GNU GRand Unified Bootloader version 2 for UEFI systems - BZR Development Version with grub-extras - Dummy pkgname - Edit PKGBUILD for actual pkgname"
86                 pkgrel="1"
87                 _UEFI_ARCH="NULL"
88                 _trns_name="NULL"
89         ;;
90 esac
93 case "${CARCH}" in
94         i686 )
95                 if [[ "${_UEFI_ARCH}" == 'x86_64' ]]; then
96                         echo "${pkgname} package can be built only in a x86_64 system. Exiting."
97                         exit 1
98                 fi
99         ;;
100         x86_64 )
101                 if [[ "${_UEFI_ARCH}" == 'i386' ]]; then
102                         # makedepends+=('gcc-multilib' 'gcc-libs-multilib' 'binutils-multilib' 'libtool-multilib' 'lib32-glibc')
103                         
104                         echo
105                 fi
106         ;;
107 esac
110 ## grub2-extras bzr repo locations
112 _bzrtrunk_lua="bzr://bzr.savannah.gnu.org/grub-extras/lua/"
113 # _bzrtrunk_lua="lp:~the-ridikulus-rat/grub/grub2-extras-lua"
115 _bzrtrunk_gpxe="bzr://bzr.savannah.gnu.org/grub-extras/gpxe/"
116 # _bzrtrunk_gpxe="lp:~the-ridikulus-rat/grub/grub2-extras-gpxe"
119 _update_bzr() {
120         
121         msg "Connecting to BZR server..."
122         
123         if [[ -d "${srcdir}/${_bzrmod}" ]]; then
124                 cd "${srcdir}/${_bzrmod}"
125                 bzr pull "${_bzrtrunk}"
126                 msg "GRUB2 BZR Local repository updated."
127         else
128                 cd "${srcdir}/"
129                 bzr branch "${_bzrtrunk}" "${_bzrmod}"
130                 msg "GRUB2 BZR repository cloned."
131         fi
132         
133         if [[ -d "${srcdir}/${_bzrmod}/grub2-extras" ]]; then
134                 cd "${srcdir}/${_bzrmod}/grub2-extras/"
135                 
136                 if [[ -d "${srcdir}/${_bzrmod}/grub2-extras/lua" ]]; then
137                         cd "${srcdir}/${_bzrmod}/grub2-extras/lua"
138                         bzr pull "${_bzrtrunk_lua}"
139                         echo
140                 else
141                         bzr branch "${_bzrtrunk_lua}" lua
142                         echo
143                 fi
144                 
145                 if [[ -d "${srcdir}/${_bzrmod}/grub2-extras/gpxe" ]]; then
146                         cd "${srcdir}/${_bzrmod}/grub2-extras/gpxe"
147                         bzr pull "${_bzrtrunk_gpxe}"
148                         echo
149                 else
150                         bzr branch "${_bzrtrunk_gpxe}" gpxe
151                         echo
152                 fi
153         else
154                 mkdir -p "${srcdir}/${_bzrmod}/grub2-extras/"
155                 cd "${srcdir}/${_bzrmod}/grub2-extras/"
156                 
157                 bzr branch "${_bzrtrunk_lua}" lua
158                 echo
159                 bzr branch "${_bzrtrunk_gpxe}" gpxe
160                 echo
161         fi
162         
163         cd "${srcdir}/${_bzrmod}/"
164         rsync -Lrtvz translationproject.org::tp/latest/grub/ "${srcdir}/${_bzrmod}/po"
165         (cd "${srcdir}/${_bzrmod}/po" && ls *.po | cut -d. -f1 | xargs) > "${srcdir}/${_bzrmod}/po/LINGUAS"
166         
170 build() {
171         
172         if [[ "${pkgname}" == "${_pkgname}" ]]; then
173                 echo "Please edit the PKGBUILD and uncomment the appropriate pkgname as per your UEFI arch and the grub2 bzr branch you want to compile."
174                 exit 1
175         else
176                 _update_bzr
177         fi
178         
179         rm -rf "${srcdir}/${_bzrmod}_build" || true
180         
181         cp -r "${srcdir}/${_bzrmod}" "${srcdir}/${_bzrmod}_build"
182         cd "${srcdir}/${_bzrmod}_build"
183         
184         patch -Np1 -i "${srcdir}/grub2_automake_1.11.2_pkglib_to_pkgdata.patch"
185         echo
186         
187         patch -Np1 -i "${srcdir}/grub-mkconfig-Use_outside_GRUB_PREFIX_if_defined.patch"
188         echo
189         
190         patch -Np1 -i "${srcdir}/archlinux_grub2_mkconfig_fixes.patch"
191         echo
192         
193         rm -rf "${srcdir}/${_bzrmod}_build/grub2-extras/zfs" || true
194         
195         export GRUB_CONTRIB="${srcdir}/${_bzrmod}_build/grub2-extras/"
196         
197         ## The below step is not required as the script now executes with python3, hence makedepends change from python2 to python pkg
198         ## Seems like python2 is required again - as on 04-JAN-2012 - grub2 bzr mainline rev 3732
199         ## Need to use python2
200         install -D -m0755 "${srcdir}/${_bzrmod}_build/autogen.sh" "${srcdir}/${_bzrmod}_build/autogen_unmodified.sh"
201         sed 's|python |python2 |g' -i "${srcdir}/${_bzrmod}_build/autogen.sh"
202         echo
203         
204         "${srcdir}/${_bzrmod}_build/autogen.sh"
205         echo
206         
207         ## fix unifont.bdf location so grub-mkfont can create *.pf2 files
208         sed 's|/usr/share/fonts/unifont|/usr/share/fonts/misc|g' -i "${srcdir}/${_bzrmod}_build/configure"
209         
210         mkdir -p "${srcdir}/${_bzrmod}_build/BUILD_UEFI_${_UEFI_ARCH}"
211         cd "${srcdir}/${_bzrmod}_build/BUILD_UEFI_${_UEFI_ARCH}"
212         
213         CFLAGS="" ../configure \
214                 --with-platform="efi" \
215                 --target="${_UEFI_ARCH}" \
216                 --host="${CARCH}-unknown-linux-gnu" \
217                 --program-transform-name="s,grub,${_trns_name}," \
218                 --enable-mm-debug \
219                 --enable-device-mapper \
220                 --enable-cache-stats \
221                 --enable-grub-mkfont \
222                 --enable-grub-mount \
223                 --enable-nls \
224                 --disable-efiemu \
225                 --prefix="/usr" \
226                 --bindir="/usr/bin" \
227                 --sbindir="/usr/sbin" \
228                 --mandir="/usr/share/man" \
229                 --infodir="/usr/share/info" \
230                 --datadir="/usr/lib" \
231                 --datarootdir="/usr/share" \
232                 --sysconfdir="/etc" \
233                 --program-prefix="" \
234                 --disable-werror
235         echo
236         
237         CFLAGS="" make
238         echo
239         
243 package() {
244         
245         cd "${srcdir}/${_bzrmod}_build/BUILD_UEFI_${_UEFI_ARCH}"
246         make DESTDIR="${pkgdir}" install
247         echo
248         
249         # move grub2 fonts from /usr/lib/${_trns_name} to /usr/share/${_trns_name} - incorrect path due to grub2_automake_1.11.2_pkglib_to_pkgdata.patch
250         mv "${pkgdir}/usr/lib/${_trns_name}"/{ascii,euro,unicode}.pf2 "${pkgdir}/usr/share/${_trns_name}/"
251         mv "${pkgdir}/usr/lib/${_trns_name}"/{ascii,widthspec}.h "${pkgdir}/usr/share/${_trns_name}/"
252         
253         ## install /etc/default/grub
254         install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
255         
256         ## install example grub2 config file
257         install -D -m0644 "${srcdir}/grub.cfg.uefi.example" "${pkgdir}/usr/share/${_trns_name}/grub.cfg.uefi.example"
258         
259         sed "s|^\(_UEFI_ARCH\)=.*|\1=${_UEFI_ARCH}|g" -i "${startdir}/${_pkgname}.install"
260         sed "s|^\(_trns_name\)=.*|\1=${_trns_name}|g" -i "${startdir}/${_pkgname}.install"
261