[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:
parent
d3681e8ee6
commit
d7c183debd
|
@ -40,7 +40,12 @@ public class Autoupdate {
|
|||
System.out.println("Snapshot requested");
|
||||
if (bundleFullName != null) {
|
||||
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 {
|
||||
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) {
|
||||
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);
|
||||
System.out.println("Remote file " + zipFileName);
|
||||
System.out.println("Server has " + connectionAndMeta.getCompleteFileSize() + " from " + new Date(connectionAndMeta.getLastModified()));
|
||||
|
|
|
@ -10,11 +10,16 @@ if [ -z "$1" ]; then
|
|||
fi
|
||||
|
||||
BUNDLE=$1
|
||||
|
||||
echo $BUNDLE > bundle_name.txt
|
||||
|
||||
CURRENT=${PWD##*/}
|
||||
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*hex
|
||||
rm -rf rusefi*dfu
|
||||
rm -rf rusefi*ini
|
||||
rm -rf rusefi*ini
|
||||
bash
|
||||
|
|
|
@ -6,25 +6,25 @@ import org.jetbrains.annotations.Nullable;
|
|||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.FileSystemNotFoundException;
|
||||
import java.util.Date;
|
||||
|
||||
public class BundleUtil {
|
||||
private static final String BUNDLE_NAME_FILE = "../bundle_name.txt";
|
||||
|
||||
/**
|
||||
* @return null in case of error
|
||||
*/
|
||||
@Nullable
|
||||
public static String readBundleFullName() {
|
||||
try {
|
||||
BufferedReader r = new BufferedReader(new FileReader(BUNDLE_NAME_FILE));
|
||||
String fullName = r.readLine();
|
||||
fullName = fullName.trim();
|
||||
Path path = Paths.get("..");
|
||||
String fullName = path.getFileName().toString();
|
||||
if (fullName.length() < 3)
|
||||
return null; // just paranoia check
|
||||
return fullName;
|
||||
} catch (IOException e) {
|
||||
System.err.println(new Date() + ": BundleUtil: Error reading " + BUNDLE_NAME_FILE);
|
||||
} catch (FileSystemNotFoundException e) {
|
||||
System.err.println(new Date() + ": BundleUtil: Error reading bundle name");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import java.util.Objects;
|
|||
public class ConnectionAndMeta {
|
||||
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_LTS = "https://rusefi.com/build_server/lts/%s/autoupdate/";
|
||||
|
||||
private static final int BUFFER_SIZE = 32 * 1024;
|
||||
public static final int CENTUM = 100;
|
||||
|
|
|
@ -19,7 +19,6 @@ pwd
|
|||
# This working folder name starts with 'temp/'
|
||||
echo "$SCRIPT_NAME: Working folder: $FOLDER"
|
||||
mkdir $FOLDER
|
||||
echo $BUNDLE_FULL_NAME > $FOLDER/bundle_name.txt
|
||||
|
||||
CONSOLE_FOLDER="$FOLDER/console"
|
||||
DRIVERS_FOLDER="$FOLDER/drivers"
|
||||
|
|
Loading…
Reference in New Issue