Skip to content

Commit

Permalink
Merge pull request #104 from drauger-os-development/dev
Browse files Browse the repository at this point in the history
Greater Wi-Fi card support, bug fixes, massive performance increases
  • Loading branch information
Batcastle authored Oct 18, 2024
2 parents e23bf7b + 2252c6b commit e94da8d
Show file tree
Hide file tree
Showing 49 changed files with 474 additions and 247 deletions.
4 changes: 2 additions & 2 deletions DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Package: edamame
Version: 2.7.8
Version: 2.9.0
Maintainer: Thomas Castleman <[email protected]>
Homepage: https://github.com/drauger-os-development/edamame
Section: admin
Architecture: amd64
Priority: important
Replaces: system-installer (<=2.7.4)
Depends: arch-install-scripts, python3 (>=3.6.7-1~18.04), bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), zenity (>=3.28.1-1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython, tzdata, laptop-detect (>=0.16)
Depends: arch-install-scripts, python3.11, bash, gir1.2-gtk-3.0 (>=3.24.12-1ubuntu1), coreutils (>=8.28-1ubuntu1), apt (>=1.6.11), squashfs-tools (>=1:4.3-6ubuntu0.18.04.1), grub2-common (>=2.02-2ubuntu8.13), initramfs-tools (>=0.130ubuntu3.8), systemd (>=237-3ubuntu10.24), locales (>=2.27-3ubuntu1), procps (>=2:3.3.12-3ubuntu1.1), grep (>=3.1-2), keyboard-configuration, util-linux (>=2.34-0.1ubuntu2), python3-parted (>=3.11.2), python3-psutil (>=5.5.0), python3-apt (>=2.0.0), python3-urllib3 (>=1.26.5-1~exp1), python3-gnupg (>=0.4.5), python3-xmltodict (>=0.11.0), python3-dnspython, tzdata, laptop-detect (>=0.16), libpython3.11
Description: System Installation utility
System Installation utility for Debian-based Operating Systems.
59 changes: 52 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,25 +58,39 @@ fi

# Pshyc - we're compiling shit now
cd usr/bin
echo "Would you like to build with Python 3.10 or 3.11?"
read -p "Python 3.10 [1], Python 3.11 [2], Exit [0]: " ans
if $(echo "${ans,,}" | grep -qE "1|one|first|3.10"); then
vert="3.10"
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.10"
echo "Input not recognized. Defaulting to Python 3.11"
fi
{
g++ -fPIE -m64 -o edamame edamame.cxx $(python"${vert}"-config --ldflags --cflags --embed)
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
##############################################################
# #
# #
Expand Down Expand Up @@ -118,6 +132,30 @@ 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
Expand All @@ -126,6 +164,7 @@ 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
Expand All @@ -136,7 +175,13 @@ rm "$base"/usr/bin/edamame
# delete C++ source from package
rm "$FOLDER"/usr/bin/edamame.cxx
# delete Python cache files
find "$FOLDER" -maxdepth 10 -type d -name __pycache__ -exec rm -rfv {} \;
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
34 changes: 34 additions & 0 deletions compile.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Compilation options
global_options="--show-progress --show-memory --show-modules --remove-output"
mod_options="--no-pyi-file"
sa_options="--python-flag=no_site"
jobs=8

# The below files will be compiled with Nuitka

# Edamame core files
mod usr/share/edamame/common.py
mod usr/share/edamame/auto_partitioner.py

# Edamame Module files
mod usr/share/edamame/modules/make_swap.py
mod usr/share/edamame/modules/set_time.py
mod usr/share/edamame/modules/auto_login_set.py
mod usr/share/edamame/modules/common.py
mod usr/share/edamame/modules/auto_partitioner.py

# UI files
mod usr/share/edamame/UI/common.py
mod usr/share/edamame/UI/auto_partitioner.py
mod usr/share/edamame/UI/main.py

# OEM files
mod usr/share/edamame/oem/auto_partitioner.py
mod usr/share/edamame/oem/post_install/configure/set_time.py
mod usr/share/edamame/oem/post_install/configure/auto_login_set.py

# Other files
mod usr/lib/python3/dist-packages/de_control/__init__.py
mod usr/lib/python3/dist-packages/de_control/_common.py
mod usr/lib/python3/dist-packages/de_control/immersion.py
mod usr/lib/python3/dist-packages/de_control/modify.py
22 changes: 22 additions & 0 deletions etc/edamame/realtek.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"rtl8111b": "r8168-dkms",
"rtl8111c": "r8168-dkms",
"rtl8111d": "r8168-dkms",
"rtl8111e": "r8168-dkms",
"rtl8111f": "r8168-dkms",
"rtl8111g(s)": "r8168-dkms",
"rtl8111h(s)": "r8168-dkms",
"rtl8118(a)(s)": "r8168-dkms",
"rtl8119i": "r8168-dkms",
"rtl8111l": "r8168-dkms",
"rtl8168b": "r8168-dkms",
"rtl8168e": "r8168-dkms",
"rtl8168h": "r8168-dkms",
"rtl8111dp": "r8168-dkms",
"rtl8111ep": "r8168-dkms",
"rtl8111fp": "r8168-dkms",
"rtl8411": "r8168-dkms",
"rtl8411b": "r8168-dkms",
"rtl8821ce": "rtl8821ce-dkms"
}

135 changes: 135 additions & 0 deletions nuitka_compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/usr/bin/bash
# Use this file to parse compile.conf, compile the files listed inside, then remove the source files
# This process requires Nuitka.

### SETUP ###

if $(echo "$*" | grep -qE "\-\-help|\-h"); then
echo -e "Nuitka Compile Script, v0.0.5
\t--dry-run Print what would be run if fully ran.
\t--force, -f Force running on raw Git repo. (Risk of potential data loss)
\t--help, -h Print this help dialog and exit.
\t--preserve-source Build, but do not delete source files after build.
\t--python-ver={python version} Compile with this Python version. If not used, will use the default system version.
"
exit
fi

if $(echo "$*" | grep -qE "\-\-dry\-run"); then
echo "NOTE: DRY RUN MODE ENGAGED!"
dry_run=1
else
dry_run=0
fi

if $(ls -a | grep -q ".git"); then
echo "ERROR: RUNNING ON RAW GIT REPOSITORY"
if $(echo "$*" | grep -qE "\-\-force|\-f"); then
echo "NOTE: OVERRIDING ERROR!!!!!"
echo "IF THIS IS A MISTAKE, RUN \`git reset --hard' to recover any lost data."
else
echo "EXITING TO PROTECT DATA!"
exit 1
fi
fi

if $(echo "$*" | grep -qE "\-\-python\-ver"); then
for each in "$*"; do
if $(echo "$each" | grep -qE "\-\-python\-ver"); then
python_ver=$(echo "$each" | sed 's/=/ /g' | awk '{print $2}' | sed 's/python//g')
which python${python_ver} 1>/dev/null 2>/dev/null
if [ "$?" != "0" ]; then
echo "ERROR: Python version $python_ver not found. Defaulting to default system version."
python_ver=""
fi
break
fi
done
fi
if [ "$python_ver" == "" ]; then
python_ver=$(file $(which python3) | awk '{print $5}' | sed 's/python//g')
fi
pyver="python${python_ver}"

which nuitka 1>/dev/null 2>/dev/null
if [ "$?" == "1" ]; then
which nuitka3 1>/dev/null 2>/dev/null
if [ "$?" == "1" ]; then
echo "FATAL ERROR: Nuitka not found. Please install Nuitka from your package manager."
exit 2
else
nuitka_command=$(which nuitka3)
fi
else
nuitka_command=$(which nuitka)
fi

# Read and parse settings file
settings=$(grep -v "^#" compile.conf)
module_files=$(echo "$settings" | grep "^mod " | awk '{print $2}')
module_settings=$(echo "$settings" | grep "^mod_options=" | sed 's/mod_options=//g' | sed 's/"//g')
standalone_files=$(echo "$settings" | grep "^sa " | awk '{print $2}')
standalone_settings=$(echo "$settings" | grep "^sa_options=" | sed 's/sa_options=//g' | sed 's/"//g')
global_settings=$(echo "$settings" | grep "^global_options=" | sed 's/global_options=//g' | sed 's/"//g')
job_count=$(echo "$settings" | grep "^jobs=" | sed 's/jobs=//g' | sed 's/"//g')

# Get Python version
if $(echo "$*" | grep -qE "\-\-python\-version"); then
for each in "$*"; do
if $(echo "$each" | grep -q "\-\-python\-version"); then
py_vert=$(echo "$each" | sed 's/=/ /g' | awk '{print $2}')
py_command="python$py_vert"
fi
done
if [ "$py_command" == "python" ]; then
py_command=""
else
echo "NOTE: USING PYTHON $py_vert!"
py_command=$py_command -m
fi
fi

### COMPILATION ###

# Compile Modules
if [ "$module_files" != "" ]; then
if [ "$dry_run" == "0" ]; then
for each in $module_files; do
name=${each##*/}
echo -e "\t\t\t### BUILDING $name ###"
$pyver $nuitka_command --module $global_settings $module_settings $each
dest=${each%/*}
source=$(ls ${name%.py}*.so)
mv -v "$source" "$dest"
done
else
echo "Would run: $pyver $nuitka_command --module $global_settings $module_settings"
echo "On each of: $module_files"
fi
else
echo "NOTE: No module files defined for compilation. Skipping module compilation..."
fi

# Compile StandAlone
# Compile Modules
if [ "$sa_files" != "" ]; then
if [ "$dry_run" == "0" ]; then
$pyver $nuitka_command --standalone $global_settings $standalone_settings $standalone_files
else
echo "Would run: $pyver $nuitka_command --standalone $global_settings $standalone_settings $standalone_files"
fi
else
echo "NOTE: No standalone files defined for compilation. Skipping standalone compilation..."
fi

### CLEAN UP ###
if [ "$dry_run" == "0" ]; then
if $(echo "$*" | grep -qE "\-\-preserve\-source"); then
echo "NOTE: Not deleting source files!"
else
rm -vf $module_files $standalone_files
fi
else
echo "Would run: rm -vf $module_files $standalone_files"
fi
33 changes: 1 addition & 32 deletions usr/bin/edamame.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,16 @@
#define int_list vector<int>
#define float_list vector<float>
#define bool_list vector<bool>
#define PY_SSIZE_T_CLEAN

// import libs
#include <iostream>
#include <string>
// #include <bits/stdc++.h>
// #include <sys/stat.h>
// #include <sstream>
#include <vector>
// #include <unistd.h>
// #include <regex>
// #include <stdlib.h>
#include <fstream>
#include <Python.h>
// #include <stdio.h>

using namespace std;

str VERSION = "2.7.8";
str VERSION = "2.9.0";
str R = "\033[0;31m";
str G = "\033[0;32m";
str Y = "\033[1;33m";
Expand All @@ -60,14 +51,6 @@ str HELP = "\n"
"\n"
"Pass nothing to start installer.\n";

wchar_t* Py_Init()
{
wchar_t *program = Py_DecodeLocale("edamame", NULL);
Py_SetProgramName(program);
Py_Initialize();
return program;
}

str run(const char* cmd) {
char buffer[128];
str result = "";
Expand Down Expand Up @@ -97,12 +80,8 @@ void launch(bool boot_time)
str command = "echo 'toor' | sudo -S nice -n -10 /usr/share/edamame/engine.py";
run((command1 + enable).c_str());
cout << Y << "RUNNING LOG LOCATED AT /tmp/edamame.log" << NC << endl;
wchar_t *program = Py_Init();
if (boot_time)
{

PyRun_SimpleString("import de_control.enable as de_enable\n"
"de_enable.immersion()\n");
FILE* file = fopen("/tmp/edamame.log", "w");
if (file != NULL)
{
Expand All @@ -117,16 +96,6 @@ void launch(bool boot_time)
}
command = command + " 2>/tmp/edamame.log 1>&2";
run(command.c_str());
if (boot_time)
{
PyRun_SimpleString("import de_control.disable as de_disable\n"
"de_disable.immersion()\n");
if (Py_FinalizeEx() < 0)
{
exit(120);
}
PyMem_RawFree(program);
}
run((command1 + disable).c_str());
}

Expand Down
7 changes: 4 additions & 3 deletions usr/lib/python3/dist-packages/de_control/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!shebang
# -*- coding: utf-8 -*-
#
# __init__.py
Expand All @@ -22,7 +22,8 @@
#
#
"""DE/WM control lib for Edamame."""
import de_control.enable as enable
import de_control.disable as disable
from de_control.immersion import Immersion as Immersion
import de_control.modify as modify
import de_control._common as _common

del immersion
Loading

0 comments on commit e94da8d

Please sign in to comment.