Added connection to backend

pull/1/head
parent 6b5ae7a1ae
commit a7e3f235ee

@ -123,6 +123,8 @@ install: check uninstall
done done
@install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop" @install -Dm644 -t "${DESTDIR}${PREFIX}/share/applications/" "${PKGNAME}.desktop"
@install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}" @install -Dm755 -t "${DESTDIR}${PREFIX}/bin/" "${CMAKE_BUILD_DIR}/${PKGNAME}"
@install -Dm644 "com.ublinux.${PKGNAME}.policy" "${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy"
@sed -e '\|annotate key=|s|/usr/bin|${PREFIX}/bin|' -e '/action id=/s/\.run/${PKGIDENT}\.run/' -i ${DESTDIR}/usr/share/polkit-1/actions/com.ublinux.${PKGNAME}${PKGIDENT}.policy
@if [ -z ${DESTDIR} ]; then \ @if [ -z ${DESTDIR} ]; then \
[ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \ [ -d "${DESTDIR}/usr/share/icons/hicolor/" ] && gtk-update-icon-cache -fiq "${DESTDIR}/usr/share/icons/hicolor/" &>/dev/null || true; \
update-desktop-database --quiet &>/dev/null || true; \ update-desktop-database --quiet &>/dev/null || true; \

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
<policyconfig>
<vendor>UBLinux</vendor>
<vendor_url>https://ublinux.ru</vendor_url>
<action id="com.ublinux.ubinstall-gtk.run">
<description>Run "ubinstall-gtk" as root</description>
<description xml:lang="ru">Запуск утилиты ubinstall-gtk с правами root</description>
<message>Authentication is required to run ubinstall-gtk</message>
<message xml:lang="ru">Требуется авторизация для запуска утилиты ubinstall-gtk с правами root</message>
<defaults>
<allow_any>auth_admin</allow_any>
<allow_inactive>auth_admin</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/ubinstall-gtk</annotate>
<annotate key="org.freedesktop.policykit.exec.allow_gui">true</annotate>
</action>
</policyconfig>

@ -254,9 +254,17 @@ gboolean on_image_slide(void *data){
return 1; return 1;
} }
void *on_config_save(char *command); void *on_config_save(void *);
void *on_config_save(char *command){ void *on_config_save(void *){
int size=0;
config_str parameters = yon_config_get_all(&size);
main_config.install_thread=(GThread*)0x1;
FILE *file = fopen(progress_path,"w");
if (file)
fclose(file);
char *command = save_config_command(yon_char_parsed_to_string(parameters,size," "));
if (system(command)){}; if (system(command)){};
main_config.install_thread=(GThread*)0x0;
main_config.config_save_thread=NULL; main_config.config_save_thread=NULL;
return NULL; return NULL;
} }
@ -264,7 +272,7 @@ void *on_config_save(char *command){
void *yon_installation_start(main_window *widgets); void *yon_installation_start(main_window *widgets);
void *yon_installation_start(main_window *widgets){ void *yon_installation_start(main_window *widgets){
int code = system(start_fast_install_command); int code = system(start_fast_install_command);
main_config.install_thread=NULL; // main_config.install_thread=NULL;
main_config.install_complete=1; main_config.install_complete=1;
if (!code) if (!code)
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_COMPLETION);
@ -275,21 +283,49 @@ void *yon_installation_start(main_window *widgets){
void *yon_installation_progress_update(void *data); void *yon_installation_progress_update(void *data);
void *yon_installation_progress_update(void *data){ void *yon_installation_progress_update(void *data){
sleep(1);
main_window *widgets = (main_window*)data; main_window *widgets = (main_window*)data;
FILE *file = fopen(progress_path,"r"); FILE *file = NULL;
char *current = g_malloc0(4096); char *current = g_malloc0(4096);
if (file){ clock_t last_time = 0;
clock_t current_time;
while (main_config.install_thread){ while (main_config.install_thread){
current = fgets(current,4096,file); while (1){
if (current[0]!='#'){ current_time = clock();
if ((double)(current_time - last_time) / CLOCKS_PER_SEC >= 0.5){
if (!file)
file = fopen(progress_path,"r");
if (file){
if (fgets(current,4096,file)){
} else {
if (!yon_char_is_empty(current)&&current[0]=='('){
char * current_copy = yon_char_new(current);
char *percentage = yon_char_divide_search(current_copy,")",-1);
free(yon_char_divide(current_copy,0));
free(yon_char_divide(percentage,0));
if (strcmp(percentage,"#pb")){
double fraction = atof(percentage);
gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),current_copy);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),fraction/100);
} else {
int size; int size;
config_str parsed = yon_char_parse(current,&size,"|"); config_str parsed = yon_char_parse(current_copy,&size," ");
gtk_label_set_text(GTK_LABEL(widgets->InstallationLabel),parsed[1]); double fraction = atof(parsed[3])/100;
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->InstallationProgress),atof(parsed[0])); gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(widgets->PackageInstallationProgress),fraction/100);
} parsed = yon_char_parsed_rip(parsed,&size,3);
gtk_label_set_text(GTK_LABEL(widgets->PackageInstallationLabel),yon_char_parsed_to_string(parsed,size," "));
} }
last_time = current_time;
}
break;
}
}
}
}
fclose(file);
file=NULL;
} }
return NULL; return NULL;
} }
@ -324,8 +360,8 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){
gtk_widget_set_sensitive(widgets->BackButton,0); gtk_widget_set_sensitive(widgets->BackButton,0);
if (main_config.config_save_thread) if (main_config.config_save_thread)
g_thread_join(main_config.config_save_thread); g_thread_join(main_config.config_save_thread);
if (!main_config.install_thread&&!main_config.install_complete) // if (!main_config.install_thread&&!main_config.install_complete)
main_config.install_thread = g_thread_new("InstallThread",(GThreadFunc)yon_installation_start,widgets); // main_config.install_thread = g_thread_new("InstallThread",(GThreadFunc)yon_installation_start,widgets);
if (!main_config.progress_thread) if (!main_config.progress_thread)
main_config.progress_thread = g_thread_new("ProgressThread",(GThreadFunc)yon_installation_progress_update,widgets); main_config.progress_thread = g_thread_new("ProgressThread",(GThreadFunc)yon_installation_progress_update,widgets);
@ -347,9 +383,8 @@ void on_page_changed(GtkWidget *,GtkWidget *,int page, main_window *widgets){
gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))),"com.ublinux.libublsettingsui-gtk3.sync-symbolic",GTK_ICON_SIZE_BUTTON); gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->NextButton))),"com.ublinux.libublsettingsui-gtk3.sync-symbolic",GTK_ICON_SIZE_BUTTON);
gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->CancelInstallButton))),"com.ublinux.libublsettingsui-gtk3.reset-symbolic",GTK_ICON_SIZE_BUTTON); gtk_image_set_from_icon_name(GTK_IMAGE(gtk_button_get_image(GTK_BUTTON(widgets->CancelInstallButton))),"com.ublinux.libublsettingsui-gtk3.reset-symbolic",GTK_ICON_SIZE_BUTTON);
int size=0; pthread_t tid;
config_str parameters = yon_config_get_all(&size); pthread_create(&tid,NULL,on_config_save,NULL);
main_config.config_save_thread = g_thread_new("savethread",(GThreadFunc)on_config_save,save_config_command(yon_char_parsed_to_string(parameters,size," ")));
} }
break; break;
case YON_PAGE_INSTALL_COMMON: case YON_PAGE_INSTALL_COMMON:
@ -481,7 +516,7 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){
char *device; char *device;
gtk_tree_model_get(model,&iter,0,&device,-1); gtk_tree_model_get(model,&iter,0,&device,-1);
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"fast"); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"fast");
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
yon_config_register(device_label_parameter,device_label_parameter_command,device_name); yon_config_register(device_label_parameter,device_label_parameter_command,device_name);
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type); yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
@ -514,8 +549,8 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){
char *part; char *part;
gtk_tree_model_get(model,&iter,0,&part,-1); gtk_tree_model_get(model,&iter,0,&part,-1);
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"next"); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"next");
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOSTART_PARTS_command,part); yon_config_register(AUTOSTART_PARTS,AUTOSTART_PARTS_command,part);
yon_config_register(device_label_parameter,device_label_parameter_command,device_name); yon_config_register(device_label_parameter,device_label_parameter_command,device_name);
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type); yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck))) if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck)))
@ -551,8 +586,8 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){
char *part; char *part;
gtk_tree_model_get(model,&iter,0,&part,-1); gtk_tree_model_get(model,&iter,0,&part,-1);
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"part"); yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_TYPE_INSTALL_command,"part");
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOINSTALL_DEVICE_command,device); yon_config_register(AUTOINSTALL_DEVICE,AUTOINSTALL_DEVICE_command,device);
yon_config_register(AUTOINSTALL_TYPE_INSTALL,AUTOSTART_PARTS_command,part); yon_config_register(AUTOSTART_PARTS,AUTOSTART_PARTS_command,part);
yon_config_register(device_label_parameter,device_label_parameter_command,device_name); yon_config_register(device_label_parameter,device_label_parameter_command,device_name);
yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type); yon_config_register(part_type_parameter,part_type_parameter_command,file_system_type);
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck))) if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->NextInstallationFormatCheck)))
@ -605,9 +640,8 @@ void on_page_navigation_clicked(GtkWidget *self, main_window *widgets){
gtk_widget_set_sensitive(widgets->BackButton,0); gtk_widget_set_sensitive(widgets->BackButton,0);
}break; }break;
case YON_PAGE_INSTALLATION_BEGIN:{ case YON_PAGE_INSTALLATION_BEGIN:{
int size=0; pthread_t tid;
config_str parameters = yon_config_get_all(&size); pthread_create(&tid,NULL,on_config_save,NULL);
main_config.config_save_thread = g_thread_new("savethread",(GThreadFunc)on_config_save,save_config_command(yon_char_parsed_to_string(parameters,size," ")));
gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION); gtk_notebook_set_current_page(GTK_NOTEBOOK(widgets->Notebook),YON_PAGE_INSTALLATION);
} break; } break;
case YON_PAGE_COMPLETION: case YON_PAGE_COMPLETION:

