forked from motioneye-project/motioneyeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·58 lines (47 loc) · 1.47 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
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <board|all> [mkimage|mkrelease|make_targets...]"
exit 1
fi
set -e # exit at first error
board=$1
target=${*:2}
cd $(dirname $0)
basedir=$(pwd)
osname=$(source $basedir/board/common/overlay/etc/version && echo $os_short_name)
osversion=$(source $basedir/board/common/overlay/etc/version && echo $os_version)
gzip=$(which pigz 2> /dev/null || which gzip 2> /dev/null)
if [ "$board" == "all" ]; then
boards=$(ls $basedir/configs/*_defconfig | grep -v initramfs | grep -oE '\w+_defconfig$' | cut -d '_' -f 1)
for b in $boards; do
if ! $0 $b $target; then
exit 1
fi
done
exit 0
fi
outputdir=$basedir/output/$board
boarddir=$basedir/board/$board
if ! [ -f $basedir/configs/${board}_defconfig ]; then
echo "unknown board: $board"
exit 1
fi
mkdir -p $outputdir
if ! [ -f $outputdir/.config ]; then
make O=$outputdir ${board}_defconfig
fi
if [ "$target" == "mkimage" ]; then
$boarddir/mkimage.sh
elif [ "$target" == "mkrelease" ]; then
$boarddir/mkimage.sh
cp $outputdir/images/$osname-$board.img $basedir
mv $basedir/$osname-$board.img $basedir/$osname-$board-$osversion.img
rm -f $basedir/$osname-$board-$osversion.img.gz
$gzip $basedir/$osname-$board-$osversion.img
echo "your image is ready at $basedir/$osname-$board-$osversion.img.gz"
elif [ -n "$target" ]; then
make O=$outputdir $target
else
make O=$outputdir all
echo "build successful"
fi