From 770ec8ad20155f1083ec97da425b2bb682922e81 Mon Sep 17 00:00:00 2001 From: Adeeb Shihadeh Date: Sun, 22 Nov 2020 15:37:13 -0800 Subject: [PATCH] Qt setup improvements (#2591) --- selfdrive/ui/qt/setup/installer.cc | 9 ++++++--- selfdrive/ui/qt/setup/setup.cc | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/selfdrive/ui/qt/setup/installer.cc b/selfdrive/ui/qt/setup/installer.cc index 46497b63e..ad0d1644b 100644 --- a/selfdrive/ui/qt/setup/installer.cc +++ b/selfdrive/ui/qt/setup/installer.cc @@ -7,9 +7,10 @@ #define BRANCH "master" #endif -#define GIT_CLONE_COMMAND "git clone https://github.com/commaai/openpilot.git" +#define GIT_URL "https://github.com/commaai/openpilot.git" +#define GIT_SSH_URL "git@github.com:commaai/openpilot.git" -#define CONTINUE_PATH "/home/comma/continue.sh" +#define CONTINUE_PATH "/data/continue.sh" bool time_valid() { time_t rawtime; @@ -29,10 +30,12 @@ int fresh_clone() { if(err) return 1; // Clone - err = std::system(GIT_CLONE_COMMAND " -b " BRANCH " --depth=1 /tmp/openpilot"); + err = std::system("git clone " GIT_URL " -b " BRANCH " --depth=1 /tmp/openpilot"); if(err) return 1; err = std::system("cd /tmp/openpilot && git submodule update --init"); if(err) return 1; + err = std::system("cd /tmp/openpilot && git remote set-url origin --push " GIT_SSH_URL); + if(err) return 1; err = std::system("mv /tmp/openpilot /data"); if(err) return 1; diff --git a/selfdrive/ui/qt/setup/setup.cc b/selfdrive/ui/qt/setup/setup.cc index a2f843a7e..051f2f7ac 100644 --- a/selfdrive/ui/qt/setup/setup.cc +++ b/selfdrive/ui/qt/setup/setup.cc @@ -1,4 +1,5 @@ #include +#include #include #include @@ -17,14 +18,14 @@ #include #endif - int download(std::string url) { CURL *curl; curl = curl_easy_init(); if (!curl) return -1; - FILE *fp; - fp = fopen("/tmp/installer", "wb"); + char tmpfile[] = "/tmp/installer_XXXXXX"; + FILE *fp = fdopen(mkstemp(tmpfile), "w"); + curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL); curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp); @@ -32,6 +33,8 @@ int download(std::string url) { curl_easy_perform(curl); curl_easy_cleanup(curl); fclose(fp); + + rename(tmpfile, "/tmp/installer"); return 0; }