xref: /OK3568_Linux_fs/debian/scripts/rockbian.sh (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1#!/bin/bash -e
2
3while getopts "c:" flag
4do
5	case "$flag" in
6		clean)
7			echo "clean build files"
8			;;
9		rebuild)
10			echo "rebuild"
11			REBUILD=1
12			;;
13		arch)
14			echo "set arch"
15			ARCH="$OPTARG"
16			;;
17		mirror)
18			echo "set mirror"
19			MIRROR="$OPTARG"
20			;;
21		*)
22			;;
23	esac
24done
25
26SCRIPTS_DIR=$(realpath $(dirname $0))
27DEBIAN_DIR=$(realpath $SCRIPTS_DIR/..)
28WORK_DIR=$(realpath $DEBIAN_DIR/work)
29
30if [ x$1 = xclean ];then
31./scripts/unmount.sh
32sudo rm -rf $WORK_DIR/rkstage* build.log $WORK_DIR/export-image/*.img
33exit 0
34fi
35
36if [ ! -d $WORK_DIR ]; then
37	git clone https://github.com/RPi-Distro/pi-gen.git $WORK_DIR
38	cd $WORK_DIR && git checkout f01430c9d8f67a4b9719cc00e74a2079d3834d5d -b work && git am $SCRIPTS_DIR/patches/* && cd $DEBIAN_DIR
39	mkdir -p $WORK_DIR/cache
40fi
41
42./scripts/unmount.sh
43sudo TOP_DIR=$(realpath $DEBIAN_DIR/..) MIRROR=${MIRROR:-"http://mirrors.ustc.edu.cn/debian/"} ARCH=${ARCH:-armhf} $WORK_DIR/build.sh -c $SCRIPTS_DIR/config
44./scripts/unmount.sh
45