-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild-ospack.sh
More file actions
executable file
·50 lines (42 loc) · 1.77 KB
/
build-ospack.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.77 KB
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
#!/bin/bash
: "${IMG_OUT:=out}"
: "${TESTS_DIR:=src/tests}"
: "${KEEP_SRC:=no}"
: "${TESTS_OUT:=prebuilt/tests}"
: "${TESTS_GIT:=https://github.com/flipperdevices/rk3576-linux-tests.git}"
: "${TESTS_BRANCH:=dev}"
set -e
# Capture Git information
[ -n "${GIT_HASH}" ] || GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")
[ -n "${GIT_BRANCH}" ] || GIT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git describe --tags --exact-match 2>/dev/null || echo "detached")
[ -n "${GIT_MSG}" ] || GIT_MSG=$(git log -1 --pretty=format:"%s" 2>/dev/null | sed 's/[\"()]/\\&/g; s/'"'"'/\\&/g' || echo "unknown")
[ -n "${GIT_INFO}" ] || GIT_INFO="${GIT_BRANCH}@${GIT_HASH}: ${GIT_MSG}"
GIT_INFO=$(echo "$GIT_INFO" | tr -dc '[:alnum:][:space:]')
case "${KEEP_SRC}" in
update)
git -C "${TESTS_DIR}" pull
;;
no)
rm -rf "${TESTS_DIR}"
;;
*)
;;
esac
[ -d "${TESTS_DIR}" ] || git clone --depth 1 -b "${TESTS_BRANCH}" "${TESTS_GIT}" "${TESTS_DIR}"
mkdir -p "$IMG_OUT"
rm -rf "${TESTS_OUT}"
mkdir -p "${TESTS_OUT}"
cp -a "${TESTS_DIR}/." "${TESTS_OUT}/"
if [ -c /dev/kvm -a -w /dev/kvm ]; then
# Have virtualization support, can use fakemachine (default, fast, safe)
DEBOS="debos -c $(nproc) -m 6Gb"
elif [ -f /.dockerenv ]; then
# Running in a container without access to virtualization, fall back to the slow method
DEBOS="debos -b qemu -c $(nproc) -m 6Gb"
elif [ `id -u` -eq 0 ]; then
# Running as root, can use the host mode without fakemachine (fast, less safe)
DEBOS="debos"
else
DEBOS="sudo debos --disable-fakemachine"
fi
$DEBOS --artifactdir="$IMG_OUT" -t gitinfo:"$GIT_INFO" -t testsdir:"${TESTS_OUT}" debian-rk3576-ospack.yaml