Fix kernel build functionality + add features to detect failures and react.
This commit is contained in:
parent
47e122a3a4
commit
40c32b1ad9
32
bash_aliases
32
bash_aliases
@ -21,6 +21,15 @@ function kernel-build() {
|
|||||||
cwd=$(pwd);
|
cwd=$(pwd);
|
||||||
mkdir -p ~/kernel;
|
mkdir -p ~/kernel;
|
||||||
cd ~/kernel;
|
cd ~/kernel;
|
||||||
|
doNotContinueKernelBuild=0;
|
||||||
|
if [ -f last-build-failed ]; then
|
||||||
|
echo "[*] Resuming last build; delete last-build-failed in the kernel directory before starting a kernel build to re-obtain sources.";
|
||||||
|
rm -f last-build-failed;
|
||||||
|
for _dir in *"linux"*; do
|
||||||
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
||||||
|
done;
|
||||||
|
cd "$linuxdir";
|
||||||
|
else
|
||||||
for _dir in *"linux"*; do
|
for _dir in *"linux"*; do
|
||||||
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
||||||
done;
|
done;
|
||||||
@ -35,6 +44,7 @@ function kernel-build() {
|
|||||||
mv *.deb old-debs/;
|
mv *.deb old-debs/;
|
||||||
echo "[+] Obtaining Sources...";
|
echo "[+] Obtaining Sources...";
|
||||||
apt-get source linux-image-unsigned-$(uname -r);
|
apt-get source linux-image-unsigned-$(uname -r);
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
for _dir in *"linux"*; do
|
for _dir in *"linux"*; do
|
||||||
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
[ -d "${_dir}" ] && linuxdir="${_dir}" && break;
|
||||||
done;
|
done;
|
||||||
@ -48,14 +58,25 @@ function kernel-build() {
|
|||||||
chmod a+x debian/scripts/misc/*;
|
chmod a+x debian/scripts/misc/*;
|
||||||
fakeroot debian/rules clean;
|
fakeroot debian/rules clean;
|
||||||
mkdir -p debian/build/build-generic/certs;
|
mkdir -p debian/build/build-generic/certs;
|
||||||
sudo cp /cert/mok/signing_key.pem ../;
|
sudo cp /cert/mok/signing_key.pem ../ -f;
|
||||||
sudo chmod u=rw,g=rw,o=rw ../signing_key.pem;
|
sudo chmod u=rw,g=rw,o=rw ../signing_key.pem;
|
||||||
|
sudo cp /var/lib/shim-signed/mok/MOK.der ../signing_key.x509 -f;
|
||||||
|
sudo chmod u=rw,g=rw,o=rw ../signing_key.x509;
|
||||||
(((until [ -f debian/build/build-generic/certs/signing_key.pem ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.pem; do sleep 0.1; done) && mv -f ../signing_key.pem debian/build/build-generic/certs/signing_key.pem) &
|
(((until [ -f debian/build/build-generic/certs/signing_key.pem ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.pem; do sleep 0.1; done) && mv -f ../signing_key.pem debian/build/build-generic/certs/signing_key.pem) &
|
||||||
|
(((until [ -f debian/build/build-generic/certs/signing_key.x509 ]; do sleep 0.1; done) && while lsof debian/build/build-generic/certs/signing_key.x509; do sleep 0.1; done) && mv -f ../signing_key.x509 debian/build/build-generic/certs/signing_key.x509) &
|
||||||
|
else
|
||||||
|
echo "[-] Failed to obtain sources!";
|
||||||
|
doNotContinueKernelBuild=1;
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
|
if [ $doNotContinueKernelBuild -eq 0 ]; then
|
||||||
echo "[*] Building kernel...";
|
echo "[*] Building kernel...";
|
||||||
fakeroot debian/rules binary;
|
fakeroot debian/rules binary;
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
echo "[*] Build Complete!";
|
echo "[*] Build Complete!";
|
||||||
rm -f debian/build/build-generic/certs/signing_key.pem;
|
rm -f debian/build/build-generic/certs/signing_key.pem;
|
||||||
rm -f ../signing_key.pem;
|
rm -f ../signing_key.pem;
|
||||||
|
rm -f ../signing_key.x509;
|
||||||
echo "[+] Extracting kernel package...";
|
echo "[+] Extracting kernel package...";
|
||||||
cd ~/kernel;
|
cd ~/kernel;
|
||||||
mkdir -p deb-contents;
|
mkdir -p deb-contents;
|
||||||
@ -88,7 +109,14 @@ function kernel-build() {
|
|||||||
sudo cp linux-lib-rust* /usr/local/mydebs/;
|
sudo cp linux-lib-rust* /usr/local/mydebs/;
|
||||||
sudo update-mydebs;
|
sudo update-mydebs;
|
||||||
cd "$cwd";
|
cd "$cwd";
|
||||||
echo "Kernel Build Finished!";
|
echo "[+] Kernel Build Finished!";
|
||||||
|
else
|
||||||
|
echo "[*] Build Failed!";
|
||||||
|
cd ~/kernel;
|
||||||
|
touch last-build-failed;
|
||||||
|
cd "$cwd";
|
||||||
|
fi;
|
||||||
|
fi;
|
||||||
}
|
}
|
||||||
function install-tar() {
|
function install-tar() {
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user