|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | + |
| 5 | +# released to public domain |
| 6 | + |
| 7 | +help() |
| 8 | +{ |
| 9 | + cat << eof |
| 10 | +
|
| 11 | +usage: $1 [-v] <esp-open-sdk path> |
| 12 | +
|
| 13 | +For each binary-only library file from ESP-NONOS-SDK, this script searches for |
| 14 | +the exact commits and reports matching versions and commit urls. |
| 15 | +
|
| 16 | +The argument must be the ESP-NONOS-SDK git-cloned directory. It is left |
| 17 | +unmodified, and is locally cloned to work with. The local copy is then |
| 18 | +removed. |
| 19 | +
|
| 20 | +Because of libmain.a local tweaks, comparison is done for each .a file by |
| 21 | +extracting object files, removing the potentially modified ones |
| 22 | +(mem_manager.o time.o user_interface.o eagle_lwip_if.o) and doing a md5 |
| 23 | +check against the core files. |
| 24 | +
|
| 25 | +eof |
| 26 | + exit 1 |
| 27 | +} |
| 28 | + |
| 29 | + |
| 30 | +verbose=false |
| 31 | +[ "$1" = "-v" ] && { shift; verbose=true; } |
| 32 | +sdk="$1" |
| 33 | +me="$0" |
| 34 | +core=$(cd ${me%/*}/../../../..; pwd) |
| 35 | + |
| 36 | + |
| 37 | +[ -r "$sdk/lib/libnet80211.a" ] || help "$0" |
| 38 | +[ -r "$core/tools/xtensa-lx106-elf/bin" ] || help "$0" |
| 39 | + |
| 40 | +tmp=$(pwd)/NONOSDK.deleteme |
| 41 | + |
| 42 | +cat << eof |
| 43 | +
|
| 44 | +nonos-sdk = '$sdk' |
| 45 | +core root directory = '$core' |
| 46 | +temporary nonos-sdk clone = '$tmp' |
| 47 | +
|
| 48 | +If libmain.a is not found, it should be the one around the same libpp.a's commit |
| 49 | +
|
| 50 | +eof |
| 51 | + |
| 52 | +md5() |
| 53 | +{ |
| 54 | + mkdir temp |
| 55 | + cd temp |
| 56 | + PATH="$core/tools/xtensa-lx106-elf/bin:$PATH" xtensa-lx106-elf-ar x "$1" |
| 57 | + rm -f mem_manager.o time.o user_interface.o eagle_lwip_if.o |
| 58 | + cat *.o | md5sum |
| 59 | + cd .. |
| 60 | + rm -rf temp |
| 61 | +} |
| 62 | + |
| 63 | +search() |
| 64 | +{ |
| 65 | + rm -rf "$tmp" |
| 66 | + git clone $sdk "$tmp" 1>&2 |
| 67 | + cd "$tmp" |
| 68 | + git reset --hard 1>&2 |
| 69 | + |
| 70 | + corelibs=$(cd "$core/tools/sdk/lib"; ls *.a) |
| 71 | + commits=$(git log|grep ^commit\ | tac | sed 's,commit ,,') |
| 72 | + |
| 73 | + for f in $corelibs; do |
| 74 | + |
| 75 | + git checkout master 1>&2 # needed |
| 76 | + |
| 77 | + if [ -r "$tmp/lib/$f" ]; then |
| 78 | + |
| 79 | + coremd5=$(md5 "$core/tools/sdk/lib/$f") |
| 80 | + found=false |
| 81 | + |
| 82 | + for i in $commits; do |
| 83 | + git reset --hard 1>&2 |
| 84 | + git checkout $i 1>&2 |
| 85 | + |
| 86 | + [ -d "$tmp/lib" ] || continue |
| 87 | + |
| 88 | + espmd5=$(md5 "$tmp/lib/$f") |
| 89 | + if [ "$espmd5" = "$coremd5" ]; then |
| 90 | + tag=$(git describe --tag) |
| 91 | + echo "$tag - https://github.com/espressif/ESP8266_NONOS_SDK/commit/$i - $f" |
| 92 | + found=true |
| 93 | + break |
| 94 | + fi |
| 95 | + done |
| 96 | + |
| 97 | + $found || echo "NOTFOUND - $f" |
| 98 | + fi |
| 99 | + |
| 100 | + done |
| 101 | + |
| 102 | + cd .. |
| 103 | + rm -rf "$tmp" |
| 104 | +} |
| 105 | + |
| 106 | +$verbose && search |
| 107 | +$verbose || search 2>/dev/null |
| 108 | + |
| 109 | +echo "all done" |
0 commit comments