move upgrade to its own subfolder
authorJohn Crispin <blogic@openwrt.org>
Mon, 16 Jun 2014 16:43:03 +0000 (17:43 +0100)
committerJohn Crispin <blogic@openwrt.org>
Mon, 16 Jun 2014 17:42:58 +0000 (18:42 +0100)
Signed-off-by: John Crispin <blogic@openwrt.org>
CMakeLists.txt
upgraded.c [deleted file]
upgraded/CMakeLists.txt [new file with mode: 0644]
upgraded/upgraded [new file with mode: 0755]
upgraded/upgraded.c [new file with mode: 0644]

index b90cdd7..dc7ecd6 100644 (file)
@@ -21,6 +21,7 @@ IF(DEBUG)
   ADD_DEFINITIONS(-DDEBUG -g3)
 ENDIF()
 
+add_subdirectory(upgraded)
 
 ADD_EXECUTABLE(procd ${SOURCES})
 TARGET_LINK_LIBRARIES(procd ${LIBS})
@@ -42,14 +43,6 @@ INSTALL(TARGETS udevtrigger
 )
 
 
-ADD_EXECUTABLE(upgraded upgraded.c watchdog.c)
-TARGET_LINK_LIBRARIES(upgraded ubox.a rt.a -static -lc -lgcc)
-set_target_properties(upgraded PROPERTIES LINK_SEARCH_END_STATIC 1)
-INSTALL(TARGETS upgraded
-       RUNTIME DESTINATION sbin
-)
-
-
 ADD_EXECUTABLE(askfirst utils/askfirst.c)
 INSTALL(TARGETS askfirst
        RUNTIME DESTINATION sbin
diff --git a/upgraded.c b/upgraded.c
deleted file mode 100644 (file)
index 345a30a..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 2.1
- * as published by the Free Software Foundation
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
-
-#include <sys/reboot.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-#include <libubox/uloop.h>
-
-#include "watchdog.h"
-
-static struct uloop_process upgrade_proc;
-unsigned int debug = 2;
-
-static void upgrade_proc_cb(struct uloop_process *proc, int ret)
-{
-       if (ret)
-               fprintf(stderr, "sysupgrade aborted with return code: %d\n", ret);
-       uloop_end();
-}
-
-static void sysupgarde(char *folder)
-{
-       char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL };
-
-       args[2] = folder;
-       upgrade_proc.cb = upgrade_proc_cb;
-       upgrade_proc.pid = fork();
-       if (!upgrade_proc.pid) {
-               execvp(args[0], args);
-               fprintf(stderr, "Failed to fork sysupgrade\n");
-               exit(-1);
-       }
-       if (upgrade_proc.pid <= 0) {
-               fprintf(stderr, "Failed to start sysupgarde\n");
-               uloop_end();
-       }
-}
-
-int main(int argc, char **argv)
-{
-       pid_t p = getpid();
-
-       chdir("/tmp");
-
-       if (p != 1) {
-               fprintf(stderr, "this tool needs to run as pid 1\n");
-               return -1;
-       }
-       if (argc != 2) {
-               fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n");
-               return -1;
-       }
-
-       uloop_init();
-       watchdog_init(0);
-       sysupgarde(argv[1]);
-       uloop_run();
-
-       reboot(RB_AUTOBOOT);
-
-       return 0;
-}
diff --git a/upgraded/CMakeLists.txt b/upgraded/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7e08c0e
--- /dev/null
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 2.6)
+
+PROJECT(upgraded C)
+ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations)
+set(CMAKE_EXE_LINKER_FLAGS -static)
+set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+set(CMAKE_EXE_LINK_DYNAMIC_C_FLAGS)
+set(CMAKE_EXE_LINK_DYNAMIC_CXX_FLAGS)
+set(CMAKE_SHARED_LIBRARY_C_FLAGS)
+set(CMAKE_SHARED_LIBRARY_CXX_FLAGS)
+set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS)
+set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS)
+ADD_EXECUTABLE(upgraded upgraded.c ../watchdog.c)
+TARGET_LINK_LIBRARIES(upgraded ubox rt)
+INSTALL(TARGETS upgraded
+       RUNTIME DESTINATION sbin
+)
diff --git a/upgraded/upgraded b/upgraded/upgraded
new file mode 100755 (executable)
index 0000000..a78470c
Binary files /dev/null and b/upgraded/upgraded differ
diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c
new file mode 100644 (file)
index 0000000..1e4057a
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
+ * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1
+ * as published by the Free Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <sys/reboot.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <libubox/uloop.h>
+
+#include "../watchdog.h"
+
+static struct uloop_process upgrade_proc;
+unsigned int debug = 2;
+
+static void upgrade_proc_cb(struct uloop_process *proc, int ret)
+{
+       if (ret)
+               fprintf(stderr, "sysupgrade aborted with return code: %d\n", ret);
+       uloop_end();
+}
+
+static void sysupgarde(char *folder)
+{
+       char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL };
+
+       args[2] = folder;
+       upgrade_proc.cb = upgrade_proc_cb;
+       upgrade_proc.pid = fork();
+       if (!upgrade_proc.pid) {
+               execvp(args[0], args);
+               fprintf(stderr, "Failed to fork sysupgrade\n");
+               exit(-1);
+       }
+       if (upgrade_proc.pid <= 0) {
+               fprintf(stderr, "Failed to start sysupgarde\n");
+               uloop_end();
+       }
+}
+
+int main(int argc, char **argv)
+{
+       pid_t p = getpid();
+
+       chdir("/tmp");
+
+       if (p != 1) {
+               fprintf(stderr, "this tool needs to run as pid 1\n");
+               return -1;
+       }
+       if (argc != 2) {
+               fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n");
+               return -1;
+       }
+
+       uloop_init();
+       watchdog_init(0);
+       sysupgarde(argv[1]);
+       uloop_run();
+
+       reboot(RB_AUTOBOOT);
+
+       return 0;
+}