summaryrefslogtreecommitdiff
path: root/efi/fetch_ref.sh
blob: 67b726b01ff40487a0387a85cc7d8cac1ebfc1b9 (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
#!/bin/bash
# Тянет из 9legacy референсный EFI-загрузчик (nboot/efi) и достаёт из него
# pe64.s (PE32+ обёртка), efi.h и mem.h. Это НЕ наш код — это Plan9/9legacy,
# поэтому качаем, а не храним в репе. Наш код — hello.c/efi_build.sh/mkesp.py.
set -e
cd "$(dirname "$0")"
echo ">> качаю 9legacy nboot.diff ..."
python3 -c "import urllib.request; urllib.request.urlretrieve('http://9legacy.org/9legacy/patch/nboot.diff','nboot.diff')"
python3 - <<'PY'
import re
d=open('nboot.diff').read().splitlines()
want={'pe64.s','efi.h','mem.h'}; cur=None; buf=[]; out={}
for l in d:
    m=re.match(r'^\+\+\+ .*/nboot/efi/(\S+)', l)
    if m:
        if cur: out[cur]='\n'.join(buf)
        cur=m.group(1) if m.group(1) in want else None; buf=[]; continue
    if cur is not None:
        if l.startswith('--- '): out[cur]='\n'.join(buf); cur=None; continue
        if l.startswith('+'): buf.append(l[1:])
if cur: out[cur]='\n'.join(buf)
for k,v in sorted(out.items()): open(k,'w').write(v); print('   извлёк', k, f'({len(v.splitlines())} строк)')
PY
echo ">> готово: pe64.s efi.h mem.h (референс 9legacy)"