mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-08-21 08:03:42 +08:00
unify agnos/neos installers (#22023)
* c2 installer * remove old installer * move to its own dir * die immediately * fix that * init app
This commit is contained in:
@@ -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)
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd /data/openpilot
|
||||
exec ./launch_chffrplus.sh
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd /data/openpilot
|
||||
exec ./launch_openpilot.sh
|
||||
@@ -1,164 +0,0 @@
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES3/gl3.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
ENVIRONMENT="${1}"
|
||||
if [ "${ENVIRONMENT}" != "staging" -a "${ENVIRONMENT}" != "prod" ]; then
|
||||
echo "usage: $0 <env>" >&2
|
||||
echo " <env> = 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
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user