@ -71,7 +71,7 @@ NULL
#define get_devices_command "lsblk --noheadings --nodeps -Jo PATH,SIZE,MODEL,VENDOR,SERIAL --exclude 7,253" #define get_devices_command "lsblk --noheadings --nodeps -Jo PATH,SIZE,MODEL,VENDOR,SERIAL --exclude 7,253"
#define get_parts_and_devices_command "lsblk --noheadings -Jo TYPE,PATH,SIZE,FSTYPE,LABEL,PARTLABEL,MOUNTPOINT,FSUSED,FSUSE% --exclude 7,253" #define get_parts_and_devices_command "lsblk --noheadings -Jo TYPE,PATH,SIZE,FSTYPE,LABEL,PARTLABEL,MOUNTPOINT,FSUSED,FSUSE% --exclude 7,253"
#define AUTOINSTALL_TYPE_INSTALL "AUTOINSTALL[type_install]" #define AUTOINSTALL_TYPE_INSTALL "AUTOINSTALL[install_type]"
#define AUTOINSTALL_DEVICE "AUTOINSTALL[device]" #define AUTOINSTALL_DEVICE "AUTOINSTALL[device]"
#define AUTOSTART_PARTS "AUTOINSTALL[part]" #define AUTOSTART_PARTS "AUTOINSTALL[part]"
@ -110,7 +110,7 @@ NULL
#define part_type_parameter "AUTOINSTALL[part_type]" #define part_type_parameter "AUTOINSTALL[part_type]"
#define part_type_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[part_type]" #define part_type_parameter_command "ubconfig --source global get [autoinstall] AUTOINSTALL[part_type]"
#define save_config_command(parameters) yon_char_append("pkexec ubconfig set [autoinstall] ",parameters) #define save_config_command(parameters) yon_char_unite("pkexec bash -c 'ubconfig set [autoinstall] ",parameters, ";ubinstall2 --test --config /etc/ublinux/autoinstall'", NULL)
#define AUTOINSTALL_TYPE_INSTALL_command "ubconfig --source global get autoinstall AUTOINSTALL[install_type]" #define AUTOINSTALL_TYPE_INSTALL_command "ubconfig --source global get autoinstall AUTOINSTALL[install_type]"
#define AUTOINSTALL_DEVICE_command "ubconfig --source global get autoinstall AUTOINSTALL[device]" #define AUTOINSTALL_DEVICE_command "ubconfig --source global get autoinstall AUTOINSTALL[device]"
@ -118,7 +118,7 @@ NULL
#define start_fast_install_command "ubinstall2 --autoinstall" #define start_fast_install_command "ubinstall2 --autoinstall"
#define progress_path "/tmp/ubinstall/ubinstall_progress.log" #define progress_path "/var/log/ubinstall_progress.log"
#define password_limits_path "/etc/security/pwquiality.conf" #define password_limits_path "/etc/security/pwquiality.conf"

@ -1,12 +1,13 @@
[Desktop Entry] [Desktop Entry]
Version=2.35 Version=2.35
Encoding=UTF-8 Encoding=UTF-8
Name=Установка UBLinux Name=ubinstall-gtk
Name[ru]=Установка UBLinux
Comment=ubinstall-gtk Comment=ubinstall-gtk
Comment[ru]=Установка UBLinux Comment[ru]=Установка UBLinux
Icon=ubinstall-gtk Icon=com.ublinux.ubinstall-gtk
Terminal=false Terminal=false
Type=Application Type=Application
Exec=/bin/ubinstall-gtk Exec=pkexec /bin/ubinstall-gtk
Categories=Settings;System; Categories=Settings;System;
StartupNotify=true StartupNotify=true

Loading…
Cancel
Save