forked from nmenon/kernel_patch_verify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkps
executable file
·81 lines (67 loc) · 2.55 KB
/
kps
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
#!/bin/bash
# Use Directly from Docker hub if not provided:
IMG_NAME="${IMG_NAME:-nishanthmenon/arm-kernel-dev}"
# TBD: If we are using from github -> I need to figure out how to get that working..
# If we are building locally
# IMG_NAME=arm-kernel-dev
# Check if docker exists
docker=`which docker`
if [ -z "$docker" ]; then
echo "Please install Docker and Image arm-kernel-dev from:" `dirname $0`
exit 1
fi
dimg=`docker image ls | grep arm-kernel-dev`
if [ -z "$dimg" ]; then
echo "Please install Docker Image arm-kernel-dev from: cd" `dirname $0` ";make"
exit 1
fi
# If we are working off docker image from docker hub, make sure
# we have the latest.
if [ "$IMG_NAME" = "nishanthmenon/arm-kernel-dev" ]; then
docker pull $IMG_NAME
fi
ccache=`which ccache`
if [ -z "ccache" ]; then
if [ ! -d "/tmp/ccache" ]; then
mkdir /tmp/ccache
fi
CCACHEDIR=/tmp/ccache
else
CCACHEDIR=`ccache -s|grep "cache directory"|sed -e "s/\s\s*/ /g"|cut -d ' ' -f3`
fi
GN=`git config --get user.name`
GE=`git config --get user.email`
if [ -z "$GE" -o -z "$GN" ]; then
echo "We need to know who you are to proceed, please check 'git config -l' and fix via:"
echo 'git config --global user.email "you@example.com"'
echo 'git config --global user.name "Your Name"'
exit 3
fi
TMP_PREFIX="kernel_patch_verify_kps"
TMP_GITCONFIG=`mktemp -t $TMP_PREFIX.gitconfig.XXXXXX`
echo '[user]' >$TMP_GITCONFIG
git config --list|grep ^user|cut -d '.' -f2->>$TMP_GITCONFIG
echo '[core]' >>$TMP_GITCONFIG
git config --list|grep ^core|cut -d '.' -f2->>$TMP_GITCONFIG
TMP_PASSWD=`mktemp -t $TMP_PREFIX.passwd.XXXXXX`
TMP_GRP=`mktemp -t $TMP_PREFIX.grp.XXXXXX`
USER_ID=`id -u`
GROUP_ID=`id -g`
getent group $(id -gn) > $TMP_GRP
getent passwd $(id -un) > $TMP_PASSWD
DOCKER_MOUNT_DIRS="-v $TMP_GITCONFIG:$HOME/.gitconfig "
DOCKER_MOUNT_DIRS+="-v $TMP_PASSWD:/etc/passwd:ro "
DOCKER_MOUNT_DIRS+="-v $TMP_GRP:/etc/group:ro "
DOCKER_MOUNT_DIRS+="-v /tmp:/tmp "
DOCKER_MOUNT_DIRS+="-v /opt:/opt "
DOCKER_MOUNT_DIRS+="-v $CCACHEDIR:/ccache "
DOCKER_MOUNT_DIRS+="-v $(pwd):/workdir "
# Mount parent directory if its a worktree
GIT_WORKTREE_COMMONDIR=$(git rev-parse --git-common-dir)
if [[ $GIT_WORKTREE_COMMONDIR != ".git" ]]; then
DOCKER_MOUNT_DIRS+=" -v $GIT_WORKTREE_COMMONDIR:$GIT_WORKTREE_COMMONDIR "
fi
export PATH=/workdir/scripts/dtc/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/opt/cross-gcc-linux-10/bin/:/opt/cross-gcc-linux-9/bin/
# If we wanted to get to bash shell:
docker run --rm -ti --user $USER_ID:$GROUP_ID -e PATH $DOCKER_MOUNT_DIRS "$IMG_NAME" bash
rm -f $TMP_GITCONFIG $TMP_GRP $TMP_PASSWD