system_recovery_imagedir = $(SYSTEM_RECOVERY_IMAGE_DIR)
system_recovery_libexecdir = $(SYSTEM_RECOVERY_LIBEXEC_DIR)
-if RECOVERY_GUI
system_recovery_SOURCES = \
- src/system-recovery/process-util.c \
- src/system-recovery/recovery-main.c \
- src/system-recovery/recovery-rui.c
+ src/system-recovery/recovery-main.c
system_recovery_CFLAGS = \
$(AM_CFLAGS) \
-DSYSTEM_RECOVERY_CONFIG_FILE=\""${system_recovery_datadir}/system-recovery.cfg"\" \
- -I $(librui_la_CFLAGS) \
- -I src/system-recovery
$(LIBCONFIG_CFLAGS) \
- -I $(top_srcdir)/src/librui \
-I $(top_srcdir)/src/system-recovery
system_recovery_LDADD = \
$(AM_LIBS) \
- $(LIBCONFIG_LIBS) \
- librui.la
+ $(LIBCONFIG_LIBS)
-system_recovery_libexec_PROGRAMS = \
- system-recovery
+if RECOVERY_GUI
+system_recovery_SOURCES += \
+ src/system-recovery/process-util.c \
+ src/system-recovery/recovery-rui.c
+
+system_recovery_CFLAGS += \
+ -I $(librui_la_CFLAGS) \
+ -I $(top_srcdir)/src/librui
+
+system_recovery_LDADD += \
+ librui.la
system_recovery_image_DATA = \
src/system-recovery/res/images/font.png \
initrd_recovery_install_dropin_DATA += \
src/system-recovery/50-system-recovery-sprd.list
+
+else
+
+system_recovery_SOURCES += \
+ src/system-recovery/recovery-headless.c
endif
+system_recovery_libexec_PROGRAMS = \
+ system-recovery
+
system_recovery_data_DATA = \
src/system-recovery/system-recovery.cfg
# common, wearable
pushd build_non_gui
%make_install
-mv %{buildroot}%{_libexecdir}/system-recovery/recovery-init \
- %{buildroot}%{_libexecdir}/system-recovery/recovery-init.non_gui
+mv %{buildroot}%{_libexecdir}/system-recovery/system-recovery \
+ %{buildroot}%{_libexecdir}/system-recovery/system-recovery.non_gui \
+
mv %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list \
- %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.non_gui
+ %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery-non_gui.list
popd
# mobile
pushd build_gui
%make_install
-mv %{buildroot}%{_libexecdir}/system-recovery/recovery-init \
- %{buildroot}%{_libexecdir}/system-recovery/recovery-init.gui
+mv %{buildroot}%{_libexecdir}/system-recovery/system-recovery \
+ %{buildroot}%{_libexecdir}/system-recovery/system-recovery.gui \
+
mv %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list \
- %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.gui
+ %{buildroot}%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery-gui.list
popd
# reboot-param-helper
install -m 644 units/mnt-inform.mount %{buildroot}%{_unitdir}
ln -s ../mnt-inform.mount %{buildroot}%{_unitdir}/local-fs.target.wants
-%post -n system-recovery-non_gui
-ln -s %{_libexecdir}/system-recovery/recovery-init.non_gui \
- %{_libexecdir}/system-recovery/recovery-init
-mv %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.non_gui \
- %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list
-%preun -n system-recovery-non_gui
-rm -f %{_libexecdir}/system-recovery/recovery-init
-mv %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list \
- %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.non_gui
-
-%post -n system-recovery-gui
-ln -s %{_libexecdir}/system-recovery/recovery-init.gui \
- %{_libexecdir}/system-recovery/recovery-init
-mv %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.gui \
- %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list
-%preun -n system-recovery-gui
-rm -f %{_libexecdir}/system-recovery/recovery-init
-mv %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list \
- %{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.gui
-
%posttrans
%{_libexecdir}/initrd-recovery/mkinitrd-recovery.sh
%defattr(-,root,root,-)
%manifest initrd-recovery.manifest
%{_datadir}/system-recovery/system-recovery.cfg
+%{_libexecdir}/system-recovery/recovery-init
%files -n system-recovery-non_gui
-%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.non_gui
-%{_libexecdir}/system-recovery/recovery-init.non_gui
+%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery-non_gui.list
+%{_libexecdir}/system-recovery/system-recovery.non_gui
%files -n system-recovery-gui
-%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery.list.gui
+%{_datadir}/initrd-recovery/initrd.list.d/50-system-recovery-gui.list
%{_datadir}/system-recovery/res/images/*.png
-%{_libexecdir}/system-recovery/recovery-init.gui
-%{_libexecdir}/system-recovery/system-recovery
+%{_libexecdir}/system-recovery/system-recovery.gui
%files -n reboot-param-helper
%{_unitdir}/mnt-inform.mount
/usr/share/system-recovery/res/images/menu-title.png
/usr/share/system-recovery/res/images/tizen-anim.png
/usr/share/system-recovery/res/images/warning.png')
-m4_ifdef(`RECOVERY_GUI', `@SYSTEM_RECOVERY_LIBEXEC_DIR@/system-recovery')
+m4_ifdef(`RECOVERY_GUI', `@SYSTEM_RECOVERY_LIBEXEC_DIR@/system-recovery.gui', `@SYSTEM_RECOVERY_LIBEXEC_DIR@/system-recovery.non_gui')
"
WITHLIBS="
# LinkFileName:Target
SYMLINKS="
-/usr/bin/system-recovery:@SYSTEM_RECOVERY_LIBEXEC_DIR@/system-recovery
/sbin/recovery-init:@SYSTEM_RECOVERY_LIBEXEC_DIR@/recovery-init
"
--- /dev/null
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <libconfig.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include "config.h"
+#include "log.h"
+#include "system-recovery.h"
+
+#include <asm-generic/setup.h> // for COMMAND_LINE_SIZE
+
+#define KERNEL_CMDLINE_KEY "tizen.recovery"
+
+static char *get_action_from_config(config_t *cfg)
+{
+ config_setting_t *node;
+ const char *action;
+
+ node = config_lookup(cfg, "headless_action");
+ if (!node)
+ return NULL;
+
+ action = config_setting_get_string(node);
+
+ return strdup(action);
+}
+
+// looks for tizen.recovery= key in kernel command line
+static char *get_action_from_cmdline(void)
+{
+ FILE *fp;
+ char cmdline[COMMAND_LINE_SIZE];
+ int len;
+
+ fp = fopen("/proc/cmdline", "r");
+ if (!fp)
+ return NULL;
+
+ char *p = fgets(cmdline, sizeof cmdline, fp);
+ fclose(fp);
+ if (!p)
+ return NULL;
+
+ const char *prefix = KERNEL_CMDLINE_KEY "=";
+ p = strstr(cmdline, prefix);
+ if (!p)
+ return NULL;
+ p += strlen(prefix);
+
+ for (len = 0; *(p + len) != 0 && !isspace(*(p + len)); ++len)
+ ; /* skip */
+
+ return strndup(p, len);
+}
+
+int recovery_headless(config_t *cfg)
+{
+ config_setting_t *node;
+
+ node = config_lookup(cfg, "action_handlers");
+ if (!node)
+ return -ENOENT;
+
+ char *action = get_action_from_cmdline();
+ if (!action)
+ action = get_action_from_config(cfg);
+ if (!action)
+ return -ENOENT;
+
+ const char *handler;
+ int r = config_setting_lookup_string(node, action, &handler);
+ free(action);
+
+ if (r == CONFIG_FALSE)
+ return -ENOENT;
+
+ return system(handler);
+}
#!/bin/bash
-SYSTEM_RECOVERY="/usr/bin/system-recovery"
+[ "@RECOVERY_GUI@" = "GUI" ] && suffix=".gui" || suffix=".non_gui"
+SYSTEM_RECOVERY="@SYSTEM_RECOVERY_LIBEXEC_DIR@/system-recovery${suffix}"
FAKE_ROOT=/system
GREP="/usr/bin/grep"
# For debugging - It should be deleted on Release
/sbin/agetty -l /bin/bash -n --keep-baud 115200,38400,9600 ttyS1 linux &
-if [ "z@RECOVERY_GUI@" == "zGUI" ]; then
- "$SYSTEM_RECOVERY"
-else
- $TOUCH ${FAKE_ROOT}/opt/.factoryreset
- if [ $? -ne 0 ]; then
- echo "Error: failed to put factory reset file flag."
- fi
-fi
+"${SYSTEM_RECOVERY}"
+
umount_partitions
do_reboot
#include <sys/types.h>
#include <sys/reboot.h>
-#include <asm-generic/setup.h> // for COMMAND_LINE_SIZE
-
#include <vconf/vconf-keys.h>
-#include "rui.h"
-#include "common.h"
-#include "graphics.h"
-#include "input-events.h"
-#include "process-util.h"
#include "system-recovery.h"
-#include "rui-progress-bar.h"
-
-bool volatile running = true;
-
-#define KERNEL_CMDLINE_KEY "tizen.recovery"
-
void sys_power_reboot(void)
{
reboot(RB_AUTOBOOT);
}
-#ifndef RECOVERY_GUI
-static char *get_action_from_config(config_t *cfg)
-{
- config_setting_t *node;
- const char *action;
-
- node = config_lookup(cfg, "headless_action");
- if (!node)
- return NULL;
-
- action = config_setting_get_string(node);
-
- return strdup(action);
-}
-
-// looks for tizen.recovery= key in kernel command line
-static char *get_action_from_cmdline(void)
-{
- FILE *fp;
- char cmdline[COMMAND_LINE_SIZE];
- int len;
-
- fp = fopen("/proc/cmdline", "r");
- if (!fp)
- return NULL;
-
- char *p = fgets(cmdline, sizeof cmdline, fp);
- fclose(fp);
- if (!p)
- return NULL;
-
- const char *prefix = KERNEL_CMDLINE_KEY "=";
- p = strstr(cmdline, prefix);
- if (!p)
- return NULL;
- p += strlen(prefix);
-
- for (len = 0; *(p + len) != 0 && !isspace(*(p + len)); ++len)
- ; /* skip */
-
- return strndup(p, len);
-}
-
-static int run_default(config_t *cfg)
-{
- config_setting_t *node;
- const char *action, *handler;
-
- node = config_lookup(cfg, "action_handlers");
- if (!node)
- return -ENOENT;
-
- action = get_action_from_cmdline();
- if (!action)
- action = get_action_from_config(cfg);
- if (!action)
- return -ENOENT;
-
- int r = config_setting_lookup_string(node, action, &handler);
- free(action);
-
- if (r == CONFIG_FALSE)
- return -ENOENT;
-
- return system(handler);
-}
-#endif
-
int main(void)
{
config_t cfg;
int ret;
LOGD("[main] recovery started.\n");
-#ifdef HAVE_TDM
- /* These should be set externally */
-
- /*
- * Under normal circumstances XDG_RUNTIME_DIR is set during
- * session setup (login). On initrd there is no session. This
- * is used in libwayland-server and there is no default value.
- */
- setenv("XDG_RUNTIME_DIR", "/run", 1);
-
- /* Tell TBM to work without an external wayland display manager. */
- setenv("TBM_DISPLAY_SERVER", "1", 1);
-#endif
config_init(&cfg);
ret = config_read_file(&cfg, SYSTEM_RECOVERY_CONFIG_FILE);
LOGD("Can't read config file");
return 1;
}
-#ifdef RECOVERY_GUI
- if (!recovery_rui_init(&cfg)) {
- LOGD("Can't initialize GUI.\n");
- return 1;
- }
-
- if (!ev_init()) {
- LOGD("Can't initialize input subsystem.\n");
- recovery_rui_exit();
- return 1;
- }
- rui_draw();
-
- while (running)
- if (!ev_dispatch(recovery_rui_input_callback))
- break;
-
- ev_exit();
- recovery_rui_exit();
+#ifdef RECOVERY_GUI
+ ret = recovery_gui(&cfg);
#else
- ret = run_default(&cfg);
+ ret = recovery_headless(&cfg);
#endif
+
LOGD("[main] recovery finished.\n");
config_destroy(&cfg);
- return 0;
+
+ return ret;
}
#include "system-recovery.h"
#include "rui-progress-bar.h"
#include "recovery-rui-skin.h"
+#include "process-util.h"
+
+bool volatile running = true;
+
+typedef enum {
+ RECOVERY_RUI_SCREEN_FACTORY_RUN = 4,
+} recovery_rui_screen_id;
void recovery_rui_input_callback(user_action action, user_action_type action_type)
{
free(rui_config_labels.rui_rulers);
free(rui_config_labels.rui_descriptions);
}
+
+
+int recovery_gui(config_t *cfg)
+{
+#ifdef HAVE_TDM
+ /* These should be set externally */
+
+ /*
+ * Under normal circumstances XDG_RUNTIME_DIR is set during
+ * session setup (login). On initrd there is no session. This
+ * is used in libwayland-server and there is no default value.
+ */
+ setenv("XDG_RUNTIME_DIR", "/run", 1);
+
+ /* Tell TBM to work without an external wayland display manager. */
+ setenv("TBM_DISPLAY_SERVER", "1", 1);
+#endif
+
+ if (!recovery_rui_init(cfg)) {
+ LOGD("Can't initialize GUI.\n");
+ return 1;
+ }
+
+ if (!ev_init()) {
+ LOGD("Can't initialize input subsystem.\n");
+ recovery_rui_exit();
+ return 1;
+ }
+
+ rui_draw();
+
+ while (running)
+ if (!ev_dispatch(recovery_rui_input_callback))
+ break;
+
+ ev_exit();
+ recovery_rui_exit();
+
+ return 0;
+}
#include <stdio.h>
#include <stdbool.h>
-#include "input-events.h"
-
#ifdef __cplusplus
extern "C" {
#endif
#define ROOT_MOUNT_DIR "/system"
#define INITRD_MOUNT_DIR "/system/mnt/initrd-recovery"
-typedef enum {
- RECOVERY_RUI_SCREEN_MAIN,
- RECOVERY_RUI_SCREEN_REBOOT,
- RECOVERY_RUI_SCREEN_SAFE,
- RECOVERY_RUI_SCREEN_FACTORY,
- RECOVERY_RUI_SCREEN_FACTORY_RUN,
- RECOVERY_RUI_SCREEN_SD_RESTORE,
- RECOVERY_RUI_SCREEN_SD_RESTORE_RUN
-} recovery_rui_screen_id;
-
-typedef enum {
- RECOVERY_RUI_IMAGE_BACKGROUND_DEFAULT,
- RECOVERY_RUI_IMAGE_MENU_TITLE
-} recovery_rui_image_id;
-
-typedef enum {
- RECOVERY_RUI_ANIMATION_WORKING
-} recovery_rui_animation_id;
-
int pivot_root(const char *new_root, const char *put_old);
void sys_power_reboot(void);
-bool recovery_rui_init(config_t *cfg);
-void recovery_rui_exit(void);
-void recovery_rui_input_callback(user_action action,
- user_action_type action_type);
+int recovery_gui(config_t *cfg);
+int recovery_headless(config_t *cfg);
#ifdef __cplusplus
}