-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·187 lines (185 loc) · 5.8 KB
/
build.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
VERSION=$(cat DEBIAN/control | grep 'Version: ' | sed 's/Version: //g')
PAK=$(cat DEBIAN/control | grep 'Package: ' | sed 's/Package: //g')
ARCH=$(cat DEBIAN/control | grep 'Architecture: '| sed 's/Architecture: //g')
FOLDER="$PAK\_$VERSION\_$ARCH"
FOLDER=$(echo "$FOLDER" | sed 's/\\//g')
OPTIONS="$1"
SETTINGS=$(grep -v "^#" build.conf | sed 's/=/ /g')
META_URL=$(echo "$SETTINGS" | grep "META_URL" | awk '{print $2}')
PACK_URL=$(echo "$SETTINGS" | grep "PACK_URL" | awk '{print $2}')
mkdir ../"$FOLDER"
##############################################################
# #
# #
# COMPILE ANYTHING NECSSARY HERE #
# #
# #
##############################################################
# Instead of compiling, we are building a tar.xz archive of the latest kernel package
# Don't make the archive if --pool passed
if [ "$OPTIONS" != "--pool" ]; then
cd usr/share/edamame
echo -e "\t###\tDOWNLOADING\t###\t"
rsync -vr "$PACK_URL" kernel
rsync -vr "$META_URL" kernel
echo -e "\t###\tDELETING CRUFT\t###\t"
list=$(ls kernel)
for each in $list; do
remove=$(ls kernel/$each | grep -v 'amd64.deb$')
for each2 in $remove; do
rm -rfv kernel/$each/$each2
done
done
meta=$(echo kernel/linux-meta/$(ls kernel/linux-meta | sort -Vr | head -1))
dep=$(dpkg-deb --field $meta Depends | sed 's/, /\\|/g')
cd kernel/linux-upstream
rm -rfv $(ls | sed "/\($dep\)/d")
dep=$(echo "$dep" | sed 's/\\|/ /g' | awk '{print $1}' | sed 's/\(image-\|headers-\)/xanmod_/g')
rm -rfv $(ls | grep "edge")
rm -rfv $(ls | grep "cacule")
cd ../linux-meta
rm -rfv $(ls | grep -v "$dep")
rm -rfv $(ls | grep "edge")
rm -rfv $(ls | grep "cacule")
cd ..
dep=$(echo "$dep" | sed 's/xanmod_//g')
mv linux-upstream "$dep"
cd ..
# delete empty folders
find . -type d -empty -print -delete
echo -e "\t###\tCOMPRESSING\t###\t"
tar --verbose --create --xz -f kernel.tar.xz kernel
echo -e "\t###\tCLEANING\t###\t"
rm -rfv kernel
cd ../../..
fi
# Pshyc - we're compiling shit now
cd usr/bin
echo "Would you like to build with Python 3.11, or 3.12?"
read -p "Exit [0], Do Not Compile [1], Python 3.11 [2], Python 3.12 [3], : " ans
if $(echo "${ans,,}" | grep -qE "1|one|first"); then
vert="dnc"
elif $(echo "${ans,,}" | grep -qE "2|two|second|3.11"); then
vert="3.11"
elif $(echo "${ans,,}" | grep -qE "3|three|third|3.12"); then
vert="3.12"
elif $(echo "${ans,,}" | grep -qE "exit|quit|leave|e|q|x|0|no|zero"); then
echo "Exiting as requested..."
exit 1
else
echo "Input not recognized. Defaulting to Python 3.11"
fi
{
g++ -fPIE -m64 -o edamame edamame.cxx
} || {
echo "Build failed. Try making sure you have 'python${vert}-dev' and 'libpython${vert}-dev' installed" 1>&2
exit 2
}
cd ../..
files_to_edit=$(find "." -maxdepth 10 -type f -name '*.py' -print)
shebang='\#\!/usr/bin/env'
if [ "$vert" == "dnc" ]; then
shebang="$shebang python3"
elif [ "$vert" == "3.11" ]; then
shebang="$shebang python3.11"
elif [ "$vert" == "3.12" ]; then
shebang="$shebang python3.12"
fi
for each in $files_to_edit; do
sed -i "s:\#\!shebang:$shebang:" $each
done
##############################################################
# #
# #
# REMEMBER TO DELETE SOURCE FILES FROM TMP #
# FOLDER BEFORE BUILD #
# #
# #
##############################################################
if [ -d bin ]; then
cp -R bin ../"$FOLDER"/bin
fi
if [ -d etc ]; then
cp -R etc ../"$FOLDER"/etc
fi
if [ -d usr ]; then
cp -R usr ../"$FOLDER"/usr
fi
if [ -d lib ]; then
cp -R lib ../"$FOLDER"/lib
fi
if [ -d lib32 ]; then
cp -R lib32 ../"$FOLDER"/lib32
fi
if [ -d lib64 ]; then
cp -R lib64 ../"$FOLDER"/lib64
fi
if [ -d libx32 ]; then
cp -R libx32 ../"$FOLDER"/libx32
fi
if [ -d sbin ]; then
cp -R sbin ../"$FOLDER"/sbin
fi
if [ -d var ]; then
cp -R var ../"$FOLDER"/var
fi
if [ -d opt ]; then
cp -R opt ../"$FOLDER"/opt
fi
if [ -d srv ]; then
cp -R srv ../"$FOLDER"/srv
fi
##############################################################
# #
# #
# COMPILE ANYTHING NECSSARY HERE #
# #
# #
##############################################################
if [[ "$vert" != "dnc" ]]; then
cp nuitka_compile.sh ../"$FOLDER"/
cp compile.conf ../"$FOLDER"/
base="$PWD"
cd ../"$FOLDER"/
./nuitka_compile.sh --python-ver=$vert
rm -v nuitka_compile.sh compile.conf
cd "$base"
fi
##############################################################
# #
# #
# REMEMBER TO DELETE SOURCE FILES FROM TMP #
# FOLDER BEFORE BUILD #
# #
# #
##############################################################
cp -R DEBIAN ../"$FOLDER"/DEBIAN
mkdir -p usr/share/doc/$PAK
git log > usr/share/doc/$PAK/changelog
cd usr/share/doc/$PAK
tar --verbose --create --xz -f changelog.gz changelog 1>/dev/null
rm changelog
cd ../../../..
base="$PWD"
cp -R usr/share/doc/$PAK ../"$FOLDER"/usr/share/doc/$PAK
cd ..
#DELETE STUFF HERE
if [ "$OPTIONS" != "--pool" ]; then
rm "$base"/usr/share/edamame/kernel.tar.xz
fi
# delete binary files from repo
rm "$base"/usr/bin/edamame
# delete C++ source from package
rm "$FOLDER"/usr/bin/edamame.cxx
# delete Python cache files
if [[ "$vert" != "dnc" ]]; then
find "$FOLDER" -maxdepth 10 -type d -name __pycache__ -exec rm -rfv {} \;
fi
#build the shit
dpkg-deb --build "$FOLDER"
rm -rf "$FOLDER"
cd "$base"
for each in $files_to_edit; do
sed -i "s:$shebang:\#\!shebang:" $each
done