~smoser/cirros/trunk.mkcabundle-in-bash

« back to all changes in this revision

Viewing changes to bin/grab-grub-efi

  • Committer: Scott Moser
  • Date: 2011-09-09 22:10:39 UTC
  • Revision ID: smoser@ubuntu.com-20110909221039-l4djwt8a270hzcas
add functional initial configs for buildroot

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
#
3
 
#    Copyright (C) 2016 Linaro Ltd
4
 
#
5
 
#    Authors: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org>
6
 
#
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.
10
 
#
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.
15
 
#
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/>.
18
 
#
19
 
 
20
 
source "${0%/*}/common-functions.sh"
21
 
 
22
 
burl="https://launchpad.net/ubuntu/+archive/primary/+files/"
23
 
outdir="./download"
24
 
def_arches="x86_64 aarch64 i386 arm"
25
 
 
26
 
[ "$1" = "--outdir" ] && { outdir="$1" && shift; }
27
 
gver="$1"
28
 
shift
29
 
 
30
 
if [ $# -eq 0 ]; then
31
 
   set -- ${def_arches}
32
 
fi
33
 
 
34
 
[ -d "$outdir" ] || mkdir -p "$outdir" ||
35
 
   fail "failed mkdir $outdir"
36
 
 
37
 
[ -n "$gver" ] || fail "must give grub version"
38
 
 
39
 
deb2tar() {
40
 
 
41
 
    local deb="$1" tar="$2" efiarch=$3 format=$4
42
 
 
43
 
    t=$(dirname "$deb")
44
 
    tdir=$(mktemp -d "$t/.XXXXXX") || return
45
 
 
46
 
    debug 1 "creating $out in tempdir at $tdir"
47
 
 
48
 
    mkdir -p "$tdir/deb"
49
 
    dpkg -x "$deb" "$tdir/deb" || fail "failed to unpack $deb"
50
 
 
51
 
    efibin=boot${efiarch}.efi
52
 
 
53
 
    "${0%/*}/build-efi-images" grub-mkimage "${tdir}/deb/usr/lib/grub/$format" \
54
 
        "${tdir}/out/" $format $efiarch
55
 
 
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";
62
 
            rm -Rf "$tdir"
63
 
            return 1;
64
 
        }
65
 
    rm -Rf "$tdir"
66
 
    return 0
67
 
    
68
 
}
69
 
 
70
 
for arch in "$@"; do
71
 
    case "$arch" in
72
 
        aarch64)
73
 
                efiarch='aa64'
74
 
                debarch='arm64'
75
 
                pkgarch='arm64'
76
 
                format='arm64-efi'
77
 
                ;;
78
 
        x86_64)
79
 
                efiarch='x64'
80
 
                debarch='amd64'
81
 
                pkgarch='amd64'
82
 
                format='x86_64-efi'
83
 
                ;;
84
 
        i386)
85
 
                efiarch='ia32'
86
 
                debarch='i386'
87
 
                pkgarch='ia32'
88
 
                format='i386-efi'
89
 
                ;;
90
 
        arm)
91
 
                efiarch='arm'
92
 
                debarch='armhf'
93
 
                pkgarch='arm'
94
 
                format='arm-efi'
95
 
                ;;
96
 
        *) debug 1 "no EFI grub for $arch";;
97
 
    esac
98
 
 
99
 
    [ -z $efiarch ] && continue
100
 
 
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"
104
 
    fi  
105
 
    tar="grub-efi-${gver}-${arch}.tar.gz"
106
 
    deb2tar "$outdir/$deb" "$outdir/$tar" $efiarch $format || 
107
 
        fail "failed deb2efi from $deb to $tar"
108
 
    
109
 
    error "wrote $outdir/${tar}"
110
 
    ln -sf "${tar}" "$outdir/grub-efi-${arch}.tar.gz" ||
111
 
        fail "failed symlink for $outdir/grub-$arch.rpm"
112
 
done
113
 
# vi: ts=4 expandtab