summaryrefslogtreecommitdiff
path: root/libre/syslinux/PKGBUILD
blob: 8b3676ccacf145a69484e36fdba16879fcbaa89f (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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
# Maintainer (Arch): Tobias Powalowski <tpowa@archlinux.org>
# Maintainer (Arch): Thomas Bächler <thomas@archlinux.org>
# Contributor (Arch): Keshav Amburay <(the ddoott ridikulus ddoott rat) (aatt) (gemmaeiil) (ddoott) (ccoomm)>
# Maintainer: André Silva <emulatorman@parabola.nu>

## "1" to enable IA32-EFI build in Arch x86_64, "0" to disable
_IA32_EFI_IN_ARCH_X64="1"

_VER="6.03-pre19"
_GIT_TAG="syslinux-${_VER}"

pkgname="syslinux"
pkgver="${_VER/-/}"
pkgrel="1"
arch=('x86_64' 'i686')
pkgdesc="Collection of boot loaders that boot from FAT, ext2/3/4 and btrfs filesystems, from CDs and via PXE (Parabola rebranded)"
url="http://syslinux.zytor.com/"
license=('GPL2')
options=('!makeflags' '!emptydirs')
backup=('boot/syslinux/syslinux.cfg'
        'boot/syslinux/splash.png')
makedepends=('git' 'python2' 'nasm' 'ncurses')
if [[ "$CARCH" == "x86_64" ]]; then
  makedepends+=('lib32-glibc')
fi
depends=('glibc')
optdepends=('perl-passwd-md5:  For md5pass'
            'perl-digest-sha1: For sha1pass'
            'mtools:           For mkdiskimage and syslinux support'
            'gptfdisk:         For GPT support'
            'util-linux:       For isohybrid'
            'efibootmgr:       For EFI support'
            'dosfstools:       For EFI support')
install="${pkgname}.install"
source=("${pkgname}::git+http://git.zytor.com/syslinux/syslinux.git#tag=${_GIT_TAG}"
        "gnu-efi::git+http://git.code.sf.net/p/gnu-efi/code#commit=3c62e78556aea01e9798380cd46794c6ca09d4bd"
        'syslinux.cfg'
        'syslinux-install_update'
        'splash.png')
md5sums=('SKIP'
         'SKIP'
         'f048880b57e2c5a7017ff8804bfda327'
         '9376f18fa3e42fc36cffa4cff0a84c09'
         'cb46ca47c6b6323127d908440057d98f')

_pkgver() {
    cd "${srcdir}/${pkgname}/"
    echo "$(git describe --tags)" | sed -e 's|syslinux-||g' -e 's|-pre|pre|g' -e 's|-|.|g'
}

prepare() {
    
    mv "${srcdir}/${pkgname}" "${srcdir}/${pkgname}-${pkgver}/"
    cd "${srcdir}/${pkgname}-${pkgver}/"
    
    msg "Run git clean"
    git clean -x -d -f
    
    msg "Do not try to build the Windows or DOS installers and DIAG files"
    sed 's|diag libinstaller dos win32 win64 dosutil txt|libinstaller txt|g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|win32/syslinux.exe win64/syslinux64.exe||g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|dosutil/*.com dosutil/*.sys||g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|dos/syslinux.com||g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|INSTALLSUBDIRS = com32 utils dosutil|INSTALLSUBDIRS = com32 utils|g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)|# install -m 644 -c $(INSTALL_DIAG) $(INSTALLROOT)$(DIAGDIR)|g' -i "${srcdir}/${pkgname}-${pkgver}/Makefile" || true
    sed 's|-include $(MAKEDIR)/devel.mk||g' -i "${srcdir}/${pkgname}-${pkgver}/mk/syslinux.mk" || true
    
    msg "Fix FHS manpage path"
    sed 's|/usr/man|/usr/share/man|g' -i "${srcdir}/${pkgname}-${pkgver}/mk/syslinux.mk" || true
    
    cd "${srcdir}/gnu-efi/"
    
    msg "Run git clean for gnu-efi"
    git clean -x -d -f
    
    msg "Revert gnu-efi Makefile 'make install' problamatic commit"
    git revert --no-commit 06744d69273de4945cf0ffcaa4a6abf7cec707b6
    
    msg "Prepare gnu-efi source"
    cp -r "${srcdir}/gnu-efi/gnu-efi-3.0" "${srcdir}/${pkgname}-${pkgver}/gnu-efi/gnu-efi-3.0"
    
    cd "${srcdir}/${pkgname}-${pkgver}/"
    
}

_build_syslinux_bios() {
    
    rm -rf "${srcdir}/${pkgname}-${pkgver}-bios/" || true
    cp -r "${srcdir}/${pkgname}-${pkgver}" "${srcdir}/${pkgname}-${pkgver}-bios"
    
    mkdir -p "${srcdir}/${pkgname}-${pkgver}-bios/OBJDIR"
    cd "${srcdir}/${pkgname}-${pkgver}-bios/"
    
    msg "Do not try to compile bios build with our default LDFLAGS, it will fail"
    unset LDFLAGS
    
    msg "Run make bios"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-bios/OBJDIR" bios
    
    msg "Run make bios installer"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-bios/OBJDIR" bios installer
    
}

_build_syslinux_efi64() {
    
    rm -rf "${srcdir}/${pkgname}-${pkgver}-efi64/" || true
    cp -r "${srcdir}/${pkgname}-${pkgver}" "${srcdir}/${pkgname}-${pkgver}-efi64"
    
    mkdir -p "${srcdir}/${pkgname}-${pkgver}-efi64/OBJDIR/efi64/"
    cd "${srcdir}/${pkgname}-${pkgver}-efi64/gnu-efi/gnu-efi-3.0/"
    
    msg "Unset all compiler FLAGS for gnu-efi efi64 build"
    unset CFLAGS
    unset CPPFLAGS
    unset CXXFLAGS
    unset LDFLAGS
    unset MAKEFLAGS
    
    msg "Run make gnu-efi for syslinux efi64"
    make ARCH="x86_64" -j1
    
    msg "Run make install gnu-efi for syslinux efi64"
    make ARCH="x86_64" PREFIX="${srcdir}/${pkgname}-${pkgver}-efi64/OBJDIR/efi64/" -j1 install
    
    cd "${srcdir}/${pkgname}-${pkgver}-efi64/"
    
    msg "Unset all compiler FLAGS for efi64 build"
    unset CFLAGS
    unset CPPFLAGS
    unset CXXFLAGS
    unset LDFLAGS
    unset MAKEFLAGS
    
    msg "Run make efi64"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi64/OBJDIR" efi64
    
    msg "Run make efi64 installer"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi64/OBJDIR" efi64 installer
    
}

_build_syslinux_efi32() {
    
    rm -rf "${srcdir}/${pkgname}-${pkgver}-efi32/" || true
    cp -r "${srcdir}/${pkgname}-${pkgver}" "${srcdir}/${pkgname}-${pkgver}-efi32"
    
    mkdir -p "${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR/efi32/"
    cd "${srcdir}/${pkgname}-${pkgver}-efi32/gnu-efi/gnu-efi-3.0/"
    
    msg "Unset all compiler FLAGS for gnu-efi efi32 build"
    unset CFLAGS
    unset CPPFLAGS
    unset CXXFLAGS
    unset LDFLAGS
    unset MAKEFLAGS
    
    msg "Run make gnu-efi for syslinux efi32"
    make ARCH="ia32" -j1
    
    msg "Run make install gnu-efi for syslinux efi32"
    make ARCH="ia32" PREFIX="${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR/efi32/" install
    
    cd "${srcdir}/${pkgname}-${pkgver}-efi32/"
    
    msg "Unset all compiler FLAGS for efi32 build"
    unset CFLAGS
    unset CPPFLAGS
    unset CXXFLAGS
    unset LDFLAGS
    unset MAKEFLAGS
    
    msg "Run make efi32"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR" efi32
    
    msg "Run make efi32 installer"
    make PYTHON="python2" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR" efi32 installer
    
}

build() {
    
    cd "${srcdir}/${pkgname}-${pkgver}/"
    
    if [[ "${CARCH}" == "x86_64" ]]; then
        msg "Build syslinux efi64"
        _build_syslinux_efi64
        
        if [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
            msg "Build syslinux efi32"
            _build_syslinux_efi32
        fi
    fi
    
    if [[ "${CARCH}" == "i686" ]]; then
        msg "Build syslinux efi32"
        _build_syslinux_efi32
    fi
    
    msg "Build syslinux bios"
    _build_syslinux_bios
    
}

_package_syslinux_bios() {
    
    cd "${srcdir}/${pkgname}-${pkgver}-bios/"
    
    msg "Install Syslinux bios"
    make INSTALLROOT="${pkgdir}/" AUXDIR="/usr/lib/syslinux/bios/" OBJDIR="${srcdir}/${pkgname}-${pkgver}-bios/OBJDIR" bios install
    
    msg "Remove syslinux.exe,syslinux64.exe,syslinux.com and dosutil dir"
    rm "${pkgdir}/usr/lib/syslinux/bios"/syslinux.{com,exe} || true
    rm "${pkgdir}/usr/lib/syslinux/bios/syslinux64.exe" || true
    rm -rf "${pkgdir}/usr/lib/syslinux/bios/dosutil/" || true
    
    msg "Remove com32 and diag dirs"
    rm -rf "${pkgdir}/usr/lib/syslinux/bios/diag/" || true
    rm -rf "${pkgdir}/usr/lib/syslinux/bios/com32/" || true
    
    msg "Move extlinux binary to /usr/bin"
    install -d "${pkgdir}/usr/bin"
    mv "${pkgdir}/sbin/extlinux" "${pkgdir}/usr/bin/extlinux"
    rm -rf "${pkgdir}/sbin/"
    
    msg "Install syslinux docs"
    install -d "${pkgdir}/usr/share/doc"
    cp -ar "${srcdir}/${pkgname}-${pkgver}/doc" "${pkgdir}/usr/share/doc/syslinux"
    
    msg "Install syslinux.cfg"
    install -D -m0644 "${srcdir}/syslinux.cfg" "${pkgdir}/boot/syslinux/syslinux.cfg"
    
    msg "Install the syslinux-install_update script"
    ## This script is maintained at https://gist.github.com/pyther/772138
    ## Script not yet updated for syslinux-efi
    install -D -m0755 "${srcdir}/syslinux-install_update" "${pkgdir}/usr/bin/syslinux-install_update"
    
    msg "Install Parabola splash"
    install -D -m644 "${srcdir}/splash.png" "${pkgdir}/boot/syslinux/splash.png"
}

_package_syslinux_efi() {
    
    cd "${srcdir}/${pkgname}-${pkgver}/"
    
    if [[ "${CARCH}" == "x86_64" ]]; then
        cd "${srcdir}/${pkgname}-${pkgver}-efi64/"
        msg "Install Syslinux efi64"
        make INSTALLROOT="${pkgdir}/" AUXDIR="/usr/lib/syslinux/" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi64/OBJDIR" efi64 install
        
        if [[ "${_IA32_EFI_IN_ARCH_X64}" == "1" ]]; then
            cd "${srcdir}/${pkgname}-${pkgver}-efi32/"
            msg "Install Syslinux efi32"
            make INSTALLROOT="${pkgdir}/" AUXDIR="/usr/lib/syslinux/" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR" efi32 install
        fi
    fi
    
    if [[ "${CARCH}" == "i686" ]]; then
        cd "${srcdir}/${pkgname}-${pkgver}-efi32/"
        msg "Install Syslinux efi32"
        make INSTALLROOT="${pkgdir}/" AUXDIR="/usr/lib/syslinux/" OBJDIR="${srcdir}/${pkgname}-${pkgver}-efi32/OBJDIR" efi32 install
    fi
    
}

package() {
    
    cd "${srcdir}/${pkgname}-${pkgver}/"
    
    msg "Package Syslinux efi"
    _package_syslinux_efi
    
    msg "Package Syslinux bios"
    _package_syslinux_bios
    
}