mirror of
https://github.com/ISpillMyDrink/OpenSuperClone.git
synced 2026-05-29 18:11:05 +00:00
Change to driver installation.
OpenSuperClone is no longer responsible for compiling the driver which from now on will be handled by DKMS.
This commit is contained in:
@@ -19,6 +19,9 @@ project(OpenSuperClone
|
||||
LANGUAGES C
|
||||
)
|
||||
|
||||
# OSCDriver version 2.6.1
|
||||
set(OSC_DRIVER_VERSION 2.6.1)
|
||||
|
||||
# If the DEBUG option is enabled, set the build type to Debug and add the define DEBUG
|
||||
option(DEBUG "Enable Debugging" OFF)
|
||||
|
||||
|
||||
+52
-2
@@ -3,7 +3,7 @@
|
||||
[ ! -d build ] && mkdir build
|
||||
|
||||
echo "Configuring..."
|
||||
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local/ $@
|
||||
cmake -S . -B ./build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/ $@
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "CMake failed. Aborting."
|
||||
@@ -27,7 +27,7 @@ else
|
||||
echo "Build succeeded."
|
||||
fi
|
||||
|
||||
echo "Installing OpenSuperClone to /usr/local/..."
|
||||
echo "Installing OpenSuperClone to /usr/..."
|
||||
sudo make install
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
@@ -37,4 +37,54 @@ else
|
||||
echo "Install succeeded."
|
||||
fi
|
||||
|
||||
VERSION=$(grep -oP '(?<=set\(OSC_DRIVER_VERSION ).*(?=\))' ../CMakeLists.txt)
|
||||
echo "Found OSCDriver version $VERSION."
|
||||
|
||||
echo "Adding OSCDriver to DKMS..."
|
||||
sudo dkms add -m oscdriver/$VERSION
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to add OSCDriver to DKMS."
|
||||
else
|
||||
echo "Added OSCDriver to DKMS."
|
||||
fi
|
||||
|
||||
echo "Building OSCDriver..."
|
||||
sudo dkms build -m oscdriver -v $VERSION
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to build OSCDriver."
|
||||
else
|
||||
echo "Built OSCDriver."
|
||||
fi
|
||||
|
||||
echo "Installing OSCDriver..."
|
||||
sudo dkms install -m oscdriver -v $VERSION
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to install OSCDriver."
|
||||
else
|
||||
echo "Installed OSCDriver."
|
||||
fi
|
||||
|
||||
echo "Loading OSCDriver..."
|
||||
sudo modprobe oscdriver
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to load OSCDriver."
|
||||
exit 1
|
||||
else
|
||||
echo "Loaded OSCDriver."
|
||||
fi
|
||||
|
||||
echo "Disabling OSCDriver from loading on boot..."
|
||||
sudo sh -c 'echo "blacklist oscdriver" > /etc/modprobe.d/oscdriver.conf'
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to disable OSCDriver from loading on boot."
|
||||
exit 1
|
||||
else
|
||||
echo "Disabled OSCDriver from loading on boot."
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
@@ -14,4 +14,5 @@ pkg_check_modules(LIBUSB REQUIRED libusb)
|
||||
pkg_check_modules(LIBCONFIG REQUIRED libconfig)
|
||||
|
||||
add_subdirectory(opensuperclone)
|
||||
add_subdirectory(oscdriver)
|
||||
add_subdirectory(oscviewer)
|
||||
@@ -1039,6 +1039,10 @@ void install_driver_ccc(void)
|
||||
message_error_ccc(tempmessage_ccc);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Information"), 0);
|
||||
clear_error_message_ccc();
|
||||
if(superclone_ccc)
|
||||
{
|
||||
initialize_memory_ccc();
|
||||
}
|
||||
driver_installed_ccc = 1;
|
||||
return;
|
||||
}
|
||||
@@ -1053,76 +1057,93 @@ void install_driver_ccc(void)
|
||||
return;
|
||||
}
|
||||
}
|
||||
char tempdir[128];
|
||||
snprintf(tempdir, sizeof(tempdir), "/tmp/hddsctemp%d", process_id_ccc);
|
||||
|
||||
// try loading the driver with modprobe
|
||||
char command[256];
|
||||
snprintf(command, sizeof(command), "rm -rf %s", tempdir);
|
||||
system(command);
|
||||
mkdir(tempdir, 0777);
|
||||
char name[256];
|
||||
snprintf(name, sizeof(name), "%s/%s.c", tempdir, DRIVER_FILE_NAME);
|
||||
FILE *writefile;
|
||||
writefile = fopen(name, "w");
|
||||
if (writefile == NULL)
|
||||
{
|
||||
snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s %s (%s).\n", _("Cannot open for writing"), name, strerror(errno));
|
||||
message_now_ccc(tempmessage_ccc);
|
||||
message_error_ccc(tempmessage_ccc);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
clear_error_message_ccc();
|
||||
return;
|
||||
}
|
||||
unsigned int i;
|
||||
for (i = 0; i < oscdriver_c_len; i++)
|
||||
{
|
||||
fprintf(writefile, "%c", oscdriver_c[i]);
|
||||
}
|
||||
int fp = fileno(writefile);
|
||||
fsync(fp);
|
||||
fclose(writefile);
|
||||
snprintf(command, sizeof(command), "modprobe %s", DRIVER_FILE_NAME);
|
||||
int result = system(command);
|
||||
|
||||
snprintf(command, sizeof(command), "%s/Makefile", tempdir);
|
||||
writefile = fopen(command, "w");
|
||||
if (writefile == NULL)
|
||||
if(result != 0)
|
||||
{
|
||||
snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s %s (%s).\n", _("Cannot open for writing"), command, strerror(errno));
|
||||
snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s", _("Error loading driver\n"));
|
||||
message_now_ccc(tempmessage_ccc);
|
||||
message_error_ccc(tempmessage_ccc);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
clear_error_message_ccc();
|
||||
return;
|
||||
}
|
||||
char obj[256];
|
||||
snprintf(obj, sizeof(obj), "obj-m = %s.o", DRIVER_FILE_NAME);
|
||||
fprintf(writefile, "%s", obj);
|
||||
fp = fileno(writefile);
|
||||
fsync(fp);
|
||||
fclose(writefile);
|
||||
|
||||
snprintf(command, sizeof(command), "(cd %s; make -C/lib/modules/`uname -r`/build M=$PWD)", tempdir);
|
||||
if (system(command))
|
||||
{
|
||||
snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s", _("Make failed, see the console for more information"));
|
||||
message_now_ccc(tempmessage_ccc);
|
||||
message_error_ccc(tempmessage_ccc);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Information"), 0);
|
||||
clear_error_message_ccc();
|
||||
driver_installed_ccc = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(command, sizeof(command), "insmod %s/%s.ko ioctl=%s mmap_m=%s mmap_tb=%s mmap_mdb=%s", tempdir, DRIVER_FILE_NAME, MAIN_DRIVER_IOCTL_NAME, MAIN_DRIVER_MMAP_NAME, MAIN_DRIVER_MMAPTB_NAME, MAIN_DRIVER_MMAPMDB_NAME);
|
||||
if (system(command))
|
||||
{
|
||||
snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s", _("Failed to install driver module, see the console for more information"));
|
||||
message_now_ccc(tempmessage_ccc);
|
||||
message_error_ccc(tempmessage_ccc);
|
||||
print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
clear_error_message_ccc();
|
||||
return;
|
||||
}
|
||||
// char tempdir[128];
|
||||
// snprintf(tempdir, sizeof(tempdir), "/tmp/hddsctemp%d", process_id_ccc);
|
||||
// char command[256];
|
||||
// snprintf(command, sizeof(command), "rm -rf %s", tempdir);
|
||||
// system(command);
|
||||
// mkdir(tempdir, 0777);
|
||||
// char name[256];
|
||||
// snprintf(name, sizeof(name), "%s/%s.c", tempdir, DRIVER_FILE_NAME);
|
||||
// FILE *writefile;
|
||||
// writefile = fopen(name, "w");
|
||||
// if (writefile == NULL)
|
||||
// {
|
||||
// snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s %s (%s).\n", _("Cannot open for writing"), name, strerror(errno));
|
||||
// message_now_ccc(tempmessage_ccc);
|
||||
// message_error_ccc(tempmessage_ccc);
|
||||
// print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
// clear_error_message_ccc();
|
||||
// return;
|
||||
// }
|
||||
// unsigned int i;
|
||||
// for (i = 0; i < oscdriver_c_len; i++)
|
||||
// {
|
||||
// fprintf(writefile, "%c", oscdriver_c[i]);
|
||||
// }
|
||||
// int fp = fileno(writefile);
|
||||
// fsync(fp);
|
||||
// fclose(writefile);
|
||||
|
||||
snprintf(command, sizeof(command), "rm -rf %s", tempdir);
|
||||
system(command);
|
||||
// snprintf(command, sizeof(command), "%s/Makefile", tempdir);
|
||||
// writefile = fopen(command, "w");
|
||||
// if (writefile == NULL)
|
||||
// {
|
||||
// snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s %s (%s).\n", _("Cannot open for writing"), command, strerror(errno));
|
||||
// message_now_ccc(tempmessage_ccc);
|
||||
// message_error_ccc(tempmessage_ccc);
|
||||
// print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
// clear_error_message_ccc();
|
||||
// return;
|
||||
// }
|
||||
// char obj[256];
|
||||
// snprintf(obj, sizeof(obj), "obj-m = %s.o", DRIVER_FILE_NAME);
|
||||
// fprintf(writefile, "%s", obj);
|
||||
// fp = fileno(writefile);
|
||||
// fsync(fp);
|
||||
// fclose(writefile);
|
||||
|
||||
// snprintf(command, sizeof(command), "(cd %s; make -C/lib/modules/`uname -r`/build M=$PWD)", tempdir);
|
||||
// if (system(command))
|
||||
// {
|
||||
// snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s", _("Make failed, see the console for more information"));
|
||||
// message_now_ccc(tempmessage_ccc);
|
||||
// message_error_ccc(tempmessage_ccc);
|
||||
// print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
// clear_error_message_ccc();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// snprintf(command, sizeof(command), "insmod %s/%s.ko ioctl=%s mmap_m=%s mmap_tb=%s mmap_mdb=%s", tempdir, DRIVER_FILE_NAME, MAIN_DRIVER_IOCTL_NAME, MAIN_DRIVER_MMAP_NAME, MAIN_DRIVER_MMAPTB_NAME, MAIN_DRIVER_MMAPMDB_NAME);
|
||||
// if (system(command))
|
||||
// {
|
||||
// snprintf(tempmessage_ccc, TEMP_MESSAGE_SIZE, "%s", _("Failed to install driver module, see the console for more information"));
|
||||
// message_now_ccc(tempmessage_ccc);
|
||||
// message_error_ccc(tempmessage_ccc);
|
||||
// print_gui_error_message_ccc(error_message_ccc, _("Error!"), 1);
|
||||
// clear_error_message_ccc();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// snprintf(command, sizeof(command), "rm -rf %s", tempdir);
|
||||
// system(command);
|
||||
|
||||
if (map_driver_memory_ccc())
|
||||
{
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
set(SOURCES
|
||||
oscdriver.c
|
||||
)
|
||||
|
||||
# Generate config file for OSCDriver
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
|
||||
# Install the config file, the sources, the DKMS config and the Makefile to ./src/oscdriver-${OSC_DRIVER_VERSION}
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION ${CMAKE_INSTALL_PREFIX}/src/oscdriver-${OSC_DRIVER_VERSION})
|
||||
install(FILES ${SOURCES} DESTINATION ${CMAKE_INSTALL_PREFIX}/src/oscdriver-${OSC_DRIVER_VERSION})
|
||||
install(FILES dkms.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/src/oscdriver-${OSC_DRIVER_VERSION})
|
||||
install(FILES Makefile DESTINATION ${CMAKE_INSTALL_PREFIX}/src/oscdriver-${OSC_DRIVER_VERSION})
|
||||
+7
-10
@@ -1,7 +1,11 @@
|
||||
CONFIG_MODULE_SIG=n
|
||||
|
||||
KMOD = oscdriver
|
||||
|
||||
KVERSION = $(shell uname -r)
|
||||
|
||||
obj-m = $(KMOD).o
|
||||
MAKE_FLAGS = -C
|
||||
KDIR = /lib/modules/$(KVERSION)/build
|
||||
|
||||
IOCTL = oscdriverc
|
||||
MMAP_M = oscdrivermap_m
|
||||
MMAP_TB = oscdrivermap_tb
|
||||
@@ -18,15 +22,8 @@ TMPS = $(KMOD).mod \
|
||||
Module.symvers \
|
||||
.tmp_versions
|
||||
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
obj-m = $(KMOD).o
|
||||
else
|
||||
MAKE_FLAGS = -C
|
||||
KDIR ?= /lib/modules/`uname -r`/build
|
||||
|
||||
default:
|
||||
$(MAKE) $(MAKE_FLAGS)$(KDIR) M=$$PWD
|
||||
endif
|
||||
$(MAKE) $(MAKE_FLAGS) $(KDIR) M=$$PWD
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
#define DRIVER_VERSION "@OSC_DRIVER_VERSION@"
|
||||
@@ -3,6 +3,8 @@
|
||||
// the GNU General Public License version 2 or later version.
|
||||
// This software is distributed WITHOUT ANY WARRANTY.
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#include <linux/module.h>
|
||||
@@ -98,8 +100,6 @@
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DRIVER_VERSION "2.6.1"
|
||||
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_DESCRIPTION("Driver for OpenSuperClone");
|
||||
MODULE_AUTHOR("Scott Dwyer and OpenSuperClone contributors");
|
||||
|
||||
+27
-19
@@ -1,40 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Uninstalling OpenSuperClone from /usr/local/..."
|
||||
echo "Uninstalling OpenSuperClone from /usr/..."
|
||||
|
||||
if [ -f /usr/local/bin/opensuperclone ]; then
|
||||
sudo rm -f /usr/local/bin/opensuperclone
|
||||
if [ -f /usr/bin/opensuperclone ]; then
|
||||
sudo rm -f /usr/bin/opensuperclone
|
||||
fi
|
||||
|
||||
if [ -f /usr/local/bin/oscviewer ]; then
|
||||
sudo rm -f /usr/local/bin/oscviewer
|
||||
if [ -f /usr/bin/oscviewer ]; then
|
||||
sudo rm -f /usr/bin/oscviewer
|
||||
fi
|
||||
|
||||
if [ -d /usr/local/bin/oscscripts ]; then
|
||||
sudo rm -rf /usr/local/bin/oscscripts
|
||||
if [ -d /usr/bin/oscscripts ]; then
|
||||
sudo rm -rf /usr/bin/oscscripts
|
||||
fi
|
||||
|
||||
if [ -f /usr/local/share/applications/opensuperclone.desktop ]; then
|
||||
sudo rm -f /usr/local/share/applications/opensuperclone.desktop
|
||||
if [ -f /usr/share/applications/opensuperclone.desktop ]; then
|
||||
sudo rm -f /usr/share/applications/opensuperclone.desktop
|
||||
fi
|
||||
|
||||
if [ -f /usr/local/share/applications/opensupertool.desktop ]; then
|
||||
sudo rm -f /usr/local/share/applications/opensupertool.desktop
|
||||
if [ -f /usr/share/applications/opensupertool.desktop ]; then
|
||||
sudo rm -f /usr/share/applications/opensupertool.desktop
|
||||
fi
|
||||
|
||||
if [ -f /usr/local/share/applications/oscviewer.desktop ]; then
|
||||
sudo rm -f /usr/local/share/applications/oscviewer.desktop
|
||||
if [ -f /usr/share/applications/oscviewer.desktop ]; then
|
||||
sudo rm -f /usr/share/applications/oscviewer.desktop
|
||||
fi
|
||||
|
||||
if [ -d /usr/local/share/locale ]; then
|
||||
for locale in $(ls /usr/local/share/locale); do
|
||||
if [ -f /usr/local/share/locale/$locale/LC_MESSAGES/opensuperclone.mo ]; then
|
||||
sudo rm -f /usr/local/share/locale/$locale/LC_MESSAGES/opensuperclone.mo
|
||||
if [ -d /usr/share/locale ]; then
|
||||
for locale in $(ls /usr/share/locale); do
|
||||
if [ -f /usr/share/locale/$locale/LC_MESSAGES/opensuperclone.mo ]; then
|
||||
sudo rm -f /usr/share/locale/$locale/LC_MESSAGES/opensuperclone.mo
|
||||
fi
|
||||
if [ -f /usr/local/share/locale/$locale/LC_MESSAGES/oscviewer.mo ]; then
|
||||
sudo rm -f /usr/local/share/locale/$locale/LC_MESSAGES/oscviewer.mo
|
||||
if [ -f /usr/share/locale/$locale/LC_MESSAGES/oscviewer.mo ]; then
|
||||
sudo rm -f /usr/share/locale/$locale/LC_MESSAGES/oscviewer.mo
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
VERSION=$(grep -oP '(?<=set\(OSC_DRIVER_VERSION ).*(?=\))' CMakeLists.txt)
|
||||
|
||||
sudo dkms remove -m oscdriver/$VERSION --all
|
||||
|
||||
if [ -d /usr/src/oscdriver-$VERSION ]; then
|
||||
sudo rm -rf /usr/src/oscdriver-$VERSION
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
Reference in New Issue
Block a user