Qt setup improvements (#2591)

old-commit-hash: 770ec8ad20
commatwo_master
Adeeb Shihadeh 5 years ago committed by GitHub
parent 00b759eaf0
commit e7284172ac
  1. 9
      selfdrive/ui/qt/setup/installer.cc
  2. 9
      selfdrive/ui/qt/setup/setup.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;

@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <QString>
@ -17,14 +18,14 @@
#include <wayland-client-protocol.h>
#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;
}

Loading…
Cancel
Save