diff options
author | Simon Rettberg | 2023-12-19 15:15:00 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-12-19 15:15:00 +0100 |
commit | 2c418033a0bf24ee24f181ea6826c4897a61504e (patch) | |
tree | a12c9384ede92d586f5aecc9ebb3f784611ef2c7 /src/main/java/org/openslx | |
parent | Update svgSalamander (diff) | |
download | tmlite-bwlp-2c418033a0bf24ee24f181ea6826c4897a61504e.tar.gz tmlite-bwlp-2c418033a0bf24ee24f181ea6826c4897a61504e.tar.xz tmlite-bwlp-2c418033a0bf24ee24f181ea6826c4897a61504e.zip |
[AptGetUpgradable] Use apt-get to list upgradable files
This (hopefully) has a stable CLI format, and lists packages that need a
dist/full-upgrade, which are missing from apt --list-upgradable.
Diffstat (limited to 'src/main/java/org/openslx')
-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' ); |