diff options
author | Simon Rettberg | 2021-04-20 16:41:03 +0200 |
---|---|---|
committer | Simon Rettberg | 2021-04-20 16:41:03 +0200 |
commit | 8522c314bdb4bd87e265e1c943169c13ed9d8b0e (patch) | |
tree | 52d1066d238c6f7d09378f2db110709e37776c25 | |
parent | [RemoteExec/RemoteReboot] switch to fork of JSch to support more key formats (diff) | |
download | tmlite-bwlp-8522c314bdb4bd87e265e1c943169c13ed9d8b0e.tar.gz tmlite-bwlp-8522c314bdb4bd87e265e1c943169c13ed9d8b0e.tar.xz tmlite-bwlp-8522c314bdb4bd87e265e1c943169c13ed9d8b0e.zip |
Add ipxe version selection, use bwlp config for ipxe
3 files changed, 201 insertions, 4 deletions
diff --git a/src/main/java/org/openslx/satserver/util/Util.java b/src/main/java/org/openslx/satserver/util/Util.java index 262fd56..2ffe261 100644 --- a/src/main/java/org/openslx/satserver/util/Util.java +++ b/src/main/java/org/openslx/satserver/util/Util.java @@ -118,6 +118,24 @@ public class Util } /** + * Parse the given String as a base10 long. + * If the string does not represent a valid long, return the given + * default value. + * + * @param value string representation to parse to an long + * @param defaultValue fallback value if given string can't be parsed + * @return + */ + public static long parseLong( String value, long defaultValue ) + { + try { + return Long.parseLong( value ); + } catch ( Exception e ) { + return defaultValue; + } + } + + /** * Compare two strings for equality. * null and "" are not considered equal. */ diff --git a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java index 575ee0a..ad921ac 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java +++ b/src/main/java/org/openslx/taskmanager/tasks/CompileIPxeNew.java @@ -126,12 +126,14 @@ public class CompileIPxeNew extends AbstractTask } else if (cpus > 256) { // Sanity check in case it (apparently) reports nonsense cpus = 4; } - ProcLogger pl = new ProcLogger(); - if ( 0 != Exec.syncAt( 600, pl, "/opt/openslx/ipxe/src", join( "nice", "make", "-j" + cpus, - "EMBED=../ipxelinux.ipxe", FILES_ALL ) ) ) { + // Use NO_WERROR so older commits compile on newer gcc versions + if ( 0 != Exec.syncAt( 600, new ProcLogger(), "/opt/openslx/ipxe/src", + join( "nice", "make", "-j" + cpus, "NO_WERROR=1", "CONFIG=bwlp", + "EMBED=../ipxelinux.ipxe", FILES_ALL ) ) ) { status.addError( "Compiling ipxe targets failed" ); return false; } + Exec.syncAt( 1, new ProcVersion(), "/opt/openslx/ipxe", "git", "rev-parse", "HEAD" ); // NETBOOT for ( String f : FILES_NET ) { String destName = new File( f ).getName(); @@ -193,11 +195,12 @@ public class CompileIPxeNew extends AbstractTask return r; } - class Output + static class Output { protected Map<String, Boolean> files = new ConcurrentHashMap<>( FILES_MAP ); protected final BoundedLog log = new BoundedLog( 20, true ); protected String errors = ""; + protected String hash; protected void addLog( String data ) { @@ -233,4 +236,22 @@ public class CompileIPxeNew extends AbstractTask } + class ProcVersion implements ExecCallback + { + + @Override + public void processStdOut( String line ) + { + if ( line.length() >= 40 && !line.contains( " " ) ) { + status.hash = line; + } + } + + @Override + public void processStdErr( String line ) + { + } + + } + } diff --git a/src/main/java/org/openslx/taskmanager/tasks/IpxeVersion.java b/src/main/java/org/openslx/taskmanager/tasks/IpxeVersion.java new file mode 100644 index 0000000..dd4d66d --- /dev/null +++ b/src/main/java/org/openslx/taskmanager/tasks/IpxeVersion.java @@ -0,0 +1,158 @@ +package org.openslx.taskmanager.tasks; + +import java.util.ArrayList; +import java.util.List; + +import org.openslx.satserver.util.Exec; +import org.openslx.satserver.util.Util; +import org.openslx.satserver.util.Exec.ExecCallback; +import org.openslx.taskmanager.api.SystemCommandTask; + +import com.google.gson.annotations.Expose; + +public class IpxeVersion extends SystemCommandTask +{ + + /* FOR COMMIT PICKING + * git log --pretty=format:"%H %at" --first-parent a58276abdd..openslx + */ + + @Expose + private Action action; + + @Expose + private String ref; + + private Status status = new Status(); + + @Override + protected String[] initCommandLine() + { + List<String> args = new ArrayList<>(); + args.add( "git" ); + args.add( "-C" ); + args.add( "/opt/openslx/ipxe" ); + switch ( action ) { + case CHECKOUT: + args.add( "checkout" ); + args.add( ref ); + break; + case LIST: + EC vec = new EC(); + Exec.syncAt( 1, vec, "/", "gcc", "-dumpversion" ); + String start; + if ( vec.version >= 10 ) { + // Versions before this commit won't build with gcc 10 + start = "a098f40893"; + } else { + start = "a58276abdd"; + } + args.add( "log" ); + args.add( "--pretty=format:%H %at" ); + args.add( "--first-parent" ); + args.add( start + "..origin/openslx" ); + status.versions = new ArrayList<Version>(); + break; + case FETCH: + args.add( "fetch" ); + break; + case RESET: + args.add( "reset" ); + args.add( "--hard" ); + break; + } + return args.toArray( new String[ args.size() ] ); + } + + @Override + protected boolean processEnded( int exitCode ) + { + if ( exitCode != 0 && status.error == null ) { + status.error = "Exit code: " + exitCode; + } + return exitCode == 0; + } + + @Override + protected void processStdOut( String line ) + { + if ( action == Action.LIST ) { + String[] parts = line.split( " " ); + if ( parts.length == 2 && parts[0].length() == 40 && parts[1].length() == 10 ) { + long d = Util.parseLong( parts[1], 0 ); + if ( d != 0 ) { + status.versions.add( new Version( parts[0], d ) ); + } + } + } else { + processStdErr( line ); + } + } + + @Override + protected void processStdErr( String line ) + { + if ( status.error == null ) { + status.error = line; + } else { + status.error += "\n" + line; + } + } + + @Override + protected boolean initTask() + { + setStatusObject( status ); + if ( action == null || ( action == Action.CHECKOUT && ref == null ) ) { + status.error = "action or commit is null"; + return false; + } + status.ref = ref; + return true; + } + + static class EC implements ExecCallback + { + + public int version = 0; + + @Override + public void processStdOut( String line ) + { + if ( line.matches( "[0-9].*" ) ) { + version = Util.parseInt( line.replaceAll( "[^0-9].*$", "" ), 0 ); + } + } + + @Override + public void processStdErr( String line ) + { + } + + } + + static enum Action + { + FETCH, RESET, CHECKOUT, LIST; + } + + static class Version + { + public String hash; + public long date; + + public Version( String hash, long date ) + { + this.date = date; + this.hash = hash; + } + } + + static class Status + { + public String error; + public List<Version> versions; + public String ref; + } + +} |