@@ -6,47 +6,54 @@ function printusage {
6
6
7
7
ME_BIN_HASH=" c140d04d792bed555e616065d48bdc327bb78f0213ccc54c0ae95f12b28896a4"
8
8
9
- if [[ " ${BASH_SOURCE[0]} " == " $0 " ]]; then
10
- if [[ " ${1:- } " == " --help" ]]; then
11
- usage
12
- else
13
- if [[ -z " ${COREBOOT_DIR} " ]]; then
14
- echo " ERROR: No COREBOOT_DIR variable defined."
15
- exit 1
16
- fi
17
-
18
- output_dir=" $( realpath " ${1:- ./ } " ) "
19
-
20
- if [[ ! -f " ${output_dir} /me.bin" ]]; then
21
- # Unpack Lenovo's Windows installer into a temporary directory and
22
- # extract the Intel ME blob.
23
- pushd " $( mktemp -d) "
9
+ if [ -e " ${output_dir} /me.bin" ]; then
10
+ echo " me.bin already exists"
11
+ if echo " ${ME_BIN_HASH} ${output_dir} /me.bin" | sha256sum --check; then
12
+ echo " SKIPPING: SHA256 checksum for me.bin matches."
13
+ exit 0
14
+ fi
15
+ echo " me.bin exists but checksum doesn't match. Continuing..."
16
+ fi
24
17
25
- curl -O https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe
26
- innoextract g1rg24ww.exe
18
+ if [[ " ${BASH_SOURCE[0]} " == " $0 " ]]; then
19
+ if [[ " ${1:- } " == " --help" ]]; then
20
+ usage
21
+ else
22
+ if [[ -z " ${COREBOOT_DIR} " ]]; then
23
+ echo " ERROR: No COREBOOT_DIR variable defined."
24
+ exit 1
25
+ fi
27
26
28
- mv app/ME8_5M_Production.bin " ${COREBOOT_DIR} /util/me_cleaner "
27
+ output_dir= " $( realpath " ${1 :- . / } " ) "
29
28
30
- popd
29
+ if [[ ! -f " ${output_dir} /me.bin" ]]; then
30
+ # Unpack Lenovo's Windows installer into a temporary directory and
31
+ # extract the Intel ME blob.
32
+ pushd " $( mktemp -d) " || exit
31
33
32
- # Neutralize and shrink Intel ME. Note that this doesn't include
33
- # --soft-disable to set the "ME Disable" or "ME Disable B" (e.g.,
34
- # High Assurance Program) bits, as they are defined within the Flash
35
- # Descriptor.
36
- # https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot
37
- pushd " ${COREBOOT_DIR} /util/me_cleaner"
34
+ curl -O https://download.lenovo.com/pccbbs/mobiles/g1rg24ww.exe
35
+ innoextract g1rg24ww.exe
38
36
39
- python me_cleaner.py -r -t -O me_shrinked.bin ME8_5M_Production.bin
37
+ mv app/ME8_5M_Production.bin " ${COREBOOT_DIR} /util/me_cleaner"
38
+ rm -rf ./*
39
+ popd || exit
40
40
41
- mv me_shrinked.bin " ${output_dir} /me.bin"
42
- # rm ./*.bin
41
+ # Neutralize and shrink Intel ME. Note that this doesn't include
42
+ # --soft-disable to set the "ME Disable" or "ME Disable B" (e.g.,
43
+ # High Assurance Program) bits, as they are defined within the Flash
44
+ # Descriptor.
45
+ # https://github.com/corna/me_cleaner/wiki/External-flashing#neutralize-and-shrink-intel-me-useful-only-for-coreboot
46
+ pushd " ${COREBOOT_DIR} /util/me_cleaner" || exit
43
47
44
- popd
45
- fi
48
+ python me_cleaner.py -r -t -O me_shrinked.bin ME8_5M_Production.bin
49
+ rm -f ME8_5M_Production.bin
50
+ mv me_shrinked.bin " ${output_dir} /me.bin"
51
+ popd || exit
52
+ fi
46
53
47
- if ! echo " ${ME_BIN_HASH} ${output_dir} /me.bin" | sha256sum --check; then
48
- echo " ERROR: SHA256 checksum for me.bin doesn't match."
49
- exit 1
50
- fi
54
+ if ! echo " ${ME_BIN_HASH} ${output_dir} /me.bin" | sha256sum --check; then
55
+ echo " ERROR: SHA256 checksum for me.bin doesn't match."
56
+ exit 1
51
57
fi
58
+ fi
52
59
fi
0 commit comments