[LTS] Put branch in bundle name (please read caveats) (#5008)

* make autoupdater check correct URL

* missed semicolon

* remove bundle_name.txt
This commit is contained in:
David Holdeman 2023-01-28 13:49:05 -06:00 committed by GitHub
parent d3681e8ee6
commit d7c183debd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 14 deletions

View File

@ -40,7 +40,12 @@ public class Autoupdate {
System.out.println("Snapshot requested"); System.out.println("Snapshot requested");
if (bundleFullName != null) { if (bundleFullName != null) {
System.out.println("Handling " + bundleFullName); System.out.println("Handling " + bundleFullName);
handleBundle(bundleFullName, mode, ConnectionAndMeta.BASE_URL_LATEST); String branchName = bundleFullName.split(".")[1];
if ( branchName == "snapshot" ) {
handleBundle(bundleFullName, mode, ConnectionAndMeta.BASE_URL_LATEST);
} else {
handleBundle(bundleFullName, mode, String.format(ConnectionAndMeta.BASE_URL_LTS, branchName));
}
} else { } else {
System.err.println("ERROR: Autoupdate: unable to perform without bundleFullName"); System.err.println("ERROR: Autoupdate: unable to perform without bundleFullName");
} }
@ -77,7 +82,8 @@ public class Autoupdate {
private static void handleBundle(String bundleFullName, UpdateMode mode, String baseUrl) { private static void handleBundle(String bundleFullName, UpdateMode mode, String baseUrl) {
try { try {
String zipFileName = bundleFullName + "_autoupdate" + ".zip"; String boardName = bundleFullName.split(".")[2];
String zipFileName = "rusefi_bundle_" + boardName + "_autoupdate" + ".zip";
ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(zipFileName).invoke(baseUrl); ConnectionAndMeta connectionAndMeta = new ConnectionAndMeta(zipFileName).invoke(baseUrl);
System.out.println("Remote file " + zipFileName); System.out.println("Remote file " + zipFileName);
System.out.println("Server has " + connectionAndMeta.getCompleteFileSize() + " from " + new Date(connectionAndMeta.getLastModified())); System.out.println("Server has " + connectionAndMeta.getCompleteFileSize() + " from " + new Date(connectionAndMeta.getLastModified()));

View File

@ -10,11 +10,16 @@ if [ -z "$1" ]; then
fi fi
BUNDLE=$1 BUNDLE=$1
CURRENT=${PWD##*/}
echo $BUNDLE > bundle_name.txt CURRENT=${CURRENT:-/}
CURRENT_BRANCH=$(echo "$CURRENT" | cut -d '.' -f 2)
CURRENT_BUNDLE=$(echo "$CURRENT" | cut -d '.' -f 3)
cd ..
mv "rusefi.${CURRENT_BRANCH}.${CURRENT_BUNDLE}" "rusefi.${CURRENT_BRANCH}.${BUNDLE}"
cd "rusefi.${CURRENT_BRANCH}.${BUNDLE}"
rm -rf rusefi*bin rm -rf rusefi*bin
rm -rf rusefi*hex rm -rf rusefi*hex
rm -rf rusefi*dfu rm -rf rusefi*dfu
rm -rf rusefi*ini rm -rf rusefi*ini
bash

View File

@ -6,25 +6,25 @@ import org.jetbrains.annotations.Nullable;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileReader; import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.FileSystemNotFoundException;
import java.util.Date; import java.util.Date;
public class BundleUtil { public class BundleUtil {
private static final String BUNDLE_NAME_FILE = "../bundle_name.txt";
/** /**
* @return null in case of error * @return null in case of error
*/ */
@Nullable @Nullable
public static String readBundleFullName() { public static String readBundleFullName() {
try { try {
BufferedReader r = new BufferedReader(new FileReader(BUNDLE_NAME_FILE)); Path path = Paths.get("..");
String fullName = r.readLine(); String fullName = path.getFileName().toString();
fullName = fullName.trim();
if (fullName.length() < 3) if (fullName.length() < 3)
return null; // just paranoia check return null; // just paranoia check
return fullName; return fullName;
} catch (IOException e) { } catch (FileSystemNotFoundException e) {
System.err.println(new Date() + ": BundleUtil: Error reading " + BUNDLE_NAME_FILE); System.err.println(new Date() + ": BundleUtil: Error reading bundle name");
return null; return null;
} }
} }

View File

@ -13,6 +13,7 @@ import java.util.Objects;
public class ConnectionAndMeta { public class ConnectionAndMeta {
public static final String BASE_URL_RELEASE = "https://github.com/rusefi/rusefi/releases/latest/download/"; public static final String BASE_URL_RELEASE = "https://github.com/rusefi/rusefi/releases/latest/download/";
public static final String BASE_URL_LATEST = "https://rusefi.com/build_server/autoupdate/"; public static final String BASE_URL_LATEST = "https://rusefi.com/build_server/autoupdate/";
public static final String BASE_URL_LTS = "https://rusefi.com/build_server/lts/%s/autoupdate/";
private static final int BUFFER_SIZE = 32 * 1024; private static final int BUFFER_SIZE = 32 * 1024;
public static final int CENTUM = 100; public static final int CENTUM = 100;

View File

@ -19,7 +19,6 @@ pwd
# This working folder name starts with 'temp/' # This working folder name starts with 'temp/'
echo "$SCRIPT_NAME: Working folder: $FOLDER" echo "$SCRIPT_NAME: Working folder: $FOLDER"
mkdir $FOLDER mkdir $FOLDER
echo $BUNDLE_FULL_NAME > $FOLDER/bundle_name.txt
CONSOLE_FOLDER="$FOLDER/console" CONSOLE_FOLDER="$FOLDER/console"
DRIVERS_FOLDER="$FOLDER/drivers" DRIVERS_FOLDER="$FOLDER/drivers"