OSDN Git Service

upg
[joborun/jobcore.git] / grub / PKGBUILD
1 #!/usr/bin/bash
2 # JOBoRun               : Jwm OpenBox Obarun RUNit
3 # Maintainer            : Joe Bo Run <joborun@disroot.org>
4 # PkgSource             : url="https://gittea.disroot.org/joborun-pkg/jobcore/$pkgname"
5 #-----------------------------------------| DESCRIPTION |---------------------------------------
6
7 ## "1" to enable IA32-EFI build in Arch x86_64, "0" to disable
8 _IA32_EFI_IN_ARCH_X64="1"
9
10 ## "1" to enable EMU build, "0" to disable
11 _GRUB_EMU_BUILD="0"
12
13 [[ "${CARCH}" == 'x86_64' ]] && _EFI_ARCH='x86_64'
14 [[ "${CARCH}" == 'i686' ]] && _EFI_ARCH='i386'
15
16 [[ "${CARCH}" == 'x86_64' ]] && _EMU_ARCH='x86_64'
17 [[ "${CARCH}" == 'i686' ]] && _EMU_ARCH='i386'
18
19 pkgname='grub'
20 pkgdesc='GNU GRand Unified Bootloader (2)'
21 epoch=2
22 _tag='53c5000739db114c229fe69ec3d4b76b92441098' # git rev-parse grub-${_pkgver}
23 _gnulib_commit='be584c56eb1311606e5ea1a36363b97bddb6eed3'
24 _unifont_ver='14.0.01'
25 _pkgver=2.06
26 pkgver=${_pkgver/-/}
27 pkgrel=05
28 url='https://www.gnu.org/software/grub/'
29 arch=('x86_64')
30 backup=('etc/default/grub'
31         'etc/grub.d/40_custom')
32 install="${pkgname}.install"
33 options=('!makeflags')
34
35 conflicts=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}" 'grub-legacy')
36 replaces=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
37 provides=('grub-common' 'grub-bios' 'grub-emu' "grub-efi-${_EFI_ARCH}")
38
39 makedepends=('git' 'rsync' 'xz' 'freetype2' 'ttf-liberation' 'python' 'autogen'
40              'texinfo' 'help2man' 'gettext' 'device-mapper' 'fuse2')
41 depends=('sh' 'xz' 'gettext' 'device-mapper')
42 optdepends=('freetype2: For grub-mkfont usage'
43             'fuse2: For grub-mount usage'
44             'dosfstools: For grub-mkrescue FAT FS and EFI support'
45             'lzop: For grub-mkrescue LZO support'
46             'efibootmgr: For grub-install EFI support'
47             'libisoburn: Provides xorriso for generating grub rescue iso using grub-mkrescue'
48             'os-prober: To detect other OSes when generating grub.cfg in BIOS systems'
49             'mtools: For grub-mkrescue FAT FS support')
50
51 if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
52     makedepends+=('libusbx' 'sdl')
53     optdepends+=('libusbx: For grub-emu USB support'
54                  'sdl: For grub-emu SDL support')
55 fi
56
57 source=("git+https://git.savannah.gnu.org/git/grub.git#tag=${_tag}?signed"
58         "git+https://git.savannah.gnu.org/git/gnulib.git#commit=${_gnulib_commit}"
59         "https://ftp.gnu.org/gnu/unifont/unifont-${_unifont_ver}/unifont-${_unifont_ver}.bdf.gz"{,.sig}
60         '0001-00_header-add-GRUB_COLOR_-variables.patch'
61         '0002-10_linux-detect-archlinux-initramfs.patch'
62         'grub.default')
63
64 _backports=(
65         # fs/xfs: Fix unreadable filesystem with v4 superblock
66         'a4b495520e4dc41a896a8b916a64eda9970c50ea'
67 )
68
69 _configure_options=(
70         FREETYPE="pkg-config freetype2"
71         BUILD_FREETYPE="pkg-config freetype2"
72         --enable-mm-debug
73         --enable-nls
74         --enable-device-mapper
75         --enable-cache-stats
76         --enable-grub-mkfont
77         --enable-grub-mount
78         --prefix="/usr"
79         --bindir="/usr/bin"
80         --sbindir="/usr/bin"
81         --mandir="/usr/share/man"
82         --infodir="/usr/share/info"
83         --datarootdir="/usr/share"
84         --sysconfdir="/etc"
85         --program-prefix=""
86         --with-bootdir="/boot"
87         --with-grubdir="grub"
88         --disable-silent-rules
89         --disable-werror
90 )
91
92 prepare() {
93         cd "${srcdir}/grub/"
94
95         echo "Apply backports..."
96         local _c
97         for _c in "${_backports[@]}"; do
98                 git log --oneline -1 "${_c}"
99                 git cherry-pick -n "${_c}"
100         done
101
102         echo "Patch to enable GRUB_COLOR_* variables in grub-mkconfig..."
103         ## Based on http://lists.gnu.org/archive/html/grub-devel/2012-02/msg00021.html
104         patch -Np1 -i "${srcdir}/0001-00_header-add-GRUB_COLOR_-variables.patch"
105
106         echo "Patch to detect of Arch Linux initramfs images by grub-mkconfig..."
107         patch -Np1 -i "${srcdir}/0002-10_linux-detect-archlinux-initramfs.patch"
108
109         echo "Fix DejaVuSans.ttf location so that grub-mkfont can create *.pf2 files for starfield theme..."
110         sed 's|/usr/share/fonts/dejavu|/usr/share/fonts/dejavu /usr/share/fonts/TTF|g' -i "configure.ac"
111
112         echo "Fix mkinitcpio 'rw' FS#36275..."
113         sed 's| ro | rw |g' -i "util/grub.d/10_linux.in"
114
115         echo "Fix OS naming FS#33393..."
116         sed 's|GNU/Linux|Linux|' -i "util/grub.d/10_linux.in"
117
118         echo "Pull in latest language files..."
119         ./linguas.sh
120
121         echo "Avoid problem with unifont during compile of grub..."
122         # http://savannah.gnu.org/bugs/?40330 and https://bugs.archlinux.org/task/37847
123         gzip -cd "${srcdir}/unifont-${_unifont_ver}.bdf.gz" > "unifont.bdf"
124
125         echo "Run bootstrap..."
126         ./bootstrap \
127                 --gnulib-srcdir="${srcdir}/gnulib/" \
128                 --no-git
129
130         echo "Make translations reproducible..."
131         sed -i '1i /^PO-Revision-Date:/ d' po/*.sed
132 }
133
134 _build_grub-common_and_bios() {
135         echo "Set ARCH dependent variables for bios build..."
136         if [[ "${CARCH}" == 'x86_64' ]]; then
137                 _EFIEMU="--enable-efiemu"
138         else
139                 _EFIEMU="--disable-efiemu"
140         fi
141
142         echo "Copy the source for building the bios part..."
143         cp -r "${srcdir}/grub/" "${srcdir}/grub-bios/"
144         cd "${srcdir}/grub-bios/"
145
146         echo "Unset all compiler FLAGS for bios build..."
147         unset CFLAGS
148         unset CPPFLAGS
149         unset CXXFLAGS
150         unset LDFLAGS
151         unset MAKEFLAGS
152
153         echo "Run ./configure for bios build..."
154         ./configure \
155                 --with-platform="pc" \
156                 --target="i386" \
157                 "${_EFIEMU}" \
158                 --enable-boot-time \
159                 "${_configure_options[@]}"
160
161         if [ ! -z "${SOURCE_DATE_EPOCH}" ]; then
162                 echo "Make info pages reproducible..."
163                 touch -d "@${SOURCE_DATE_EPOCH}" $(find -name '*.texi')
164         fi
165
166         echo "Run make for bios build..."
167         make
168 }
169
170 _build_grub-efi() {
171         echo "Copy the source for building the ${_EFI_ARCH} efi part..."
172         cp -r "${srcdir}/grub/" "${srcdir}/grub-efi-${_EFI_ARCH}/"
173         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
174
175         echo "Unset all compiler FLAGS for ${_EFI_ARCH} efi build..."
176         unset CFLAGS
177         unset CPPFLAGS
178         unset CXXFLAGS
179         unset LDFLAGS
180         unset MAKEFLAGS
181
182         echo "Run ./configure for ${_EFI_ARCH} efi build..."
183         ./configure \
184                 --with-platform="efi" \
185                 --target="${_EFI_ARCH}" \
186                 --disable-efiemu \
187                 --enable-boot-time \
188                 "${_configure_options[@]}"
189
190         echo "Run make for ${_EFI_ARCH} efi build..."
191         make
192 }
193
194 _build_grub-emu() {
195         echo "Copy the source for building the emu part..."
196         cp -r "${srcdir}/grub/" "${srcdir}/grub-emu/"
197         cd "${srcdir}/grub-emu/"
198
199         echo "Unset all compiler FLAGS for emu build..."
200         unset CFLAGS
201         unset CPPFLAGS
202         unset CXXFLAGS
203         unset LDFLAGS
204         unset MAKEFLAGS
205
206         echo "Run ./configure for emu build..."
207         ./configure \
208                 --with-platform="emu" \
209                 --target="${_EMU_ARCH}" \
210                 --enable-grub-emu-usb=no \
211                 --enable-grub-emu-sdl=no \
212                 --disable-grub-emu-pci \
213                 "${_configure_options[@]}"
214
215         echo "Run make for emu build..."
216         make
217 }
218
219 build() {
220         cd "${srcdir}/grub/"
221
222         echo "Build grub bios stuff..."
223         _build_grub-common_and_bios
224
225         echo "Build grub ${_EFI_ARCH} efi stuff..."
226         _build_grub-efi
227
228         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
229                 echo "Build grub i386 efi stuff..."
230                 _EFI_ARCH="i386" _build_grub-efi
231         fi
232
233         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
234                 echo "Build grub emu stuff..."
235                 _build_grub-emu
236         fi
237 }
238
239 _package_grub-common_and_bios() {
240         cd "${srcdir}/grub-bios/"
241
242         echo "Run make install for bios build..."
243         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
244
245         echo "Remove gdb debugging related files for bios build..."
246         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.module || true
247         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/*.image || true
248         rm -f "${pkgdir}/usr/lib/grub/i386-pc"/{kernel.exec,gdb_grub,gmodule.pl} || true
249
250         echo "Install /etc/default/grub (used by grub-mkconfig)..."
251         install -D -m0644 "${srcdir}/grub.default" "${pkgdir}/etc/default/grub"
252 }
253
254 _package_grub-efi() {
255         cd "${srcdir}/grub-efi-${_EFI_ARCH}/"
256
257         echo "Run make install for ${_EFI_ARCH} efi build..."
258         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
259
260         echo "Remove gdb debugging related files for ${_EFI_ARCH} efi build..."
261         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.module || true
262         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/*.image || true
263         rm -f "${pkgdir}/usr/lib/grub/${_EFI_ARCH}-efi"/{kernel.exec,gdb_grub,gmodule.pl} || true
264
265         _sbat_file="${pkgdir}/usr/share/grub/sbat.csv"
266         touch "${_sbat_file}"
267         echo "sbat,1,SBAT Version,sbat,1,https://github.com/rhboot/shim/blob/main/SBAT.md" >> "${_sbat_file}"
268         echo "grub,1,Free Software Foundation,grub,${_pkgver},https//www.gnu.org/software/grub/" >> "${_sbat_file}"
269         echo "grub.arch,1,Arch Linux,grub,${_pkgver},https://archlinux.org/packages/core/x86_64/grub/" >> "${_sbat_file}"
270 }
271
272 _package_grub-emu() {
273         cd "${srcdir}/grub-emu/"
274
275         echo "Run make install for emu build..."
276         make DESTDIR="${pkgdir}/" bashcompletiondir="/usr/share/bash-completion/completions" install
277
278         echo "Remove gdb debugging related files for emu build..."
279         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.module || true
280         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/*.image || true
281         rm -f "${pkgdir}/usr/lib/grub/${_EMU_ARCH}-emu"/{kernel.exec,gdb_grub,gmodule.pl} || true
282 }
283
284 package() {
285         cd "${srcdir}/grub/"
286
287         echo "Package grub ${_EFI_ARCH} efi stuff..."
288         _package_grub-efi
289
290         if [[ "${CARCH}" == "x86_64" ]] && [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
291                 echo "Package grub i386 efi stuff..."
292                 _EFI_ARCH="i386" _package_grub-efi
293         fi
294
295         if [[ "${_GRUB_EMU_BUILD}" == "1" ]]; then
296                 echo "Package grub emu stuff..."
297                 _package_grub-emu
298         fi
299
300         echo "Package grub bios stuff..."
301         _package_grub-common_and_bios
302 }
303
304 #---- license gpg-key sha256sums ----
305
306 license=('GPL3')
307
308 validpgpkeys=('E53D497F3FA42AD8C9B4D1E835A93B74E82E4209'  # Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
309               'BE5C23209ACDDACEB20DB0A28C8189F1988C2166'  # Daniel Kiper <dkiper@net-space.pl>
310               '95D2E9AB8740D8046387FD151A09227B1F435A33') # Paul Hardy <unifoundry@unifoundry.com>
311
312 sha256sums=(SKIP
313         SKIP
314         391d194f6307fcd0915daafd360509a734e26f3e4013e63d47deb2530d59e66e # unifont-14.0.01.bdf.gz
315         a76e389b444b2ad4c3a22b68b53c6fe27b66bc412de102d111483940b40eb56c # unifont-14.0.01.bdf.gz.sig
316         5dee6628c48eef79812bb9e86ee772068d85e7fcebbd2b2b8d1e19d24eda9dab # 0001-00_header-add-GRUB_COLOR_-variables.patch
317         8488aec30a93e8fe66c23ef8c23aefda39c38389530e9e73ba3fbcc8315d244d # 0002-10_linux-detect-archlinux-initramfs.patch
318         5f82bf6d68dc690765f447fce8e52a0204d24805b23d63db04020d727b0f13f8) # grub.default