-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·94 lines (77 loc) · 2 KB
/
build.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/bash
#########################################################################
#
# Generate moode audio player image
#
# (C) bitkeeper 2022 http://moodeaudio.org
# License: GPLv3
#
# 2023:
# updated for bookworm
# auto depend install from depends file
#
#########################################################################
ROOT_PATH=`pwd`
echo $ROOT_PATH
uname -m | grep "64" > /dev/null
if [[ $? -eq 1 ]]
then
echo "Support for building 32bits is removed"
exit 1
fi
PI_GEN="$ROOT_PATH/pi-gen-64"
echo "building 64 bit"
PI_GEN_UTILS="$ROOT_PATH/pi-gen-utils"
PI_GEN_CONFIG_DIR="moode-cfg"
# This var is used by pi-gen-utils script as the pi-gen dir
PP=$PI_GEN
function prepare_environment {
# read deps for this build and strip categories
readarray -t DEPENDS < $PI_GEN/depends
count=0
for d in "${DEPENDS[@]}"
do
DEPENDS["$count"]=`echo $d | cut -d ":" -f2`
count=$((count + 1))
done
echo ${DEPENDS[@]}
# check if present
missing=0
for i in "${DEPENDS[@]}"
do
dpkg -s $i 2>&1 | grep Status | grep "installed" > /dev/null 2>&1
if [[ ! $? -eq 0 ]]
then
echo "missing $i"
missing=1
break
fi
done
#if not install the deps
if [ $missing -eq 1 ]
then
echo ${DEPENDS[@]} | xargs sudo apt-get -y install
fi
git submodule init
git submodule update
cat $PI_GEN/build.sh |grep "\-\-allow-downgrades" > /dev/null 2>&1
if [[ ! $? -eq 0 ]]
then
cd $PI_GEN
patch -p1 < ../pi-gen-allowdowngrades.patch
cd ..
fi
}
# setup build environment by checkout pi-gen and pi-gen-utils
echo "Prepare environment:"
prepare_environment
# Setup correct config for pi-gen
echo "Set build config:"
cd $PI_GEN_CONFIG_DIR
rm -rf $PI_GEN/stage3/00-install-packages || true
$PI_GEN_UTILS/setuppigen.sh $PI_GEN
sed -i "s/IMG_NAME[=]\(.*\)/IMG_NAME=\1-arm64/" $PI_GEN/config
# Perform image build
cd $PI_GEN
echo "Starting build:"
sudo ./build.sh