diff options
-rw-r--r-- | src/main/java/org/openslx/taskmanager/tasks/AptGetUpgradable.java | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/org/openslx/taskmanager/tasks/AptGetUpgradable.java b/src/main/java/org/openslx/taskmanager/tasks/AptGetUpgradable.java index 8c34143..0c0bb65 100644 --- a/src/main/java/org/openslx/taskmanager/tasks/AptGetUpgradable.java +++ b/src/main/java/org/openslx/taskmanager/tasks/AptGetUpgradable.java @@ -12,12 +12,13 @@ import org.openslx.taskmanager.api.SystemCommandTask; public class AptGetUpgradable extends SystemCommandTask { - private static final Pattern REGEX = Pattern.compile( "^(\\S+)/(\\S+)\\s+(\\S+)\\s.*\\[upgrad.*from:\\s+(\\S+)[,\\]]" ); + // Inst vivaldi-snapshot [6.4.3160.29-1] (6.5.3222.3-1 Official Vivaldi package repository:stable [amd64]) + private static final Pattern REGEX = Pattern.compile( "^Inst (\\S+) \\[(\\S+)\\] \\((\\S+) ([^\\[\\)]+)" ); private final Output status = new Output(); private StringBuilder otherOutput = new StringBuilder(); - + @Override protected boolean initTask() { @@ -29,7 +30,7 @@ public class AptGetUpgradable extends SystemCommandTask @Override protected String[] initCommandLine() { - return new String[] { "apt", "list", "--upgradable" }; + return new String[] { "apt-get", "-s", "full-upgrade" }; } @Override @@ -52,8 +53,19 @@ public class AptGetUpgradable extends SystemCommandTask protected void processStdOut( String line ) { Matcher m = REGEX.matcher( line ); - if ( m.matches() ) { - status.packages.add( new Package( m.group( 1 ), m.group( 2 ), m.group( 4 ), m.group( 3 ) ) ); + if ( m.find() ) { + String source = null; + String[] list = m.group( 4 ).split( ", " ); + for ( String src : list ) { + String tmp = src.trim().replaceFirst( "^.*[:/]", "" ); + if ( source == null || tmp.endsWith( "-security" ) ) { + source = tmp; + } + } + if ( source == null ) { + source = m.group( 4 ); + } + status.packages.add( new Package( m.group( 1 ), source, m.group( 2 ), m.group( 3 ) ) ); } else { otherOutput.append( line ); otherOutput.append( '\n' ); |