-
Notifications
You must be signed in to change notification settings - Fork 35
/
docker-entrypoint.sh
executable file
·150 lines (118 loc) · 3.43 KB
/
docker-entrypoint.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash
set -e
echo $(ip r)
DEFAULT_GATEWAY=`ip r | grep default | cut -d ' ' -f 3`
echo "Gateway: $DEFAULT_GATEWAY"
if ( ! ping -q -w 1 -c 1 "${DEFAULT_GATEWAY}" > /dev/null 2>&1 ); then
echo "Internet test failed."
echo "RESULT:"
ping -q -w 1 -c 1 "${DEFAULT_GATEWAY}"
else
echo "Internet test passed."
fi
if [ "$1" = 'kernel' ]; then
# Check if kernel sources have already been downloaded
if [ ! -d kernel-build ]; then
# Download them if missing
git clone https://github.com/jwrdegoede/linux-sunxi.git ./kernel-build
cd kernel-build
else
# Update them if already there
cd kernel-build
git fetch origin
git reset --hard origin/master
fi
# Build another branch
if [ -n "$2" ]; then
if [ "$2" != 'keepconfig' ]; then
git checkout "$2"
fi
fi
# If a config file is provided in input we will use that for kernel building
if [ -f /docker-input/.config ]; then
echo "Using custom kernel config..."
cp /docker-input/.config .config
fi
# patch kernel config for audio crackling
# echo "Patch audio config"
# sed -i "s|CONFIG_INTEL_ATOMISP=y|CONFIG_INTEL_ATOMISP=n|" .config
CPUS=$(getconf _NPROCESSORS_ONLN)
CPUS=$(($CPUS*2+1))
echo "Processors in use for build $CPUS"
# Build kernel
make clean
make -j"$CPUS" deb-pkg LOCALVERSION=-stockmind-gpdpocket
cd ..
# Remove possible old files
rm -f "gpdpocket-kernel-files.zip"
# Try to extract kernel version
KERNELIMAGE=$(ls linux-image-* | head -1)
KERNELVERSION=$(echo "$KERNELIMAGE" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" | head -1)
# Compress kernel files
zip "gpdpocket-kernel-files.zip" *.deb
# Delete old deb files
rm -f *.deb
LABEL=""
NOW=$(date +"%Y%m%d")
if [ -n "$KERNELVERSION" ]; then
LABEL="$NOW-$KERNELVERSION"
else
LABEL="$NOW"
fi
mv "gpdpocket-kernel-files.zip" "/docker-output/gpdpocket-""$LABEL""-kernel-files.zip"
if [ "$2" = 'keepkernel' ]; then
echo "Copy kernel for future respins"
cp "/docker-output/gpdpocket-""$LABEL""-kernel-files.zip" "/docker-input/gpdpocket-""$LABEL""-kernel-files.zip"
fi
exit 0
fi
if [ "$1" = 'respin' ]; then
if [ -z "$2" ]; then
echo "An iso image must be selected!"
exit 1
else
# If node is not present
if [ -d /dev/loop0 ]; then
# Make node for respin
mknod /dev/loop0 b 7 0
fi
cd gpd-pocket-ubuntu-respin
git pull origin master
echo "Images found in folder:"
ls /docker-input/
# Use a local kernel zip if provided
if [ -f /docker-input/gpdpocket-*kernel-files.zip ]; then
cp /docker-input/gpdpocket-*kernel-files.zip ./gpdpocket-kernel-files.zip
echo "Local kernel found!"
else
echo "No local kernel found!"
fi
echo "Starting process..."
LABEL=""
./build.sh "/docker-input/${@:2}"
for i in "$@" ; do
if [[ $i == "unity" ]] ; then
echo "Setting unity label..."
LABEL+="unity-"
continue
fi
done
# Try to extract kernel version
KERNELIMAGE=$(ls linux-image-* | head -1)
KERNELVERSION=$(echo "$KERNELIMAGE" | grep -Eo "[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)?" | head -1)
FILE=$2
# Remove path from file
FILECLEAN="${FILE##*/}"
# Today date
NOW=$(date +"%Y%m%d")
TIMESTAMP=$(date +"%Y%m%d%H%M%S")
if [ -n "$KERNELVERSION" ]; then
LABEL+="$NOW-$KERNELVERSION"
else
LABEL+="$NOW"
fi
mv linuxium-* "/docker-output/gpdpocket-$LABEL-$FILECLEAN"
mv isorespin.log "/docker-output/isorespin-$LABEL-$TIMESTAMP"
fi
exit 0
fi