3
# Copyright (C) 2016 Linaro Ltd
5
# Authors: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, version 3 of the License.
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
source "${0%/*}/common-functions.sh"
22
burl="https://launchpad.net/ubuntu/+archive/primary/+files/"
24
def_arches="x86_64 aarch64 i386 arm"
26
[ "$1" = "--outdir" ] && { outdir="$1" && shift; }
34
[ -d "$outdir" ] || mkdir -p "$outdir" ||
35
fail "failed mkdir $outdir"
37
[ -n "$gver" ] || fail "must give grub version"
41
local deb="$1" tar="$2" efiarch=$3 format=$4
44
tdir=$(mktemp -d "$t/.XXXXXX") || return
46
debug 1 "creating $out in tempdir at $tdir"
49
dpkg -x "$deb" "$tdir/deb" || fail "failed to unpack $deb"
51
efibin=boot${efiarch}.efi
53
"${0%/*}/build-efi-images" grub-mkimage "${tdir}/deb/usr/lib/grub/$format" \
54
"${tdir}/out/" $format $efiarch
56
mv "${tdir}/out/grub${efiarch}.efi" "${tdir}/boot${efiarch}.efi"
57
rm -rf "$tdir/{deb,out}"
58
debug 2 "creating grub.tar.gz"
59
tar -C "$tdir/" -czf "$tdir/grub.tar.gz" $efibin &&
60
mv "$tdir/grub.tar.gz" "$tar" || {
61
error "failed creating tarball";
96
*) debug 1 "no EFI grub for $arch";;
99
[ -z $efiarch ] && continue
101
deb="grub-efi-${pkgarch}-bin_${gver}_${debarch}.deb"
102
if [ ! -f "${outdir}/${deb}" ]; then
103
dl $burl/$deb "$outdir/$deb" || fail "failed dl $burl/$deb"
105
tar="grub-efi-${gver}-${arch}.tar.gz"
106
deb2tar "$outdir/$deb" "$outdir/$tar" $efiarch $format ||
107
fail "failed deb2efi from $deb to $tar"
109
error "wrote $outdir/${tar}"
110
ln -sf "${tar}" "$outdir/grub-efi-${arch}.tar.gz" ||
111
fail "failed symlink for $outdir/grub-$arch.rpm"