diff --git a/installer/Makefile b/installer/Makefile deleted file mode 100644 index cb42fab77f..0000000000 --- a/installer/Makefile +++ /dev/null @@ -1,121 +0,0 @@ -CC = clang -CXX = clang++ - - -PHONELIBS = ../phonelibs - -WARN_FLAGS = -Werror=implicit-function-declaration \ - -Werror=incompatible-pointer-types \ - -Werror=int-conversion \ - -Werror=return-type \ - -Werror=format-extra-args - -CFLAGS = -std=gnu11 -fPIC -O2 $(WARN_FLAGS) -CXXFLAGS = -std=c++1z -fPIC -O2 $(WARN_FLAGS) - -NANOVG_FLAGS = -I$(PHONELIBS)/nanovg - -OPENGL_LIBS = -lGLESv3 - -FRAMEBUFFER_LIBS = -lutils -lgui -lEGL - -COMMON_OBJS = ../selfdrive/common/glutil.o \ - ../selfdrive/common/framebuffer.o \ - ../selfdrive/common/util.o \ - $(PHONELIBS)/nanovg/nanovg.o \ - ../selfdrive/common/spinner.o \ - opensans_semibold.o \ - img_spinner_track.o \ - img_spinner_comma.o - -OPENPILOT_OBJS = installer_openpilot.o \ - continue_openpilot.o \ - $(COMMON_OBJS) - -DASHCAM_OBJS = installer_dashcam.o \ - continue_dashcam.o \ - $(COMMON_OBJS) - -DEPS := $(OPENPILOT_OBJS:.o=.d) $(DASHCAM_OBJS:.o=.d) - -.PHONY: all -all: installers/installer_dashcam installers/installer_openpilot - -installers/installer_openpilot: $(OPENPILOT_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - -s \ - $(FRAMEBUFFER_LIBS) \ - -L/system/vendor/lib64 \ - $(OPENGL_LIBS) \ - -lm -llog - -installers/installer_dashcam: $(DASHCAM_OBJS) - @echo "[ LINK ] $@" - $(CXX) -fPIC -o '$@' $^ \ - -s \ - $(FRAMEBUFFER_LIBS) \ - -L/system/vendor/lib64 \ - $(OPENGL_LIBS) \ - -lm -llog - -../selfdrive/common/framebuffer.o: ../selfdrive/common/framebuffer.cc - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include \ - -c -o '$@' '$<' - -../selfdrive/common/spinner.o: ../selfdrive/common/spinner.c - @echo "[ CXX ] $@" - $(CXX) $(CXXFLAGS) -MMD \ - -I$(PHONELIBS)/android_frameworks_native/include \ - -I$(PHONELIBS)/android_system_core/include \ - -I$(PHONELIBS)/android_hardware_libhardware/include \ - $(NANOVG_FLAGS) \ - -c -o '$@' '$<' - -opensans_semibold.o: ../selfdrive/assets/fonts/opensans_semibold.ttf - @echo "[ bin2o ] $@" - cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' - -img_spinner_track.o: ../selfdrive/assets/img_spinner_track.png - @echo "[ bin2o ] $@" - cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' - -img_spinner_comma.o: ../selfdrive/assets/img_spinner_comma.png - @echo "[ bin2o ] $@" - cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' - -installer_openpilot.o: installer.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I.. -I../selfdrive \ - -DBRAND=openpilot \ - -DBRANCH=release2 \ - -c -o '$@' '$<' - -installer_dashcam.o: installer.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I.. -I../selfdrive \ - -DBRAND=dashcam \ - -DBRANCH=dashcam \ - -c -o '$@' '$<' - -%.o: %.c - @echo "[ CC ] $@" - $(CC) $(CFLAGS) -MMD \ - -I.. -I../selfdrive \ - -c -o '$@' '$<' - -%.o: %.sh - @echo "[ bin2o ] $@" - cd '$(dir $<)' && ld -r -b binary '$(notdir $<)' -o '$(abspath $@)' - -.PHONY: clean -clean: - rm -f installer_openpilot installer_dashcam $(OPENPILOT_OBJS) $(DASHCAM_OBJS) $(DEPS) - --include $(DEPS) diff --git a/installer/installer.c b/installer/installer.c deleted file mode 100644 index 2e070c6d90..0000000000 --- a/installer/installer.c +++ /dev/null @@ -1,164 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "selfdrive/common/framebuffer.h" -#include "selfdrive/common/glutil.h" -#include "selfdrive/common/mat.h" -#include "selfdrive/common/spinner.h" -#include "selfdrive/common/util.h" - -#ifndef BRAND -#define BRAND openpilot -#endif - -#define STR(X) #X -#define STR2(X) STR(X) -#define PASTE(A, B) A ## B -#define PASTE2(A, B) PASTE(A, B) -#define BRAND_S STR2(BRAND) -#define BRANCH_S STR2(BRANCH) - -#define PRE_CHECKOUT_FOLDER "/system/comma/openpilot" -#define GIT_CLONE_COMMAND "git clone https://github.com/commaai/openpilot.git " - - -extern const uint8_t str_continue[] asm("_binary_continue_" BRAND_S "_sh_start"); -extern const uint8_t str_continue_end[] asm("_binary_continue_" BRAND_S "_sh_end"); - -static bool time_valid() { - time_t rawtime; - time(&rawtime); - - struct tm * sys_time = gmtime(&rawtime); - return (1900 + sys_time->tm_year) >= 2019; -} - -static int use_pre_checkout() { - int err; - - // Cleanup - err = system("rm -rf /tmp/openpilot"); - if(err) return 1; - err = system("rm -rf /data/openpilot"); - if(err) return 1; - - // Copy pre checkout into tmp so we can work on it - err = system("cp -rp " PRE_CHECKOUT_FOLDER " /tmp"); - if(err) return 1; - - err = chdir("/tmp/openpilot"); - if(err) return 1; - - // Checkout correct branch - err = system("git remote set-branches --add origin " BRANCH_S); - if(err) return 1; - err = system("git fetch origin " BRANCH_S); - if(err) return 1; - err = system("git checkout " BRANCH_S); - if(err) return 1; - err = system("git reset --hard origin/" BRANCH_S); - if(err) return 1; - - // Move to final location - err = system("mv /tmp/openpilot /data"); - if(err) return 1; - - return 0; -} - -static int fresh_clone() { - int err; - - // Cleanup - err = chdir("/tmp"); - if(err) return 1; - err = system("rm -rf /tmp/openpilot"); - if(err) return 1; - - err = system(GIT_CLONE_COMMAND " -b " BRANCH_S " --depth=1 openpilot"); - if(err) return 1; - - // Cleanup old folder in /data - err = system("rm -rf /data/openpilot"); - if(err) return 1; - - // this won't move if /data/openpilot exists - err = system("mv /tmp/openpilot /data"); - if(err) return 1; - - return 0; -} - -static int do_install() { - int err; - - - // Wait for valid time - while (!time_valid()){ - usleep(500 * 1000); - printf("Waiting for valid time\n"); - } - - struct stat sb; - if (stat(PRE_CHECKOUT_FOLDER, &sb) == 0 && S_ISDIR(sb.st_mode)) { - printf("Pre-checkout found\n"); - err = use_pre_checkout(); - } else { - printf("Doing fresh clone\n"); - err = fresh_clone(); - } - if(err) return 1; - - - // Write continue.sh - FILE *of = fopen("/data/data/com.termux/files/continue.sh.new", "wb"); - if(of == NULL) return 1; - - size_t num = str_continue_end - str_continue; - size_t num_written = fwrite(str_continue, 1, num, of); - if (num != num_written) return 1; - - fclose(of); - - err = system("chmod +x /data/data/com.termux/files/continue.sh.new"); - if(err) return 1; - - err = rename("/data/data/com.termux/files/continue.sh.new", "/data/data/com.termux/files/continue.sh"); - if(err == -1) return 1; - - // Disable SSH - err = system("setprop persist.neos.ssh 0"); - if(err) return 1; - - return 0; -} - - -void * run_spinner(void * args) { - char *loading_msg = "Installing " BRAND_S; - char *argv[2] = {NULL, loading_msg}; - spin(2, argv); - return NULL; -} - - -int main() { - pthread_t spinner_thread; - int err = pthread_create(&spinner_thread, NULL, run_spinner, NULL); - assert(err == 0); - - int status = do_install(); - - return status; -} diff --git a/installer/installers/deploy.sh b/installer/installers/deploy.sh deleted file mode 100755 index 2b904f0ed9..0000000000 --- a/installer/installers/deploy.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env bash -set -e - -ENVIRONMENT="${1}" -if [ "${ENVIRONMENT}" != "staging" -a "${ENVIRONMENT}" != "prod" ]; then - echo "usage: $0 " >&2 - echo " = staging or prod" >&2 - exit 1 -fi - -SUFFIX="" -if [ "${ENVIRONMENT}" != "prod" ]; then - SUFFIX="_test" -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -if [[ -z $(az account show 2>/dev/null) ]]; then - echo "$(date --rfc-3339=s) LOGIN: azure" - az login -fi - -FILES=( -installer_openpilot -installer_dashcam -) -for FILE in ${FILES[@]}; do - KEY="${FILE}${SUFFIX}" - echo "$(date --rfc-3339=s) PUSHING: ${FILE} -> ${KEY}" - az storage blob upload \ - --account-name commadist \ - --container-name neosupdate \ - --name "${KEY}" \ - --file "${FILE}" -done diff --git a/installer/installers/installer_dashcam b/installer/installers/installer_dashcam deleted file mode 100755 index 9db27cd8ba..0000000000 --- a/installer/installers/installer_dashcam +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:405521bd1d24415808f724d1f81d2ce0bdaf2db5f844fcba1d9b9b3a3b364429 -size 538912 diff --git a/installer/installers/installer_openpilot b/installer/installers/installer_openpilot deleted file mode 100755 index 739c76063f..0000000000 --- a/installer/installers/installer_openpilot +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0e17adb56d6fd3e8797360b314a911f4567f27e739e230ccb326049bfa453890 -size 538912 diff --git a/selfdrive/ui/.gitignore b/selfdrive/ui/.gitignore index 4525455912..8646fed180 100644 --- a/selfdrive/ui/.gitignore +++ b/selfdrive/ui/.gitignore @@ -1,6 +1,8 @@ moc_* *.moc +installer/installers/* + replay/replay qt/text qt/spinner @@ -8,4 +10,3 @@ qt/setup/setup qt/setup/reset qt/setup/wifi qt/setup/updater -qt/setup/installer_* diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index a4836cdb71..7166fe5b5d 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -52,7 +52,8 @@ qt_src = ["main.cc", "ui.cc", "paint.cc", "qt/sidebar.cc", "qt/onroad.cc", qt_env.Program("_ui", qt_src, LIBS=qt_libs) -# setup, factory resetter, and installer + +# setup, factory resetter, and agnos updater if arch != 'aarch64' and GetOption('setup'): # TODO: do this for all resources once NEOS has rcc @@ -67,20 +68,26 @@ if arch != 'aarch64' and GetOption('setup'): qt_env.Program("qt/setup/setup", ["qt/setup/setup.cc", asset_obj], LIBS=qt_libs + ['curl', 'common', 'json11']) + +# build installers +if GetOption('setup'): senv = qt_env.Clone() senv['LINKFLAGS'].append('-Wl,-strip-debug') + + release = "release3" if arch == 'larch64' else "release2" + dashcam = "dashcam3" if arch == 'larch64' else "dashcam" installers = [ - ("openpilot", "release3"), - ("openpilot_test", "release3-staging"), + ("openpilot", release), + ("openpilot_test", f"{release}-staging"), ("openpilot_nightly", "master-ci"), ("openpilot_internal", "master"), - ("dashcam", "dashcam3"), - ("dashcam_test", "dashcam3-staging"), + ("dashcam", dashcam), + ("dashcam_test", f"{dashcam}-staging"), ] cont = {} for brand in ("openpilot", "dashcam"): - cont[brand] = senv.Command(f"qt/setup/continue_{brand}.o", f"#installer/continue_{brand}.sh", + cont[brand] = senv.Command(f"installer/continue_{brand}.o", f"installer/continue_{brand}.sh", "ld -r -b binary -o $TARGET $SOURCE") for name, branch in installers: brand = "dashcam" if "dashcam" in branch else "openpilot" @@ -92,8 +99,8 @@ if arch != 'aarch64' and GetOption('setup'): r = requests.get("https://github.com/commaci2.keys") r.raise_for_status() d['SSH_KEYS'] = f'\\"{r.text.strip()}\\"' - obj = senv.Object(f"qt/setup/installer_{name}.o", ["qt/setup/installer.cc"], CPPDEFINES=d) - f = senv.Program(f"qt/setup/installer_{name}", [obj, cont[brand]], LIBS=qt_libs) + obj = senv.Object(f"installer/installers/installer_{name}.o", ["installer/installer.cc"], CPPDEFINES=d) + f = senv.Program(f"installer/installers/installer_{name}", [obj, cont[brand]], LIBS=qt_libs) # keep installers small assert f[0].get_size() < 300*1e3 diff --git a/installer/continue_dashcam.sh b/selfdrive/ui/installer/continue_dashcam.sh similarity index 100% rename from installer/continue_dashcam.sh rename to selfdrive/ui/installer/continue_dashcam.sh diff --git a/installer/continue_openpilot.sh b/selfdrive/ui/installer/continue_openpilot.sh similarity index 100% rename from installer/continue_openpilot.sh rename to selfdrive/ui/installer/continue_openpilot.sh diff --git a/selfdrive/ui/qt/setup/installer.cc b/selfdrive/ui/installer/installer.cc similarity index 89% rename from selfdrive/ui/qt/setup/installer.cc rename to selfdrive/ui/installer/installer.cc index 198b9319f6..c97dd06c26 100644 --- a/selfdrive/ui/qt/setup/installer.cc +++ b/selfdrive/ui/installer/installer.cc @@ -10,21 +10,26 @@ #include #include +#include "selfdrive/ui/installer/installer.h" #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/qt_window.h" -#include "selfdrive/ui/qt/setup/installer.h" #define GIT_URL "https://github.com/commaai/openpilot.git" #define GIT_SSH_URL "git@github.com:commaai/openpilot.git" -#define CONTINUE_PATH "/data/continue.sh" +#ifdef QCOM + #define CONTINUE_PATH "/data/data/com.termux/files/continue.sh" + #define CACHE_PATH "/system/comma/openpilot" +#else + #define CONTINUE_PATH "/data/continue.sh" + #define CACHE_PATH "/usr/comma/openpilot" +#endif -#define CACHE_PATH "/usr/comma/openpilot" #define INSTALL_PATH "/data/openpilot" #define TMP_INSTALL_PATH "/data/tmppilot" -extern const uint8_t str_continue[] asm("_binary_installer_continue_" BRAND "_sh_start"); -extern const uint8_t str_continue_end[] asm("_binary_installer_continue_" BRAND "_sh_end"); +extern const uint8_t str_continue[] asm("_binary_selfdrive_ui_installer_continue_" BRAND "_sh_start"); +extern const uint8_t str_continue_end[] asm("_binary_selfdrive_ui_installer_continue_" BRAND "_sh_end"); bool time_valid() { time_t rawtime; @@ -195,8 +200,12 @@ void Installer::cloneFinished(int exitCode, QProcess::ExitStatus exitStatus) { run("chmod +x /data/continue.sh.new"); run("mv /data/continue.sh.new " CONTINUE_PATH); +#ifdef QCOM + QTimer::singleShot(100, &QCoreApplication::quit); +#else // wait for the installed software's UI to take over QTimer::singleShot(60 * 1000, &QCoreApplication::quit); +#endif } int main(int argc, char *argv[]) { diff --git a/selfdrive/ui/qt/setup/installer.h b/selfdrive/ui/installer/installer.h similarity index 100% rename from selfdrive/ui/qt/setup/installer.h rename to selfdrive/ui/installer/installer.h