forked from pyavitz/rpi-img-builder
-
Notifications
You must be signed in to change notification settings - Fork 5
/
uscripts
104 lines (91 loc) · 3.15 KB
/
uscripts
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
#!/bin/bash
run_function0 (){
if [[ -f "board.txt" ]]; then
sed -i 's/net.ifnames=0/net.ifnames=0 processor.max_cstate=1 isolcpus=2,3/g' board.txt
fi
}
run_function1 (){
# move sudo no password
rm -f /p2/etc/sudoers.d/010_${USERNAME}-nopasswd
echo "run_function 1 completed"
}
run_function2 (){
# Install the Linuxcnc Debs
# if the linuxcnc folder exists
#if [[ `ls /tmp/devel/linuxcnc-dev/scripts/rip-environment` ]]; then
## move to linuxcnc-dev/src folder
#echo "linuxcnc-dev found, executing git pull"
#cd /tmp/devel/linuxcnc-dev/src
#git pull
## return to linuxcnc-dev folder
#cd ..
#else
## Linuxcnc does not exist so clone it
#mkdir -p /tmp/devel/
#cd /tmp/devel/
#echo "linuxcnc-dev not found, executing git clone"
#git clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
#cd linuxcnc-dev/srcgit clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
#cd linuxcnc-dev/src
##git checkout 2.9
## move to linuxcnc-dev/debian folder
#cd ../debian
##./configure no-docs
#./configure
#cd ..
#fi
# Should now be in linuxcnc-dev folder
# Lets build linuxcnc in/tmp/devel/linuxcnc-dev/src
if [["$CLONE_IN_ROOTFS" == "0"]]; then # We have not cloned thee source in ROOTFS
# we need to clone linuxcnc
rm -rf /tmp/devel
mkdir -p /tmp/devel/
cd /tmp/devel/
git clone https://github.com/LinuxCNC/linuxcnc.git linuxcnc-dev
else # We have cloned thee source in ROOTFS to speed things up, we just need to pull the latest source
cd /tmp/devel/linuxcnc-dev
git pull
fi
cd /tmp/devel/linuxcnc-dev/
git checkout "$BRANCH" # Check out the beanch requested
cd ./debian
### NOTE: Building with $BUILD_DOCS" == "1" will fail if ROOTFS was built with "$BUILD_DOCS" == "0" as dependencies will be missing
if [[ "$BUILD_DOCS" == "1" ]]; then # We will build the docs
./configure
else
./configure no-docs # Skip building docs
fi
cd ..
echo "Building linuxcnc with dpkg-buildpackage "
dpkg-buildpackage -b -uc -j$(nproc)
echo "installing linuxcnc debs"
cd .. # now in /tmp/devel folder
FILES="./*.deb" # we want to dynamically install packagesa in case the file names change
for f in $FILES # We need to install debs in the right order and we don't want debug symbols
do
if [[ $f == *dbgsym*.deb ]]
then
continue # Skip installing this deb file
fi
if [[ $f == *dev*.deb ]]
then
g=$f # save linuxcnc-uspace-dev file name and install it last
continue
fi
echo "Installing $f" # linuxcnc-uspace
dpkg -i "$f" #dpkg will fail if dependencies are not installed in ROOTFS
done
echo "Installing $g" # linuxcnc-uspace-dev
dpkg -i "$g"
# Finished!
echo "Stage 2 All done installing linuxcnc!"
}
run_function3 (){
echo "Entering run_function3"
# Copy debs to output
if [[ `ls p2/tmp/devel/*.deb` ]]; then
mkdir -p output/${BOARD}/linuxcnc
cp -fr p2/tmp/devel/*.deb output/${BOARD}/linuxcnc # copy linuxcnc debs to the output folder
rm -rf p2/tmp/devel # remove /tmp/devel folder which includes linuxcnc-dev to keep image size down
fi
}