-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuildAndChecksum.sh
executable file
·67 lines (56 loc) · 2.04 KB
/
buildAndChecksum.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
set -eu
source "$(dirname "${BASH_SOURCE[0]}")/setup.sh"
: "${num_procs:=$(nproc)}"
GREEN='\033[0;32m'
LGREEN='\033[1;32m'
RED='\033[0;31m'
YELLOW='\033[0;33m'
NC='\033[0m'
targetFileName="lineage-$(get_build_var LINEAGE_VERSION).zip"
targetFile="$ANDROID_PRODUCT_OUT/$targetFileName"
function is_hardlink {
[[ $(stat --printf '%h' "$1") != 1 ]]
}
if [ -e "$targetFile" ]; then
echo -e "${RED}Moving old build file ${LGREEN}$(basename "$targetFile")${NC}"
rm -f "$targetFile.bak"*
for f in "$targetFile"*; do
old_name="$(basename "$f")"
new_name="${old_name/.zip/.bak.zip}"
if is_hardlink "$f"; then
cp -a "$f" "$(dirname "$f")/$new_name"
else
mv "$f" "$(dirname "$f")/$new_name"
fi
done
fi
if [ "${CLEAN_BUILD:-0}" == "1" ]; then
echo -e "${YELLOW}Cleaning build dir"
mka installclean
fi
echo -e "${YELLOW}Starting build...${NC}"
if mka bacon; then
outDir="$OUT_DIR_COMMON_BASE/$(basename "$PWD")"
if [ "${CHECK_LFS:-1}" == "1" ] && grep -rF --files-with-matches "https://git-lfs." "$outDir"; then
echo -e "${RED}Found git LFS files in $outDir!${NC}" && false
fi
otaFile="$ANDROID_PRODUCT_OUT/$(get_build_var TARGET_PRODUCT)-ota-"*.zip
[ ! -e "$otaFile" ] || rm "$otaFile"
if is_hardlink "$targetFile"; then
tmpFile="$(mktemp -p /dev/shm)"
cp -af "$targetFile" "$tmpFile"
mv -f "$tmpFile" "$targetFile"
fi
cs="$(cd "$ANDROID_PRODUCT_OUT" && md5sum "$targetFileName")"
echo -e "${LGREEN}Created ${YELLOW}${targetFile}${LGREEN}, checksum=${YELLOW}${cs% *}${NC}"
echo "$cs" > "$targetFile.md5sum"
cs_f="$targetFile.sha256sum"
[ ! -e "$cs_f" ] || rm "$cs_f"
if [ "${CHECK_KERNEL_CFG:-1}" == "1" ]; then
kernel/sony/msm8998/scripts/extract-ikconfig "$ANDROID_PRODUCT_OUT/kernel" | diff kernel/sony/msm8998/arch/arm64/configs/lineage-msm8998-yoshino-lilac_defconfig -
fi
(cd "$ANDROID_PRODUCT_OUT" && md5sum lineage-*.zip)
mv "$targetFile"* "$OUT_DIR_COMMON_BASE"
else
echo "Failed to build" && false
fi