-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVanilla-mesa-minimal-git.sh
144 lines (138 loc) · 7.72 KB
/
Vanilla-mesa-minimal-git.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
#!/bin/bash
# Function to handle cleanup when script exits or is interrupted
cleanup() {
echo "Cleaning up..."
kill $SUDO_REFRESH_PID 2>/dev/null # Terminate sudo refresh background process
echo "Exiting script..."
exit 1
}
# Trap Ctrl+C and call cleanup function
trap cleanup INT
# Ask for sudo password at the beginning of the script
sudo -v
# Start a background process to refresh sudo and prevent being asked for password twice
( while true; do sudo -v; sleep 270; done ) & # Refresh every 4.5 minutes
SUDO_REFRESH_PID=$! # Save the PID of the background process
# Make directory where we will do our work
mkdir /home/$USER/mesa-minimal-git
cd /home/$USER/mesa-minimal-git
# Create "Packages" directory where at the end all compiled packages will be placed
mkdir Built-Packages
# Clone the Git repositories
git clone https://aur.archlinux.org/llvm-minimal-git.git
git clone https://aur.archlinux.org/lib32-llvm-minimal-git.git
git clone https://aur.archlinux.org/spirv-llvm-translator-minimal-git.git
git clone https://aur.archlinux.org/libclc-minimal-git.git
git clone https://aur.archlinux.org/mesa-minimal-git.git
git clone https://aur.archlinux.org/lib32-mesa-minimal-git.git
git clone https://aur.archlinux.org/lib32-spirv-llvm-translator-minimal-git.git
cd /home/$USER/mesa-minimal-git
arch-nspawn "$CHROOT/root" pacman -Syu --noconfirm
# Move compiled to spirv-llvm-translator-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/spirv-llvm-translator-minimal-git/"
# Make llvm-minimal-git
cd /home/$USER/mesa-minimal-git/llvm-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -- --nocheck
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move the generated packages to lib32-llvm-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/lib32-llvm-minimal-git/"
# Build lib32-llvm-minimal in its folder
cd /home/$USER/mesa-minimal-git/lib32-llvm-minimal-git
# Edit PKGBUILD to disable the check function
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst -- --nocheck
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compiled to spirv-llvm-translator-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/spirv-llvm-translator-minimal-git/"
# Make spirv-llvm-translator-minimal-git
cd /home/$USER/mesa-minimal-git/spirv-llvm-translator-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compild to lib32-spirv-llvm-translator-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/lib32-spirv-llvm-translator-minimal-git"
# Make lib32-spirv-llvm-translator-minimal-git
cd /home/$USER/mesa-minimal-git/lib32-spirv-llvm-translator-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst -I lib32-llvm-libs-minimal-git-*.pkg.tar.zst -I lib32-llvm-minimal-git-*.pkg.tar.zst -I lib32-clang-libs-minimal-git-*.pkg.tar.zst -I lib32-clang-minimal-git-*.pkg.tar.zst -I spirv-llvm-translator-minimal-git-*.pkg.tar.zst
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compiled to libclc-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/libclc-minimal-git/"
# Make libclc-minimal-git
cd /home/$USER/mesa-minimal-git/libclc-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst -I spirv-llvm-translator-minimal-git-*.pkg.tar.zst
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compiled to mesa-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/mesa-minimal-git/"
# Make mesa-minimal-git
cd /home/$USER/mesa-minimal-git/mesa-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst -I spirv-llvm-translator-minimal-git-*.pkg.tar.zst -I libclc-minimal-git-*.pkg.tar.zst
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compiled to lib32-mesa-minimal-git
mv *.pkg.tar.zst "/home/$USER/mesa-minimal-git/lib32-mesa-minimal-git/"
# Make lib32-mesa-minimal-git
cd /home/$USER/mesa-minimal-git/lib32-mesa-minimal-git
sudo makechrootpkg -c -r "$CHROOT" -I llvm-minimal-git-*.pkg.tar.zst -I llvm-libs-minimal-git*.pkg.tar.zst -I clang-libs-minimal-git-*.pkg.tar.zst -I clang-minimal-git-*.pkg.tar.zst -I clang-opencl-headers-minimal-git-*.pkg.tar.zst -I lib32-llvm-libs-minimal-git-*.pkg.tar.zst -I lib32-llvm-minimal-git-*.pkg.tar.zst -I lib32-clang-libs-minimal-git-*.pkg.tar.zst -I lib32-clang-minimal-git-*.pkg.tar.zst -I lib32-clang-opencl-headers-minimal-git-*.pkg.tar.zst -I spirv-llvm-translator-minimal-git-*.pkg.tar.zst -I lib32-spirv-llvm-translator-minimal-git-*.pkg.tar.zst -I libclc-minimal-git-*.pkg.tar.zst -I mesa-minimal-git-*.pkg.tar.zst
# Check the exit status of makechrootpkg command 1
if [ $? -ne 0 ]; then
echo "makechrootpkg command 1 failed. Exiting script."
exit 1
fi
# Move compiled to Built-Packages
mv *.pkg.tar.zst /home/$USER/mesa-minimal-git/Built-Packages
# Install
cd /home/$USER/mesa-minimal-git/Built-Packages
# Step 1: Remove the existing folder
rm -rf /home/$USER/Documents/MAKE/repo-mesa-minimal-git
# Step 2: Recreate the folder
mkdir -p /home/$USER/Documents/MAKE/repo-mesa-minimal-git
# Step 3: Move *.pkg.tar.zst files to the repo folder
mv /home/$USER/mesa-minimal-git/Built-Packages/*.pkg.tar.zst /home/$USER/Documents/MAKE/repo-mesa-minimal-git/
# Make repo
repo-add -n /home/$USER/Documents/MAKE/repo-mesa-minimal-git/mesa-minimal-git.db.tar.gz /home/$USER/Documents/MAKE/repo-mesa-minimal-git/*.pkg.tar.zst
# Step 4: Create a folder with the current date
current_date=$(date +%Y-%m-%d)
target_folder="/home/$USER/Documents/MAKE/mesa-minimal-git-$current_date"
mkdir -p "$target_folder"
# Step 5: Copy *.pkg.tar.zst files to the created folder
cp /home/$USER/Documents/MAKE/repo-mesa-minimal-git/*.pkg.tar.zst "$target_folder"
echo "Packages copied to: $target_folder"
# Ask if the user wants to delete the mesa-minimal-git folder
read -p "Do you want to delete the mesa-minimal-git folder? (Y/n): " delete_folder
if [[ "$delete_folder" =~ ^[Yy]$ ]]; then
rm -rf /home/$USER/mesa-minimal-git
echo "mesa-minimal-git folder deleted."
fi
# Ask if the user wants to install the packages now
read -p "Do you want to install the packages now? (Y/n): " install_packages
if [[ "$install_packages" =~ ^[Yy]$ ]]; then
sudo pacman -Syu # Use sudo for the installation command
else
echo "Installation skipped."
fi
# Cleanup: Kill the sudo refresher process
kill $SUDO_REFRESH_PID 2>/dev/null # Ensure the refresher is terminated
# Final message
echo "Script finished. Exiting."
exit 0